mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
Patch #1024670: Support int objects in PyLong_AsUnsignedLong[Mask].
This commit is contained in:
parent
f13337dd38
commit
729d47db09
2 changed files with 12 additions and 1 deletions
|
@ -12,7 +12,7 @@ What's New in Python 2.4 beta 1?
|
||||||
Core and builtins
|
Core and builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
...
|
- PyLong_AsUnsignedLong[Mask] now support int objects as well.
|
||||||
|
|
||||||
Extension modules
|
Extension modules
|
||||||
-----------------
|
-----------------
|
||||||
|
|
|
@ -245,6 +245,15 @@ PyLong_AsUnsignedLong(PyObject *vv)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (vv == NULL || !PyLong_Check(vv)) {
|
if (vv == NULL || !PyLong_Check(vv)) {
|
||||||
|
if (vv != NULL && PyInt_Check(vv)) {
|
||||||
|
long val = PyInt_AsLong(vv);
|
||||||
|
if (val < 0) {
|
||||||
|
PyErr_SetString(PyExc_OverflowError,
|
||||||
|
"can't convert negative value to unsigned long");
|
||||||
|
return (unsigned long) -1;
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
PyErr_BadInternalCall();
|
PyErr_BadInternalCall();
|
||||||
return (unsigned long) -1;
|
return (unsigned long) -1;
|
||||||
}
|
}
|
||||||
|
@ -279,6 +288,8 @@ PyLong_AsUnsignedLongMask(PyObject *vv)
|
||||||
int i, sign;
|
int i, sign;
|
||||||
|
|
||||||
if (vv == NULL || !PyLong_Check(vv)) {
|
if (vv == NULL || !PyLong_Check(vv)) {
|
||||||
|
if (vv != NULL && PyInt_Check(vv))
|
||||||
|
return PyInt_AsUnsignedLongMask(vv);
|
||||||
PyErr_BadInternalCall();
|
PyErr_BadInternalCall();
|
||||||
return (unsigned long) -1;
|
return (unsigned long) -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue