[Python-checkins] cpython (3.2): Rename a local variable for readability and change a "this can't

gregory.p.smith python-checkins at python.org
Sun Nov 11 08:35:21 CET 2012


http://hg.python.org/cpython/rev/99c63578f932
changeset: 80372:99c63578f932
branch: 3.2
parent: 80368:63ff4c9a2ed2
user: Gregory P. Smith <greg at krypto.org>
date: Sat Nov 10 23:33:17 2012 -0800
summary:
 Rename a local variable for readability and change a "this can't
happen" print() call into a RuntimeWarning as it should've been in the
first place. Because nothing should ever cause unexpected stdout output.
files:
 Lib/subprocess.py | 14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -1351,26 +1351,28 @@
 
 # Wait for exec to fail or succeed; possibly raising an
 # exception (limited in size)
- data = bytearray()
+ errpipe_data = bytearray()
 while True:
 part = _eintr_retry_call(os.read, errpipe_read, 50000)
- data += part
- if not part or len(data) > 50000:
+ errpipe_data += part
+ if not part or len(errpipe_data) > 50000:
 break
 finally:
 # be sure the FD is closed no matter what
 os.close(errpipe_read)
 
- if data:
+ if errpipe_data:
 try:
 _eintr_retry_call(os.waitpid, self.pid, 0)
 except OSError as e:
 if e.errno != errno.ECHILD:
 raise
 try:
- exception_name, hex_errno, err_msg = data.split(b':', 2)
+ exception_name, hex_errno, err_msg = (
+ errpipe_data.split(b':', 2))
 except ValueError:
- print('Bad exception data:', repr(data))
+ warnings.warn(RuntimeWarning(
+ 'Bad exception data: %r' % errpipe_data))
 exception_name = b'RuntimeError'
 hex_errno = b'0'
 err_msg = b'Unknown'
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /