Ticket #53 (closed defect: wontfix)

Opened 2 years ago

Last modified 1 year ago

Assert fails if response header contains unicode. [patch]

Reported by: trac Assigned to: asaddi
Priority: minor Milestone: flup.server-1.0.3
Component: flup.server Version: 1.0.2
Keywords: Cc: epronk@muftor.com

Description

The assert checks if type is str. Fails for unicode.

diff -r 72496e17674f flup/server/fcgi_base.py
--- a/flup/server/fcgi_base.py	Tue May 25 11:09:06 2010 -0700
+++ b/flup/server/fcgi_base.py	Fri May 28 13:52:51 2010 +1000
@@ -1146,8 +1146,8 @@
             assert type(response_headers) is list, 'Headers must be a list'
             if __debug__:
                 for name,val in response_headers:
-                    assert type(name) is str, 'Header name "%s" must be a string' % name
-                    assert type(val) is str, 'Value of header "%s" must be a string' % name
+                    assert isinstance(name, basestring), 'Header name "%s" must be a string' % name
+                    assert isinstance(val, basestring), 'Value of header "%s" must be a string' % name
 
             headers_set[:] = [status, response_headers]
             return write

Eddy Pronk

Change History

05/27/10 21:51:33 changed by asaddi

WSGI spec requires all strings to be of type str. Unicode encoding/decoding must be done at the application level.

http://www.python.org/dev/peps/pep-0333/#unicode-issues

Though, are you running under Jython or Python 3.x?

05/27/10 22:19:07 changed by trac

Python 2.6.2

05/27/10 22:36:24 changed by trac

It was glob.glob which returns filenames in unicode. Thanks for pointing that out.

10/14/10 16:36:18 changed by asaddi

  • status changed from new to closed.
  • resolution set to wontfix.