summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2010-03-13 14:18:34 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2010-03-13 14:18:34 (GMT)
commitf1ff88f0e4e803fac33b98da7af7cb6c3d8fb917 (patch)
tree6870149031c040ae59dad8b93a1fc05735021ad2
parent45534cec26386890ff773d1f7a507e67573471a7 (diff)
downloadcpython-f1ff88f0e4e803fac33b98da7af7cb6c3d8fb917.zip
cpython-f1ff88f0e4e803fac33b98da7af7cb6c3d8fb917.tar.gz
cpython-f1ff88f0e4e803fac33b98da7af7cb6c3d8fb917.tar.bz2
Fix incorrect error checks in structmember.c (backport of r78920 from py3k).
-rw-r--r--Python/structmember.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/Python/structmember.c b/Python/structmember.c
index 9f87c07..d2d8273 100644
--- a/Python/structmember.c
+++ b/Python/structmember.c
@@ -257,12 +257,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");
@@ -286,7 +287,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");