"""
Returns True if this issues is fixed for the currently
running version of python: http://bugs.python.org/issue5380
- Returns None if openpty fails, and False if the above issue
- is not fixed.
+ Raises an EnvironmentError from openpty() if it fails.
"""
import array, pty, termios
test_string = _unicode_decode(test_string,
encoding='utf_8', errors='strict')
- try:
- master_fd, slave_fd = pty.openpty()
- except EnvironmentError:
- global _disable_openpty
- _disable_openpty = True
- return None
+ # may raise EnvironmentError
+ master_fd, slave_fd = pty.openpty()
master_file = os.fdopen(master_fd, 'rb')
slave_file = os.fdopen(slave_fd, 'wb')
got_pty = False
global _disable_openpty, _tested_pty
- if not _tested_pty:
- if not _test_pty_eof():
+ if not (_tested_pty or _disable_openpty):
+ try:
+ if not _test_pty_eof():
+ _disable_openpty = True
+ except EnvironmentError as e:
_disable_openpty = True
+ writemsg("openpty failed: '%s'\n" % str(e),
+ noiselevel=-1)
+ del e
_tested_pty = True
if _disable_openpty:
# http://bugs.python.org/issue5380
# Since it might not be fixed, mark as todo.
self.todo = True
- result = portage._test_pty_eof()
- # The result is only valid if openpty works (result is
- # True or False, not None).
- if result is not None:
- self.assertEqual(result, True)
+ # The result is only valid if openpty does not raise EnvironmentError.
+ try:
+ self.assertEqual(portage._test_pty_eof(), True)
+ except EnvironmentError:
+ pass