Re: [Python-Dev] co_firstlineno on decorated functions

2010-08-03 Thread Greg Ewing
Guido van Rossum wrote: What are the use cases for co_firstlineno? Even if it is for displaying the source code, I can find virtue for both sides of this argument. Seems to me that if the code is being displayed to a human, the decorators are an important thing to know about, so including them

Re: [Python-Dev] co_firstlineno on decorated functions

2010-08-03 Thread Terry Reedy
On 8/3/2010 8:48 AM, Antoine Pitrou wrote: On Tue, 3 Aug 2010 22:25:01 +1000 Nick Coghlan wrote: On Tue, Aug 3, 2010 at 1:40 PM, Eli Bendersky 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

Re: [Python-Dev] co_firstlineno on decorated functions

2010-08-03 Thread Alexander Belopolsky
On Tue, Aug 3, 2010 at 9:05 AM, Nick Coghlan wrote: > .. While I'd agree with you for a > clean slate definition, that's not what we're dealing with here: > "co_firstlineno" has an existing meaning, and it *isn't* "the line > containing the def keyword", it's "the first line of the function, > inc

Re: [Python-Dev] co_firstlineno on decorated functions

2010-08-03 Thread Antoine Pitrou
Le mardi 03 août 2010 à 11:05 -0400, Raghuram Devarakonda a écrit : > On Tue, Aug 3, 2010 at 10:14 AM, Guido van Rossum wrote: > > > What are the use cases for co_firstlineno? Even if it is for > > displaying the source code, I can find virtue for both sides of this > > argument. > > nose uses c

Re: [Python-Dev] co_firstlineno on decorated functions

2010-08-03 Thread Raghuram Devarakonda
On Tue, Aug 3, 2010 at 10:14 AM, Guido van Rossum wrote: > What are the use cases for co_firstlineno? Even if it is for > displaying the source code, I can find virtue for both sides of this > argument. nose uses co_firstlineno to determine order of the test functions and decorating a test funct

Re: [Python-Dev] co_firstlineno on decorated functions

2010-08-03 Thread Guido van Rossum
On Tue, Aug 3, 2010 at 6:05 AM, Nick Coghlan wrote: > On Tue, Aug 3, 2010 at 10:48 PM, Antoine Pitrou wrote: >> Furthermore, co_firstlineno is an attribute of the code object, not the >> function object, so it shouldn't ideally depend on whether a decorator >> was applied or not. > > You cut the

Re: [Python-Dev] co_firstlineno on decorated functions

2010-08-03 Thread Nick Coghlan
On Tue, Aug 3, 2010 at 10:48 PM, Antoine Pitrou wrote: > Furthermore, co_firstlineno is an attribute of the code object, not the > function object, so it shouldn't ideally depend on whether a decorator > was applied or not. You cut the part about the inspect module (and no doubt other code) relyi

Re: [Python-Dev] co_firstlineno on decorated functions

2010-08-03 Thread Antoine Pitrou
On Tue, 3 Aug 2010 22:25:01 +1000 Nick Coghlan wrote: > On Tue, Aug 3, 2010 at 1:40 PM, Eli Bendersky 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] > > > > T

Re: [Python-Dev] co_firstlineno on decorated functions

2010-08-03 Thread Nick Coghlan
On Tue, Aug 3, 2010 at 1:40 PM, Eli Bendersky 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 o