Author eltoder
Recipients eltoder
Date 2020-10-23.05:26:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1603430813.16.0.973913314648.issue42125@roundup.psfhosted.org>
In-reply-to
Content
If a module has a loader, linecache calls its get_source() passing __name__ as the argument. This works most of the time, except that the __main__ module has it set to "__main__", which is commonly not the real name of the module. Luckily, we now have __spec__ which has the real name, so we can just use it.

Attached zip file reproduces the problem:
$ python t.zip
Traceback (most recent call last):
  ...
  File "t.zip/t.py", line 11, in <module>
  File "t.zip/t.py", line 8, in f
  File "t.zip/t.py", line 8, in f
  File "t.zip/t.py", line 8, in f
  [Previous line repeated 2 more times]
  File "t.zip/t.py", line 7, in f
ValueError

Note that entries from t.py don't have source code lines.
History
Date User Action Args
2020-10-23 05:26:53eltodersetrecipients: + eltoder
2020-10-23 05:26:53eltodersetmessageid: <1603430813.16.0.973913314648.issue42125@roundup.psfhosted.org>
2020-10-23 05:26:53eltoderlinkissue42125 messages
2020-10-23 05:26:52eltodercreate