[pypy-commit] pypy default: Test and fix (from unicode-utf8): an obscure case where we get

arigo pypy.commits at gmail.com
Mon Feb 27 10:32:22 EST 2017


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r90405:98f4a2ce0fa5
Date: 2017-02-27 16:31 +0100
http://bitbucket.org/pypy/pypy/changeset/98f4a2ce0fa5/

Log:	Test and fix (from unicode-utf8): an obscure case where we get
	convert_from_to() that targets SomeImpossibleValue.

diff --git a/rpython/rtyper/rmodel.py b/rpython/rtyper/rmodel.py
--- a/rpython/rtyper/rmodel.py
+++ b/rpython/rtyper/rmodel.py
@@ -359,6 +359,10 @@
     def ll_str(self, nothing): raise AssertionError("unreachable code")
 impossible_repr = VoidRepr()
 
+class __extend__(pairtype(Repr, VoidRepr)):
+    def convert_from_to((r_from, r_to), v, llops):
+        return inputconst(lltype.Void, None)
+
 class SimplePointerRepr(Repr):
     "Convenience Repr for simple ll pointer types with no operation on them."
 
diff --git a/rpython/rtyper/test/test_rpbc.py b/rpython/rtyper/test/test_rpbc.py
--- a/rpython/rtyper/test/test_rpbc.py
+++ b/rpython/rtyper/test/test_rpbc.py
@@ -1746,6 +1746,29 @@
         res = self.interpret(g, [1])
         assert res == True
 
+    def test_convert_from_anything_to_impossible(self):
+        def f1():
+            return 42
+        def f2():
+            raise ValueError
+        def f3():
+            raise ValueError
+        def f(i):
+            if i > 5:
+                f = f2
+            else:
+                f = f3
+            try:
+                f()
+            except ValueError:
+                pass
+            if i > 1:
+                f = f2
+            else:
+                f = f1
+            return f()
+        self.interpret(f, [-5])
+
 # ____________________________________________________________
 
 def test_hlinvoke_simple():


More information about the pypy-commit mailing list