New submission from Naftali Harris:

The traceback documentation states that it "exactly mimics the behavior of the 
Python interpreter when it prints a stack trace." Here's a small case where it 
doesn't, on 2.7.13:

~/repos/Python-2.7.13$ cat example.py
def f(x):
    global x
~/repos/Python-2.7.13$ ./python.exe
Python 2.7.13 (default, Dec 29 2016, 09:54:42)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import traceback
>>> import example
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "example.py", line 1
    def f(x):
SyntaxError: name 'x' is local and global
>>> try:
...     import example
... except:
...     traceback.print_exc()
...
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
SyntaxError: name 'x' is local and global (example.py, line 1)
>>>

I believe Kurt fixed this for Python 3000 with 
https://mail.python.org/pipermail/python-3000-checkins/2007-July/001259.html

----------
components: Library (Lib)
messages: 284287
nosy: Naftali.Harris, benjamin.peterson, kbk
priority: normal
severity: normal
status: open
title: traceback module incorrectly formats args-less syntax errors
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29107>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to