Use the t# format where appropriate. Greg Stein.
diff --git a/Modules/binascii.c b/Modules/binascii.c
index 295ff74..26e4b6c 100644
--- a/Modules/binascii.c
+++ b/Modules/binascii.c
@@ -213,7 +213,7 @@
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 @@
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 @@
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) */
diff --git a/Modules/mpzmodule.c b/Modules/mpzmodule.c
index 0400605..4299f45 100644
--- a/Modules/mpzmodule.c
+++ b/Modules/mpzmodule.c
@@ -969,12 +969,9 @@
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;
diff --git a/Modules/nismodule.c b/Modules/nismodule.c
index d99daeb..fcd64ff 100644
--- a/Modules/nismodule.c
+++ b/Modules/nismodule.c
@@ -106,7 +106,7 @@
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);
diff --git a/Modules/pcremodule.c b/Modules/pcremodule.c
index f8bde04..9819fdd 100644
--- a/Modules/pcremodule.c
+++ b/Modules/pcremodule.c
@@ -111,11 +111,11 @@
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
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index e6143e5..876522b 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -612,7 +612,7 @@
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 @@
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 @@
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");
diff --git a/Modules/regexmodule.c b/Modules/regexmodule.c
index 7a289d5..afc7722 100644
--- a/Modules/regexmodule.c
+++ b/Modules/regexmodule.c
@@ -121,7 +121,7 @@
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 @@
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 @@
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) {
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index e195389..9d672a6 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -472,7 +472,7 @@
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,
diff --git a/Modules/stdwinmodule.c b/Modules/stdwinmodule.c
index c24b3ef..a272047 100644
--- a/Modules/stdwinmodule.c
+++ b/Modules/stdwinmodule.c
@@ -546,7 +546,7 @@
{
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 @@
{
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 @@
{
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 @@
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 @@
{
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 @@
{
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);
diff --git a/Modules/stropmodule.c b/Modules/stropmodule.c
index 85cab10..3921d34 100644
--- a/Modules/stropmodule.c
+++ b/Modules/stropmodule.c
@@ -141,7 +141,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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;