[issue41007] test_importlib logs ResourceWarning: test_path.CommonTests.test_importing_module_as_side_effect()
STINNER Victor
report at bugs.python.org
Wed Jun 17 10:33:20 EDT 2020
New submission from STINNER Victor <vstinner at python.org>:
It seems like the issue was introduced in bpo-39791 by:
commit 843c27765652e2322011fb3e5d88f4837de38c06
Author: Jason R. Coombs <jaraco at jaraco.com>
Date: Sun Jun 7 21:00:51 2020 -0400
bpo-39791 native hooks for importlib.resources.files (GH-20576)
The warning:
$ ./python -X tracemalloc=20 -m test test_importlib -m test.test_importlib.test_path.CommonTests.test_importing_module_as_side_effect -v
== CPython 3.10.0a0 (heads/importlib_typing:d1b0d052cf, Jun 17 2020, 16:09:52) [GCC 10.1.1 20200507 (Red Hat 10.1.1-1)]
== Linux-5.6.18-300.fc32.x86_64-x86_64-with-glibc2.31 little-endian
== cwd: /home/vstinner/python/master/build/test_python_67972
== CPU count: 8
== encodings: locale=UTF-8, FS=utf-8
0:00:00 load avg: 0.44 Run tests sequentially
0:00:00 load avg: 0.44 [1/1] test_importlib
test_importing_module_as_side_effect (test.test_importlib.test_path.CommonTests) ... /home/vstinner/python/master/Lib/contextlib.py:124: ResourceWarning: unclosed file <_io.BufferedReader name='/home/vstinner/python/master/Lib/test/test_importlib/data01/utf-8.file'>
next(self.gen)
Object allocated at (most recent call last):
File "/home/vstinner/python/master/Lib/unittest/runner.py", lineno 176
test(result)
File "/home/vstinner/python/master/Lib/unittest/suite.py", lineno 84
return self.run(*args, **kwds)
File "/home/vstinner/python/master/Lib/unittest/suite.py", lineno 122
test(result)
File "/home/vstinner/python/master/Lib/unittest/suite.py", lineno 84
return self.run(*args, **kwds)
File "/home/vstinner/python/master/Lib/unittest/suite.py", lineno 122
test(result)
File "/home/vstinner/python/master/Lib/unittest/suite.py", lineno 84
return self.run(*args, **kwds)
File "/home/vstinner/python/master/Lib/unittest/suite.py", lineno 122
test(result)
File "/home/vstinner/python/master/Lib/unittest/suite.py", lineno 84
return self.run(*args, **kwds)
File "/home/vstinner/python/master/Lib/unittest/suite.py", lineno 122
test(result)
File "/home/vstinner/python/master/Lib/unittest/suite.py", lineno 84
return self.run(*args, **kwds)
File "/home/vstinner/python/master/Lib/unittest/suite.py", lineno 122
test(result)
File "/home/vstinner/python/master/Lib/unittest/case.py", lineno 653
return self.run(*args, **kwds)
File "/home/vstinner/python/master/Lib/unittest/case.py", lineno 593
self._callTestMethod(testMethod)
File "/home/vstinner/python/master/Lib/unittest/case.py", lineno 550
method()
File "/home/vstinner/python/master/Lib/test/test_importlib/util.py", lineno 509
self.execute(data01.__name__, 'utf-8.file')
File "/home/vstinner/python/master/Lib/test/test_importlib/test_path.py", lineno 10
with resources.path(package, path):
File "/home/vstinner/python/master/Lib/contextlib.py", lineno 117
return next(self.gen)
File "/home/vstinner/python/master/Lib/importlib/resources.py", lineno 118
opener_reader = reader.open_resource(norm_resource)
File "/home/vstinner/python/master/Lib/importlib/abc.py", lineno 465
return self.files().joinpath(resource).open('rb')
File "/home/vstinner/python/master/Lib/pathlib.py", lineno 1238
return io.open(self, mode, buffering, encoding, errors, newline,
ok
----------------------------------------------------------------------
Ran 1 test in 0.134s
OK
== Tests result: SUCCESS ==
1 test OK.
Total duration: 6.2 sec
Tests result: SUCCESS
----------
components: Tests
messages: 371743
nosy: vstinner
priority: normal
severity: normal
status: open
title: test_importlib logs ResourceWarning: test_path.CommonTests.test_importing_module_as_side_effect()
versions: Python 3.10
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41007>
_______________________________________
More information about the Python-bugs-list
mailing list