This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: inspect module and class startlineno
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: aligrudi, georg.brandl
Priority: normal Keywords:

Created on 2006-09-01 13:26 by aligrudi, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg29723 - (view) Author: Ali Gholami Rudi (aligrudi) Date: 2006-09-01 13:26
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.
msg29724 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-10-12 09:21
Logged In: YES 
user_id=849994

Added a better find heuristics in rev.  52299, 52300 (2.5).
(More can't be done)
History
Date User Action Args
2022-04-11 14:56:19adminsetgithub: 43921
2006-09-01 13:26:38aligrudicreate