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.

classification
Title: ResourceWarning in test_zipfile64
Type: resource usage Stage: resolved
Components: Tests Versions: Python 3.6, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: SilentGhost, alanmcintyre, martin.panter, python-dev, serhiy.storchaka, twouters
Priority: normal Keywords: needs review

Created on 2015-12-04 22:36 by SilentGhost, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue25801.diff SilentGhost, 2015-12-05 09:02 review
Messages (7)
msg255890 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2015-12-04 22:36
Running test_zipfile64 from command line (i.e., ./python Lib/test/test_zipfile64.py) I get two ResourceWarnings:

» ./python Lib/test/test_zipfile64.py                                                     
..Lib/test/test_zipfile64.py:82: ResourceWarning: unclosed file <_io.BufferedRandom name=4>
  for f in TemporaryFile(), TESTFN2:
.Lib/test/test_zipfile64.py:75: ResourceWarning: unclosed file <_io.BufferedRandom name=4>
  for f in TemporaryFile(), TESTFN2:
.
----------------------------------------------------------------------
Ran 4 tests in 356.228s

OK

Wasn't able to test with "-m test" even with -uall. Will try again tomorrow.
msg255906 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-12-05 00:08
It looks like it is disabled from the regular test suite on purpose:

# XXX(nnorwitz): disable this test by looking for extra largfile [sic] resource
# which doesn't exist.  This test takes over 30 minutes to run in general
# and requires more disk space than most of the buildbots.
support.requires(
        'extralargefile',
        'test requires loads of disk-space bytes and a long time to run'
    )

I’m not sure why the proper “largefile” flag cannot be used: “It is okay to run some test that may create huge files. These tests can take a long time and may consume >2GB of disk space temporarily.”

As for the reported problem, perhaps the TemporaryFile() call sites should have a “with” statement added.
msg255932 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-12-05 08:09
The purpose was to exclude it from run with -uall. It is norm if one or two test methods are needed the "largefile" flag. But if all methods in a test file create large files, running this test file becomes a pain.
msg255938 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2015-12-05 09:02
Thanks, Serhiy. Running the test with test module: ./python -m test -v test_zipfile64
doesn't produce the same warning. With this patch the warning is gone in command-line mode too.

I haven't looked to verify that it's not an issue on 3.5 or earlier versions, but then I'm not sure about policy on that anyway.
msg255988 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-12-05 22:50
Patch looks fine according to my limited understanding of the zipfile module.
msg260849 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-02-25 11:16
New changeset baec3e2e1b1f by Serhiy Storchaka in branch '3.5':
Issue #25801: Fixed resource warnings in test_zipfile64.
https://hg.python.org/cpython/rev/baec3e2e1b1f

New changeset 32051701a49d by Serhiy Storchaka in branch '2.7':
Issue #25801: Fixed resource warnings in test_zipfile64.
https://hg.python.org/cpython/rev/32051701a49d

New changeset 2193f8b956de by Serhiy Storchaka in branch 'default':
Issue #25801: Fixed resource warnings in test_zipfile64.
https://hg.python.org/cpython/rev/2193f8b956de
msg260850 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-02-25 11:23
Thank you for your patch SilentGhost.
History
Date User Action Args
2022-04-11 14:58:24adminsetgithub: 69987
2016-02-25 11:23:49serhiy.storchakasetstatus: languishing -> closed
versions: + Python 2.7, Python 3.5
type: resource usage
messages: + msg260850

resolution: fixed
stage: patch review -> resolved
2016-02-25 11:16:36python-devsetnosy: + python-dev
messages: + msg260849
2016-02-24 10:42:31serhiy.storchakasetassignee: serhiy.storchaka
2016-02-22 17:45:10SilentGhostsetstatus: open -> languishing
2015-12-05 22:50:25martin.pantersetmessages: + msg255988
2015-12-05 13:00:12SilentGhostsetkeywords: + needs review, - patch
2015-12-05 09:02:50SilentGhostsetkeywords: + patch
files: + issue25801.diff
messages: + msg255938

stage: patch review
2015-12-05 08:09:19serhiy.storchakasetmessages: + msg255932
2015-12-05 00:08:01martin.pantersetnosy: + martin.panter
messages: + msg255906
2015-12-04 22:36:35SilentGhostcreate