Opened 8 years ago

Closed 8 years ago

#3663 defect closed fixed (fixed)

imap4-utf-7 codec improperly registered

Reported by: exarkun Owned by:
Priority: low Milestone:
Component: mail Keywords: easy
Cc: Branch: branches/imap4-utf7-registration-3663
branch-diff, diff-cov, branch-cov, buildbot
Author: exarkun


In Python 2.5, it's not possible to look up the imap4-utf-7 codec registered by twisted/mail/

exarkun@boson:~$ python
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from twisted.mail import imap4
>>> import codecs
>>> codecs.lookup('imap4-utf-7')
(<function encoder at 0x8395df4>, <function decoder at 0x8395e2c>, <class twisted.mail.imap4.StreamReader at 0x837bdac>, <class twisted.mail.imap4.StreamWriter at 0x837bddc>)
>>> codecs.getreader('imap4-utf-7')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/", line 920, in getreader
    return lookup(encoding).streamreader
AttributeError: 'tuple' object has no attribute 'streamreader'

Though this did use to work:

exarkun@boson:~$ ~/Projects/python/branches/release23-maint/python 
Python 2.3.7 (#2, Mar 25 2008, 19:31:49) 
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from twisted.mail import imap4
>>> import codecs
>>> codecs.getreader('imap4-utf-7')
<class twisted.mail.imap4.StreamReader at 0xb7a0d5fc>

Also, StreamWriter might be misdefined. It has a decode method, but perhaps it should have an encode method.

Change History (7)

comment:1 Changed 8 years ago by exarkun

  • Keywords easy added

comment:2 Changed 8 years ago by exarkun

  • Author set to exarkun
  • Branch set to branches/imap4-utf7-registration-3663

(In [26379]) Branching to 'imap4-utf7-registration-3663'

comment:3 Changed 8 years ago by exarkun

(In [26380]) Fix the definition of StreamWriter and return a CodecInfo from the lookup function

refs #3663

comment:4 Changed 8 years ago by exarkun

  • Keywords review added
  • Owner exarkun deleted

comment:5 Changed 8 years ago by glyph

  • Keywords review removed
  • Owner set to exarkun

Looks good. Merge.

comment:6 Changed 8 years ago by exarkun

  • Resolution set to fixed
  • Status changed from new to closed

(In [26479]) Merge imap4-utf7-registration-3663

Author: exarkun Reviewer: glyph Fixes: #3663

Update the IMAP4-UTF7 codec registration to use the preferred Python 2.5 behavior of returning a CodecInfo instance instead of a four tuple. This causes the codecs.getreader and codecs.getwriter functions to work for this encoding (again). Also fix the implementation of the stream writer to define the correct method, encode, instead of the incorrect one, decode.

comment:7 Changed 6 years ago by <automation>

  • Owner exarkun deleted
Note: See TracTickets for help on using tickets.