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.

Author beazley
Recipients beazley
Date 2008-12-29.18:00:34
SpamBayes Score 7.402412e-13
Marked as misclassified No
Message-id <1230573653.7.0.91596129114.issue4770@psf.upfronthosting.co.za>
In-reply-to
Content
See Issue 4869 for a related bug.

Most of the functions in binascii are meant to go from binary data to 
textual representations (hex digits, base64, binhex, etc.).  There are 
numerous problems:

1.  Misleading error messages.  For example:

>>> binascii.b2a_base64("Some text")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: b2a_base64() argument 1 must be string or buffer, not str
>>> binascii.crc32("Some text")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: crc32() argument 1 must be string or buffer, not str
>>>

Huh?  Didn't I just pass a string?   Error message should say "argument 
1 must be bytes or buffer, not str".

This problem shows up with most of the other encoding functions too 
(i.e., b2a_uu).

2. Expected behavior with encoding/decoding.

The functions in this module are going from binary to text. To be 
consistent, I think the result of encoding operations such as b2a_uu(),
b2a_base64(), should be strings, not bytes.

Similarly, decoding operations are going from text back to bytes.  I 
think the input arguments should be allowed to be str (in addition to 
bytes if you want).
History
Date User Action Args
2008-12-29 18:00:53beazleysetrecipients: + beazley
2008-12-29 18:00:53beazleysetmessageid: <1230573653.7.0.91596129114.issue4770@psf.upfronthosting.co.za>
2008-12-29 18:00:35beazleylinkissue4770 messages
2008-12-29 18:00:35beazleycreate