Mercurial > cpython-lru_cache-weakref
diff Python/structmember.c @ 60396:64fdf66f69b0 3.1
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.
........
| author | Mark Dickinson <dickinsm@gmail.com> |
|---|---|
| date | Tue, 06 Apr 2010 15:44:57 +0000 |
| parents | c04a6222cc7d |
| children | f197407bdba2 |
line wrap: on
line diff
--- a/Python/structmember.c Tue Apr 06 15:24:08 2010 +0000 +++ b/Python/structmember.c Tue Apr 06 15:44:57 2010 +0000 @@ -187,12 +187,13 @@ } 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 @@ 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");
