diff options
author | Robert Brewer <fumanchu@aminus.org> | 2006-09-27 22:14:32 +0000 |
---|---|---|
committer | Robert Brewer <fumanchu@aminus.org> | 2006-09-27 22:14:32 +0000 |
commit | 8da13b31bb5d1c064f355a4d521b3e08a8724934 (patch) | |
tree | c0532a6e79e2e49ccd751cf303f05d7560fcd5df /cherrypy/lib/encoding.py | |
parent | ad5fbb041723c2f03135552e917eca1b813b6ac5 (diff) | |
download | cherrypy-git-8da13b31bb5d1c064f355a4d521b3e08a8724934.tar.gz |
Fixed bug in encode (shouldn't attempt encode on any body chunk unless it's of type 'unicode').
Diffstat (limited to 'cherrypy/lib/encoding.py')
-rw-r--r-- | cherrypy/lib/encoding.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/cherrypy/lib/encoding.py b/cherrypy/lib/encoding.py index d1d66a45..d2028898 100644 --- a/cherrypy/lib/encoding.py +++ b/cherrypy/lib/encoding.py @@ -66,8 +66,10 @@ def encode_stream(encoding, errors='strict'): being written out. """ def encoder(body): - for line in body: - yield line.encode(encoding, errors) + for chunk in body: + if isinstance(chunk, unicode): + chunk = chunk.encode(encoding, errors) + yield chunk cherrypy.response.body = encoder(cherrypy.response.body) return True @@ -76,7 +78,9 @@ def encode_string(encoding, errors='strict'): try: body = [] for chunk in cherrypy.response.body: - body.append(chunk.encode(encoding, errors)) + if isinstance(chunk, unicode): + chunk = chunk.encode(encoding, errors) + body.append(chunk) cherrypy.response.body = body except (LookupError, UnicodeError): return False |