diff options
Diffstat (limited to 'pym')
-rw-r--r-- | pym/portage/__init__.py | 23 | ||||
-rw-r--r-- | pym/portage/tests/ebuild/test_pty_eof.py | 9 |
2 files changed, 25 insertions, 7 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 08d8f4152..54d45dabc 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -3777,6 +3777,15 @@ class config(object): keys = __iter__ items = iteritems +def _can_test_pty_eof(): + """ + The _test_pty_eof() function seems to hang on most + kernels other than Linux. + @rtype: bool + @returns: True if _test_pty_eof() won't hang, False otherwise. + """ + return platform.system() in ("Linux",) + def _test_pty_eof(): """ Returns True if this issues is fixed for the currently @@ -3861,9 +3870,13 @@ def _test_pty_eof(): return test_string == ''.join(data) -# In some cases, openpty can be slow when it fails. Therefore, -# stop trying to use it after the first failure. -if platform.system() not in ["FreeBSD", "Linux"]: +# If _test_pty_eof() can't be used for runtime detection of +# http://bugs.python.org/issue5380, openpty can't safely be used +# unless we can guarantee that the current version of python has +# been fixed (affects all current versions of python3). When +# this issue is fixed in python3, we can add another sys.hexversion +# conditional to enable openpty support in the fixed versions. +if sys.hexversion >= 0x3000000 and not _can_test_pty_eof(): # Disable the use of openpty on Solaris as it seems Python's openpty # implementation doesn't play nice on Solaris with Portage's # behaviour causing hangs/deadlocks. @@ -3880,6 +3893,10 @@ else: _disable_openpty = False _tested_pty = False +if not _can_test_pty_eof(): + # Skip _test_pty_eof() on systems where it hangs. + _tested_pty = True + def _create_pty_or_pipe(copy_term_size=None): """ Try to create a pty and if then fails then create a normal diff --git a/pym/portage/tests/ebuild/test_pty_eof.py b/pym/portage/tests/ebuild/test_pty_eof.py index 0dd1e8506..31a5df4aa 100644 --- a/pym/portage/tests/ebuild/test_pty_eof.py +++ b/pym/portage/tests/ebuild/test_pty_eof.py @@ -13,7 +13,8 @@ class PtyEofTestCase(TestCase): # Since it might not be fixed, mark as todo. self.todo = True # The result is only valid if openpty does not raise EnvironmentError. - try: - self.assertEqual(portage._test_pty_eof(), True) - except EnvironmentError: - pass + if portage._can_test_pty_eof(): + try: + self.assertEqual(portage._test_pty_eof(), True) + except EnvironmentError: + pass |