Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
3908d7de
Commit
3908d7de
authored
Mar 06, 2015
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix potential refleak in PyFloat_AsDouble (closes #23590)
parent
3c05585e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
0 deletions
+7
-0
Lib/test/test_float.py
Lib/test/test_float.py
+6
-0
Objects/floatobject.c
Objects/floatobject.c
+1
-0
No files found.
Lib/test/test_float.py
View file @
3908d7de
...
@@ -8,6 +8,7 @@ import operator
...
@@ -8,6 +8,7 @@ import operator
import
random
import
random
import
fractions
import
fractions
import
sys
import
sys
import
time
INF
=
float
(
"inf"
)
INF
=
float
(
"inf"
)
NAN
=
float
(
"nan"
)
NAN
=
float
(
"nan"
)
...
@@ -164,6 +165,11 @@ class GeneralFloatCases(unittest.TestCase):
...
@@ -164,6 +165,11 @@ class GeneralFloatCases(unittest.TestCase):
self
.
assertAlmostEqual
(
float
(
FooUnicode
(
'8'
)),
9.
)
self
.
assertAlmostEqual
(
float
(
FooUnicode
(
'8'
)),
9.
)
self
.
assertAlmostEqual
(
float
(
FooStr
(
'8'
)),
9.
)
self
.
assertAlmostEqual
(
float
(
FooStr
(
'8'
)),
9.
)
class
Foo5
:
def
__float__
(
self
):
return
""
self
.
assertRaises
(
TypeError
,
time
.
sleep
,
Foo5
())
def
test_is_integer
(
self
):
def
test_is_integer
(
self
):
self
.
assertFalse
((
1.1
).
is_integer
())
self
.
assertFalse
((
1.1
).
is_integer
())
self
.
assertTrue
((
1.
).
is_integer
())
self
.
assertTrue
((
1.
).
is_integer
())
...
...
Objects/floatobject.c
View file @
3908d7de
...
@@ -271,6 +271,7 @@ PyFloat_AsDouble(PyObject *op)
...
@@ -271,6 +271,7 @@ PyFloat_AsDouble(PyObject *op)
if
(
fo
==
NULL
)
if
(
fo
==
NULL
)
return
-
1
;
return
-
1
;
if
(
!
PyFloat_Check
(
fo
))
{
if
(
!
PyFloat_Check
(
fo
))
{
Py_DECREF
(
fo
);
PyErr_SetString
(
PyExc_TypeError
,
PyErr_SetString
(
PyExc_TypeError
,
"nb_float should return float object"
);
"nb_float should return float object"
);
return
-
1
;
return
-
1
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment