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.

Author ggenellina
Recipients ggenellina
Date 2009-08-14.04:19:18
SpamBayes Score 5.912082e-11
Marked as misclassified No
Message-id <1250223562.74.0.274098839265.issue6700@psf.upfronthosting.co.za>
In-reply-to
Content
inspect.getsource(obj) returns incorrect results when obj is a 
traceback or frame object outside any function (that is, at the module 
level).

This demo script shows the problem. The correct output should contain 
all source lines in the module, but it only returns the first two:


D:\temp>type show_inspect_bug.py
def foo(x):
  return y + z

import inspect
frame = inspect.currentframe()
print inspect.getsource(frame)


D:\temp>python show_inspect_bug.py
def foo(x):
  return y + z


The attached patch fixes the problem and adds some missing test cases.
Originally reported by Juanjo Conti at the local Python group.
History
Date User Action Args
2009-08-14 04:19:22ggenellinasetrecipients: + ggenellina
2009-08-14 04:19:22ggenellinasetmessageid: <1250223562.74.0.274098839265.issue6700@psf.upfronthosting.co.za>
2009-08-14 04:19:21ggenellinalinkissue6700 messages
2009-08-14 04:19:20ggenellinacreate