summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2002-04-02 18:17:57 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2002-04-02 18:17:57 (GMT)
commit187ae561667f82142edbe7beaa612381b6bb0827 (patch)
tree1d2e0fba61e51cbbddee5f7370c283ecbf137c3c
parent155db9aa222e96fcaf2db4d80b414098889a7c5d (diff)
downloadcpython-187ae561667f82142edbe7beaa612381b6bb0827.zip
cpython-187ae561667f82142edbe7beaa612381b6bb0827.tar.gz
cpython-187ae561667f82142edbe7beaa612381b6bb0827.tar.bz2
Get rid of more PyArg_Parse & METH_OLDARGS.
PyArg_Parse( "s" ) -> PyString_AsString PyArg_Parse( "t#" ) -> PyString_AsStringAndSize
-rw-r--r--Modules/stropmodule.c24
-rw-r--r--Modules/structmodule.c3
2 files changed, 14 insertions, 13 deletions
diff --git a/Modules/stropmodule.c b/Modules/stropmodule.c
index 9af9312..0d5b75c 100644
--- a/Modules/stropmodule.c
+++ b/Modules/stropmodule.c
@@ -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 */
};
diff --git a/Modules/structmodule.c b/Modules/structmodule.c
index df80302..bf871ee 100644
--- a/Modules/structmodule.c
+++ b/Modules/structmodule.c
@@ -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);