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 /Python/structmember.c | |
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 'Python/structmember.c')
-rw-r--r-- | Python/structmember.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Python/structmember.c b/Python/structmember.c index 8e37184..9109f23 100644 --- a/Python/structmember.c +++ b/Python/structmember.c @@ -187,12 +187,13 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v) } case T_UINT:{ unsigned long ulong_val = PyLong_AsUnsignedLong(v); - if ((ulong_val == (unsigned int)-1) && PyErr_Occurred()) { + if ((ulong_val == (unsigned long)-1) && PyErr_Occurred()) { /* XXX: For compatibility, accept negative int values as well. */ PyErr_Clear(); ulong_val = PyLong_AsLong(v); - if ((ulong_val == (unsigned int)-1) && PyErr_Occurred()) + if ((ulong_val == (unsigned long)-1) && + PyErr_Occurred()) return -1; *(unsigned int *)addr = (unsigned int)ulong_val; WARN("Writing negative value into unsigned field"); @@ -216,7 +217,7 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v) as well. */ PyErr_Clear(); *(unsigned long*)addr = PyLong_AsLong(v); - if ((*(unsigned long*)addr == (unsigned int)-1) + if ((*(unsigned long*)addr == (unsigned long)-1) && PyErr_Occurred()) return -1; WARN("Writing negative value into unsigned field"); |