diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2009-07-11 09:37:09 +0000 |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2009-07-11 09:37:09 +0000 |
commit | 041b3baf53e3d1bf4b9941fd91ff807daef5965d (patch) | |
tree | e1ea38a7af741763ce9138df82530c0e64ec1d1e | |
parent | 1caf206ac941c2051cfea189d7431e7cf27fa21b (diff) | |
download | cpython-git-041b3baf53e3d1bf4b9941fd91ff807daef5965d.tar.gz |
Merged revisions 73934 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r73934 | amaury.forgeotdarc | 2009-07-11 11:35:13 +0200 (sam., 11 juil. 2009) | 3 lines
#6358: Merge r73933: Add basic tests for the return value of os.popen().close().
And fix the implementation to make these tests pass with py3k
........
-rw-r--r-- | Lib/os.py | 8 | ||||
-rw-r--r-- | Lib/test/test_popen.py | 7 | ||||
-rw-r--r-- | Misc/NEWS | 3 |
3 files changed, 17 insertions, 1 deletions
@@ -643,7 +643,13 @@ class _wrap_close: self._proc = proc def close(self): self._stream.close() - return self._proc.wait() << 8 # Shift left to match old behavior + returncode = self._proc.wait() + if returncode == 0: + return None + if name == 'nt': + return returncode + else: + return returncode << 8 # Shift left to match old behavior def __getattr__(self, name): return getattr(self._stream, name) def __iter__(self): diff --git a/Lib/test/test_popen.py b/Lib/test/test_popen.py index d72879280c..99ad41df74 100644 --- a/Lib/test/test_popen.py +++ b/Lib/test/test_popen.py @@ -42,6 +42,13 @@ class PopenTest(unittest.TestCase): ) support.reap_children() + def test_return_code(self): + self.assertEqual(os.popen("exit 0").close(), None) + if os.name == 'nt': + self.assertEqual(os.popen("exit 42").close(), 42) + else: + self.assertEqual(os.popen("exit 42").close(), 42 << 8) + def test_main(): support.run_unittest(PopenTest) @@ -34,6 +34,9 @@ C-API Library ------- +- Issue #6358: The exit status of a command started with os.popen() was + reported differently than it did with python 2.x. + - Issue #6323: The pdb debugger did not exit when running a script with a syntax error. |