Ticket #3663 defect closed fixed

Opened 5 years ago

Last modified 5 years ago

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
(diff, github, buildbot, log)
Author: exarkun Launchpad Bug:

Description

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

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/codecs.py", 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

1

Changed 5 years ago by exarkun

  • keywords easy added

2

Changed 5 years ago by exarkun

  • branch set to branches/imap4-utf7-registration-3663
  • branch_author set to exarkun

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

3

Changed 5 years ago by exarkun

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

refs #3663

4

Changed 5 years ago by exarkun

  • keywords review added
  • owner exarkun deleted

5

Changed 5 years ago by glyph

  • keywords review removed
  • owner set to exarkun

Looks good. Merge.

6

Changed 5 years ago by exarkun

  • status changed from new to closed
  • resolution set to fixed

(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.

7

Changed 3 years ago by <automation>

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