[pypy-svn] pypy interplevel-exception-classes: Kill select/app_select.py and rewrite the exception at interp_level
amauryfa
commits-noreply at bitbucket.org
Fri Feb 18 11:49:16 CET 2011
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: interplevel-exception-classes
Changeset: r42142:e9e95d67f547
Date: 2011-02-18 11:19 +0100
http://bitbucket.org/pypy/pypy/changeset/e9e95d67f547/
Log: Kill select/app_select.py and rewrite the exception at interp_level
diff --git a/pypy/module/select/__init__.py b/pypy/module/select/__init__.py
--- a/pypy/module/select/__init__.py
+++ b/pypy/module/select/__init__.py
@@ -7,12 +7,12 @@
class Module(MixedModule):
appleveldefs = {
- 'error': 'app_select.error',
}
interpleveldefs = {
'poll' : 'interp_select.poll',
'select': 'interp_select.select',
+ 'error' : 'space.new_exception_class("select.error")',
}
# TODO: this doesn't feel right...
diff --git a/pypy/module/select/app_select.py b/pypy/module/select/app_select.py
deleted file mode 100644
--- a/pypy/module/select/app_select.py
+++ /dev/null
@@ -1,2 +0,0 @@
-class error(Exception):
- pass
diff --git a/pypy/module/select/interp_select.py b/pypy/module/select/interp_select.py
--- a/pypy/module/select/interp_select.py
+++ b/pypy/module/select/interp_select.py
@@ -9,6 +9,10 @@
defaultevents = rpoll.POLLIN | rpoll.POLLOUT | rpoll.POLLPRI
+class Cache:
+ def __init__(self, space):
+ self.w_error = space.new_exception_class("select.error")
+
def poll(space):
"""Returns a polling object, which supports registering and
unregistering file descriptors, and then polling them for I/O events."""
@@ -55,8 +59,7 @@
try:
retval = rpoll.poll(self.fddict, timeout)
except rpoll.PollError, e:
- w_module = space.getbuiltinmodule('select')
- w_errortype = space.getattr(w_module, space.wrap('error'))
+ w_errortype = space.fromcache(Cache).w_error
message = e.get_msg()
raise OperationError(w_errortype,
space.newtuple([space.wrap(e.errno),
@@ -116,8 +119,7 @@
else:
iwtd, owtd, ewtd = rpoll.select(iwtd, owtd, ewtd, space.float_w(w_timeout))
except rpoll.SelectError, s:
- w_module = space.getbuiltinmodule('select')
- w_errortype = space.getattr(w_module, space.wrap('error'))
+ w_errortype = space.fromcache(Cache).w_error
raise OperationError(w_errortype, space.newtuple([
space.wrap(s.errno), space.wrap(s.get_msg())]))
More information about the Pypy-commit
mailing list