]> granicus.if.org Git - python/commitdiff
Issue2564: Prevent a hang in "import test.autotest", which runs the entire test
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>
Tue, 8 Apr 2008 21:27:42 +0000 (21:27 +0000)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>
Tue, 8 Apr 2008 21:27:42 +0000 (21:27 +0000)
suite as a side-effect of importing the module.

- in test_capi, a thread tried to import other modules
- re.compile() imported sre_parse again on every call.

Lib/sre_compile.py
Lib/test/test_capi.py

index 22ab2fd14889314d7f733728d03850133c1e6b72..65d2ccf016f0c73af02a6c8e2bf7597b65e9e9fb 100644 (file)
@@ -11,7 +11,7 @@
 """Internal support module for sre"""
 
 import _sre, sys
-
+import sre_parse
 from sre_constants import *
 
 assert _sre.MAGIC == MAGIC, "SRE module mismatch"
@@ -502,7 +502,6 @@ def compile(p, flags=0):
     # internal: convert pattern list to internal format
 
     if isstring(p):
-        import sre_parse
         pattern = p
         p = sre_parse.parse(p, flags)
     else:
index cdd84bb222e24fb3477fba28b891a3429395ba36..eea41c1f7c4a9259ae14233185ec5c12cd46b414 100644 (file)
@@ -19,9 +19,6 @@ def test_main():
 
     # some extra thread-state tests driven via _testcapi
     def TestThreadState():
-        import thread
-        import time
-
         if test_support.verbose:
             print "auto-thread-state"
 
@@ -45,6 +42,8 @@ def test_main():
         have_thread_state = False
 
     if have_thread_state:
+        import thread
+        import time
         TestThreadState()
         import threading
         t=threading.Thread(target=TestThreadState)