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/102735.html below:

[Python-Dev] co_firstlineno on decorated functions

[Python-Dev] co_firstlineno on decorated functions [Python-Dev] co_firstlineno on decorated functionsEli Bendersky eliben at gmail.com
Tue Aug 3 05:40:52 CEST 2010
[Since I received no replies on this in python-list, perhaps python-dev is
more appropriate]


Hello,

I've been tinkering with __code__.co_firstlineno for testing the trace.py
module (Python Issue 9315), and ran into an interesting problem. Consider
this code:


def dummydecorator(f):
    return f

def foo(a):
    return a

@dummydecorator
def bar(a):
    return a


if __name__ == "__main__":
    print foo.__code__.co_firstlineno
    print bar.__code__.co_firstlineno

----
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?

Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20100803/069d2b81/attachment.html>
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