[pypy-commit] pypy default: register builtin exceptions with the annotator at the same time as the other builtins
rlamy
noreply at buildbot.pypy.org
Fri Mar 27 03:19:13 CET 2015
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch:
Changeset: r76584:fe4080908368
Date: 2014-11-03 16:48 +0000
http://bitbucket.org/pypy/pypy/changeset/fe4080908368/
Log: register builtin exceptions with the annotator at the same time as
the other builtins
diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py
--- a/rpython/annotator/bookkeeper.py
+++ b/rpython/annotator/bookkeeper.py
@@ -42,7 +42,7 @@
def __setstate__(self, dic):
self.__dict__.update(dic) # normal action
- delayed_imports()
+ self.register_builtins()
def __init__(self, annotator):
self.annotator = annotator
@@ -67,7 +67,13 @@
self.needs_generic_instantiate = {}
self.thread_local_fields = set()
- delayed_imports()
+ self.register_builtins()
+
+ def register_builtins(self):
+ import rpython.annotator.builtin # for side-effects
+ from rpython.annotator.exception import standardexceptions
+ for cls in standardexceptions:
+ self.getuniqueclassdef(cls)
def enter(self, position_key):
"""Start of an operation.
@@ -605,6 +611,3 @@
def immutablevalue(x):
return getbookkeeper().immutablevalue(x)
-
-def delayed_imports():
- import rpython.annotator.builtin
diff --git a/rpython/annotator/exception.py b/rpython/annotator/exception.py
new file mode 100644
--- /dev/null
+++ b/rpython/annotator/exception.py
@@ -0,0 +1,7 @@
+from rpython.rlib import rstackovf
+
+# the exceptions that can be implicitely raised by some operations
+standardexceptions = set([TypeError, OverflowError, ValueError,
+ ZeroDivisionError, MemoryError, IOError, OSError, StopIteration, KeyError,
+ IndexError, AssertionError, RuntimeError, UnicodeDecodeError,
+ UnicodeEncodeError, NotImplementedError, rstackovf._StackOverflow])
diff --git a/rpython/rtyper/exceptiondata.py b/rpython/rtyper/exceptiondata.py
--- a/rpython/rtyper/exceptiondata.py
+++ b/rpython/rtyper/exceptiondata.py
@@ -1,15 +1,9 @@
from rpython.annotator import model as annmodel
+from rpython.annotator.exception import standardexceptions
from rpython.rtyper.llannotation import SomePtr
-from rpython.rlib import rstackovf
from rpython.rtyper.rclass import (
ll_issubclass, ll_type, ll_cast_to_object, getclassrepr, getinstancerepr)
-# the exceptions that can be implicitely raised by some operations
-standardexceptions = set([TypeError, OverflowError, ValueError,
- ZeroDivisionError, MemoryError, IOError, OSError, StopIteration, KeyError,
- IndexError, AssertionError, RuntimeError, UnicodeDecodeError,
- UnicodeEncodeError, NotImplementedError, rstackovf._StackOverflow])
-
class UnknownException(Exception):
pass
@@ -20,7 +14,6 @@
standardexceptions = standardexceptions
def __init__(self, rtyper):
- self.make_standard_exceptions(rtyper)
# (NB. rclass identifies 'Exception' and 'object')
r_type = rtyper.rootclass_repr
r_instance = getinstancerepr(rtyper, None)
@@ -32,11 +25,6 @@
self.lltype_of_exception_value = r_instance.lowleveltype
self.rtyper = rtyper
- def make_standard_exceptions(self, rtyper):
- bk = rtyper.annotator.bookkeeper
- for cls in self.standardexceptions:
- bk.getuniqueclassdef(cls)
-
def finish(self, rtyper):
bk = rtyper.annotator.bookkeeper
for cls in self.standardexceptions:
diff --git a/rpython/rtyper/normalizecalls.py b/rpython/rtyper/normalizecalls.py
--- a/rpython/rtyper/normalizecalls.py
+++ b/rpython/rtyper/normalizecalls.py
@@ -404,9 +404,6 @@
# ____________________________________________________________
def perform_normalizations(annotator):
- from rpython.rtyper.exceptiondata import standardexceptions
- for cls in standardexceptions:
- annotator.bookkeeper.getuniqueclassdef(cls)
create_class_constructors(annotator)
annotator.frozen += 1
try:
More information about the pypy-commit
mailing list