[pypy-commit] pypy union-side-effects: Fix union() and give a correct explanation for the s1==s2 case

rlamy pypy.commits at gmail.com
Fri Sep 2 22:42:45 EDT 2016


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: union-side-effects
Changeset: r86851:81eb595adb63
Date: 2016-09-03 01:44 +0100
http://bitbucket.org/pypy/pypy/changeset/81eb595adb63/

Log:	Fix union() and give a correct explanation for the s1==s2 case

diff --git a/rpython/annotator/model.py b/rpython/annotator/model.py
--- a/rpython/annotator/model.py
+++ b/rpython/annotator/model.py
@@ -745,6 +745,10 @@
     except AttributeError:
         TLS.no_side_effects_in_union = 1
     try:
+        if s1 == s2:
+            # Most pair(...).union() methods deal incorrectly with that case
+            # when constants are involved.
+            return s1
         return pair(s1, s2).union()
     finally:
         TLS.no_side_effects_in_union -= 1
@@ -759,8 +763,7 @@
             if s1 != s2:
                 s1 = pair(s1, s2).union()
     else:
-        # this is just a performance shortcut
-        # XXX: This is a lie! Grep for no_side_effects_in_union and weep.
+        # See comment in union() above
         if s1 != s2:
             s1 = pair(s1, s2).union()
     return s1


More information about the pypy-commit mailing list