STINNER Victor added the comment:
It looks like logging a warning at Python exit always works on Python 2.7:
---
import _warnings
class Bla:
def __del__(self, w=_warnings):
w.warn_explicit('message', DeprecationWarning, 'x.py', 5)
bla = Bla()
---
It looks like it uses the Python implementation and linecache.getline() always
works. Maybe the warning is emitted earlier that the Python 3 code emitting
ResourceWarning. I see that warnings.py of Python 2 imports linecache at top
level, whereas the Python 3 code imports the module at the first use in
showwarning(). I recall that imports at top level are avoided to get faster
startup time.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue21925>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com