blob: 891e90c31254520c66096297e31539820b4ecaed [file] [log] [blame]
Serhiy Storchaka1009bf12015-04-03 23:53:51 +03001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_STRVAR(unicode_maketrans__doc__,
6"maketrans(x, y=None, z=None, /)\n"
7"--\n"
8"\n"
9"Return a translation table usable for str.translate().\n"
10"\n"
11"If there is only one argument, it must be a dictionary mapping Unicode\n"
12"ordinals (integers) or characters to Unicode ordinals, strings or None.\n"
13"Character keys will be then converted to ordinals.\n"
14"If there are two arguments, they must be strings of equal length, and\n"
15"in the resulting dictionary, each character in x will be mapped to the\n"
16"character at the same position in y. If there is a third argument, it\n"
17"must be a string, whose characters will be mapped to None in the result.");
18
19#define UNICODE_MAKETRANS_METHODDEF \
20 {"maketrans", (PyCFunction)unicode_maketrans, METH_VARARGS|METH_STATIC, unicode_maketrans__doc__},
21
22static PyObject *
23unicode_maketrans_impl(PyObject *x, PyObject *y, PyObject *z);
24
25static PyObject *
26unicode_maketrans(void *null, PyObject *args)
27{
28 PyObject *return_value = NULL;
29 PyObject *x;
30 PyObject *y = NULL;
31 PyObject *z = NULL;
32
Serhiy Storchaka247789c2015-04-24 00:40:51 +030033 if (!PyArg_ParseTuple(args, "O|UU:maketrans",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030034 &x, &y, &z)) {
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030035 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030036 }
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030037 return_value = unicode_maketrans_impl(x, y, z);
38
39exit:
40 return return_value;
41}
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030042/*[clinic end generated code: output=4a86dd108d92d104 input=a9049054013a1b77]*/