Skip to content

Commit 43713e5

Browse files
committed
Massive patch by Skip Montanaro to add ":name" to as many
PyArg_ParseTuple() format string arguments as possible.
1 parent a9b2b4b commit 43713e5

37 files changed

+272
-272
lines changed

Modules/_localemodule.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ PyLocale_setlocale(self,args)
135135
char *locale=0,*result;
136136
PyObject *result_object;
137137
struct lconv *lc;
138-
if(!PyArg_ParseTuple(args,"i|z",&category,&locale))return 0;
138+
if(!PyArg_ParseTuple(args,"i|z:setlocale",&category,&locale))return 0;
139139
if(locale){
140140
/* set locale */
141141
result=setlocale(category,locale);
@@ -266,7 +266,7 @@ PyLocale_strcoll(self,args)
266266
PyObject *args;
267267
{
268268
char *s1,*s2;
269-
if(!PyArg_ParseTuple(args,"ss",&s1,&s2))
269+
if(!PyArg_ParseTuple(args,"ss:strcoll",&s1,&s2))
270270
return NULL;
271271
return PyInt_FromLong(strcoll(s1,s2));
272272
}
@@ -283,7 +283,7 @@ PyLocale_strxfrm(self,args)
283283
char *s,*buf;
284284
int n1,n2;
285285
PyObject *result;
286-
if(!PyArg_ParseTuple(args,"s",&s))
286+
if(!PyArg_ParseTuple(args,"s:strxfrm",&s))
287287
return NULL;
288288
/* assume no change in size, first */
289289
n1=strlen(s)+1;

Modules/_tkinter.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ Tkapp_Eval(self, args)
697697
PyObject *res = NULL;
698698
int err;
699699

700-
if (!PyArg_ParseTuple(args, "s", &script))
700+
if (!PyArg_ParseTuple(args, "s:eval", &script))
701701
return NULL;
702702

703703
ENTER_TCL
@@ -720,7 +720,7 @@ Tkapp_GlobalEval(self, args)
720720
PyObject *res = NULL;
721721
int err;
722722

723-
if (!PyArg_ParseTuple(args, "s", &script))
723+
if (!PyArg_ParseTuple(args, "s:globaleval", &script))
724724
return NULL;
725725

726726
ENTER_TCL
@@ -743,7 +743,7 @@ Tkapp_EvalFile(self, args)
743743
PyObject *res = NULL;
744744
int err;
745745

746-
if (!PyArg_ParseTuple(args, "s", &fileName))
746+
if (!PyArg_ParseTuple(args, "s:evalfile", &fileName))
747747
return NULL;
748748

749749
ENTER_TCL
@@ -788,7 +788,7 @@ Tkapp_AddErrorInfo(self, args)
788788
{
789789
char *msg;
790790

791-
if (!PyArg_ParseTuple(args, "s", &msg))
791+
if (!PyArg_ParseTuple(args, "s:adderrorinfo", &msg))
792792
return NULL;
793793
ENTER_TCL
794794
Tcl_AddErrorInfo(Tkapp_Interp(self), msg);
@@ -816,7 +816,7 @@ SetVar(self, args, flags)
816816
if (!tmp)
817817
return NULL;
818818

819-
if (PyArg_ParseTuple(args, "sO", &name1, &newValue)) {
819+
if (PyArg_ParseTuple(args, "sO:setvar", &name1, &newValue)) {
820820
/* XXX Merge? */
821821
s = AsString(newValue, tmp);
822822
ENTER_TCL
@@ -825,7 +825,7 @@ SetVar(self, args, flags)
825825
}
826826
else {
827827
PyErr_Clear();
828-
if (PyArg_ParseTuple(args, "ssO", &name1, &name2, &newValue)) {
828+
if (PyArg_ParseTuple(args, "ssO:setvar", &name1, &name2, &newValue)) {
829829
s = AsString (newValue, tmp);
830830
ENTER_TCL
831831
ok = Tcl_SetVar2(Tkapp_Interp(self), name1, name2,
@@ -873,7 +873,7 @@ GetVar(self, args, flags)
873873
char *name1, *name2=NULL, *s;
874874
PyObject *res = NULL;
875875

876-
if (!PyArg_ParseTuple(args, "s|s", &name1, &name2))
876+
if (!PyArg_ParseTuple(args, "s|s:getvar", &name1, &name2))
877877
return NULL;
878878
ENTER_TCL
879879
if (name2 == NULL)
@@ -919,7 +919,7 @@ UnsetVar(self, args, flags)
919919
PyObject *res = NULL;
920920
int code;
921921

922-
if (!PyArg_ParseTuple(args, "s|s", &name1, &name2))
922+
if (!PyArg_ParseTuple(args, "s|s:unsetvar", &name1, &name2))
923923
return NULL;
924924
ENTER_TCL
925925
if (name2 == NULL)
@@ -967,7 +967,7 @@ Tkapp_GetInt(self, args)
967967
char *s;
968968
int v;
969969

970-
if (!PyArg_ParseTuple(args, "s", &s))
970+
if (!PyArg_ParseTuple(args, "s:getint", &s))
971971
return NULL;
972972
if (Tcl_GetInt(Tkapp_Interp(self), s, &v) == TCL_ERROR)
973973
return Tkinter_Error(self);
@@ -982,7 +982,7 @@ Tkapp_GetDouble(self, args)
982982
char *s;
983983
double v;
984984

985-
if (!PyArg_ParseTuple(args, "s", &s))
985+
if (!PyArg_ParseTuple(args, "s:getdouble", &s))
986986
return NULL;
987987
if (Tcl_GetDouble(Tkapp_Interp(self), s, &v) == TCL_ERROR)
988988
return Tkinter_Error(self);
@@ -997,7 +997,7 @@ Tkapp_GetBoolean(self, args)
997997
char *s;
998998
int v;
999999

1000-
if (!PyArg_ParseTuple(args, "s", &s))
1000+
if (!PyArg_ParseTuple(args, "s:getboolean", &s))
10011001
return NULL;
10021002
if (Tcl_GetBoolean(Tkapp_Interp(self), s, &v) == TCL_ERROR)
10031003
return Tkinter_Error(self);
@@ -1013,7 +1013,7 @@ Tkapp_ExprString(self, args)
10131013
PyObject *res = NULL;
10141014
int retval;
10151015

1016-
if (!PyArg_ParseTuple(args, "s", &s))
1016+
if (!PyArg_ParseTuple(args, "s:exprstring", &s))
10171017
return NULL;
10181018
ENTER_TCL
10191019
retval = Tcl_ExprString(Tkapp_Interp(self), s);
@@ -1036,7 +1036,7 @@ Tkapp_ExprLong(self, args)
10361036
int retval;
10371037
long v;
10381038

1039-
if (!PyArg_ParseTuple(args, "s", &s))
1039+
if (!PyArg_ParseTuple(args, "s:exprlong", &s))
10401040
return NULL;
10411041
ENTER_TCL
10421042
retval = Tcl_ExprLong(Tkapp_Interp(self), s, &v);
@@ -1059,7 +1059,7 @@ Tkapp_ExprDouble(self, args)
10591059
double v;
10601060
int retval;
10611061

1062-
if (!PyArg_ParseTuple(args, "s", &s))
1062+
if (!PyArg_ParseTuple(args, "s:exprdouble", &s))
10631063
return NULL;
10641064
PyFPE_START_PROTECT("Tkapp_ExprDouble", return 0)
10651065
ENTER_TCL
@@ -1084,7 +1084,7 @@ Tkapp_ExprBoolean(self, args)
10841084
int retval;
10851085
int v;
10861086

1087-
if (!PyArg_ParseTuple(args, "s", &s))
1087+
if (!PyArg_ParseTuple(args, "s:exprboolean", &s))
10881088
return NULL;
10891089
ENTER_TCL
10901090
retval = Tcl_ExprBoolean(Tkapp_Interp(self), s, &v);
@@ -1110,7 +1110,7 @@ Tkapp_SplitList(self, args)
11101110
PyObject *v;
11111111
int i;
11121112

1113-
if (!PyArg_ParseTuple(args, "s", &list))
1113+
if (!PyArg_ParseTuple(args, "s:splitlist", &list))
11141114
return NULL;
11151115

11161116
if (Tcl_SplitList(Tkapp_Interp(self), list, &argc, &argv) == TCL_ERROR)
@@ -1140,7 +1140,7 @@ Tkapp_Split(self, args)
11401140
{
11411141
char *list;
11421142

1143-
if (!PyArg_ParseTuple(args, "s", &list))
1143+
if (!PyArg_ParseTuple(args, "s:split", &list))
11441144
return NULL;
11451145
return Split(list);
11461146
}
@@ -1261,7 +1261,7 @@ Tkapp_CreateCommand(self, args)
12611261
PyObject *func;
12621262
Tcl_Command err;
12631263

1264-
if (!PyArg_ParseTuple(args, "sO", &cmdName, &func))
1264+
if (!PyArg_ParseTuple(args, "sO:createcommand", &cmdName, &func))
12651265
return NULL;
12661266
if (!PyCallable_Check(func)) {
12671267
PyErr_SetString(PyExc_TypeError, "command not callable");
@@ -1300,7 +1300,7 @@ Tkapp_DeleteCommand(self, args)
13001300
char *cmdName;
13011301
int err;
13021302

1303-
if (!PyArg_ParseTuple(args, "s", &cmdName))
1303+
if (!PyArg_ParseTuple(args, "s:deletecommand", &cmdName))
13041304
return NULL;
13051305
ENTER_TCL
13061306
err = Tcl_DeleteCommand(Tkapp_Interp(self), cmdName);
@@ -1443,7 +1443,7 @@ Tkapp_CreateFileHandler(self, args)
14431443
int mask, id;
14441444
FHANDLE tfile;
14451445

1446-
if (!PyArg_ParseTuple(args, "OiO", &file, &mask, &func))
1446+
if (!PyArg_ParseTuple(args, "OiO:createfilehandler", &file, &mask, &func))
14471447
return NULL;
14481448
id = GetFileNo(file);
14491449
if (id < 0)
@@ -1476,7 +1476,7 @@ Tkapp_DeleteFileHandler(self, args)
14761476
int id;
14771477
FHANDLE tfile;
14781478

1479-
if (!PyArg_ParseTuple(args, "O", &file))
1479+
if (!PyArg_ParseTuple(args, "O:deletefilehandler", &file))
14801480
return NULL;
14811481
id = GetFileNo(file);
14821482
if (id < 0)
@@ -1513,7 +1513,7 @@ Tktt_DeleteTimerHandler(self, args)
15131513
TkttObject *v = (TkttObject *)self;
15141514
PyObject *func = v->func;
15151515

1516-
if (!PyArg_ParseTuple(args, ""))
1516+
if (!PyArg_ParseTuple(args, ":deletetimerhandler"))
15171517
return NULL;
15181518
if (v->token != NULL) {
15191519
Tcl_DeleteTimerHandler(v->token);
@@ -1646,7 +1646,7 @@ Tkapp_CreateTimerHandler(self, args)
16461646
PyObject *func;
16471647
TkttObject *v;
16481648

1649-
if (!PyArg_ParseTuple(args, "iO", &milliseconds, &func))
1649+
if (!PyArg_ParseTuple(args, "iO:createtimerhandler", &milliseconds, &func))
16501650
return NULL;
16511651
if (!PyCallable_Check(func)) {
16521652
PyErr_SetString(PyExc_TypeError, "bad argument list");
@@ -1672,7 +1672,7 @@ Tkapp_MainLoop(self, args)
16721672
PyThreadState *tstate = PyThreadState_Get();
16731673
#endif
16741674

1675-
if (!PyArg_ParseTuple(args, "|i", &threshold))
1675+
if (!PyArg_ParseTuple(args, "|i:mainloop", &threshold))
16761676
return NULL;
16771677

16781678
quitMainLoop = 0;
@@ -1721,7 +1721,7 @@ Tkapp_DoOneEvent(self, args)
17211721
int flags = 0;
17221722
int rv;
17231723

1724-
if (!PyArg_ParseTuple(args, "|i", &flags))
1724+
if (!PyArg_ParseTuple(args, "|i:dooneevent", &flags))
17251725
return NULL;
17261726

17271727
ENTER_TCL
@@ -1736,7 +1736,7 @@ Tkapp_Quit(self, args)
17361736
PyObject *args;
17371737
{
17381738

1739-
if (!PyArg_ParseTuple(args, ""))
1739+
if (!PyArg_ParseTuple(args, ":quit"))
17401740
return NULL;
17411741

17421742
quitMainLoop = 1;
@@ -1750,7 +1750,7 @@ Tkapp_InterpAddr(self, args)
17501750
PyObject *args;
17511751
{
17521752

1753-
if (!PyArg_ParseTuple(args, ""))
1753+
if (!PyArg_ParseTuple(args, ":interpaddr"))
17541754
return NULL;
17551755

17561756
return PyInt_FromLong((long)Tkapp_Interp(self));
@@ -1862,7 +1862,7 @@ Tkinter_Create(self, args)
18621862
baseName = Py_GetProgramName();
18631863
className = "Tk";
18641864

1865-
if (!PyArg_ParseTuple(args, "|zssi",
1865+
if (!PyArg_ParseTuple(args, "|zssi:create",
18661866
&screenName, &baseName, &className,
18671867
&interactive))
18681868
return NULL;

0 commit comments

Comments
 (0)