mirror of
https://github.com/python/cpython.git
synced 2025-12-15 21:44:50 +00:00
#17806: Added keyword-argument support for "tabsize" to str/bytes.expandtabs().
This commit is contained in:
parent
b41c2547e0
commit
745d54d2fa
8 changed files with 51 additions and 23 deletions
|
|
@ -5,21 +5,23 @@
|
|||
shared code in bytes_methods.c to cut down on duplicate code bloat. */
|
||||
|
||||
PyDoc_STRVAR(expandtabs__doc__,
|
||||
"B.expandtabs([tabsize]) -> copy of B\n\
|
||||
"B.expandtabs(tabsize=8) -> copy of B\n\
|
||||
\n\
|
||||
Return a copy of B where all tab characters are expanded using spaces.\n\
|
||||
If tabsize is not given, a tab size of 8 characters is assumed.");
|
||||
|
||||
static PyObject*
|
||||
stringlib_expandtabs(PyObject *self, PyObject *args)
|
||||
stringlib_expandtabs(PyObject *self, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
const char *e, *p;
|
||||
char *q;
|
||||
size_t i, j;
|
||||
PyObject *u;
|
||||
static char *kwlist[] = {"tabsize", 0};
|
||||
int tabsize = 8;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|i:expandtabs", &tabsize))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|i:expandtabs",
|
||||
kwlist, &tabsize))
|
||||
return NULL;
|
||||
|
||||
/* First pass: determine size of output string */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue