More bug 460020: when F is a subclass of float, disable the unary plus

optimization (+F(whatever)).
This commit is contained in:
Tim Peters 2001-09-11 21:53:35 +00:00
parent 73a1dfe367
commit 0280cf79a7
2 changed files with 7 additions and 2 deletions

View File

@ -1401,6 +1401,7 @@ def inherits():
a = precfloat(12345)
verify(float(a) == 12345.0)
verify(float(a).__class__ is float)
verify((+a).__class__ is float)
class madtuple(tuple):
_rev = None

View File

@ -553,8 +553,12 @@ float_neg(PyFloatObject *v)
static PyObject *
float_pos(PyFloatObject *v)
{
Py_INCREF(v);
return (PyObject *)v;
if (PyFloat_CheckExact(v)) {
Py_INCREF(v);
return (PyObject *)v;
}
else
return PyFloat_FromDouble(v->ob_fval);
}
static PyObject *