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

Changeset 1382

Show
Ignore:
Timestamp:
09/27/06 17:14:32
Author:
fumanchu
Message:

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
  • trunk/cherrypy/lib/encoding.py

    r1376 r1382  
    6767    """ 
    6868    def encoder(body): 
    69         for line in body: 
    70             yield line.encode(encoding, errors) 
     69        for chunk in body: 
     70            if isinstance(chunk, unicode): 
     71                chunk = chunk.encode(encoding, errors) 
     72            yield chunk 
    7173    cherrypy.response.body = encoder(cherrypy.response.body) 
    7274    return True 
     
    7779        body = [] 
    7880        for chunk in cherrypy.response.body: 
    79             body.append(chunk.encode(encoding, errors)) 
     81            if isinstance(chunk, unicode): 
     82                chunk = chunk.encode(encoding, errors) 
     83            body.append(chunk) 
    8084        cherrypy.response.body = body 
    8185    except (LookupError, UnicodeError): 

Hosted by WebFaction

Log in as guest/cpguest to create tickets