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

mwh at codespeak.net mwh at codespeak.net
Tue Jan 25 12:09:31 CET 2005


Author: mwh
Date: Tue Jan 25 12:09:31 2005
New Revision: 8548

Modified:
   pypy/dist/pypy/annotation/binaryop.py
   pypy/dist/pypy/annotation/model.py
Log:
Some special handling of SomePBC(None) in union methods.


Modified: pypy/dist/pypy/annotation/binaryop.py
==============================================================================
--- pypy/dist/pypy/annotation/binaryop.py	(original)
+++ pypy/dist/pypy/annotation/binaryop.py	Tue Jan 25 12:09:31 2005
@@ -24,7 +24,7 @@
                          'getitem', 'setitem',
                          'inplace_add', 'inplace_sub',
                          'lt', 'le', 'eq', 'ne', 'gt', 'ge', 'is_',
-                         'union'])
+                         'union', 'issubtype'])
 
 for opname in BINARY_OPERATIONS:
     missing_operation(pairtype(SomeObject, SomeObject), opname)
@@ -286,6 +286,8 @@
 
 class __extend__(pairtype(SomeInstance, SomePBC)):
     def union((ins, pbc)):
+        if pbc.isNone():
+            return ins
         classdef = ins.classdef.superdef_containing(pbc.knowntype)
         if classdef is None:
             # print warning?

Modified: pypy/dist/pypy/annotation/model.py
==============================================================================
--- pypy/dist/pypy/annotation/model.py	(original)
+++ pypy/dist/pypy/annotation/model.py	Tue Jan 25 12:09:31 2005
@@ -185,8 +185,13 @@
         prebuiltinstances = prebuiltinstances.copy()
         self.prebuiltinstances = prebuiltinstances
         self.simplify()
-        self.knowntype = reduce(commonbase,
-                                [new_or_old_class(x) for x in prebuiltinstances])
+        if self.isNone():
+            self.knowntype = type(None)
+        else:
+            self.knowntype = reduce(commonbase,
+                                    [new_or_old_class(x)
+                                     for x in prebuiltinstances
+                                     if x is not None])
         if prebuiltinstances.values() == [True]:
             # hack for the convenience of direct callers to SomePBC():
             # only if there is a single object in prebuiltinstances and
@@ -202,6 +207,9 @@
                 if isinstance(x.im_self, classdef.cls):
                     del self.prebuiltinstances[x]
 
+    def isNone(self):
+        return self.prebuiltinstances == {None:True}
+
     def fmt_prebuiltinstances(self, pbis):
         if hasattr(self, 'const'):
             return None



More information about the Pypy-commit mailing list