Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 1517

Show
Ignore:
Timestamp:
12/11/06 13:34:41
Author:
fumanchu
Message:

2.x backport of [1382] (Fixed bug in encode; shouldn't attempt encode on any body chunk unless it's of type 'unicode').

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/cherrypy-2.x/cherrypy/filters/encodingfilter.py

    r1480 r1517  
    2727    """ 
    2828    def encoder(body): 
    29         for line in body: 
    30             yield line.encode(encoding, errors) 
     29        for chunk in body: 
     30            if isinstance(chunk, unicode): 
     31                chunk = chunk.encode(encoding, errors) 
     32            yield chunk 
    3133    cherrypy.response.body = encoder(cherrypy.response.body) 
    3234    return True 
     
    3739        body = [] 
    3840        for chunk in cherrypy.response.body: 
    39             body.append(chunk.encode(encoding, errors)) 
     41            if isinstance(chunk, unicode): 
     42                chunk = chunk.encode(encoding, errors) 
     43            body.append(chunk) 
    4044        cherrypy.response.body = body 
    4145    except (LookupError, UnicodeError): 

Hosted by WebFaction

Log in as guest/cpguest to create tickets