This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: codecs: Documentation Inconsistency
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: doerwalter, lemburg, mfwitten
Priority: normal Keywords:

Created on 2008-10-22 19:51 by mfwitten, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (5)
msg75104 - (view) Author: Michael Witten (mfwitten) Date: 2008-10-22 19:51
CodecInfo objects are supposed to have 'encoder' and 'decoder' 
attributes as per http://www.python.org/doc/2.5.2/lib/module-codecs.html 
(naturally, this applies to 2.5.* as well). However, at least the 
CodecInfo object for 'string_escape' names these attributes 'encode' and 
'decode'.

>>> import codecs
>>> dir(codecs.lookup('string_escape'))
['__add__', '__class__', '__contains__', '__delattr__', '__dict__', 
'__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__', 
'__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', 
'__iter__', '__le__', '__len__', '__lt__', '__module__', '__mul__', 
'__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', 
'__rmul__', '__setattr__', '__str__', 'decode', 'encode', 
'incrementaldecoder', 'incrementalencoder', 'name', 'streamreader', 
'streamwriter']
msg75105 - (view) Author: Michael Witten (mfwitten) Date: 2008-10-22 19:54
Apparently, it might affect all CodecInfo objects:

class CodecInfo(tuple):

    def __new__(cls, encode, decode, streamreader=None, 
streamwriter=None,
        incrementalencoder=None, incrementaldecoder=None, name=None):
        self = tuple.__new__(cls, (encode, decode, streamreader, 
streamwriter))
        self.name = name
        self.encode = encode
        self.decode = decode
        self.incrementalencoder = incrementalencoder
        self.incrementaldecoder = incrementaldecoder
        self.streamwriter = streamwriter
        self.streamreader = streamreader
        return self
...
msg75106 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2008-10-22 20:04
Before CodecInfo tuple subclasses were introduced, the lookup() function
used to return a tuple: (encoder, decoder, stream_reader, stream_writer)

See http://www.python.org/dev/peps/pep-0100/

These were normally addressed by position rather than name and still are
in most cases.

I'm not sure whether the choice of attribute names on CodecInfo was done
on purpose or a simple oversight. Walter added them... I've added him on CC.

They do match the names of the methods on codecs, so perhaps we should
just change everything to read encode/decode instead of encoder/decoder ?!
msg75137 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2008-10-23 09:22
I agree that the documentation should be fixed to read "encode/decode"
instead of "encoder/decoder".
msg75143 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2008-10-23 13:22
Fixed in r67005 (trunk) and r67006 (pk3k).
History
Date User Action Args
2022-04-11 14:56:40adminsetgithub: 48428
2008-10-23 13:22:47doerwaltersetstatus: open -> closed
resolution: fixed
messages: + msg75143
2008-10-23 09:22:50doerwaltersetmessages: + msg75137
2008-10-22 20:04:03lemburgsetnosy: + lemburg, doerwalter
messages: + msg75106
2008-10-22 19:54:08mfwittensetmessages: + msg75105
2008-10-22 19:51:47mfwittensettype: behavior
2008-10-22 19:51:21mfwittencreate