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
f132c161
Commit
f132c161
authored
Jan 03, 2010
by
Mark Dickinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make use of PyLong_AsLongAndOverflow in math_ldexp.
parent
722a8a95
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
20 deletions
+7
-20
Modules/mathmodule.c
Modules/mathmodule.c
+7
-20
No files found.
Modules/mathmodule.c
View file @
f132c161
...
...
@@ -1175,31 +1175,18 @@ math_ldexp(PyObject *self, PyObject *args)
double
x
,
r
;
PyObject
*
oexp
;
long
exp
;
int
overflow
;
if
(
!
PyArg_ParseTuple
(
args
,
"dO:ldexp"
,
&
x
,
&
oexp
))
return
NULL
;
if
(
PyLong_Check
(
oexp
))
{
if
(
PyLong_Check
(
oexp
)
||
PyInt_Check
(
oexp
)
)
{
/* on overflow, replace exponent with either LONG_MAX
or LONG_MIN, depending on the sign. */
exp
=
PyLong_AsLong
(
oexp
);
if
(
exp
==
-
1
&&
PyErr_Occurred
())
{
if
(
PyErr_ExceptionMatches
(
PyExc_OverflowError
))
{
if
(
Py_SIZE
(
oexp
)
<
0
)
{
exp
=
LONG_MIN
;
}
else
{
exp
=
LONG_MAX
;
}
PyErr_Clear
();
}
else
{
/* propagate any unexpected exception */
return
NULL
;
}
}
}
else
if
(
PyInt_Check
(
oexp
))
{
exp
=
PyInt_AS_LONG
(
oexp
);
exp
=
PyLong_AsLongAndOverflow
(
oexp
,
&
overflow
);
if
(
exp
==
-
1
&&
PyErr_Occurred
())
return
NULL
;
if
(
overflow
)
exp
=
overflow
<
0
?
LONG_MIN
:
LONG_MAX
;
}
else
{
PyErr_SetString
(
PyExc_TypeError
,
...
...
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