[ python-Bugs-1550524 ] inspect module and class startlineno

SourceForge.net noreply at sourceforge.net
Fri Sep 1 15:26:38 CEST 2006


Bugs item #1550524, was opened at 2006-09-01 17:56
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1550524&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Ali Gholami Rudi (aligrudi)
Assigned to: Nobody/Anonymous (nobody)
Summary: inspect module and class startlineno

Initial Comment:
Inspect module fails to find the correct starting line
number of a class. ::

  import inspect

  def a_func():
      class AClass(object):
          pass

  class AClass(object):
      pass

  print inspect.findsource(AClass)[1]
  # the result should have been 7, but it is 4

After reading `inspect` module I realized that for
classes it does a
simple RE search to find their definition location. 
Apart from that I
think python does not seem to fully support classes
with the same name
in one module (nested classes that are defined in other
functions or
classes).  That is a `ClassType` only holds its module
and its name
and that is hardly enough for runtime analysis of objects.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1550524&group_id=5470


More information about the Python-bugs-list mailing list