Skip to content

Commit 689f4fa

Browse files
committed
Backport Jeremy's checkin 2.57:
vgetargs1() and vgetargskeywords(): Replace uses of PyTuple_Size() and PyTuple_GetItem() with PyTuple_GET_SIZE() and PyTuple_GET_ITEM(). The code has already done a PyTuple_Check().
1 parent 7a5b674 commit 689f4fa

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

Python/getargs.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ vgetargs1(PyObject *args, char *format, va_list *p_va, int compat)
166166
return 0;
167167
}
168168

169-
len = PyTuple_Size(args);
169+
len = PyTuple_GET_SIZE(args);
170170

171171
if (len < min || max < len) {
172172
if (message == NULL) {
@@ -188,8 +188,8 @@ vgetargs1(PyObject *args, char *format, va_list *p_va, int compat)
188188
for (i = 0; i < len; i++) {
189189
if (*format == '|')
190190
format++;
191-
msg = convertitem(PyTuple_GetItem(args, i), &format, p_va,
192-
levels, msgbuf);
191+
msg = convertitem(PyTuple_GET_ITEM(args, i), &format, p_va,
192+
levels, msgbuf);
193193
if (msg) {
194194
seterror(i+1, msg, levels, fname, message);
195195
return 0;
@@ -995,12 +995,10 @@ vgetargskeywords(PyObject *args, PyObject *keywords, char *format,
995995
else if (c == ':') {
996996
fname = format;
997997
break;
998-
}
999-
else if (c == ';') {
998+
} else if (c == ';') {
1000999
message = format;
10011000
break;
1002-
}
1003-
else if (c == 'e')
1001+
} else if (c == 'e')
10041002
; /* Pass */
10051003
else if (isalpha(c))
10061004
max++;
@@ -1019,7 +1017,7 @@ vgetargskeywords(PyObject *args, PyObject *keywords, char *format,
10191017
return 0;
10201018
}
10211019

1022-
tplen = PyTuple_Size(args);
1020+
tplen = PyTuple_GET_SIZE(args);
10231021

10241022
/* do a cursory check of the keywords just to see how many we got */
10251023

@@ -1095,7 +1093,7 @@ vgetargskeywords(PyObject *args, PyObject *keywords, char *format,
10951093
for (i = 0; i < tplen; i++) {
10961094
if (*format == '|')
10971095
format++;
1098-
msg = convertitem(PyTuple_GetItem(args, i), &format, p_va,
1096+
msg = convertitem(PyTuple_GET_ITEM(args, i), &format, p_va,
10991097
levels, msgbuf);
11001098
if (msg) {
11011099
seterror(i+1, msg, levels, fname, message);

0 commit comments

Comments
 (0)