]> granicus.if.org Git - python/commitdiff
Use the t# format where appropriate. Greg Stein.
authorGuido van Rossum <guido@python.org>
Thu, 8 Oct 1998 02:25:24 +0000 (02:25 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 8 Oct 1998 02:25:24 +0000 (02:25 +0000)
Modules/binascii.c
Modules/mpzmodule.c
Modules/nismodule.c
Modules/pcremodule.c
Modules/posixmodule.c
Modules/regexmodule.c
Modules/socketmodule.c
Modules/stdwinmodule.c
Modules/stropmodule.c

index 295ff74b1b8df2f8ed37b98287532217b98356c4..26e4b6c755116a3b9eee42d49924f290449c24d0 100644 (file)
@@ -213,7 +213,7 @@ binascii_a2b_uu(self, args)
        PyObject *rv;
        int ascii_len, bin_len;
        
-       if ( !PyArg_ParseTuple(args, "s#", &ascii_data, &ascii_len) )
+       if ( !PyArg_ParseTuple(args, "t#", &ascii_data, &ascii_len) )
                return NULL;
 
        /* First byte: binary data length (in bytes) */
@@ -343,7 +343,7 @@ binascii_a2b_base64(self, args)
        PyObject *rv;
        int ascii_len, bin_len;
        
-       if ( !PyArg_ParseTuple(args, "s#", &ascii_data, &ascii_len) )
+       if ( !PyArg_ParseTuple(args, "t#", &ascii_data, &ascii_len) )
                return NULL;
 
        bin_len = ((ascii_len+3)/4)*3; /* Upper bound, corrected later */
@@ -457,7 +457,7 @@ binascii_a2b_hqx(self, args)
        int len;
        int done = 0;
        
-       if ( !PyArg_ParseTuple(args, "s#", &ascii_data, &len) )
+       if ( !PyArg_ParseTuple(args, "t#", &ascii_data, &len) )
                return NULL;
 
        /* Allocate a string that is too big (fixed later) */
index 0400605ed662da56702f1cb49d01123260153f29..4299f454b71c97c80d231237e6328b2f0810e110 100644 (file)
@@ -969,12 +969,9 @@ MPZ_mpz(self, args)
                mpz_clear(&mplongdigit);
        }
        else if (PyString_Check(objp)) {
-               char *cp;
-               int len;
+               char *cp = PyString_AS_STRING(objp);
+               int len = PyString_GET_SIZE(objp);
                MP_INT mplongdigit;
-               
-               if (!PyArg_Parse(objp, "s#", &cp, &len))
-                       return NULL;
 
                if ((mpzp = newmpzobject()) == NULL)
                        return NULL;
index d99daeb0d42cd1fa8f30d3c4befa217f276ec560..fcd64ffe318c42baf6d82e7acbaab4960499f2f7 100644 (file)
@@ -106,7 +106,7 @@ nis_match (self, args)
        int err;
        PyObject *res;
 
-       if (!PyArg_Parse(args, "(s#s)", &key, &keylen, &map))
+       if (!PyArg_Parse(args, "(t#s)", &key, &keylen, &map))
                return NULL;
        if ((err = yp_get_default_domain(&domain)) != 0)
                return nis_error(err);
index f8bde043604ab9f34f16273bd093203073d0ac14..9819fdde15f32068c4b29d2c71fdde691ad04056 100644 (file)
@@ -111,11 +111,11 @@ PyPcre_exec(self, args)
        int offsets[100*2]; 
        PyObject *list;
 
-       if (!PyArg_ParseTuple(args, "s#|iiii", &string, &stringlen, &pos, &endpos, &options))
+       if (!PyArg_ParseTuple(args, "t#|iiii", &string, &stringlen, &pos, &endpos, &options))
                return NULL;
        if (endpos == -1) {endpos = stringlen;}
        count = pcre_exec(self->regex, self->regex_extra, 
-                         (char *)string, endpos, pos, options,
+                         string, endpos, pos, options,
                          offsets, sizeof(offsets)/sizeof(int) );
        /* If an error occurred during the match, and an exception was raised,
           just return NULL and leave the exception alone.  The most likely
index e6143e5f9a700294b91137036a6ab26b9292d691..876522b93ad0c097aa1ddc2c442401ee3ae624c6 100644 (file)
@@ -612,7 +612,7 @@ posix_listdir(self, args)
        WIN32_FIND_DATA FileData;
        char namebuf[MAX_PATH+5];
 
-       if (!PyArg_Parse(args, "s#", &name, &len))
+       if (!PyArg_Parse(args, "t#", &name, &len))
                return NULL;
        if (len >= MAX_PATH) {
                PyErr_SetString(PyExc_ValueError, "path too long");
@@ -673,7 +673,7 @@ posix_listdir(self, args)
        char namebuf[MAX_PATH+5];
        struct _find_t ep;
 
-       if (!PyArg_Parse(args, "s#", &name, &len))
+       if (!PyArg_Parse(args, "t#", &name, &len))
                return NULL;
        if (len >= MAX_PATH) {
                PyErr_SetString(PyExc_ValueError, "path too long");
@@ -738,7 +738,7 @@ posix_listdir(self, args)
     FILEFINDBUF3   ep;
     APIRET rc;
 
-       if (!PyArg_Parse(args, "s#", &name, &len))
+       if (!PyArg_Parse(args, "t#", &name, &len))
         return NULL;
     if (len >= MAX_PATH) {
                PyErr_SetString(PyExc_ValueError, "path too long");
index 7a289d5c4ecd05841e68d1b125312eaccd341b15..afc772264d5336323f3ddf80e93c7a492cd3cffb 100644 (file)
@@ -121,7 +121,7 @@ regobj_match(re, args)
 
        if (!PyArg_ParseTuple(args, "O|i", &argstring, &offset))
                return NULL;
-       if (!PyArg_Parse(argstring, "s#", &buffer, &size))
+       if (!PyArg_Parse(argstring, "t#", &buffer, &size))
                return NULL;
 
        if (offset < 0 || offset > size) {
@@ -160,7 +160,7 @@ regobj_search(re, args)
        
        if (!PyArg_ParseTuple(args, "O|i", &argstring, &offset))
                return NULL;
-       if (!PyArg_Parse(argstring, "s#", &buffer, &size))
+       if (!PyArg_Parse(argstring, "t#", &buffer, &size))
                return NULL;
 
        if (offset < 0 || offset > size) {
@@ -410,7 +410,7 @@ newregexobject(pattern, translate, givenpat, groupindex)
        char *pat;
        int size;
 
-       if (!PyArg_Parse(pattern, "s#", &pat, &size))
+       if (!PyArg_Parse(pattern, "t#", &pat, &size))
                return NULL;
        
        if (translate != NULL && PyString_Size(translate) != 256) {
index e195389041761505da4b26909a5b49740cd082f2..9d672a64a6cccacf964c2a6b7ac7d4d259c99fcd 100644 (file)
@@ -472,7 +472,7 @@ getsockaddrarg,PySocketSockObject *,s, PyObject *,args, struct sockaddr **,addr_
                char *path;
                int len;
                addr = (struct sockaddr_un* )&(s->sock_addr).un;
-               if (!PyArg_Parse(args, "s#", &path, &len))
+               if (!PyArg_Parse(args, "t#", &path, &len))
                        return 0;
                if (len > sizeof addr->sun_path) {
                        PyErr_SetString(PySocket_Error,
index c24b3ef64d27c70b15c64ca72cb568b8b4021922..a27204744304eeb1b90923168d0244b7e5de0d01 100644 (file)
@@ -546,7 +546,7 @@ drawing_text(dp, args)
 {
        int h, v, size;
        char *text;
-       if (!PyArg_Parse(args, "((ii)s#)", &h, &v, &text, &size))
+       if (!PyArg_Parse(args, "((ii)t#)", &h, &v, &text, &size))
                return NULL;
        wdrawtext(h, v, text, size);
        Py_INCREF(Py_None);
@@ -582,7 +582,7 @@ drawing_textwidth(dp, args)
 {
        char *text;
        int size;
-       if (!PyArg_Parse(args, "s#", &text, &size))
+       if (!PyArg_Parse(args, "t#", &text, &size))
                return NULL;
        return PyInt_FromLong((long)wtextwidth(text, size));
 }
@@ -594,7 +594,7 @@ drawing_textbreak(dp, args)
 {
        char *text;
        int size, width;
-       if (!PyArg_Parse(args, "(s#i)", &text, &size, &width))
+       if (!PyArg_Parse(args, "(t#i)", &text, &size, &width))
                return NULL;
        return PyInt_FromLong((long)wtextbreak(text, size, width));
 }
@@ -1056,7 +1056,7 @@ text_settext(self, args)
        char *text;
        char *buf;
        int size;
-       if (!PyArg_Parse(args, "s#", &text, &size))
+       if (!PyArg_Parse(args, "t#", &text, &size))
                return NULL;
        if ((buf = PyMem_NEW(char, size)) == NULL) {
                return PyErr_NoMemory();
@@ -1809,7 +1809,7 @@ window_setselection(self, args)
 {
        int sel, size, ok;
        char *text;
-       if (!PyArg_Parse(args, "(is#)", &sel, &text, &size))
+       if (!PyArg_Parse(args, "(it#)", &sel, &text, &size))
                return NULL;
        ok = wsetselection(self->w_win, sel, text, size);
        return PyInt_FromLong(ok);
@@ -2320,7 +2320,7 @@ stdwin_setcutbuffer(self, args)
 {
        int i, size;
        char *str;
-       if (!PyArg_Parse(args, "(is#)", &i, &str, &size))
+       if (!PyArg_Parse(args, "(it#)", &i, &str, &size))
                return NULL;
        wsetcutbuffer(i, str, size);
        Py_INCREF(Py_None);
index 85cab10267862867ca5899318e5a25ffb506e9ed..3921d3460eb26147e6174bf705edcba91aec2df8 100644 (file)
@@ -141,7 +141,7 @@ strop_splitfields(self, args)
        n = 0;
        splitcount = 0;
        maxsplit = 0;
-       if (!PyArg_ParseTuple(args, "s#|z#i", &s, &len, &sub, &n, &maxsplit))
+       if (!PyArg_ParseTuple(args, "t#|z#i", &s, &len, &sub, &n, &maxsplit))
                return NULL;
        if (sub == NULL)
                return split_whitespace(s, len, maxsplit);
@@ -211,7 +211,7 @@ strop_joinfields(self, args)
        char* p = NULL;
        intargfunc getitemfunc;
 
-       if (!PyArg_ParseTuple(args, "O|s#", &seq, &sep, &seplen))
+       if (!PyArg_ParseTuple(args, "O|t#", &seq, &sep, &seplen))
                return NULL;
        if (sep == NULL) {
                sep = " ";
@@ -337,7 +337,7 @@ strop_find(self, args)
        char *s, *sub;
        int len, n, i = 0, last = INT_MAX;
 
-       if (!PyArg_ParseTuple(args, "s#s#|ii", &s, &len, &sub, &n, &i, &last))
+       if (!PyArg_ParseTuple(args, "t#t#|ii", &s, &len, &sub, &n, &i, &last))
                return NULL;
 
        if (last > len)
@@ -382,7 +382,7 @@ strop_rfind(self, args)
        int len, n, j;
        int i = 0, last = INT_MAX;
 
-       if (!PyArg_ParseTuple(args, "s#s#|ii", &s, &len, &sub, &n, &i, &last))
+       if (!PyArg_ParseTuple(args, "t#t#|ii", &s, &len, &sub, &n, &i, &last))
                return NULL;
 
        if (last > len)
@@ -417,7 +417,7 @@ do_strip(args, striptype)
        int len, i, j;
 
 
-       if (!PyArg_Parse(args, "s#", &s, &len))
+       if (!PyArg_Parse(args, "t#", &s, &len))
                return NULL;
 
        i = 0;
@@ -502,7 +502,7 @@ strop_lower(self, args)
        PyObject *new;
        int changed;
 
-       if (!PyArg_Parse(args, "s#", &s, &n))
+       if (!PyArg_Parse(args, "t#", &s, &n))
                return NULL;
        new = PyString_FromStringAndSize(NULL, n);
        if (new == NULL)
@@ -542,7 +542,7 @@ strop_upper(self, args)
        PyObject *new;
        int changed;
 
-       if (!PyArg_Parse(args, "s#", &s, &n))
+       if (!PyArg_Parse(args, "t#", &s, &n))
                return NULL;
        new = PyString_FromStringAndSize(NULL, n);
        if (new == NULL)
@@ -583,7 +583,7 @@ strop_capitalize(self, args)
        PyObject *new;
        int changed;
 
-       if (!PyArg_Parse(args, "s#", &s, &n))
+       if (!PyArg_Parse(args, "t#", &s, &n))
                return NULL;
        new = PyString_FromStringAndSize(NULL, n);
        if (new == NULL)
@@ -634,7 +634,7 @@ strop_count(self, args)
        int i = 0, last = INT_MAX;
        int m, r;
 
-       if (!PyArg_ParseTuple(args, "s#s#|ii", &s, &len, &sub, &n, &i, &last))
+       if (!PyArg_ParseTuple(args, "t#t#|ii", &s, &len, &sub, &n, &i, &last))
                return NULL;
        if (last > len)
                last = len;
@@ -679,7 +679,7 @@ strop_swapcase(self, args)
        PyObject *new;
        int changed;
 
-       if (!PyArg_Parse(args, "s#", &s, &n))
+       if (!PyArg_Parse(args, "t#", &s, &n))
                return NULL;
        new = PyString_FromStringAndSize(NULL, n);
        if (new == NULL)
@@ -877,7 +877,7 @@ strop_maketrans(self, args)
        int i, fromlen=0, tolen=0;
        PyObject *result;
 
-       if (!PyArg_ParseTuple(args, "s#s#", &from, &fromlen, &to, &tolen))
+       if (!PyArg_ParseTuple(args, "t#t#", &from, &fromlen, &to, &tolen))
                return NULL;
 
        if (fromlen != tolen) {
@@ -920,7 +920,7 @@ strop_translate(self, args)
        PyObject *result;
        int trans_table[256];
 
-       if (!PyArg_ParseTuple(args, "Ss#|s#", &input_obj,
+       if (!PyArg_ParseTuple(args, "St#|t#", &input_obj,
                              &table1, &tablen, &del_table, &dellen))
                return NULL;
        if (tablen != 256) {
@@ -1134,7 +1134,7 @@ strop_replace(self, args)
        int count = 0;
        PyObject *new;
 
-       if (!PyArg_ParseTuple(args, "s#s#s#|i",
+       if (!PyArg_ParseTuple(args, "t#t#t#|i",
                              &str, &len, &pat, &pat_len, &sub, &sub_len,
                              &count))
                return NULL;