diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2007-06-09 07:42:52 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2007-06-09 07:42:52 (GMT) |
commit | 6371cd81775298dfd5dbbffbc172f3e5ddf6b5ea (patch) | |
tree | 2e9902bb1fd520e34704bf119e27094542b5814e /Python/structmember.c | |
parent | 080b598990aae43b2ee4880d98b1a575fae2a778 (diff) | |
download | cpython-6371cd81775298dfd5dbbffbc172f3e5ddf6b5ea.zip cpython-6371cd81775298dfd5dbbffbc172f3e5ddf6b5ea.tar.gz cpython-6371cd81775298dfd5dbbffbc172f3e5ddf6b5ea.tar.bz2 |
Patch #1733960: Allow T_LONGLONG to accept ints.
Will backport to 2.5.
Diffstat (limited to 'Python/structmember.c')
-rw-r--r-- | Python/structmember.c | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/Python/structmember.c b/Python/structmember.c index 94d222a..17422d0 100644 --- a/Python/structmember.c +++ b/Python/structmember.c @@ -293,31 +293,25 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v) } break; #ifdef HAVE_LONG_LONG - case T_LONGLONG: - if (!PyLong_Check(v)) { - PyErr_BadArgument(); + case T_LONGLONG:{ + PY_LONG_LONG value; + *(PY_LONG_LONG*)addr = value = PyLong_AsLongLong(v); + if ((value == -1) && PyErr_Occurred()) return -1; - } else { - PY_LONG_LONG value; - *(PY_LONG_LONG*)addr = value = PyLong_AsLongLong(v); - if ((value == -1) && PyErr_Occurred()) { - return -1; - } - } - break; - case T_ULONGLONG: - if (!PyLong_Check(v)) { - PyErr_BadArgument(); - return -1; - } else { - unsigned PY_LONG_LONG value; - *(unsigned PY_LONG_LONG*)addr = value = PyLong_AsUnsignedLongLong(v); - if ((value == (unsigned PY_LONG_LONG)-1) && - PyErr_Occurred()) { - return -1; - } - } - break; + break; + } + case T_ULONGLONG:{ + unsigned PY_LONG_LONG value; + /* ??? PyLong_AsLongLong accepts an int, but PyLong_AsUnsignedLongLong + doesn't ??? */ + if (PyLong_Check(v)) + *(unsigned PY_LONG_LONG*)addr = value = PyLong_AsUnsignedLongLong(v); + else + *(unsigned PY_LONG_LONG*)addr = value = PyInt_AsLong(v); + if ((value == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred()) + return -1; + break; + } #endif /* HAVE_LONG_LONG */ default: PyErr_Format(PyExc_SystemError, |