diff options
author | Zac Medico <zmedico@gentoo.org> | 2012-12-15 14:04:28 -0800 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2012-12-15 14:04:28 -0800 |
commit | 0db4c2a0f8b80b3f08a9a1f068a8cd0b2ff1fe4f (patch) | |
tree | c204d69eae88d5977ed70fdf32df3ee00b19680b /pym/portage/__init__.py | |
parent | e91e0dac2fbcec4ebb42af29e2914a120341eefa (diff) | |
download | portage-0db4c2a0f8b80b3f08a9a1f068a8cd0b2ff1fe4f.tar.gz portage-0db4c2a0f8b80b3f08a9a1f068a8cd0b2ff1fe4f.tar.bz2 portage-0db4c2a0f8b80b3f08a9a1f068a8cd0b2ff1fe4f.zip |
Handle closed sys.__stdin__, for multiprocessing
Buggy code in python's multiprocessing/process.py closes sys.stdin and
reassigns it to open(os.devnull), but fails to update the corresponding
__stdin__ reference. So, detect that case and handle it appropriately.
The buggy code is visible in http://hg.python.org/lookup/r73708.
Diffstat (limited to 'pym/portage/__init__.py')
-rw-r--r-- | pym/portage/__init__.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 3e634b53b..96a4fa98c 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -339,6 +339,17 @@ _internal_warnings = False _sync_disabled_warnings = False +def _get_stdin(): + """ + Buggy code in python's multiprocessing/process.py closes sys.stdin + and reassigns it to open(os.devnull), but fails to update the + corresponding __stdin__ reference. So, detect that case and handle + it appropriately. + """ + if not sys.__stdin__.closed: + return sys.__stdin__ + return sys.stdin + def _shell_quote(s): """ Quote a string in double-quotes and use backslashes to |