Author: Ronan Lamy <[email protected]>
Branch: 
Changeset: r71739:181bc0186716
Date: 2014-05-27 03:13 +0100
http://bitbucket.org/pypy/pypy/changeset/181bc0186716/

Log:    kill some uses of pbc.isNone()

diff --git a/rpython/annotator/binaryop.py b/rpython/annotator/binaryop.py
--- a/rpython/annotator/binaryop.py
+++ b/rpython/annotator/binaryop.py
@@ -791,28 +791,35 @@
 _make_none_union('SomeDict',          'obj.dictdef')
 _make_none_union('SomeWeakRef',         'obj.classdef')
 
-# getitem on SomePBCs, in particular None fails
 
 class __extend__(pairtype(SomePBC, SomeObject)):
     def getitem((pbc, o)):
-        if not pbc.isNone():
-            raise AnnotatorError("getitem on %r" % pbc)
+        raise AnnotatorError("getitem on %r" % pbc)
+
+    def setitem((pbc, o), s_value):
+        raise AnnotatorError("setitem on %r" % pbc)
+
+class __extend__(pairtype(SomeNone, SomeObject)):
+    def getitem((none, o)):
         return s_ImpossibleValue
 
-    def setitem((pbc, o), s_value):
-        if not pbc.isNone():
-            raise AnnotatorError("setitem on %r" % pbc)
+    def setitem((none, o), s_value):
+        return None
 
 class __extend__(pairtype(SomePBC, SomeString)):
     def add((pbc, o)):
-        if not pbc.isNone():
-            raise AnnotatorError('add on %r' % pbc)
+        raise AnnotatorError('add on %r' % pbc)
+
+class __extend__(pairtype(SomeNone, SomeString)):
+    def add((none, o)):
         return s_ImpossibleValue
 
 class __extend__(pairtype(SomeString, SomePBC)):
     def add((o, pbc)):
-        if not pbc.isNone():
-            raise AnnotatorError('add on %r' % pbc)
+        raise AnnotatorError('add on %r' % pbc)
+
+class __extend__(pairtype(SomeString, SomeNone)):
+    def add((o, none)):
         return s_ImpossibleValue
 
 #_________________________________________
diff --git a/rpython/annotator/classdef.py b/rpython/annotator/classdef.py
--- a/rpython/annotator/classdef.py
+++ b/rpython/annotator/classdef.py
@@ -2,8 +2,8 @@
 Type inference for user-defined classes.
 """
 from rpython.annotator.model import (
-    SomePBC, s_ImpossibleValue, unionof, s_None, SomeInteger, SomeTuple,
-    SomeString, AnnotatorError)
+    SomePBC, SomeNone, s_ImpossibleValue, unionof, s_None, SomeInteger,
+    SomeTuple, SomeString, AnnotatorError)
 from rpython.annotator import description
 
 
@@ -104,10 +104,10 @@
             self.bookkeeper.annotator.reflowfromposition(position)
 
         # check for method demotion and after-the-fact method additions
-        if isinstance(s_newvalue, SomePBC):
+        if (isinstance(s_newvalue, SomePBC) and
+                not isinstance(s_newvalue, SomeNone)):
             attr = self.name
-            if (not s_newvalue.isNone() and
-                s_newvalue.getKind() == description.MethodDesc):
+            if s_newvalue.getKind() == description.MethodDesc:
                 # is method
                 if homedef.classdesc.read_attribute(attr, None) is None:
                     if not homedef.check_missing_attribute_update(attr):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to