Issue 5325: "SyntaxError: None" when the name of the dir contains non-ascii chars (original) (raw)

Step to reproduce:

  1. create a directory with non-ascii chars in the name
  2. create a python module with a syntax error (I used an unclosed '(')
  3. execute the module.py directly ('module.py', not 'python module.py')

I tested this only on Windows, with Python3 as the default interpreter used to execute *.py files, this is the output:

ascii dir, works fine

D:>module1.py File "D:\module1.py", line 21 ^ SyntaxError: invalid syntax

moving to non-ascii dir

D:>cd äåæ

non ascii-dir, fails

D:\äåæ>module1.py SyntaxError: None

here is using py2.6, but with 'python module1.py' it doesn't print the

dir name D:\äåæ>python module1.py File "module1.py", line 21 ^ SyntaxError: invalid syntax

same as before but with py3

D:\äåæ>python3 module1.py File "module1.py", line 21 ^ SyntaxError: invalid syntax

with print(sys.version) in module1.py

D:\äåæ>module1.py 3.0 (r30:67507, Dec 3 2008, 20:14:27) [MSC v.1500 32 bit (Intel)] D:\äåæ>python module1.py 2.6 (r26:66721, Oct 2 2008, 11:35:03) [MSC v.1500 32 bit (Intel)] D:\äåæ>python3 module1.py 3.0 (r30:67507, Dec 3 2008, 20:14:27) [MSC v.1500 32 bit (Intel)]

This seems to happen only with SyntaxErrors, I tested a couple of other errors and it seems to work:

with print(sys.version) and 5/0 in module1

here it prints the dir name without problems (but it doesn't show '5/0')

D:\äåæ>module1.py 3.0 (r30:67507, Dec 3 2008, 20:14:27) [MSC v.1500 32 bit (Intel)] Traceback (most recent call last): File "D:\äåæ\module1.py", line 3, in ZeroDivisionError: int division or modulo by zero

D:\äåæ>python module1.py 2.6 (r26:66721, Oct 2 2008, 11:35:03) [MSC v.1500 32 bit (Intel)] Traceback (most recent call last): File "module1.py", line 3, in 5/0 ZeroDivisionError: integer division or modulo by zero

D:\äåæ>python3 module1.py 3.0 (r30:67507, Dec 3 2008, 20:14:27) [MSC v.1500 32 bit (Intel)] Traceback (most recent call last): File "module1.py", line 3, in 5/0 ZeroDivisionError: int division or modulo by zero