[Python-checkins] CVS: python/dist/src/Python getargs.c,2.85,2.86
Jeremy Hylton
jhylton@users.sourceforge.net
Wed, 28 Nov 2001 12:29:24 -0800
- Previous message: [Python-checkins] CVS: python/dist/src/Modules _hotshot.c,1.9,1.10 _localemodule.c,2.24,2.25 _testcapimodule.c,1.13,1.14 _tkinter.c,1.119,1.120 arraymodule.c,2.64,2.65 flmodule.c,1.45,1.46 gdbmmodule.c,2.30,2.31 pcremodule.c,2.28,2.29 posixmodule.c,2.209,2.210 pyexpat.c,2.55,2.56 readline.c,2.40,2.41 socketmodule.c,1.197,1.198 stropmodule.c,2.82,2.83
- Next message: [Python-checkins] CVS: python/dist/src/RISCOS/Python dynload_riscos.c,1.2,1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv5913
Modified Files:
getargs.c
Log Message:
Use PyOS_snprintf when possible.
Index: getargs.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/getargs.c,v
retrieving revision 2.85
retrieving revision 2.86
diff -C2 -d -r2.85 -r2.86
*** getargs.c 2001/11/28 11:47:00 2.85
--- getargs.c 2001/11/28 20:29:22 2.86
***************
*** 136,142 ****
if (args == NULL)
return 1;
! sprintf(msgbuf, "%.200s%s takes no arguments",
! fname==NULL ? "function" : fname,
! fname==NULL ? "" : "()");
PyErr_SetString(PyExc_TypeError, msgbuf);
return 0;
--- 136,143 ----
if (args == NULL)
return 1;
! PyOS_snprintf(msgbuf, sizeof(msgbuf),
! "%.200s%s takes no arguments",
! fname==NULL ? "function" : fname,
! fname==NULL ? "" : "()");
PyErr_SetString(PyExc_TypeError, msgbuf);
return 0;
***************
*** 144,151 ****
else if (min == 1 && max == 1) {
if (args == NULL) {
! sprintf(msgbuf,
! "%.200s%s takes at least one argument",
! fname==NULL ? "function" : fname,
! fname==NULL ? "" : "()");
PyErr_SetString(PyExc_TypeError, msgbuf);
return 0;
--- 145,152 ----
else if (min == 1 && max == 1) {
if (args == NULL) {
! PyOS_snprintf(msgbuf, sizeof(msgbuf),
! "%.200s%s takes at least one argument",
! fname==NULL ? "function" : fname,
! fname==NULL ? "" : "()");
PyErr_SetString(PyExc_TypeError, msgbuf);
return 0;
***************
*** 174,186 ****
if (len < min || max < len) {
if (message == NULL) {
! sprintf(msgbuf,
! "%.150s%s takes %s %d argument%s (%d given)",
! fname==NULL ? "function" : fname,
! fname==NULL ? "" : "()",
! min==max ? "exactly"
! : len < min ? "at least" : "at most",
! len < min ? min : max,
! (len < min ? min : max) == 1 ? "" : "s",
! len);
message = msgbuf;
}
--- 175,188 ----
if (len < min || max < len) {
if (message == NULL) {
! PyOS_snprintf(msgbuf, sizeof(msgbuf),
! "%.150s%s takes %s %d argument%s "
! "(%d given)",
! fname==NULL ? "function" : fname,
! fname==NULL ? "" : "()",
! min==max ? "exactly"
! : len < min ? "at least" : "at most",
! len < min ? min : max,
! (len < min ? min : max) == 1 ? "" : "s",
! len);
message = msgbuf;
}
***************
*** 223,226 ****
--- 225,229 ----
return;
else if (message == NULL) {
+ /* XXX snprintf */
if (fname != NULL) {
sprintf(p, "%.200s() ", fname);
***************
*** 295,302 ****
if (!PySequence_Check(arg) || PyString_Check(arg)) {
levels[0] = 0;
! sprintf(msgbuf,
! toplevel ? "expected %d arguments, not %.50s" :
! "must be %d-item sequence, not %.50s",
! n, arg == Py_None ? "None" : arg->ob_type->tp_name);
return msgbuf;
}
--- 298,306 ----
if (!PySequence_Check(arg) || PyString_Check(arg)) {
levels[0] = 0;
! PyOS_snprintf(msgbuf, sizeof(msgbuf),
! toplevel ? "expected %d arguments, not %.50s" :
! "must be %d-item sequence, not %.50s",
! n,
! arg == Py_None ? "None" : arg->ob_type->tp_name);
return msgbuf;
}
***************
*** 304,311 ****
if ((i = PySequence_Size(arg)) != n) {
levels[0] = 0;
! sprintf(msgbuf,
! toplevel ? "expected %d arguments, not %d" :
! "must be sequence of length %d, not %d",
! n, i);
return msgbuf;
}
--- 308,315 ----
if ((i = PySequence_Size(arg)) != n) {
levels[0] = 0;
! PyOS_snprintf(msgbuf, sizeof(msgbuf),
! toplevel ? "expected %d arguments, not %d" :
! "must be sequence of length %d, not %d",
! n, i);
return msgbuf;
}
***************
*** 367,371 ****
assert(expected != NULL);
assert(arg != NULL);
! sprintf(msgbuf, "must be %.50s, not %.50s", expected,
arg == Py_None ? "None" : arg->ob_type->tp_name);
return msgbuf;
--- 371,377 ----
assert(expected != NULL);
assert(arg != NULL);
! /* XXX use snprintf? */
! sprintf(msgbuf,
! "must be %.50s, not %.50s", expected,
arg == Py_None ? "None" : arg->ob_type->tp_name);
return msgbuf;
***************
*** 1130,1142 ****
if (len < min || max < len) {
if (message == NULL) {
! sprintf(msgbuf,
! "%.200s%s takes %s %d argument%s (%d given)",
! fname==NULL ? "function" : fname,
! fname==NULL ? "" : "()",
! min==max ? "exactly"
! : len < min ? "at least" : "at most",
! len < min ? min : max,
! (len < min ? min : max) == 1 ? "" : "s",
! len);
message = msgbuf;
}
--- 1136,1149 ----
if (len < min || max < len) {
if (message == NULL) {
! PyOS_snprintf(msgbuf, sizeof(msgbuf),
! "%.200s%s takes %s %d argument%s "
! "(%d given)",
! fname==NULL ? "function" : fname,
! fname==NULL ? "" : "()",
! min==max ? "exactly"
! : len < min ? "at least" : "at most",
! len < min ? min : max,
! (len < min ? min : max) == 1 ? "" : "s",
! len);
message = msgbuf;
}
- Previous message: [Python-checkins] CVS: python/dist/src/Modules _hotshot.c,1.9,1.10 _localemodule.c,2.24,2.25 _testcapimodule.c,1.13,1.14 _tkinter.c,1.119,1.120 arraymodule.c,2.64,2.65 flmodule.c,1.45,1.46 gdbmmodule.c,2.30,2.31 pcremodule.c,2.28,2.29 posixmodule.c,2.209,2.210 pyexpat.c,2.55,2.56 readline.c,2.40,2.41 socketmodule.c,1.197,1.198 stropmodule.c,2.82,2.83
- Next message: [Python-checkins] CVS: python/dist/src/RISCOS/Python dynload_riscos.c,1.2,1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]