Author: David C Ellis <ducks...@gmail.com>
Branch: py3.6
Changeset: r95162:b7814a6b95eb
Date: 2018-09-19 19:31 +0100
http://bitbucket.org/pypy/pypy/changeset/b7814a6b95eb/

Log:    Coerce float subclasses returned by __float__ to float class

        First working version

diff --git a/pypy/objspace/std/floatobject.py b/pypy/objspace/std/floatobject.py
--- a/pypy/objspace/std/floatobject.py
+++ b/pypy/objspace/std/floatobject.py
@@ -229,6 +229,10 @@
                         "in a future version of Python." %
                             (space.type(w_value).name, w_obj_type.name)),
                         space.w_DeprecationWarning)
+                    # Convert to a non-subclass float
+                    value = w_obj.floatval
+                    w_obj = space.allocate_instance(W_FloatObject, w_floattype)
+                    W_FloatObject.__init__(w_obj, value)
                 return w_obj
             value = space.float_w(w_obj)
         elif space.isinstance_w(w_value, space.w_unicode):
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to