[pypy-svn] pypy interplevel-exception-classes: interp-level implementation of thread.exit()
amauryfa
commits-noreply at bitbucket.org
Fri Feb 18 11:49:19 CET 2011
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: interplevel-exception-classes
Changeset: r42144:4ca9870b73ff
Date: 2011-02-18 11:33 +0100
http://bitbucket.org/pypy/pypy/changeset/4ca9870b73ff/
Log: interp-level implementation of thread.exit()
diff --git a/pypy/module/thread/__init__.py b/pypy/module/thread/__init__.py
--- a/pypy/module/thread/__init__.py
+++ b/pypy/module/thread/__init__.py
@@ -4,8 +4,6 @@
class Module(MixedModule):
appleveldefs = {
- 'exit': 'app_thread.exit',
- 'exit_thread': 'app_thread.exit', # obsolete synonym
'error': 'app_thread.error',
}
@@ -13,6 +11,8 @@
'start_new_thread': 'os_thread.start_new_thread',
'start_new': 'os_thread.start_new_thread', # obsolete syn.
'get_ident': 'os_thread.get_ident',
+ 'exit': 'os_thread.exit',
+ 'exit_thread': 'os_thread.exit', # obsolete synonym
'stack_size': 'os_thread.stack_size',
'_count': 'os_thread._count',
'allocate_lock': 'os_lock.allocate_lock',
diff --git a/pypy/module/thread/app_thread.py b/pypy/module/thread/app_thread.py
--- a/pypy/module/thread/app_thread.py
+++ b/pypy/module/thread/app_thread.py
@@ -1,7 +1,2 @@
class error(Exception):
pass
-
-def exit():
- """This is synonymous to ``raise SystemExit''. It will cause the current
-thread to exit silently unless the exception is caught."""
- raise SystemExit
diff --git a/pypy/module/thread/os_thread.py b/pypy/module/thread/os_thread.py
--- a/pypy/module/thread/os_thread.py
+++ b/pypy/module/thread/os_thread.py
@@ -244,3 +244,7 @@
In most applications `threading.enumerate()` should be used instead."""
return space.wrap(bootstrapper.nbthreads)
+def exit(space):
+ """This is synonymous to ``raise SystemExit''. It will cause the current
+thread to exit silently unless the exception is caught."""
+ raise OperationError(space.w_SystemExit, space.w_None)
diff --git a/pypy/module/thread/test/test_thread.py b/pypy/module/thread/test/test_thread.py
--- a/pypy/module/thread/test/test_thread.py
+++ b/pypy/module/thread/test/test_thread.py
@@ -132,6 +132,7 @@
result = sys.stderr.getvalue()
assert "ValueError" in result
assert "hello world" in result
+ assert len(result.splitlines()) == 1
finally:
sys.stderr = prev
More information about the Pypy-commit
mailing list