mirror of
https://github.com/python/cpython.git
synced 2024-11-28 12:31:14 +08:00
Get rid of more PyArg_Parse & METH_OLDARGS.
PyArg_Parse( "s" ) -> PyString_AsString PyArg_Parse( "t#" ) -> PyString_AsStringAndSize
This commit is contained in:
parent
155db9aa22
commit
187ae56166
@ -376,7 +376,7 @@ do_strip(PyObject *args, int striptype)
|
||||
int len, i, j;
|
||||
|
||||
|
||||
if (!PyArg_Parse(args, "t#", &s, &len))
|
||||
if (PyString_AsStringAndSize(args, &s, &len))
|
||||
return NULL;
|
||||
|
||||
i = 0;
|
||||
@ -457,7 +457,7 @@ strop_lower(PyObject *self, PyObject *args)
|
||||
int changed;
|
||||
|
||||
WARN;
|
||||
if (!PyArg_Parse(args, "t#", &s, &n))
|
||||
if (PyString_AsStringAndSize(args, &s, &n))
|
||||
return NULL;
|
||||
new = PyString_FromStringAndSize(NULL, n);
|
||||
if (new == NULL)
|
||||
@ -496,7 +496,7 @@ strop_upper(PyObject *self, PyObject *args)
|
||||
int changed;
|
||||
|
||||
WARN;
|
||||
if (!PyArg_Parse(args, "t#", &s, &n))
|
||||
if (PyString_AsStringAndSize(args, &s, &n))
|
||||
return NULL;
|
||||
new = PyString_FromStringAndSize(NULL, n);
|
||||
if (new == NULL)
|
||||
@ -536,7 +536,7 @@ strop_capitalize(PyObject *self, PyObject *args)
|
||||
int changed;
|
||||
|
||||
WARN;
|
||||
if (!PyArg_Parse(args, "t#", &s, &n))
|
||||
if (PyString_AsStringAndSize(args, &s, &n))
|
||||
return NULL;
|
||||
new = PyString_FromStringAndSize(NULL, n);
|
||||
if (new == NULL)
|
||||
@ -702,7 +702,7 @@ strop_swapcase(PyObject *self, PyObject *args)
|
||||
int changed;
|
||||
|
||||
WARN;
|
||||
if (!PyArg_Parse(args, "t#", &s, &n))
|
||||
if (PyString_AsStringAndSize(args, &s, &n))
|
||||
return NULL;
|
||||
new = PyString_FromStringAndSize(NULL, n);
|
||||
if (new == NULL)
|
||||
@ -1190,24 +1190,24 @@ strop_methods[] = {
|
||||
{"atof", strop_atof, METH_VARARGS, atof__doc__},
|
||||
{"atoi", strop_atoi, METH_VARARGS, atoi__doc__},
|
||||
{"atol", strop_atol, METH_VARARGS, atol__doc__},
|
||||
{"capitalize", strop_capitalize, METH_OLDARGS, capitalize__doc__},
|
||||
{"capitalize", strop_capitalize, METH_O, capitalize__doc__},
|
||||
{"count", strop_count, METH_VARARGS, count__doc__},
|
||||
{"expandtabs", strop_expandtabs, METH_VARARGS, expandtabs__doc__},
|
||||
{"find", strop_find, METH_VARARGS, find__doc__},
|
||||
{"join", strop_joinfields, METH_VARARGS, joinfields__doc__},
|
||||
{"joinfields", strop_joinfields, METH_VARARGS, joinfields__doc__},
|
||||
{"lstrip", strop_lstrip, METH_OLDARGS, lstrip__doc__},
|
||||
{"lower", strop_lower, METH_OLDARGS, lower__doc__},
|
||||
{"lstrip", strop_lstrip, METH_O, lstrip__doc__},
|
||||
{"lower", strop_lower, METH_O, lower__doc__},
|
||||
{"maketrans", strop_maketrans, METH_VARARGS, maketrans__doc__},
|
||||
{"replace", strop_replace, METH_VARARGS, replace__doc__},
|
||||
{"rfind", strop_rfind, METH_VARARGS, rfind__doc__},
|
||||
{"rstrip", strop_rstrip, METH_OLDARGS, rstrip__doc__},
|
||||
{"rstrip", strop_rstrip, METH_O, rstrip__doc__},
|
||||
{"split", strop_splitfields, METH_VARARGS, splitfields__doc__},
|
||||
{"splitfields", strop_splitfields, METH_VARARGS, splitfields__doc__},
|
||||
{"strip", strop_strip, METH_OLDARGS, strip__doc__},
|
||||
{"swapcase", strop_swapcase, METH_OLDARGS, swapcase__doc__},
|
||||
{"strip", strop_strip, METH_O, strip__doc__},
|
||||
{"swapcase", strop_swapcase, METH_O, swapcase__doc__},
|
||||
{"translate", strop_translate, METH_VARARGS, translate__doc__},
|
||||
{"upper", strop_upper, METH_OLDARGS, upper__doc__},
|
||||
{"upper", strop_upper, METH_O, upper__doc__},
|
||||
{NULL, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
|
@ -1273,7 +1273,8 @@ struct_pack(PyObject *self, PyObject *args)
|
||||
return NULL;
|
||||
}
|
||||
format = PyTuple_GetItem(args, 0);
|
||||
if (!PyArg_Parse(format, "s", &fmt))
|
||||
fmt = PyString_AsString(format);
|
||||
if (!fmt)
|
||||
return NULL;
|
||||
f = whichtable(&fmt);
|
||||
size = calcsize(fmt, f);
|
||||
|
Loading…
Reference in New Issue
Block a user