New submission from Jonathan Ballet <j...@multani.info>:
While using the 'threads' middleware of repoze.debug, I noticed that sometimes,
I got the following message if I access "/debug_threads":
URL: http://localhost:8080/debug_threads
File '.../eggs/Paste-1.7.2-py2.5.egg/paste/evalexception/middleware.py',
line 306 in respond
app_iter = self.application(environ, detect_start_response)
File '.../eggs/repoze.who-1.0.15-py2.5.egg/repoze/who/middleware.py', line
107 in __call__
app_iter = app(environ, wrapper.wrap_start_response)
File
'.../eggs/sact.utils-0.17.0dev_r201008091621-py2.5.egg/sact/utils/wsgi.py', line
29 in _app
ans = app(environ, start_response)
File '/home/jon/projects/repoze/repoze.debug/repoze/debug/threads.py', line
74 in __call__
response.body = dump_threads()
File '.../eggs/WebOb-0.9.6.1-py2.5.egg/webob/__init__.py', line 1719 in
_body__set
"You cannot set Response.body to a unicode object (use
Response.unicode_body)")
TypeError: You cannot set Response.body to a unicode object (use
Response.unicode_body)
And WebOb is right, since the content of dump_threads() is of type unicode (I
don't know why, because it doesn't seem to contain any unicode values, but the
pages I was requesting contained Japonese characters).
Anyway, I provide a patch which assign the content of the threads data to the
right Response attribute, depending if it's unicode or not.
----------
files: fix-crash-on-unicode.patch
messages: 445
nosy: multani
priority: bug
status: unread
title: [repoze.debug] Don't crash if unicode presents while dumping thread
states
topic: repoze.debug
__________________________________
Repoze Bugs <b...@bugs.repoze.org>
<http://bugs.repoze.org/issue163>
__________________________________
# HG changeset patch
# Parent 1ce4d44d669ccb0d588a39685a0850436776bd35
Don't crash if unicode values are present in threads' state.
diff -r 1ce4d44d669c repoze/debug/threads.py
--- a/repoze/debug/threads.py Mon Aug 30 15:27:00 2010 +0200
+++ b/repoze/debug/threads.py Mon Aug 30 16:07:05 2010 +0200
@@ -71,7 +71,11 @@
if request.path == '/debug_threads':
response = webob.Response(request=request)
response.content_type = 'text/plain'
- response.body = dump_threads()
+ t = dump_threads()
+ if isinstance(t, unicode):
+ response.unicode_body = t
+ else:
+ response.body = t
else:
response = request.get_response(self.app, catch_exc_info=True)
_______________________________________________
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev