Use the t# format where appropriate. Greg Stein. · pythoncapi/cpython@7e48898 · GitHub
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

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

0 commit comments

Comments
 (0)