Michael Felt <aixto...@felt.demon.nl> added the comment:
When testing the PR with --with-pydebug I started getting the following error: root@x066:[/data/prj/python/git/pr-test]./python '-X' 'tracemalloc' -m test test_venv Run tests sequentially 0:00:00 [1/1] test_venv test test_venv failed -- Traceback (most recent call last): File "/data/prj/python/git/pr-test/Lib/test/test_venv.py", line 501, in test_with_pip self.do_test_with_pip(False) File "/data/prj/python/git/pr-test/Lib/test/test_venv.py", line 459, in do_test_with_pip self.assertEqual(err, "") AssertionError: '/data/prj/python/git/pr-test/Lib/_aix_sup[277 chars]t,\n' != '' - /data/prj/python/git/pr-test/Lib/_aix_support.py:47: ResourceWarning: unclosed file <_io.TextIOWrapper name=4 encoding='ISO8859-1'> - return aix_pep425() - Object allocated at (most recent call last): - File "/data/prj/python/git/pr-test/Lib/subprocess.py", lineno 837 - self.stdout = io.TextIOWrapper(self.stdout, test_venv failed in 34 sec 401 ms == Tests result: FAILURE == 1 test failed: test_venv Total duration: 34 sec 485 ms Tests result: FAILURE +++ capturing some debug output: root@x066:[/data/prj/python/git/pr-test]cat /tmp/test_venv.debug env:/tmp/tmppcl06489/bin/python '-X', 'tracemalloc', '-W', 'ignore::DeprecationWarning', '-I', -m pip --version err:/data/prj/python/git/pr-test/Lib/_aix_support.py:47: ResourceWarning: unclosed file <_io.TextIOWrapper name=4 encoding='ISO8859-1'> return aix_pep425() Object allocated at (most recent call last): File "/data/prj/python/git/pr-test/Lib/subprocess.py", lineno 837 self.stdout = io.TextIOWrapper(self.stdout, out:pip 19.2.1 from /tmp/tmppcl06489/lib/python3.9/site-packages/pip (python 3.9) +++ I thought - p = Popen(....) .... p.wait() that the call p.wait() was waiting for the process to complete (and close files). Apparently, that is not the case. Note: changing p.wait() to p.wait is not the solution: the message changes to: AssertionError: '/data/prj/python/git/pr-test/Lib/subproce[609 chars]t,\n' != '' - /data/prj/python/git/pr-test/Lib/subprocess.py:933: ResourceWarning: subprocess 11337774 is still running - _warn("subprocess %s is still running" % self.pid, - Object allocated at (most recent call last): - File "/data/prj/python/git/pr-test/Lib/_aix_support.py", lineno 35 - p = Popen(["/usr/bin/lslpp", "-Lqc", "bos.mp64"], - /data/prj/python/git/pr-test/Lib/_aix_support.py:47: ResourceWarning: unclosed file <_io.TextIOWrapper name=4 encoding='ISO8859-1'> - return aix_pep425() - Object allocated at (most recent call last): - File "/data/prj/python/git/pr-test/Lib/subprocess.py", lineno 837 - self.stdout = io.TextIOWrapper(self.stdout, root@x066:[/data/prj/python/git/pr-test]cat /tmp/test_venv.debug env:/tmp/tmp8wpnz193/bin/python '-X', 'tracemalloc', '-W', 'ignore::DeprecationWarning', '-I', -m pip --version err:/data/prj/python/git/pr-test/Lib/subprocess.py:933: ResourceWarning: subprocess 11337774 is still running _warn("subprocess %s is still running" % self.pid, Object allocated at (most recent call last): File "/data/prj/python/git/pr-test/Lib/_aix_support.py", lineno 35 p = Popen(["/usr/bin/lslpp", "-Lqc", "bos.mp64"], /data/prj/python/git/pr-test/Lib/_aix_support.py:47: ResourceWarning: unclosed file <_io.TextIOWrapper name=4 encoding='ISO8859-1'> return aix_pep425() Object allocated at (most recent call last): File "/data/prj/python/git/pr-test/Lib/subprocess.py", lineno 837 self.stdout = io.TextIOWrapper(self.stdout, out:pip 19.2.1 from /tmp/tmp8wpnz193/lib/python3.9/site-packages/pip (python 3.9) I was able to resolve the issue by changing Popen() to run(): oot@x066:[/data/prj/python/git/pr-test]diff -u /data/prj/python/git/pr-test/Lib/_aix_support.py /tmp/_aix_support.py --- /data/prj/python/git/pr-test/Lib/_aix_support.py 2019-09-08 16:24:51.000000000 +0000 +++ /tmp/_aix_support.py 2019-09-08 16:17:14.000000000 +0000 @@ -1,7 +1,7 @@ """Shared AIX support functions.""" import sys - from subprocess import Popen, PIPE, DEVNULL + from subprocess import run from sysconfig import get_config_var as get_var _is_32bit = sys.maxsize == 2147483647 @@ -32,10 +32,9 @@ The pep425 platform tag for AIX becomes: AIX.VRTL.YYWW.SZ, e.g., AIX.6107.1415.32 """ - p = Popen(["/usr/bin/lslpp", "-Lqc", "bos.mp64"], - universal_newlines=True, stdout=PIPE, stderr=DEVNULL) - _lslppLqc = p.stdout.read().strip().split(":") - p.wait + p = run(["/usr/bin/lslpp", "-Lqc", "bos.mp64"], + capture_output=True, text=True) + _lslppLqc = p.stdout.strip().split(":") (lpp, vrmf, bd) = list(_lslppLqc[index] for index in [0, 2, -1]) assert lpp == "bos.mp64", "%s != %s" % (lpp, "bos.mp64") Don't know if this is a bug in Popen(), or just an error in my use of Popen(). Happy that using run() solves it! ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue38021> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com