From 0db4c2a0f8b80b3f08a9a1f068a8cd0b2ff1fe4f Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sat, 15 Dec 2012 14:04:28 -0800 Subject: 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. --- pym/portage/__init__.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'pym/portage/__init__.py') 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 -- cgit v1.2.3-1-g7c22