summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-11-18 00:21:12 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-11-18 00:21:12 (GMT)
commit74387f5cac59d9cdafdd98e91f796d4731bd533a (patch)
tree848ab1e1878045aa191c740bf3446ec86859203e /Python
parentcad876d54273e6f3f9cb3ff575da1c45ef5410c6 (diff)
downloadcpython-74387f5cac59d9cdafdd98e91f796d4731bd533a.zip
cpython-74387f5cac59d9cdafdd98e91f796d4731bd533a.tar.gz
cpython-74387f5cac59d9cdafdd98e91f796d4731bd533a.tar.bz2
Use Py_ssize_t type for sizes in getargs.c
Fix compiler warnings on Windows 64-bit
Diffstat (limited to 'Python')
-rw-r--r--Python/getargs.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/Python/getargs.c b/Python/getargs.c
index f313a37..2cc3031 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -421,6 +421,7 @@ converttuple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
int n = 0;
const char *format = *p_format;
int i;
+ Py_ssize_t len;
for (;;) {
int c = *format++;
@@ -450,12 +451,20 @@ converttuple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
return msgbuf;
}
- if ((i = PySequence_Size(arg)) != n) {
+ len = PySequence_Size(arg);
+ if (len != n) {
levels[0] = 0;
- PyOS_snprintf(msgbuf, bufsize,
- toplevel ? "expected %d arguments, not %d" :
- "must be sequence of length %d, not %d",
- n, i);
+ if (toplevel) {
+ PyOS_snprintf(msgbuf, bufsize,
+ "expected %d arguments, not %" PY_FORMAT_SIZE_T "d",
+ n, len);
+ }
+ else {
+ PyOS_snprintf(msgbuf, bufsize,
+ "must be sequence of length %d, "
+ "not %" PY_FORMAT_SIZE_T "d",
+ n, len);
+ }
return msgbuf;
}
@@ -1426,7 +1435,8 @@ vgetargskeywords(PyObject *args, PyObject *keywords, const char *format,
const char *fname, *msg, *custom_msg, *keyword;
int min = INT_MAX;
int max = INT_MAX;
- int i, len, nargs, nkeywords;
+ int i, len;
+ Py_ssize_t nargs, nkeywords;
PyObject *current_arg;
freelistentry_t static_entries[STATIC_FREELIST_ENTRIES];
freelist_t freelist = {static_entries, 0, 0};
@@ -1466,7 +1476,8 @@ vgetargskeywords(PyObject *args, PyObject *keywords, const char *format,
nkeywords = (keywords == NULL) ? 0 : PyDict_Size(keywords);
if (nargs + nkeywords > len) {
PyErr_Format(PyExc_TypeError,
- "%s%s takes at most %d argument%s (%d given)",
+ "%s%s takes at most %d argument%s "
+ "(%" PY_FORMAT_SIZE_T "d given)",
(fname == NULL) ? "function" : fname,
(fname == NULL) ? "" : "()",
len,