This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author stefan
Recipients stefan
Date 2017-05-28.13:28:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1495978134.83.0.774241176124.issue30496@psf.upfronthosting.co.za>
In-reply-to
Content
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)
History
Date User Action Args
2017-05-28 13:28:54stefansetrecipients: + stefan
2017-05-28 13:28:54stefansetmessageid: <1495978134.83.0.774241176124.issue30496@psf.upfronthosting.co.za>
2017-05-28 13:28:54stefanlinkissue30496 messages
2017-05-28 13:28:54stefancreate