STINNER Victor added the comment: By the way, the filename of the warning is not really useful. Example script test.py: --------------------- f = open(__file__) ---------------------
At exit, Python displays: --------------------- sys:1: ResourceWarning: unclosed file <_io.TextIOWrapper name='test.py' mode='r' encoding='UTF-8'> --------------------- "sys" is not a real file, _Py_DisplaySourceLine() would not be able to display the Python line (the correct filename is test.py). Python traceback when the warning is emitted, according to gdb: --------------------- (gdb) py-bt Traceback (most recent call first): <built-in method _dealloc_warn of _io.FileIO object at remote 0x7ffff1a04368> <built-in method _dealloc_warn of _io.BufferedReader object at remote 0x7ffff1ae4838> <built-in method close of _io.TextIOWrapper object at remote 0x7ffff1b97dc0> --------------------- We are in PyImport_Cleanup(), called by Py_Finalize(). ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue19421> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com