diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-11-05 19:58:28 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-11-05 19:58:28 (GMT) |
commit | db1bad2d70a0c11f3540c172d341edc92ba68c30 (patch) | |
tree | ca14622b6ddb94498576919f99817781d23f0066 /Lib | |
parent | 39a65915076bb9c3719813f9d079925d661cdbd5 (diff) | |
download | cpython-db1bad2d70a0c11f3540c172d341edc92ba68c30.zip cpython-db1bad2d70a0c11f3540c172d341edc92ba68c30.tar.gz cpython-db1bad2d70a0c11f3540c172d341edc92ba68c30.tar.bz2 |
Fix bootstrap issues when building without threads
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/_dummy_thread.py | 12 | ||||
-rw-r--r-- | Lib/reprlib.py | 2 |
2 files changed, 9 insertions, 5 deletions
diff --git a/Lib/_dummy_thread.py b/Lib/_dummy_thread.py index e10bae8..ed50520 100644 --- a/Lib/_dummy_thread.py +++ b/Lib/_dummy_thread.py @@ -16,12 +16,14 @@ Suggested usage is:: __all__ = ['error', 'start_new_thread', 'exit', 'get_ident', 'allocate_lock', 'interrupt_main', 'LockType'] -import traceback as _traceback -import time - # A dummy value TIMEOUT_MAX = 2**31 +# NOTE: this module can be imported early in the extension building process, +# and so top level imports of other modules should be avoided. Instead, all +# imports are done when needed on a function-by-function basis. Since threads +# are disabled, the import lock should not be an issue anyway (??). + class error(Exception): """Dummy implementation of _thread.error.""" @@ -52,7 +54,8 @@ def start_new_thread(function, args, kwargs={}): except SystemExit: pass except: - _traceback.print_exc() + import traceback + traceback.print_exc() _main = True global _interrupt if _interrupt: @@ -116,6 +119,7 @@ class LockType(object): return True else: if timeout > 0: + import time time.sleep(timeout) return False diff --git a/Lib/reprlib.py b/Lib/reprlib.py index c44c75c..7b5c436 100644 --- a/Lib/reprlib.py +++ b/Lib/reprlib.py @@ -6,7 +6,7 @@ import builtins from itertools import islice try: from _thread import get_ident -except AttributeError: +except ImportError: from _dummy_thread import get_ident def recursive_repr(fillvalue='...'): |