Author: Ronan Lamy <ronan.l...@gmail.com>
Branch: fix-result-types
Changeset: r77657:ca908627b665
Date: 2015-05-28 16:32 +0100
http://bitbucket.org/pypy/pypy/changeset/ca908627b665/

Log:    Ensure that casting_table and promotion_table are built
        deterministically (they used to depend on the ordering of the
        globals() dict)

diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -2498,6 +2498,8 @@
             if issubclass(tp, ComplexFloating):
                 all_complex_types.append((tp, 'complex'))
                 complex_types.append(tp)
+    for l in [float_types, int_types, complex_types]:
+        l.sort(key=lambda tp: tp.num)
 _setup()
 del _setup
 
@@ -2577,9 +2579,8 @@
                 if _can_cast(tp1, tp3) and _can_cast(tp2, tp3):
                     if result is None:
                         result = tp3
-                    else:
-                        if _can_cast(tp3, result):
-                            result = tp3
+                    elif _can_cast(tp3, result) and not _can_cast(result, tp3):
+                        result = tp3
             promotes(tp1, tp2, result)
 
 
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to