Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news2.arglkargh.de!news.ecp.fr!news.stack.nl!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:not': 0.03; 'preferably': 0.05; 'decorator': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:using': 0.09; 'python': 0.11; '2.7': 0.14; 'called,': 0.16; 'raised.': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'subject:raised': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'code,': 0.22; 'creating': 0.23; 'header:User-Agent:1': 0.23; 'example.': 0.24; 'logging': 0.26; 'header:X-Complaints-To:1': 0.27; 'function': 0.29; "i'm": 0.30; 'exceptions': 0.31; 'extract': 0.31; 'origin': 0.31; 'raised': 0.31; 'class': 0.32; 'subject:the': 0.34; 'thank': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'you.': 0.62; 'show': 0.63; 'information': 0.63 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: When using a decorator exceptions raised reference the decorator not the function Date: Thu, 30 Oct 2014 13:45:42 +0100 Organization: None References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Gmane-NNTP-Posting-Host: p57bd8db1.dip0.t-ipconnect.de User-Agent: KNode/4.13.3 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1414673413 news.xs4all.nl 2848 [2001:888:2000:d::a6]:37370 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:79955 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 you.