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: errors='replace' works in IDLE, fails at Windows command line.
Type: behavior Stage:
Components: Windows Versions: Python 3.1
process
Status: closed Resolution: duplicate
Dependencies: Superseder: errors='replace' does not work at Windows command line
View: 9126
Assigned To: Nosy List: jvanpraag, r.david.murray
Priority: normal Keywords:

Created on 2010-06-18 19:43 by jvanpraag, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg108130 - (view) Author: John Van Praag (jvanpraag) Date: 2010-06-18 19:43
Platforms:
Windows Vista Ultimate 64 bit
Python v3.1.2

Goal is to read a tab-separated CSV file. Some records have garbage characters in them.

The following code fragment works when the program is run in IDLE, but fails when run from the Windows command line.

...
	fh_read = open(company_info, encoding='utf_8', errors='replace')
	fh_write = open(quotes_file, 'w')
	count = 0
	try:
		rdr = csv.reader(fh_read, delimiter='\t')
		wrt = csv.writer(fh_write, delimiter='\t', quotechar='"', lineterminator='\n')
		for row in rdr:
...

Within IDLE the code works with or without the encoding='utf_8' declaration; and it fails with or without the declaration when run from the Windows command line.

The error message from the Windows command line is as follows:

'charmap' codec can't encode character '\u2019' in position 207: character maps to <undefined>
msg108176 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-06-19 12:48
What you show is not a complete program, nor do you provide the complete traceback or the data causing the problem.  The most helpful thing would be a complete small program and data file demonstrating the problem.  That said, I'm wondering if your problem is the encoding of the terminal window.
msg108989 - (view) Author: John Van Praag (jvanpraag) Date: 2010-06-30 15:28
I just now resubmitted, with a text file and program demonstrating the
problem: Issue9126.

I am new to submitting Python bug reports and I would like to do it
right. I found I could only attach 1 file to the bug report. However, I
had two files: The text file to read, and the program doing the reading.
Is there some way to attach multiple files to a bug report? If not, what
is the customary way to handle submissions where there is a file to be
processed, and a program doing the processing? And perhaps other files
exhibiting output(s)?

Thanks,

John

On Sat, 19 Jun 2010 12:48 +0000, "R. David Murray"
<report@bugs.python.org> wrote:
> 
> R. David Murray <rdmurray@bitdance.com> added the comment:
> 
> What you show is not a complete program, nor do you provide the complete
> traceback or the data causing the problem.  The most helpful thing would
> be a complete small program and data file demonstrating the problem. 
> That said, I'm wondering if your problem is the encoding of the terminal
> window.
> 
> ----------
> nosy: +r.david.murray
> 
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue9029>
> _______________________________________
>
History
Date User Action Args
2022-04-11 14:57:02adminsetgithub: 53275
2010-06-30 16:51:42benjamin.petersonsetstatus: open -> closed
resolution: duplicate
superseder: errors='replace' does not work at Windows command line
2010-06-30 15:28:56jvanpraagsetmessages: + msg108989
2010-06-19 12:48:00r.david.murraysetnosy: + r.david.murray
messages: + msg108176
2010-06-18 19:43:48jvanpraagcreate