[New-bugs-announce] [issue4747] SyntaxError executing a script containing non-ASCII characters in its name or path

Gabriel Genellina report at bugs.python.org
Fri Dec 26 01:41:47 CET 2008


New submission from Gabriel Genellina <gagsl-py2 at yahoo.com.ar>:

Attempting to directly execute a script containing non-ASCII 
characters in its name or path raises SyntaxError.

The script contents are mostly irrelevant, except it must contain an 
encoding declaration (with *any* encoding, real or inexistent).

Running "python foo.py" works, but invoking it directly as "foo.py" 
raises `SyntaxError: None`, or sometimes `SyntaxError: encoding 
problem: with BOM` (no BOM is present in the source file, a plain 
ASCII text file).

C:\TEMP>cd áéíóú

C:\TEMP\áéíóú>type test.py
# -*- coding: ascii -*-

C:\TEMP\áéíóú>C:\Apps\Python30\python.exe test.py

C:\TEMP\áéíóú>test.py
SyntaxError: None

To avoid any doubt, the file has no strange characters:

C:\TEMP\áéíóú>python -c "print(repr(open('test.py','rb').read()))"
'# -*- coding: ascii -*-\r\n'

and .py files are associated with the same interpreter:

C:\TEMP\áéíóú>assoc .py
.py=Python.File

C:\TEMP\áéíóú>ftype Python.File
Python.File="C:\Apps\Python30\python.exe" "%1" %*

The same thing happens if the file name contains any non-ASCII 
character (the path may be pure ASCII).

----------
components: Interpreter Core, Windows
messages: 78286
nosy: gagenellina
severity: normal
status: open
title: SyntaxError executing a script containing non-ASCII characters in its name or path
type: compile error
versions: Python 3.0

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


More information about the New-bugs-announce mailing list