[New-bugs-announce] [issue9029] errors='replace' works in IDLE, fails at Windows command line.

John Van Praag report at bugs.python.org
Fri Jun 18 21:43:49 CEST 2010


New submission from John Van Praag <john at jvp247.com>:

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>

----------
components: Windows
messages: 108130
nosy: jvanpraag
priority: normal
severity: normal
status: open
title: errors='replace' works in IDLE, fails at Windows command line.
type: behavior
versions: Python 3.1

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9029>
_______________________________________


More information about the New-bugs-announce mailing list