[Python-checkins] r86217 - in python/branches/py3k/Lib: _dummy_thread.py reprlib.py
antoine.pitrou
python-checkins at python.org
Fri Nov 5 20:58:28 CET 2010
Author: antoine.pitrou
Date: Fri Nov 5 20:58:28 2010
New Revision: 86217
Log:
Fix bootstrap issues when building without threads
Modified:
python/branches/py3k/Lib/_dummy_thread.py
python/branches/py3k/Lib/reprlib.py
Modified: python/branches/py3k/Lib/_dummy_thread.py
==============================================================================
--- python/branches/py3k/Lib/_dummy_thread.py (original)
+++ python/branches/py3k/Lib/_dummy_thread.py Fri Nov 5 20:58:28 2010
@@ -16,12 +16,14 @@
__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 @@
except SystemExit:
pass
except:
- _traceback.print_exc()
+ import traceback
+ traceback.print_exc()
_main = True
global _interrupt
if _interrupt:
@@ -116,6 +119,7 @@
return True
else:
if timeout > 0:
+ import time
time.sleep(timeout)
return False
Modified: python/branches/py3k/Lib/reprlib.py
==============================================================================
--- python/branches/py3k/Lib/reprlib.py (original)
+++ python/branches/py3k/Lib/reprlib.py Fri Nov 5 20:58:28 2010
@@ -6,7 +6,7 @@
from itertools import islice
try:
from _thread import get_ident
-except AttributeError:
+except ImportError:
from _dummy_thread import get_ident
def recursive_repr(fillvalue='...'):
More information about the Python-checkins
mailing list