Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #79955

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

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 <python-python-list@m.gmane.org>
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 <CALyLaQJxfX_3aeACPjjkfzOKx+5K=uG9_PJZVFAfiUbL2t=ekw@mail.gmail.com>
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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.15322.1414673413.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


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.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: When using a decorator exceptions raised reference the decorator not the function Peter Otten <__peter__@web.de> - 2014-10-30 13:45 +0100

csiph-web