A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2010-August/102748.html below:

[Python-Dev] co_firstlineno on decorated functions

[Python-Dev] co_firstlineno on decorated functionsNick Coghlan ncoghlan at gmail.com
Tue Aug 3 14:25:01 CEST 2010
On Tue, Aug 3, 2010 at 1:40 PM, Eli Bendersky <eliben at gmail.com> wrote:
> The first print out correctly specifies the line "def foo" is in. However,
> the second one points to the line with "@dummydecorator" instead of "def
> bar". [Python 2.6]
>
> The side-effects of this behavior can be easily seen in the output of
> modules like trace and profile. Would you say it's normal, or could this be
> considered a bug?

Since the decorator is as much a part of the function definition as
the def line is, I would say that it is correct (the name says
"firstlineno", not "deflineno"). inspect.getsource() and friends
actually rely on this behaviour, so changing it really isn't an
option.

However, that does mean *using* it as though it always points to the
def line is incorrect, suggesting there are related bugs in trace and
profile.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4