homepage

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 jvanpraag
Recipients jvanpraag
Date 2010年06月30日.15:22:44
SpamBayes Score 1.3504914e-05
Marked as misclassified No
Message-id <1277911366.4.0.473449546724.issue9126@psf.upfronthosting.co.za>
In-reply-to
Content
The declaration errors='replace' works from within IDLE but not at the Windows command line. I am attaching a program and text file that demonstrate the problem. The error shows up at the Windows command line as follows:
C:\Users\John\Documents\Python\bug_reports001円>python -m read_my_file
aaaaaaa aaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaa
bbbbbbbbbbb bbbbbbbbbbbb bbbbbbbbbbbbbbbbbbb bbbbbbbbbbbb
Traceback (most recent call last):
 File "C:\Python31\lib\runpy.py", line 128, in _run_module_as_main
 "__main__", fname, loader, pkg_name)
 File "C:\Python31\lib\runpy.py", line 34, in _run_code
 exec(code, run_globals)
 File "C:\Users\John\Documents\Python\bug_reports001円\read_my_file.py", line 20, in <module>
 readf()
 File "C:\Users\John\Documents\Python\bug_reports001円\read_my_file.py", line 17, in readf
 print(line)
 File "C:\Python31\lib\encodings\cp437.py", line 19, in encode
 return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 10-11: character maps to <undefined>
NOTE: It appears I can only attach 1 file to this report. So I am copying the program here. The text file to read is attached.
'''
read_my_file.py:
Reads lines from faulty file.
Hangs at line 3 when run from Windows command line.
Platforms:
Windows Vista Ultimate 64-bit
Python 3.1.2
'''
#The file to read.
my_file = 'junk.txt'
def readf():
	#The declaration "errors='replace'" is suppposed replace characters the reader does not recognize with a dummy character such as a question mark.
	#This fix works in the interpreter, but not from the Windows command line.
	fh_read = open(my_file, errors='replace')
	for line in fh_read:
		print(line)
#Run.
readf()
History
Date User Action Args
2010年06月30日 15:22:46jvanpraagsetrecipients: + jvanpraag
2010年06月30日 15:22:46jvanpraagsetmessageid: <1277911366.4.0.473449546724.issue9126@psf.upfronthosting.co.za>
2010年06月30日 15:22:44jvanpraaglinkissue9126 messages
2010年06月30日 15:22:44jvanpraagcreate

AltStyle によって変換されたページ (->オリジナル) /