Message287850
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 |
|
Date |
User |
Action |
Args |
2017-02-15 13:02:05 | martin.panter | set | recipients:
+ martin.panter, vstinner, David Ford (FirefighterBlu3) |
2017-02-15 13:02:05 | martin.panter | set | messageid: <1487163725.52.0.135232602747.issue29564@psf.upfronthosting.co.za> |
2017-02-15 13:02:05 | martin.panter | link | issue29564 messages |
2017-02-15 13:02:05 | martin.panter | create | |
|