Edgewall Software
Modify

#13590 closed defect (fixed)

ValueError not logged when a unicode instance is passed to req.send()

Reported by: Jun Omae Owned by: Jun Omae
Priority: normal Milestone: 1.4.4
Component: rendering Version: 1.4.3
Severity: normal Keywords:
Cc: Branch:
Release Notes:

Fixed the exception not logged after starting a response.

API Changes:
Internal Changes:

Description

I noticed that the raised ValueError is not logged when a unicode instance is passed to req.send() and the response is empty. The issue occurs regardless of the [trac] use_chunked_encoding option.

The behavior appears to have been introduced in [17055] (#13038). The change was based on my suggestion (my fault).

  • trac/web/main.py

    diff --git a/trac/web/main.py b/trac/web/main.py
    index 3645cd990..dc8ec9714 100644
    a b def dispatch_request(environ, start_response):  
    640640        except RequestDone as req_done:
    641641            resp = req_done.iterable
    642642    except HTTPException as e:
    643         if not req.response_started:
    644             _send_user_error(req, env, e)
     643        _send_user_error(req, env, e)
    645644    except Exception:
    646         if not req.response_started:
    647             send_internal_error(env, req, sys.exc_info())
     645        send_internal_error(env, req, sys.exc_info())
    648646    else:
    649647        resp = resp or req._response or []
    650648    finally:
    def _send_user_error(req, env, e):  
    706704        env.log.warning('[%s] %s, %r, referrer %r',
    707705                        req.remote_addr, exception_to_unicode(e),
    708706                        req, req.environ.get('HTTP_REFERER'))
     707    if req.response_started:
     708        return
    709709    data = {'title': e.title, 'type': 'TracError', 'message': e.message,
    710710            'frames': [], 'traceback': None}
    711711    if e.code == 403 and not req.is_authenticated:
    def send_internal_error(env, req, exc_info):  
    721721        env.log.error("[%s] Internal Server Error: %r, referrer %r%s",
    722722                      req.remote_addr, req, req.environ.get('HTTP_REFERER'),
    723723                      exception_to_unicode(exc_info[1], traceback=True))
     724    if req.response_started:
     725        return
    724726    message = exception_to_unicode(exc_info[1])
    725727    traceback = get_last_traceback()

(I plan to apply the patch to 1.0-stable and 1.2-stable as well)

Attachments (0)

Change History (1)

comment:1 by Jun Omae, 19 months ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Fixed in [17695:17698].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.