[New-bugs-announce] [issue4742] 3.0 distutils byte-compiling -> Syntax error: unknown encoding: cp1252

John Machin report at bugs.python.org
Wed Dec 24 23:39:27 CET 2008

New submission from John Machin <sjmachin at users.sourceforge.net>:

File foo3.py is [cut down (orig 87Kb)] output of 2to3 conversion tool
and (coincidentally) is still valid 2.x syntax. There are no syntax
errors reported by any of the following:
   \python26\python -c "import foo3"
   \python26\python foo3.py
   \python26\python setup.py install
   \python30\python -c "import foo3"
   \python30\python foo3.py
However 3.0 install
   \python30\python setup.py install
running install_lib
copying build\lib\foo3.py -> C:\python30\Lib\site-packages
byte-compiling C:\python30\Lib\site-packages\foo3.py to foo3.pyc
  File "C:\python30\Lib\site-packages\foo3.py", line 0
### Note also "line 0" above ###
SyntaxError: unknown encoding: cp1252
Same happens if alternative name windows-1252 is used instead of cp1252.

NOTE: file foo3.py actually does have some non-ASCII characters (\xa0,
\x93, \x94), in comments. Another file (bar3.py) from the same package
contains \xb7 twice, but doesn't have the unknown encoding problem.
There are several other files in the same package that start with "# -*-
coding: windows-1252 -*-" (or cp1252, or even cp1251(!)) but have no
non-ASCII characters in them. They don't get this incorrect error
message either.

components: Distutils
files: py3encbug.zip
messages: 78273
nosy: sjmachin
severity: normal
status: open
title: 3.0 distutils byte-compiling -> Syntax error: unknown encoding: cp1252
versions: Python 3.0
Added file: http://bugs.python.org/file12445/py3encbug.zip

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list