Read about our upcoming Code of Conduct on this issue

Commit 78bee8a9 authored by Ronan Lamy's avatar Ronan Lamy
Browse files

kill some uses of pbc.isNone()

parent e9af47acbea2
......@@ -791,28 +791,35 @@ _make_none_union('SomeOrderedDict', 'obj.dictdef')
_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)
return s_ImpossibleValue
raise AnnotatorError("getitem on %r" % pbc)
def setitem((pbc, o), s_value):
if not pbc.isNone():
raise AnnotatorError("setitem on %r" % pbc)
raise AnnotatorError("setitem on %r" % pbc)
class __extend__(pairtype(SomeNone, SomeObject)):
def getitem((none, o)):
return s_ImpossibleValue
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
#_________________________________________
......
......@@ -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 @@ class Attribute(object):
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):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment