better info about unicode encoding errors

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39278 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6e869e1b
...@@ -19,8 +19,10 @@ ...@@ -19,8 +19,10 @@
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
############################################################################## ##############################################################################
from zLOG import LOG from logging import getLogger
import sys import traceback
logger = getLogger(__name__)
try: try:
from Products.PageTemplates.unicodeconflictresolver \ from Products.PageTemplates.unicodeconflictresolver \
import PreferredCharsetResolver import PreferredCharsetResolver
...@@ -34,9 +36,11 @@ else: ...@@ -34,9 +36,11 @@ else:
# requests that do not contain Accept-Charset header. # requests that do not contain Accept-Charset header.
try: try:
result = unicode(text, 'utf-8') result = unicode(text, 'utf-8')
except UnicodeDecodeError: except UnicodeDecodeError, e:
LOG('unicodeconflictresolver, Unicode Error', 0, text, tb_info = ''.join(traceback.format_stack())
error=sys.exc_info()) logger.warn('UnicodeDecodeError: %s\ntext: %r\nat:\n%s' %
(e, text, tb_info))
result = unicode(text, 'utf-8', 'replace') result = unicode(text, 'utf-8', 'replace')
return result return result
PreferredCharsetResolver.resolve = PreferredCharsetResolver_resolve PreferredCharsetResolver.resolve = PreferredCharsetResolver_resolve
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment