]> granicus.if.org Git - python/commitdiff
Fixes issue #26083: Workaround a subprocess bug that raised an incorrect
authorGregory P. Smith <greg@krypto.org>
Mon, 11 Jan 2016 21:56:42 +0000 (13:56 -0800)
committerGregory P. Smith <greg@krypto.org>
Mon, 11 Jan 2016 21:56:42 +0000 (13:56 -0800)
"ValueError: insecure string pickle" exception instead of the actual exception
on some platforms such as Mac OS X when an exception raised in the forked child
process prior to the exec() was large enough that it overflowed the internal
errpipe_read pipe buffer.

Lib/subprocess.py
Misc/NEWS

index 4e7b0644a6bd21f5107d279e97162648954ba6d1..78189f42defcb5d97b0010123590c8299926dbb8 100644 (file)
@@ -1313,8 +1313,12 @@ class Popen(object):
                     os.close(errpipe_write)
 
                 # Wait for exec to fail or succeed; possibly raising exception
-                # Exception limited to 1M
                 data = _eintr_retry_call(os.read, errpipe_read, 1048576)
+                pickle_bits = [data]
+                while data:
+                    pickle_bits.append(data)
+                    data = _eintr_retry_call(os.read, errpipe_read, 1048576)
+                data = "".join(pickle_bits)
             finally:
                 if p2cread is not None and p2cwrite is not None:
                     _close_in_parent(p2cread)
index f74c18473189b8803c9940bee6bf35780eaf84a9..e533d55d7117056c5d17c706aae69deda49b5e39 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -39,6 +39,12 @@ Core and Builtins
 Library
 -------
 
+- Issue #26083: Workaround a subprocess bug that raises an incorrect
+  "ValueError: insecure string pickle" exception instead of the actual
+  exception on some platforms such as Mac OS X when an exception raised
+  in the forked child process prior to the exec() was large enough that
+  it overflowed the internal errpipe_read pipe buffer.
+
 - Issue #24103: Fixed possible use after free in ElementTree.iterparse().
 
 - Issue #20954: _args_from_interpreter_flags used by multiprocessing and some