New submission from Stefan Seefeld:

The following code is supposed to catch and report errors encountered during 
the execution of a (python) script:

```
import traceback
import sys

try:
    env = {}
    with open('script') as f:
        exec(f.read(), env)
except:
    type_, value_, tb = sys.exc_info()
    print (traceback.print_tb(tb))
```
However, depending on the nature of the error, the traceback may contain the 
location of the error *within* the executed `script` file, or it may only 
report the above `exec(f.read(), env)` line.

The attached tarball contains both the above as well as a 'script' that exhibit 
the problem.

Is this a bug or am I missing something ? Are there ways to work around this, 
i.e. determine the correct (inner) location of the error ?

(I'm observing this with both Python 2.7 and Python 3.5)

----------
files: pyerror.tgz
messages: 294645
nosy: stefan
priority: normal
severity: normal
status: open
title: Incomplete traceback with `exec`
type: behavior
Added file: http://bugs.python.org/file46908/pyerror.tgz

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

Reply via email to