Opened 9 years ago

#6072 enhancement new

Fix the decode/encode hack in `twisted.web.util.formatFailure`

Reported by: Jean-Paul Calderone Owned by:
Priority: normal Milestone:
Component: web Keywords:
Cc: jknight Branch:
Author:

Description

twisted.web.util.formatFailure uses a trick to ensure that its output is ASCII-only to avoid imposing new requirements on code calling it (ie, that such code be sure to include a correct "charset" field in the Content-Type header being used). The trick is:

result[0].decode('utf-8').encode('ascii', 'xmlcharrefreplace')

This is correct but probably not particularly efficient, therefore it would be nice if this decode/encode trick were not necessary.

There was a conversation on twisted-web about some of the details surrounding this issue that may be informative. Here are some links to the first message of the thread in each month in which it occurred (because pipermail can't thread across month boundaries):

http://twistedmatrix.com/pipermail/twisted-web/2011-November/004839.html http://twistedmatrix.com/pipermail/twisted-web/2011-December/004846.html http://twistedmatrix.com/pipermail/twisted-web/2012-January/004854.html

Change History (1)

comment:1 Changed 9 years ago by DefaultCC Plugin

Cc: jknight added
Note: See TracTickets for help on using tickets.