Ticket #3931 (new defect)
t.p.amp.AmpBox.serialize will _not_ return a string if any value is unicode
| Reported by: | dotz | Owned by: | dotz |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | core | Keywords: | win32 |
| Cc: | exarkun | Branch: | |
| Author: | Launchpad Bug: |
Description
If you place an unicode value in AmpBox, AmpBox.serialize will return an unicode string, not str.
For example:
>>> from twisted.protocols.amp import AmpBox >>> a = AmpBox(asdf = 'foo') >>> type(a.serialize()) <type 'str'> >>> a = AmpBox(asdf = u'foo') >>> type(a.serialize()) <type 'unicode'>
This will cause funny errors on some platforms (see #3930).
This is also against AmpBox.serialize docstring, which says that it should return a str type, not unicode.
def serialize(self):
"""
Convert me into a wire-encoded string.
@return: a str encoded according to the rules described in the module
docstring.
"""
Please let me know what is the preferred way to get this fixed in trunk and I'll prepare a patch.
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

