diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/stropmodule.c | 24 | ||||
-rw-r--r-- | Modules/structmodule.c | 3 |
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); |