]> granicus.if.org Git - python/commitdiff
Get rid of more PyArg_Parse & METH_OLDARGS.
authorNeal Norwitz <nnorwitz@gmail.com>
Tue, 2 Apr 2002 18:17:57 +0000 (18:17 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Tue, 2 Apr 2002 18:17:57 +0000 (18:17 +0000)
  PyArg_Parse( "s" )  -> PyString_AsString
  PyArg_Parse( "t#" ) -> PyString_AsStringAndSize

Modules/stropmodule.c
Modules/structmodule.c

index 9af93129cccd08fad50cd585ea250e8ad43e6474..0d5b75c5102bcbcf49950d0d88eca667e666527e 100644 (file)
@@ -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 */
 };
 
index df80302d6d7306e50d47351d3a8fa694a9330041..bf871ee7f416610ea01fd38201445ea4973c279f 100644 (file)
@@ -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);