Martin Panter added the comment:
The file position is often useful when the cleanup is deterministic. Example:
def f1():
file1 = open("/dev/null")
def f2():
file2 = open("/dev/null")
del file2 # ResourceWarning
f1() # ResourceWarning at function exit
f2()
In the these cases, the line number can identify the affected code:
demo.py:8: ResourceWarning: unclosed file <_io.TextIOWrapper name='/dev/null'
mode='r' encoding='UTF-8'>
f1() # ResourceWarning at function exit
demo.py:6: ResourceWarning: unclosed file <_io.TextIOWrapper name='/dev/null'
mode='r' encoding='UTF-8'>
del file2 # ResourceWarning
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue29564>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com