From d464838ebcf68659617a62abf5e0d04a5425ddfc Mon Sep 17 00:00:00 2001 From: Tim Peters Date: Mon, 2 Aug 2004 03:55:18 +0000 Subject: [PATCH] Removed no-longer-needed convolutions to recover from damaged modules getting left beyind in sys.modules. --- Lib/pty.py | 11 ----------- Lib/test/test___all__.py | 14 -------------- 2 files changed, 25 deletions(-) diff --git a/Lib/pty.py b/Lib/pty.py index cafbc9c962d..fae162dc487 100644 --- a/Lib/pty.py +++ b/Lib/pty.py @@ -8,17 +8,6 @@ from select import select import os - -# Absurd: import termios and then delete it. This is to force an attempt -# to import pty to raise an ImportError on platforms that lack termios. -# Without this explicit import of termios here, some other module may -# import tty first, which in turn imports termios and dies with an -# ImportError then. But since tty *does* exist across platforms, that -# leaves a damaged module object for tty in sys.modules, and the import -# of tty here then appears to work despite that the tty imported is junk. -import termios -del termios - import tty __all__ = ["openpty","fork","spawn"] diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py index ea23846f691..0794bd8263a 100644 --- a/Lib/test/test___all__.py +++ b/Lib/test/test___all__.py @@ -21,20 +21,6 @@ class AllTest(unittest.TestCase): except ImportError: # Silent fail here seems the best route since some modules # may not be available in all environments. - # Since an ImportError may leave a partial module object in - # sys.modules, get rid of that first. Here's what happens if - # you don't: importing pty fails on Windows because pty tries to - # import FCNTL, which doesn't exist. That raises an ImportError, - # caught here. It also leaves a partial pty module in sys.modules. - # So when test_pty is called later, the import of pty succeeds, - # but shouldn't. As a result, test_pty crashes with an - # AttributeError instead of an ImportError, and regrtest interprets - # the latter as a test failure (ImportError is treated as "test - # skipped" -- which is what test_pty should say on Windows). - try: - del sys.modules[modname] - except KeyError: - pass return verify(hasattr(sys.modules[modname], "__all__"), "%s has no __all__ attribute" % modname)