[pypy-commit] pypy py3.6: Warning should be raised even if it's a float subclass
David C Ellis
pypy.commits at gmail.com
Tue Sep 25 12:25:51 EDT 2018
Author: David C Ellis <ducksual at gmail.com>
Branch: py3.6
Changeset: r95164:8feed387bf12
Date: 2018-09-24 14:19 +0100
http://bitbucket.org/pypy/pypy/changeset/8feed387bf12/
Log: Warning should be raised even if it's a float subclass
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
@@ -219,16 +219,17 @@
w_value = w_x # 'x' is the keyword argument name in CPython
if space.lookup(w_value, "__float__") is not None:
w_obj = space.float(w_value)
+ w_obj_type = space.type(w_obj)
+ if not space.is_w(w_obj_type, space.w_float):
+ space.warn(space.newtext(
+ "%s.__float__ returned non-float (type %s). "
+ "The ability to return an instance of a strict subclass "
+ "of float is deprecated, and may be removed "
+ "in a future version of Python." %
+ (space.type(w_value).name, w_obj_type.name)),
+ space.w_DeprecationWarning)
if space.is_w(w_floattype, space.w_float):
- w_obj_type = space.type(w_obj)
if not space.is_w(w_obj_type, space.w_float):
- space.warn(space.newtext(
- "%s.__float__ returned non-float (type %s). "
- "The ability to return an instance of a strict subclass "
- "of float is deprecated, and may be removed "
- "in a future version of Python." %
- (space.type(w_value).name, w_obj_type.name)),
- space.w_DeprecationWarning)
if isinstance(w_obj, W_FloatObject):
# Convert to a non-subclass float
value = w_obj.floatval
More information about the pypy-commit
mailing list