This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author martin.panter
Recipients David Ford (FirefighterBlu3), martin.panter, vstinner
Date 2017-02-15.13:02:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1487163725.52.0.135232602747.issue29564@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2017-02-15 13:02:05martin.pantersetrecipients: + martin.panter, vstinner, David Ford (FirefighterBlu3)
2017-02-15 13:02:05martin.pantersetmessageid: <1487163725.52.0.135232602747.issue29564@psf.upfronthosting.co.za>
2017-02-15 13:02:05martin.panterlinkissue29564 messages
2017-02-15 13:02:05martin.pantercreate