[pypy-svn] r34842 - pypy/dist/pypy/annotation

arigo at codespeak.net arigo at codespeak.net
Tue Nov 21 23:07:30 CET 2006


Author: arigo
Date: Tue Nov 21 23:07:29 2006
New Revision: 34842

Modified:
   pypy/dist/pypy/annotation/annrpython.py
   pypy/dist/pypy/annotation/model.py
   pypy/dist/pypy/annotation/unaryop.py
Log:
(pedronis, arre, arigo)

We need a version of 'getattr' that doesn't give blocked blocks when
applied to classes that are never instantiated, but still seen because
of an isinstance().


Modified: pypy/dist/pypy/annotation/annrpython.py
==============================================================================
--- pypy/dist/pypy/annotation/annrpython.py	(original)
+++ pypy/dist/pypy/annotation/annrpython.py	Tue Nov 21 23:07:29 2006
@@ -564,6 +564,10 @@
                 # later by reflowing).  Throw the BlockedInference up to
                 # processblock().
                 raise
+
+        except annmodel.HarmlesslyBlocked:
+            return
+
         else:
             # dead code removal: don't follow all exits if the exitswitch
             # is known

Modified: pypy/dist/pypy/annotation/model.py
==============================================================================
--- pypy/dist/pypy/annotation/model.py	(original)
+++ pypy/dist/pypy/annotation/model.py	Tue Nov 21 23:07:29 2006
@@ -713,6 +713,11 @@
         return s_ImpossibleValue
     setattr(cls, name, default_op)
 
+class HarmlesslyBlocked(Exception):
+    """Raised by the unaryop/binaryop to signal a harmless kind of
+    BlockedInference: the current block is blocked, but not in a way
+    that gives 'Blocked block' errors at the end of annotation."""
+
 #
 # safety check that no-one is trying to make annotation and translation
 # faster by providing the -O option to Python.

Modified: pypy/dist/pypy/annotation/unaryop.py
==============================================================================
--- pypy/dist/pypy/annotation/unaryop.py	(original)
+++ pypy/dist/pypy/annotation/unaryop.py	Tue Nov 21 23:07:29 2006
@@ -8,7 +8,7 @@
      SomeInstance, SomeBuiltin, SomeFloat, SomeIterator, SomePBC, \
      SomeExternalObject, SomeTypedAddressAccess, SomeAddress, \
      SomeCTypesObject, s_ImpossibleValue, s_Bool, \
-     unionof, set, missing_operation, add_knowntypedata
+     unionof, set, missing_operation, add_knowntypedata, HarmlesslyBlocked
 from pypy.annotation.bookkeeper import getbookkeeper
 from pypy.annotation import builtin
 from pypy.annotation.binaryop import _clone ## XXX where to put this?
@@ -524,6 +524,9 @@
                 s_result = ins.classdef.lookup_filter(s_result, attr)
             elif isinstance(s_result, SomeImpossibleValue):
                 ins.classdef.check_missing_attribute_update(attr)
+                if ins.classdef.classdesc.allslots is not None:
+                    if attr in ins.classdef.classdesc.allslots:
+                        raise HarmlesslyBlocked("getattr on a slot")
             return s_result
         return SomeObject()
     getattr.can_only_throw = []



More information about the Pypy-commit mailing list