New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3.0 distutils byte-compiling -> Syntax error: unknown encoding: cp1252 #48992
Comments
File foo3.py is [cut down (orig 87Kb)] output of 2to3 conversion tool NOTE: file foo3.py actually does have some non-ASCII characters (\xa0, |
A clue: >>> print(ascii(b'\xa0\x93\x94\xb7'.decode('cp1252')))
'\xa0\u201c\u201d\xb7' Could be that it only happens where there's a cp1252 character that's |
Here's a status: The problem is located in the codec that decodes the data (called by the It throws an error : *** UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in Which is caught by compile and translated into: SyntaxError: unknown encoding: cp1252 So I see two problems: 1/ why compile throws such an error when there's an UnicodeDecodeError I have written a test that reproduces the problem, and I am still |
TWO POINTS: byte-compiling C:\python30\Lib\site-packages\x9d.py to x9d.pyc
Traceback (most recent call last):
File "setup.py", line 5, in <module>
py_modules = ["foo3", "bar3", "x93", "x94", "x9d", "xa0b7"]
File "C:\python30\lib\distutils\core.py", line 149, in setup
dist.run_commands()
File "C:\python30\lib\distutils\dist.py", line 942, in run_commands
self.run_command(cmd)
File "C:\python30\lib\distutils\dist.py", line 962, in run_command
cmd_obj.run()
File "C:\python30\lib\distutils\command\install.py", line 571, in run
self.run_command(cmd_name)
File "C:\python30\lib\distutils\cmd.py", line 317, in run_command
self.distribution.run_command(command)
File "C:\python30\lib\distutils\dist.py", line 962, in run_command
cmd_obj.run()
File "C:\python30\lib\distutils\command\install_lib.py", line 91, in run
self.byte_compile(outfiles)
File "C:\python30\lib\distutils\command\install_lib.py", line 125, in
byte_compile
dry_run=self.dry_run)
File "C:\python30\lib\distutils\util.py", line 520, in byte_compile
compile(file, cfile, dfile)
File "C:\python30\lib\py_compile.py", line 137, in compile
codestring = f.read()
File "C:\python30\lib\io.py", line 1724, in read
decoder.decode(self.buffer.read(), final=True))
File "C:\python30\lib\io.py", line 1295, in decode
output = self.decoder.decode(input, final=final)
File "C:\python30\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position
64: character maps to <undefined> byte-compiling C:\python26\Lib\site-packages\x9d.py to x9d.pyc byte-compiling c:\python25\Lib\site-packages\x9d.py to x9d.pyc |
On 2008-12-30 13:20, John Machin wrote:
FWIW, I've tried that file with Python 2.5 and 2.6 on my machine: lemburg/tmp> python2.5 ~/bin/pycompile.py x9d.py lemburg/tmp> python2.6 ~/bin/pycompile.py x9d.py Note that the line number is wrong in both messages. It is interesting that simply running the files gives a more correct lemburg/tmp> python2.5 x9d.py lemburg/tmp> python2.6 x9d.py The character position is wrong again in both messages. Needless to say that the encoding "cp1252" is *not* unknown. It looks |
yup, here's the test I have written to demonstrate the problem. In any |
(1) what am I supposed to infer from "Yup"?? That all of that \x9d stuff (2) os.patth is novel :-) |
This is a duplicate of bpo-4626. Here, the content is correctly decoded with cp1252, then passed to Yes, the error message is overwritten. If I remove the code that sets >>> compile(open("c:/temp/t1252.py", encoding="cp1252").read(),
"t1252.py", "exec")
SyntaxError: 'charmap' codec can't decode byte 0x9d in position 35:
character maps to <undefined>
The 0x9d explains easily:
>>> b"\x94".decode('cp1252').encode('utf8')
b'\xe2\x80\x9d' |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: