When using a decorator exceptions raised reference the decorator not the function

Peter Otten __peter__ at web.de
Thu Oct 30 13:45:42 CET 2014

Néstor Boscán wrote:

> I'm using Python 2.7 and I'm creating a class decorator that extract
> information from exceptions for logging purposes.
> Everytime an exception is raised from the original function and I extract
> the origin of the exception with sys.exc_info() I get a reference to the
> line in the decorator where the function is called, not the line of the
> original function where the exception was raised.
> Any ideas?

Please show us the code, preferably as a small self-contained example. Thank 

More information about the Python-list mailing list