Skip to content

Commit 7e48898

Browse files
committed
Use the t# format where appropriate. Greg Stein.
1 parent b317f8a commit 7e48898

9 files changed

Lines changed: 34 additions & 37 deletions

File tree

Modules/binascii.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ binascii_a2b_uu(self, args)
213213
PyObject *rv;
214214
int ascii_len, bin_len;
215215

216-
if ( !PyArg_ParseTuple(args, "s#", &ascii_data, &ascii_len) )
216+
if ( !PyArg_ParseTuple(args, "t#", &ascii_data, &ascii_len) )
217217
return NULL;
218218

219219
/* First byte: binary data length (in bytes) */
@@ -343,7 +343,7 @@ binascii_a2b_base64(self, args)
343343
PyObject *rv;
344344
int ascii_len, bin_len;
345345

346-
if ( !PyArg_ParseTuple(args, "s#", &ascii_data, &ascii_len) )
346+
if ( !PyArg_ParseTuple(args, "t#", &ascii_data, &ascii_len) )
347347
return NULL;
348348

349349
bin_len = ((ascii_len+3)/4)*3; /* Upper bound, corrected later */
@@ -457,7 +457,7 @@ binascii_a2b_hqx(self, args)
457457
int len;
458458
int done = 0;
459459

460-
if ( !PyArg_ParseTuple(args, "s#", &ascii_data, &len) )
460+
if ( !PyArg_ParseTuple(args, "t#", &ascii_data, &len) )
461461
return NULL;
462462

463463
/* Allocate a string that is too big (fixed later) */

Modules/mpzmodule.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -969,12 +969,9 @@ MPZ_mpz(self, args)
969969
mpz_clear(&mplongdigit);
970970
}
971971
else if (PyString_Check(objp)) {
972-
char *cp;
973-
int len;
972+
char *cp = PyString_AS_STRING(objp);
973+
int len = PyString_GET_SIZE(objp);
974974
MP_INT mplongdigit;
975-
976-
if (!PyArg_Parse(objp, "s#", &cp, &len))
977-
return NULL;
978975

979976
if ((mpzp = newmpzobject()) == NULL)
980977
return NULL;

Modules/nismodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ nis_match (self, args)
106106
int err;
107107
PyObject *res;
108108

109-
if (!PyArg_Parse(args, "(s#s)", &key, &keylen, &map))
109+
if (!PyArg_Parse(args, "(t#s)", &key, &keylen, &map))
110110
return NULL;
111111
if ((err = yp_get_default_domain(&domain)) != 0)
112112
return nis_error(err);

Modules/pcremodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ PyPcre_exec(self, args)
111111
int offsets[100*2];
112112
PyObject *list;
113113

114-
if (!PyArg_ParseTuple(args, "s#|iiii", &string, &stringlen, &pos, &endpos, &options))
114+
if (!PyArg_ParseTuple(args, "t#|iiii", &string, &stringlen, &pos, &endpos, &options))
115115
return NULL;
116116
if (endpos == -1) {endpos = stringlen;}
117117
count = pcre_exec(self->regex, self->regex_extra,
118-
(char *)string, endpos, pos, options,
118+
string, endpos, pos, options,
119119
offsets, sizeof(offsets)/sizeof(int) );
120120
/* If an error occurred during the match, and an exception was raised,
121121
just return NULL and leave the exception alone. The most likely

Modules/posixmodule.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ posix_listdir(self, args)
612612
WIN32_FIND_DATA FileData;
613613
char namebuf[MAX_PATH+5];
614614

615-
if (!PyArg_Parse(args, "s#", &name, &len))
615+
if (!PyArg_Parse(args, "t#", &name, &len))
616616
return NULL;
617617
if (len >= MAX_PATH) {
618618
PyErr_SetString(PyExc_ValueError, "path too long");
@@ -673,7 +673,7 @@ posix_listdir(self, args)
673673
char namebuf[MAX_PATH+5];
674674
struct _find_t ep;
675675

676-
if (!PyArg_Parse(args, "s#", &name, &len))
676+
if (!PyArg_Parse(args, "t#", &name, &len))
677677
return NULL;
678678
if (len >= MAX_PATH) {
679679
PyErr_SetString(PyExc_ValueError, "path too long");
@@ -738,7 +738,7 @@ posix_listdir(self, args)
738738
FILEFINDBUF3 ep;
739739
APIRET rc;
740740

741-
if (!PyArg_Parse(args, "s#", &name, &len))
741+
if (!PyArg_Parse(args, "t#", &name, &len))
742742
return NULL;
743743
if (len >= MAX_PATH) {
744744
PyErr_SetString(PyExc_ValueError, "path too long");

Modules/regexmodule.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ regobj_match(re, args)
121121

122122
if (!PyArg_ParseTuple(args, "O|i", &argstring, &offset))
123123
return NULL;
124-
if (!PyArg_Parse(argstring, "s#", &buffer, &size))
124+
if (!PyArg_Parse(argstring, "t#", &buffer, &size))
125125
return NULL;
126126

127127
if (offset < 0 || offset > size) {
@@ -160,7 +160,7 @@ regobj_search(re, args)
160160

161161
if (!PyArg_ParseTuple(args, "O|i", &argstring, &offset))
162162
return NULL;
163-
if (!PyArg_Parse(argstring, "s#", &buffer, &size))
163+
if (!PyArg_Parse(argstring, "t#", &buffer, &size))
164164
return NULL;
165165

166166
if (offset < 0 || offset > size) {
@@ -410,7 +410,7 @@ newregexobject(pattern, translate, givenpat, groupindex)
410410
char *pat;
411411
int size;
412412

413-
if (!PyArg_Parse(pattern, "s#", &pat, &size))
413+
if (!PyArg_Parse(pattern, "t#", &pat, &size))
414414
return NULL;
415415

416416
if (translate != NULL && PyString_Size(translate) != 256) {

Modules/socketmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ getsockaddrarg,PySocketSockObject *,s, PyObject *,args, struct sockaddr **,addr_
472472
char *path;
473473
int len;
474474
addr = (struct sockaddr_un* )&(s->sock_addr).un;
475-
if (!PyArg_Parse(args, "s#", &path, &len))
475+
if (!PyArg_Parse(args, "t#", &path, &len))
476476
return 0;
477477
if (len > sizeof addr->sun_path) {
478478
PyErr_SetString(PySocket_Error,

Modules/stdwinmodule.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ drawing_text(dp, args)
546546
{
547547
int h, v, size;
548548
char *text;
549-
if (!PyArg_Parse(args, "((ii)s#)", &h, &v, &text, &size))
549+
if (!PyArg_Parse(args, "((ii)t#)", &h, &v, &text, &size))
550550
return NULL;
551551
wdrawtext(h, v, text, size);
552552
Py_INCREF(Py_None);
@@ -582,7 +582,7 @@ drawing_textwidth(dp, args)
582582
{
583583
char *text;
584584
int size;
585-
if (!PyArg_Parse(args, "s#", &text, &size))
585+
if (!PyArg_Parse(args, "t#", &text, &size))
586586
return NULL;
587587
return PyInt_FromLong((long)wtextwidth(text, size));
588588
}
@@ -594,7 +594,7 @@ drawing_textbreak(dp, args)
594594
{
595595
char *text;
596596
int size, width;
597-
if (!PyArg_Parse(args, "(s#i)", &text, &size, &width))
597+
if (!PyArg_Parse(args, "(t#i)", &text, &size, &width))
598598
return NULL;
599599
return PyInt_FromLong((long)wtextbreak(text, size, width));
600600
}
@@ -1056,7 +1056,7 @@ text_settext(self, args)
10561056
char *text;
10571057
char *buf;
10581058
int size;
1059-
if (!PyArg_Parse(args, "s#", &text, &size))
1059+
if (!PyArg_Parse(args, "t#", &text, &size))
10601060
return NULL;
10611061
if ((buf = PyMem_NEW(char, size)) == NULL) {
10621062
return PyErr_NoMemory();
@@ -1809,7 +1809,7 @@ window_setselection(self, args)
18091809
{
18101810
int sel, size, ok;
18111811
char *text;
1812-
if (!PyArg_Parse(args, "(is#)", &sel, &text, &size))
1812+
if (!PyArg_Parse(args, "(it#)", &sel, &text, &size))
18131813
return NULL;
18141814
ok = wsetselection(self->w_win, sel, text, size);
18151815
return PyInt_FromLong(ok);
@@ -2320,7 +2320,7 @@ stdwin_setcutbuffer(self, args)
23202320
{
23212321
int i, size;
23222322
char *str;
2323-
if (!PyArg_Parse(args, "(is#)", &i, &str, &size))
2323+
if (!PyArg_Parse(args, "(it#)", &i, &str, &size))
23242324
return NULL;
23252325
wsetcutbuffer(i, str, size);
23262326
Py_INCREF(Py_None);

Modules/stropmodule.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ strop_splitfields(self, args)
141141
n = 0;
142142
splitcount = 0;
143143
maxsplit = 0;
144-
if (!PyArg_ParseTuple(args, "s#|z#i", &s, &len, &sub, &n, &maxsplit))
144+
if (!PyArg_ParseTuple(args, "t#|z#i", &s, &len, &sub, &n, &maxsplit))
145145
return NULL;
146146
if (sub == NULL)
147147
return split_whitespace(s, len, maxsplit);
@@ -211,7 +211,7 @@ strop_joinfields(self, args)
211211
char* p = NULL;
212212
intargfunc getitemfunc;
213213

214-
if (!PyArg_ParseTuple(args, "O|s#", &seq, &sep, &seplen))
214+
if (!PyArg_ParseTuple(args, "O|t#", &seq, &sep, &seplen))
215215
return NULL;
216216
if (sep == NULL) {
217217
sep = " ";
@@ -337,7 +337,7 @@ strop_find(self, args)
337337
char *s, *sub;
338338
int len, n, i = 0, last = INT_MAX;
339339

340-
if (!PyArg_ParseTuple(args, "s#s#|ii", &s, &len, &sub, &n, &i, &last))
340+
if (!PyArg_ParseTuple(args, "t#t#|ii", &s, &len, &sub, &n, &i, &last))
341341
return NULL;
342342

343343
if (last > len)
@@ -382,7 +382,7 @@ strop_rfind(self, args)
382382
int len, n, j;
383383
int i = 0, last = INT_MAX;
384384

385-
if (!PyArg_ParseTuple(args, "s#s#|ii", &s, &len, &sub, &n, &i, &last))
385+
if (!PyArg_ParseTuple(args, "t#t#|ii", &s, &len, &sub, &n, &i, &last))
386386
return NULL;
387387

388388
if (last > len)
@@ -417,7 +417,7 @@ do_strip(args, striptype)
417417
int len, i, j;
418418

419419

420-
if (!PyArg_Parse(args, "s#", &s, &len))
420+
if (!PyArg_Parse(args, "t#", &s, &len))
421421
return NULL;
422422

423423
i = 0;
@@ -502,7 +502,7 @@ strop_lower(self, args)
502502
PyObject *new;
503503
int changed;
504504

505-
if (!PyArg_Parse(args, "s#", &s, &n))
505+
if (!PyArg_Parse(args, "t#", &s, &n))
506506
return NULL;
507507
new = PyString_FromStringAndSize(NULL, n);
508508
if (new == NULL)
@@ -542,7 +542,7 @@ strop_upper(self, args)
542542
PyObject *new;
543543
int changed;
544544

545-
if (!PyArg_Parse(args, "s#", &s, &n))
545+
if (!PyArg_Parse(args, "t#", &s, &n))
546546
return NULL;
547547
new = PyString_FromStringAndSize(NULL, n);
548548
if (new == NULL)
@@ -583,7 +583,7 @@ strop_capitalize(self, args)
583583
PyObject *new;
584584
int changed;
585585

586-
if (!PyArg_Parse(args, "s#", &s, &n))
586+
if (!PyArg_Parse(args, "t#", &s, &n))
587587
return NULL;
588588
new = PyString_FromStringAndSize(NULL, n);
589589
if (new == NULL)
@@ -634,7 +634,7 @@ strop_count(self, args)
634634
int i = 0, last = INT_MAX;
635635
int m, r;
636636

637-
if (!PyArg_ParseTuple(args, "s#s#|ii", &s, &len, &sub, &n, &i, &last))
637+
if (!PyArg_ParseTuple(args, "t#t#|ii", &s, &len, &sub, &n, &i, &last))
638638
return NULL;
639639
if (last > len)
640640
last = len;
@@ -679,7 +679,7 @@ strop_swapcase(self, args)
679679
PyObject *new;
680680
int changed;
681681

682-
if (!PyArg_Parse(args, "s#", &s, &n))
682+
if (!PyArg_Parse(args, "t#", &s, &n))
683683
return NULL;
684684
new = PyString_FromStringAndSize(NULL, n);
685685
if (new == NULL)
@@ -877,7 +877,7 @@ strop_maketrans(self, args)
877877
int i, fromlen=0, tolen=0;
878878
PyObject *result;
879879

880-
if (!PyArg_ParseTuple(args, "s#s#", &from, &fromlen, &to, &tolen))
880+
if (!PyArg_ParseTuple(args, "t#t#", &from, &fromlen, &to, &tolen))
881881
return NULL;
882882

883883
if (fromlen != tolen) {
@@ -920,7 +920,7 @@ strop_translate(self, args)
920920
PyObject *result;
921921
int trans_table[256];
922922

923-
if (!PyArg_ParseTuple(args, "Ss#|s#", &input_obj,
923+
if (!PyArg_ParseTuple(args, "St#|t#", &input_obj,
924924
&table1, &tablen, &del_table, &dellen))
925925
return NULL;
926926
if (tablen != 256) {
@@ -1134,7 +1134,7 @@ strop_replace(self, args)
11341134
int count = 0;
11351135
PyObject *new;
11361136

1137-
if (!PyArg_ParseTuple(args, "s#s#s#|i",
1137+
if (!PyArg_ParseTuple(args, "t#t#t#|i",
11381138
&str, &len, &pat, &pat_len, &sub, &sub_len,
11391139
&count))
11401140
return NULL;

0 commit comments

Comments
 (0)