Issue #8014: Fix incorrect error checks in structmember.c, and re-enable
previously failing test_structmember.py tests.
This commit is contained in:
parent
d59b41641e
commit
252e4003b9
|
@ -87,8 +87,8 @@ class ReadWriteTests(unittest.TestCase):
|
||||||
'T_BOOL',
|
'T_BOOL',
|
||||||
'T_BYTE', 'T_UBYTE',
|
'T_BYTE', 'T_UBYTE',
|
||||||
'T_SHORT', 'T_USHORT',
|
'T_SHORT', 'T_USHORT',
|
||||||
'T_INT', #'T_UINT',
|
'T_INT', 'T_UINT',
|
||||||
'T_LONG', #'T_ULONG',
|
'T_LONG', 'T_ULONG',
|
||||||
'T_PYSSIZET'
|
'T_PYSSIZET'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -187,12 +187,13 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v)
|
||||||
}
|
}
|
||||||
case T_UINT:{
|
case T_UINT:{
|
||||||
unsigned long ulong_val = PyLong_AsUnsignedLong(v);
|
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
|
/* XXX: For compatibility, accept negative int values
|
||||||
as well. */
|
as well. */
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
ulong_val = PyLong_AsLong(v);
|
ulong_val = PyLong_AsLong(v);
|
||||||
if ((ulong_val == (unsigned int)-1) && PyErr_Occurred())
|
if ((ulong_val == (unsigned long)-1) &&
|
||||||
|
PyErr_Occurred())
|
||||||
return -1;
|
return -1;
|
||||||
*(unsigned int *)addr = (unsigned int)ulong_val;
|
*(unsigned int *)addr = (unsigned int)ulong_val;
|
||||||
WARN("Writing negative value into unsigned field");
|
WARN("Writing negative value into unsigned field");
|
||||||
|
@ -216,7 +217,7 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v)
|
||||||
as well. */
|
as well. */
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
*(unsigned long*)addr = PyLong_AsLong(v);
|
*(unsigned long*)addr = PyLong_AsLong(v);
|
||||||
if ((*(unsigned long*)addr == (unsigned int)-1)
|
if ((*(unsigned long*)addr == (unsigned long)-1)
|
||||||
&& PyErr_Occurred())
|
&& PyErr_Occurred())
|
||||||
return -1;
|
return -1;
|
||||||
WARN("Writing negative value into unsigned field");
|
WARN("Writing negative value into unsigned field");
|
||||||
|
|
Loading…
Reference in New Issue