Message294645
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) |
|
Date |
User |
Action |
Args |
2017-05-28 13:28:54 | stefan | set | recipients:
+ stefan |
2017-05-28 13:28:54 | stefan | set | messageid: <1495978134.83.0.774241176124.issue30496@psf.upfronthosting.co.za> |
2017-05-28 13:28:54 | stefan | link | issue30496 messages |
2017-05-28 13:28:54 | stefan | create | |
|