[pypy-commit] pypy default: Test and fix in the annotator! Still!
arigo
noreply at buildbot.pypy.org
Sat Jul 4 20:09:04 CEST 2015
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r78430:705d7abb7534
Date: 2015-07-04 20:09 +0200
http://bitbucket.org/pypy/pypy/changeset/705d7abb7534/
Log: Test and fix in the annotator! Still!
diff --git a/rpython/annotator/builtin.py b/rpython/annotator/builtin.py
--- a/rpython/annotator/builtin.py
+++ b/rpython/annotator/builtin.py
@@ -156,7 +156,10 @@
if s_type.is_constant():
typ = s_type.const
if issubclass(typ, rpython.rlib.rarithmetic.base_int):
- r.const = issubclass(s_obj.knowntype, typ)
+ try:
+ r.const = issubclass(s_obj.knowntype, typ)
+ except TypeError: # s_obj.knowntype is not a Python type at all
+ r.const = False
else:
if typ == long:
getbookkeeper().warning("isinstance(., long) is not RPython")
diff --git a/rpython/annotator/test/test_annrpython.py b/rpython/annotator/test/test_annrpython.py
--- a/rpython/annotator/test/test_annrpython.py
+++ b/rpython/annotator/test/test_annrpython.py
@@ -1135,7 +1135,7 @@
assert famCinit.calltables == {(1, (), False): [{mdescCinit.funcdesc: gfCinit}] }
- def test_isinstance_usigned(self):
+ def test_isinstance_unsigned_1(self):
def f(x):
return isinstance(x, r_uint)
def g():
@@ -1145,6 +1145,18 @@
s = a.build_types(g, [])
assert s.const == True
+ def test_isinstance_unsigned_2(self):
+ class Foo:
+ pass
+ def f(x):
+ return isinstance(x, r_uint)
+ def g():
+ v = Foo()
+ return f(v)
+ a = self.RPythonAnnotator()
+ s = a.build_types(g, [])
+ assert s.const == False
+
def test_isinstance_base_int(self):
def f(x):
return isinstance(x, base_int)
More information about the pypy-commit
mailing list