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
dc247650
Commit
dc247650
authored
Jun 06, 2019
by
Zackery Spytz
Committed by
Victor Stinner
Jun 06, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-37170: Fix the cast on error in PyLong_AsUnsignedLongLongMask() (GH-13860)
parent
f6713e84
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
4 deletions
+29
-4
Doc/c-api/long.rst
Doc/c-api/long.rst
+4
-2
Misc/NEWS.d/next/C API/2019-06-06-08-47-04.bpo-37170.hO_fpM.rst
...EWS.d/next/C API/2019-06-06-08-47-04.bpo-37170.hO_fpM.rst
+1
-0
Modules/_testcapimodule.c
Modules/_testcapimodule.c
+22
-0
Objects/longobject.c
Objects/longobject.c
+2
-2
No files found.
Doc/c-api/long.rst
View file @
dc247650
...
@@ -288,7 +288,8 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
...
@@ -288,7 +288,8 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
If the value of *obj* is out of range for an :c:type:`unsigned long`,
If the value of *obj* is out of range for an :c:type:`unsigned long`,
return the reduction of that value modulo ``ULONG_MAX + 1``.
return the reduction of that value modulo ``ULONG_MAX + 1``.
Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.
Returns ``(unsigned long)-1`` on error. Use :c:func:`PyErr_Occurred` to
disambiguate.
.. versionchanged:: 3.8
.. versionchanged:: 3.8
Use :meth:`__index__` if available.
Use :meth:`__index__` if available.
...
@@ -307,7 +308,8 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
...
@@ -307,7 +308,8 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
If the value of *obj* is out of range for an :c:type:`unsigned long long`,
If the value of *obj* is out of range for an :c:type:`unsigned long long`,
return the reduction of that value modulo ``PY_ULLONG_MAX + 1``.
return the reduction of that value modulo ``PY_ULLONG_MAX + 1``.
Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.
Returns ``(unsigned long long)-1`` on error. Use :c:func:`PyErr_Occurred`
to disambiguate.
.. versionchanged:: 3.8
.. versionchanged:: 3.8
Use :meth:`__index__` if available.
Use :meth:`__index__` if available.
...
...
Misc/NEWS.d/next/C API/2019-06-06-08-47-04.bpo-37170.hO_fpM.rst
0 → 100644
View file @
dc247650
Fix the cast on error in :c:func:`PyLong_AsUnsignedLongLongMask()`.
Modules/_testcapimodule.c
View file @
dc247650
...
@@ -825,6 +825,26 @@ test_long_as_size_t(PyObject *self, PyObject *Py_UNUSED(ignored))
...
@@ -825,6 +825,26 @@ test_long_as_size_t(PyObject *self, PyObject *Py_UNUSED(ignored))
return
Py_None
;
return
Py_None
;
}
}
static
PyObject
*
test_long_as_unsigned_long_long_mask
(
PyObject
*
self
,
PyObject
*
Py_UNUSED
(
ignored
))
{
unsigned
long
long
res
=
PyLong_AsUnsignedLongLongMask
(
NULL
);
if
(
res
!=
(
unsigned
long
long
)
-
1
||
!
PyErr_Occurred
())
{
return
raiseTestError
(
"test_long_as_unsigned_long_long_mask"
,
"PyLong_AsUnsignedLongLongMask(NULL) didn't "
"complain"
);
}
if
(
!
PyErr_ExceptionMatches
(
PyExc_SystemError
))
{
return
raiseTestError
(
"test_long_as_unsigned_long_long_mask"
,
"PyLong_AsUnsignedLongLongMask(NULL) raised "
"something other than SystemError"
);
}
PyErr_Clear
();
Py_RETURN_NONE
;
}
/* Test the PyLong_AsDouble API. At present this just tests that
/* Test the PyLong_AsDouble API. At present this just tests that
non-integer arguments are handled correctly.
non-integer arguments are handled correctly.
*/
*/
...
@@ -5070,6 +5090,8 @@ static PyMethodDef TestMethods[] = {
...
@@ -5070,6 +5090,8 @@ static PyMethodDef TestMethods[] = {
{
"test_long_and_overflow"
,
test_long_and_overflow
,
METH_NOARGS
},
{
"test_long_and_overflow"
,
test_long_and_overflow
,
METH_NOARGS
},
{
"test_long_as_double"
,
test_long_as_double
,
METH_NOARGS
},
{
"test_long_as_double"
,
test_long_as_double
,
METH_NOARGS
},
{
"test_long_as_size_t"
,
test_long_as_size_t
,
METH_NOARGS
},
{
"test_long_as_size_t"
,
test_long_as_size_t
,
METH_NOARGS
},
{
"test_long_as_unsigned_long_long_mask"
,
test_long_as_unsigned_long_long_mask
,
METH_NOARGS
},
{
"test_long_numbits"
,
test_long_numbits
,
METH_NOARGS
},
{
"test_long_numbits"
,
test_long_numbits
,
METH_NOARGS
},
{
"test_k_code"
,
test_k_code
,
METH_NOARGS
},
{
"test_k_code"
,
test_k_code
,
METH_NOARGS
},
{
"test_empty_argparse"
,
test_empty_argparse
,
METH_NOARGS
},
{
"test_empty_argparse"
,
test_empty_argparse
,
METH_NOARGS
},
...
...
Objects/longobject.c
View file @
dc247650
...
@@ -1376,7 +1376,7 @@ _PyLong_AsUnsignedLongLongMask(PyObject *vv)
...
@@ -1376,7 +1376,7 @@ _PyLong_AsUnsignedLongLongMask(PyObject *vv)
if
(
vv
==
NULL
||
!
PyLong_Check
(
vv
))
{
if
(
vv
==
NULL
||
!
PyLong_Check
(
vv
))
{
PyErr_BadInternalCall
();
PyErr_BadInternalCall
();
return
(
unsigned
long
)
-
1
;
return
(
unsigned
long
long
)
-
1
;
}
}
v
=
(
PyLongObject
*
)
vv
;
v
=
(
PyLongObject
*
)
vv
;
switch
(
Py_SIZE
(
v
))
{
switch
(
Py_SIZE
(
v
))
{
...
@@ -1404,7 +1404,7 @@ PyLong_AsUnsignedLongLongMask(PyObject *op)
...
@@ -1404,7 +1404,7 @@ PyLong_AsUnsignedLongLongMask(PyObject *op)
if
(
op
==
NULL
)
{
if
(
op
==
NULL
)
{
PyErr_BadInternalCall
();
PyErr_BadInternalCall
();
return
(
unsigned
long
)
-
1
;
return
(
unsigned
long
long
)
-
1
;
}
}
if
(
PyLong_Check
(
op
))
{
if
(
PyLong_Check
(
op
))
{
...
...
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