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
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.
_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
# 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