summaryrefslogtreecommitdiff
path: root/Python/structmember.c
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2010-04-06 15:44:57 +0000
committerMark Dickinson <dickinsm@gmail.com>2010-04-06 15:44:57 +0000
commit89d69fbc95a651aca78eae63991c2f9b6064105d (patch)
tree435bb1a0ba9a97cf955453dc817f3ad5a055cadb /Python/structmember.c
parent57d480b837fed17dfc18a8d3abfa14dbf2c72f6c (diff)
downloadcpython-89d69fbc95a651aca78eae63991c2f9b6064105d.tar.gz
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.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/Python/structmember.c b/Python/structmember.c
index 8e371844fd..9109f23540 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");