[issue34500] Fix ResourceWarning in difflib.py
New submission from Mickaël Schoentgen <contact@tiger-222.fr>: Fix 2 unclosed files in the documentation and the difflib.py script: diff.py:77: ResourceWarning: unclosed file <_io.TextIOWrapper name='/tmp/tmpnby8pemn' mode='U' encoding='UTF-8'> fromlines = open(fromfile, 'U').readlines() diff.py:78: ResourceWarning: unclosed file <_io.TextIOWrapper name='/tmp/tmpnby8pemm' mode='U' encoding='UTF-8'> self.tolines = open(tofile, 'U').readlines() ---------- assignee: docs@python components: Demos and Tools, Documentation messages: 324071 nosy: David Bieber, Tiger-222, docs@python priority: normal severity: normal status: open title: Fix ResourceWarning in difflib.py versions: Python 2.7 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34500> _______________________________________
Change by Mickaël Schoentgen <contact@tiger-222.fr>: ---------- keywords: +patch pull_requests: +8397 stage: -> patch review _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34500> _______________________________________
Mickaël Schoentgen <contact@tiger-222.fr> added the comment: This is a little patch to mostly keep aligned with https://github.com/google/python-fire/pull/135. ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34500> _______________________________________
Terry J. Reedy <tjreedy@udel.edu> added the comment: The change to Tools/scripts/diff.py us effectively a backport of the the patch merged for #7582. The git log labels it as a2637729f23dc993e820fd92f0d1759ad714c9b2. The change to Doc/library/difflib.rst does not apply to current 3.x as the test code is no longer present. ---------- nosy: +terry.reedy _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34500> _______________________________________
Terry J. Reedy <tjreedy@udel.edu> added the comment: New changeset 30af2e737aad427d4da97f8dadeeecff6c2b28f5 by Terry Jan Reedy (Mickaël Schoentgen) in branch '2.7': bpo-34500: Fix ResourceWarning in difflib.py (GH-8926) https://github.com/python/cpython/commit/30af2e737aad427d4da97f8dadeeecff6c2... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34500> _______________________________________
Terry J. Reedy <tjreedy@udel.edu> added the comment: Using 'with open' is now standard. Thanks for the update. In the message above, /us/is/. ---------- resolution: -> fixed stage: patch review -> resolved status: open -> closed type: -> behavior _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34500> _______________________________________
participants (2)
-
Mickaël Schoentgen
-
Terry J. Reedy