mirror of
https://github.com/python/cpython.git
synced 2026-01-06 23:42:34 +00:00
Merged revisions 78918,78920 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r78918 | mark.dickinson | 2010-03-13 11:34:40 +0000 (Sat, 13 Mar 2010) | 4 lines Issue #8014: Fix PyLong_As<c-integer-type> methods not to produce an internal error on non-integer input: they now raise TypeError instead. This is needed for attributes declared via PyMemberDefs. ........ r78920 | mark.dickinson | 2010-03-13 13:23:05 +0000 (Sat, 13 Mar 2010) | 3 lines Issue #8014: Fix incorrect error checks in structmember.c, and re-enable previously failing test_structmember.py tests. ........
This commit is contained in:
parent
de33ffffed
commit
bee1fb0f75
5 changed files with 61 additions and 13 deletions
|
|
@ -440,10 +440,15 @@ PyLong_AsSsize_t(PyObject *vv) {
|
|||
Py_ssize_t i;
|
||||
int sign;
|
||||
|
||||
if (vv == NULL || !PyLong_Check(vv)) {
|
||||
if (vv == NULL) {
|
||||
PyErr_BadInternalCall();
|
||||
return -1;
|
||||
}
|
||||
if (!PyLong_Check(vv)) {
|
||||
PyErr_SetString(PyExc_TypeError, "an integer is required");
|
||||
return -1;
|
||||
}
|
||||
|
||||
v = (PyLongObject *)vv;
|
||||
i = Py_SIZE(v);
|
||||
switch (i) {
|
||||
|
|
@ -490,10 +495,15 @@ PyLong_AsUnsignedLong(PyObject *vv)
|
|||
unsigned long x, prev;
|
||||
Py_ssize_t i;
|
||||
|
||||
if (vv == NULL || !PyLong_Check(vv)) {
|
||||
if (vv == NULL) {
|
||||
PyErr_BadInternalCall();
|
||||
return (unsigned long) -1;
|
||||
return (unsigned long)-1;
|
||||
}
|
||||
if (!PyLong_Check(vv)) {
|
||||
PyErr_SetString(PyExc_TypeError, "an integer is required");
|
||||
return (unsigned long)-1;
|
||||
}
|
||||
|
||||
v = (PyLongObject *)vv;
|
||||
i = Py_SIZE(v);
|
||||
x = 0;
|
||||
|
|
@ -528,10 +538,15 @@ PyLong_AsSize_t(PyObject *vv)
|
|||
size_t x, prev;
|
||||
Py_ssize_t i;
|
||||
|
||||
if (vv == NULL || !PyLong_Check(vv)) {
|
||||
if (vv == NULL) {
|
||||
PyErr_BadInternalCall();
|
||||
return (unsigned long) -1;
|
||||
return (size_t) -1;
|
||||
}
|
||||
if (!PyLong_Check(vv)) {
|
||||
PyErr_SetString(PyExc_TypeError, "an integer is required");
|
||||
return (size_t)-1;
|
||||
}
|
||||
|
||||
v = (PyLongObject *)vv;
|
||||
i = Py_SIZE(v);
|
||||
x = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue