Skip to content

Commit abda8dd

Browse files
committed
merge 3.4 (python#23590)
2 parents 49f373b + a915723 commit abda8dd

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

‎Lib/test/test_float.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import math
77
from math import isinf, isnan, copysign, ldexp
88
import operator
9+
import time
910
import random, fractions
1011

1112
INF = float("inf")
@@ -129,6 +130,11 @@ def __float__(self):
129130
self.assertRaises(TypeError, float, Foo4(42))
130131
self.assertAlmostEqual(float(FooStr('8')), 9.)
131132

133+
class Foo5:
134+
def __float__(self):
135+
return ""
136+
self.assertRaises(TypeError, time.sleep, Foo5())
137+
132138
def test_is_integer(self):
133139
self.assertFalse((1.1).is_integer())
134140
self.assertTrue((1.).is_integer())

‎Objects/floatobject.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ PyFloat_AsDouble(PyObject *op)
220220
if (fo == NULL)
221221
return -1;
222222
if (!PyFloat_Check(fo)) {
223+
Py_DECREF(fo);
223224
PyErr_SetString(PyExc_TypeError,
224225
"nb_float should return float object");
225226
return -1;

0 commit comments

Comments
 (0)