[pypy-commit] pypy default: Fix another rare annotation ordering issue
arigo
noreply at buildbot.pypy.org
Sat Feb 15 18:34:48 CET 2014
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r69166:625f047a5759
Date: 2014-02-15 18:34 +0100
http://bitbucket.org/pypy/pypy/changeset/625f047a5759/
Log: Fix another rare annotation ordering issue
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
@@ -4170,6 +4170,21 @@
a = self.RPythonAnnotator()
assert isinstance(a.build_types(f, []), annmodel.SomeOrderedDict)
+ def test_enumerate_none(self):
+ # enumerate(None) can occur as an intermediate step during a full
+ # annotation, because the None will be generalized later to
+ # None-or-list for example
+ def f(flag):
+ if flag:
+ x = None
+ else:
+ x = [42]
+ return enumerate(x).next()
+ a = self.RPythonAnnotator()
+ s = a.build_types(f, [int])
+ assert isinstance(s, annmodel.SomeTuple)
+ assert s.items[1].const == 42
+
def g(n):
return [0, 1, 2, n]
diff --git a/rpython/annotator/unaryop.py b/rpython/annotator/unaryop.py
--- a/rpython/annotator/unaryop.py
+++ b/rpython/annotator/unaryop.py
@@ -614,6 +614,8 @@
return can_throw
def next(self):
+ if s_None.contains(self.s_container):
+ return s_ImpossibleValue # so far
if self.variant == ("enumerate",):
s_item = self.s_container.getanyitem()
return SomeTuple((SomeInteger(nonneg=True), s_item))
More information about the pypy-commit
mailing list