Author pekka.klarck
Recipients pekka.klarck
Date 2020-06-01.11:41:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The docs of inspect.getsourcefile [1] mention the function can raise TypeError, but there's nothing about the function possibly returning None. This caused a bug in our project [2].

If I understand the code [3] correctly, None is returned if getsourcefile cannot determine the original source file of the file returned by getfile. That's understandable but should definitely be documented. Raising TypeError that getfile itself may raise might be even better, but such a backwards incompatible API change is probably not worth the effort.

While looking at the code, I also noticed there's getabsfile [4] that uses getfile if getsourcefile returns None. That looks handy but since the function isn't included in the inspect module documentation [5] using it feels pretty risky.

Date User Action Args
2020-06-01 11:41:44pekka.klarcksetrecipients: + pekka.klarck
2020-06-01 11:41:44pekka.klarcksetmessageid: <>
2020-06-01 11:41:44pekka.klarcklinkissue40838 messages
2020-06-01 11:41:44pekka.klarckcreate