diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2010-04-06 15:44:57 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2010-04-06 15:44:57 (GMT) |
commit | bee1fb0f75331bf5ba97579d75ac623c2edcaa25 (patch) | |
tree | 5141b33ce1e910e07ce323fc39be355a5a56a83b /Objects | |
parent | de33ffffed46521a7ffd62350ecfd8f5f7ec8943 (diff) | |
download | cpython-bee1fb0f75331bf5ba97579d75ac623c2edcaa25.zip cpython-bee1fb0f75331bf5ba97579d75ac623c2edcaa25.tar.gz cpython-bee1fb0f75331bf5ba97579d75ac623c2edcaa25.tar.bz2 |
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.
........
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/longobject.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c index f84b54e..cfd6eba 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -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; |