summaryrefslogtreecommitdiff
path: root/Modules/_codecsmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_codecsmodule.c')
-rw-r--r--Modules/_codecsmodule.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/Modules/_codecsmodule.c b/Modules/_codecsmodule.c
index 52f34793c4..bf408afeca 100644
--- a/Modules/_codecsmodule.c
+++ b/Modules/_codecsmodule.c
@@ -95,13 +95,15 @@ a ValueError. Other possible values are 'ignore', 'replace' and\n\
codecs.register_error that can handle ValueErrors.");
static PyObject *
-codec_encode(PyObject *self, PyObject *args)
+codec_encode(PyObject *self, PyObject *args, PyObject *kwargs)
{
+ static char *kwlist[] = {"obj", "encoding", "errors", NULL};
const char *encoding = NULL;
const char *errors = NULL;
PyObject *v;
- if (!PyArg_ParseTuple(args, "O|ss:encode", &v, &encoding, &errors))
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|ss:encode", kwlist,
+ &v, &encoding, &errors))
return NULL;
if (encoding == NULL)
@@ -122,13 +124,15 @@ as well as any other name registered with codecs.register_error that is\n\
able to handle ValueErrors.");
static PyObject *
-codec_decode(PyObject *self, PyObject *args)
+codec_decode(PyObject *self, PyObject *args, PyObject *kwargs)
{
+ static char *kwlist[] = {"obj", "encoding", "errors", NULL};
const char *encoding = NULL;
const char *errors = NULL;
PyObject *v;
- if (!PyArg_ParseTuple(args, "O|ss:decode", &v, &encoding, &errors))
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|ss:decode", kwlist,
+ &v, &encoding, &errors))
return NULL;
if (encoding == NULL)
@@ -750,7 +754,7 @@ unicode_internal_encode(PyObject *self,
u = PyUnicode_AsUnicodeAndSize(obj, &len);
if (u == NULL)
return NULL;
- if (len > PY_SSIZE_T_MAX / sizeof(Py_UNICODE))
+ if ((size_t)len > (size_t)PY_SSIZE_T_MAX / sizeof(Py_UNICODE))
return PyErr_NoMemory();
size = len * sizeof(Py_UNICODE);
return codec_tuple(PyBytes_FromStringAndSize((const char*)u, size),
@@ -1179,9 +1183,9 @@ static PyMethodDef _codecs_functions[] = {
register__doc__},
{"lookup", codec_lookup, METH_VARARGS,
lookup__doc__},
- {"encode", codec_encode, METH_VARARGS,
+ {"encode", (PyCFunction)codec_encode, METH_VARARGS|METH_KEYWORDS,
encode__doc__},
- {"decode", codec_decode, METH_VARARGS,
+ {"decode", (PyCFunction)codec_decode, METH_VARARGS|METH_KEYWORDS,
decode__doc__},
{"escape_encode", escape_encode, METH_VARARGS},
{"escape_decode", escape_decode, METH_VARARGS},