[ python-Bugs-1377394 ] read() / readline() blow up if file has even number of char.
SourceForge.net
noreply at sourceforge.net
Fri Dec 9 22:43:57 CET 2005
Bugs item #1377394, was opened at 2005-12-09 15:43
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1377394&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Unicode
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: superwesman (superwesman)
Assigned to: M.-A. Lemburg (lemburg)
Summary: read() / readline() blow up if file has even number of char.
Initial Comment:
Hello, I am having a problem with the read() and
readline() functions. I'm using codecs.open() to open
a text file, then using either read() or readline() to
get its contents. In python 2.4.2, if the file has an
even number of characters, I get a UnicodeDecodeError.
If python 2.4.1 this works regardless of the character
count. I've pasted below a sample script and the
sample text file I was running. This is the command I
executed at the Windows 2000 CMD prompt:
python sample.py sample.txt
Again, in 2.4.1, this works fine - in 2.4.2 it breaks
when the file-to-be-read has an odd number of characters.
Thanks.
-w
# start: sample.py
import codecs
import sys
print "open the file"
in_file = codecs.open( sys.argv[1], "r",
"unicode_internal" )
print "read the file"
the_file = in_file.read()
print "close the file"
in_file.close()
print "done"
# end: sample.py
# start: sample.txt
RESULTHOST=vivaldi
RESULTPORT=a
DB_XML=/test/art/jfw/config/DBList.xml
LOGCHECK_IGNORE=art_actions.txt
# end: sample.txt
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1377394&group_id=5470
More information about the Python-bugs-list
mailing list