diff options
author | Georg Brandl <georg@python.org> | 2005-11-24 15:37:42 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2005-11-24 15:37:42 (GMT) |
commit | f06e30af4a0b556d2144b6fd473afeddbc21bb2f (patch) | |
tree | 2edf45d64c13319d09d09f22eca6200c1d1e2279 /Python | |
parent | 9df23ea1fc7cc9325b03c9a4beb7f4852687378f (diff) | |
download | cpython-f06e30af4a0b556d2144b6fd473afeddbc21bb2f.zip cpython-f06e30af4a0b556d2144b6fd473afeddbc21bb2f.tar.gz cpython-f06e30af4a0b556d2144b6fd473afeddbc21bb2f.tar.bz2 |
bug #1281408: make Py_BuildValue work with unsigned longs and long longs
Diffstat (limited to 'Python')
-rw-r--r-- | Python/modsupport.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/Python/modsupport.c b/Python/modsupport.c index fbfb48d..3b4c517 100644 --- a/Python/modsupport.c +++ b/Python/modsupport.c @@ -303,18 +303,35 @@ do_mkvalue(char **p_format, va_list *p_va) case 'H': return PyInt_FromLong((long)va_arg(*p_va, unsigned int)); + case 'I': + { + unsigned int n; + n = va_arg(*p_va, unsigned int); + if (n > PyInt_GetMax()) + return PyLong_FromUnsignedLong((unsigned long)n); + else + return PyInt_FromLong(n); + } + case 'l': - return PyInt_FromLong((long)va_arg(*p_va, long)); + return PyInt_FromLong(va_arg(*p_va, long)); case 'k': - return PyInt_FromLong((long)va_arg(*p_va, unsigned long)); + { + unsigned long n; + n = va_arg(*p_va, unsigned long); + if (n > PyInt_GetMax()) + return PyLong_FromUnsignedLong(n); + else + return PyInt_FromLong(n); + } #ifdef HAVE_LONG_LONG case 'L': return PyLong_FromLongLong((PY_LONG_LONG)va_arg(*p_va, PY_LONG_LONG)); case 'K': - return PyLong_FromLongLong((PY_LONG_LONG)va_arg(*p_va, unsigned PY_LONG_LONG)); + return PyLong_FromUnsignedLongLong((PY_LONG_LONG)va_arg(*p_va, unsigned PY_LONG_LONG)); #endif #ifdef Py_USING_UNICODE case 'u': |