Author: Ronan Lamy <[email protected]>
Branch: anntype
Changeset: r80786:b7728cb83be9
Date: 2015-11-19 17:04 +0000
http://bitbucket.org/pypy/pypy/changeset/b7728cb83be9/
Log: Implement unions of SomeException with s_None
diff --git a/rpython/annotator/binaryop.py b/rpython/annotator/binaryop.py
--- a/rpython/annotator/binaryop.py
+++ b/rpython/annotator/binaryop.py
@@ -677,11 +677,15 @@
thistype = pairtype(SomeInstance, SomeInstance)
return super(thistype, pair(ins1, ins2)).improve()
-class __extend__(pairtype(SomeException, SomeInstance)):
+class __extend__(
+ pairtype(SomeException, SomeInstance),
+ pairtype(SomeException, SomeNone)):
def union((s_exc, s_inst)):
return unionof(s_exc.as_SomeInstance(), s_inst)
-class __extend__(pairtype(SomeInstance, SomeException)):
+class __extend__(
+ pairtype(SomeInstance, SomeException),
+ pairtype(SomeNone, SomeException)):
def union((s_inst, s_exc)):
return unionof(s_exc.as_SomeInstance(), s_inst)
diff --git a/rpython/annotator/test/test_model.py
b/rpython/annotator/test/test_model.py
--- a/rpython/annotator/test/test_model.py
+++ b/rpython/annotator/test/test_model.py
@@ -145,3 +145,6 @@
s_exc = bk.new_exception([ValueError, IndexError])
assert unionof(s_exc, s_inst) == s_inst
assert unionof(s_inst, s_exc) == s_inst
+ s_nullable = unionof(s_None, bk.new_exception([ValueError]))
+ assert isinstance(s_nullable, SomeInstance)
+ assert s_nullable.can_be_None
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit