summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2010-03-13 13:23:05 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2010-03-13 13:23:05 (GMT)
commit252e4003b95f4d79560d4c8d30aa9d2514b15caf (patch)
treeb4687c546721e60ecfe4bb9bb51f396ff13ac898
parentd59b41641e7f800a65f4241d05710b774cafa04f (diff)
downloadcpython-252e4003b95f4d79560d4c8d30aa9d2514b15caf.zip
cpython-252e4003b95f4d79560d4c8d30aa9d2514b15caf.tar.gz
cpython-252e4003b95f4d79560d4c8d30aa9d2514b15caf.tar.bz2
Issue #8014: Fix incorrect error checks in structmember.c, and re-enable
previously failing test_structmember.py tests.
-rw-r--r--Lib/test/test_structmembers.py4
-rw-r--r--Python/structmember.c7
2 files changed, 6 insertions, 5 deletions
diff --git a/Lib/test/test_structmembers.py b/Lib/test/test_structmembers.py
index 145a16e..27db161 100644
--- a/Lib/test/test_structmembers.py
+++ b/Lib/test/test_structmembers.py
@@ -87,8 +87,8 @@ class ReadWriteTests(unittest.TestCase):
'T_BOOL',
'T_BYTE', 'T_UBYTE',
'T_SHORT', 'T_USHORT',
- 'T_INT', #'T_UINT',
- 'T_LONG', #'T_ULONG',
+ 'T_INT', 'T_UINT',
+ 'T_LONG', 'T_ULONG',
'T_PYSSIZET'
]
diff --git a/Python/structmember.c b/Python/structmember.c
index 8edc354..88ea6f8 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");