[pypy-commit] pypy flowoperators: Split off a builtins_exceptions dict from operation.implicit_exceptions
rlamy
noreply at buildbot.pypy.org
Fri Jul 5 21:25:53 CEST 2013
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: flowoperators
Changeset: r65227:c5ec93a944ef
Date: 2013-07-05 21:25 +0200
http://bitbucket.org/pypy/pypy/changeset/c5ec93a944ef/
Log: Split off a builtins_exceptions dict from
operation.implicit_exceptions
The keys of implicit_exceptions were a mixture of builtin callables
and operator names. Now both dicts are homogenous.
diff --git a/rpython/flowspace/objspace.py b/rpython/flowspace/objspace.py
--- a/rpython/flowspace/objspace.py
+++ b/rpython/flowspace/objspace.py
@@ -45,6 +45,16 @@
}
}
+# built-ins that can always raise exceptions
+builtins_exceptions = {
+ int: [ValueError],
+ float: [ValueError],
+ chr: [ValueError],
+ unichr: [ValueError],
+ unicode: [UnicodeDecodeError],
+}
+
+
def _assert_rpythonic(func):
"""Raise ValueError if ``func`` is obviously not RPython"""
if func.func_doc and func.func_doc.lstrip().startswith('NOT_RPYTHON'):
@@ -365,15 +375,6 @@
args_w = args.arguments_w
w_res = self.frame.do_operation('simple_call', w_callable, *args_w)
- # maybe the call has generated an exception (any one)
- # but, let's say, not if we are calling a built-in class or function
- # because this gets in the way of the special-casing of
- #
- # raise SomeError(x)
- #
- # as shown by test_objspace.test_raise3.
-
- exceptions = [Exception] # *any* exception by default
if isinstance(w_callable, Constant):
c = w_callable.value
if (isinstance(c, (types.BuiltinFunctionType,
@@ -381,8 +382,11 @@
types.ClassType,
types.TypeType)) and
c.__module__ in ['__builtin__', 'exceptions']):
- exceptions = operation.implicit_exceptions.get(c)
- self.frame.handle_implicit_exceptions(exceptions)
+ if c in builtins_exceptions:
+ self.frame.handle_implicit_exceptions(builtins_exceptions[c])
+ return w_res
+ # *any* exception for non-builtins
+ self.frame.handle_implicit_exceptions([Exception])
return w_res
def find_global(self, w_globals, varname):
diff --git a/rpython/flowspace/operation.py b/rpython/flowspace/operation.py
--- a/rpython/flowspace/operation.py
+++ b/rpython/flowspace/operation.py
@@ -253,11 +253,6 @@
}
implicit_exceptions = {
- int: [ValueError], # built-ins that can always raise exceptions
- float: [ValueError],
- chr: [ValueError],
- unichr: [ValueError],
- unicode: [UnicodeDecodeError],
# specifying IndexError, and KeyError beyond Exception,
# allows the annotator to be more precise, see test_reraiseAnything/KeyError in
# the annotator tests
More information about the pypy-commit
mailing list