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: StreamReader broken for byte string to byte string codecs
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: doerwalter, pysquared
Priority: normal Keywords:

Created on 2005-07-20 11:47 by pysquared, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
streamreadbug.py pysquared, 2005-07-20 11:47 Exercise the bug
Messages (2)
msg25838 - (view) Author: Graham Horler (pysquared) Date: 2005-07-20 11:47
print sys.version
2.4.1 (#2, Jul 12 2005, 09:22:25)
[GCC 4.0.1 (Debian 4.0.1-1)]

Decoding to what (according to the documentation)
should be a byte string (using StreamReader) does one
of 2 incorrect things, depending on the default encoding:

1) If the byte string has values not in the current
default encoding then StreamReader.read() incorrectly
triggers an exception.

2) If the byte string can be accomodated by the current
default encoding then StreamReader.read() incorrectly
returns a unicode object.

The documentation says in lib/standard-encodings.html:
  "The result of the ``decoding'' direction is listed
as operand type in the table."
  "base64_codec ... byte string"

(This bug does not exist in python2.2 or 2.3)

The attached script demonstrates the 2 related bugs.

Many thanks,
Graham
msg25839 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2005-07-20 22:53
Logged In: YES 
user_id=89016

Checked in a fix as:

Lib/codecs.py 1.46
Lib/test/test_codecs.py 1.24
Lib/codecs.py 1.35.2.8
Lib/test/test_codecs.py 1.15.2.6

Thanks for the report.
History
Date User Action Args
2022-04-11 14:56:12adminsetgithub: 42201
2005-07-20 11:47:03pysquaredcreate