diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-10-11 09:01:02 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-10-11 09:01:02 (GMT) |
commit | e84c97656899750a8e6b01bef2cfc01b31d60220 (patch) | |
tree | df461163e3ade56701a5844d1b1b47e29c887f9f /Modules/clinic | |
parent | 5df7fddc0c678f10ae6f9995c516dd7091fd6cbc (diff) | |
download | cpython-e84c97656899750a8e6b01bef2cfc01b31d60220.zip cpython-e84c97656899750a8e6b01bef2cfc01b31d60220.tar.gz cpython-e84c97656899750a8e6b01bef2cfc01b31d60220.tar.bz2 |
Issue #25357: Add an optional newline paramer to binascii.b2a_base64().
base64.b64encode() uses it to avoid a memory copy.
Diffstat (limited to 'Modules/clinic')
-rw-r--r-- | Modules/clinic/binascii.c.h | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/Modules/clinic/binascii.c.h b/Modules/clinic/binascii.c.h index e348bee..46cfb8e 100644 --- a/Modules/clinic/binascii.c.h +++ b/Modules/clinic/binascii.c.h @@ -93,26 +93,29 @@ exit: } PyDoc_STRVAR(binascii_b2a_base64__doc__, -"b2a_base64($module, data, /)\n" +"b2a_base64($module, /, data, *, newline=True)\n" "--\n" "\n" "Base64-code line of data."); #define BINASCII_B2A_BASE64_METHODDEF \ - {"b2a_base64", (PyCFunction)binascii_b2a_base64, METH_O, binascii_b2a_base64__doc__}, + {"b2a_base64", (PyCFunction)binascii_b2a_base64, METH_VARARGS|METH_KEYWORDS, binascii_b2a_base64__doc__}, static PyObject * -binascii_b2a_base64_impl(PyModuleDef *module, Py_buffer *data); +binascii_b2a_base64_impl(PyModuleDef *module, Py_buffer *data, int newline); static PyObject * -binascii_b2a_base64(PyModuleDef *module, PyObject *arg) +binascii_b2a_base64(PyModuleDef *module, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; + static char *_keywords[] = {"data", "newline", NULL}; Py_buffer data = {NULL, NULL}; + int newline = 1; - if (!PyArg_Parse(arg, "y*:b2a_base64", &data)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "y*|$i:b2a_base64", _keywords, + &data, &newline)) goto exit; - return_value = binascii_b2a_base64_impl(module, &data); + return_value = binascii_b2a_base64_impl(module, &data, newline); exit: /* Cleanup for data */ @@ -516,4 +519,4 @@ exit: return return_value; } -/*[clinic end generated code: output=b1a3cbf7660ebaa5 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b15a24350d105251 input=a9049054013a1b77]*/ |