summaryrefslogtreecommitdiffstats
path: root/Objects/bytesobject.c
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-04-12 15:51:51 (GMT)
committerGeorg Brandl <georg@python.org>2009-04-12 15:51:51 (GMT)
commitabc387747dc573e05a4b31387797a0272062b2ef (patch)
treec12c0a0e45cb06edb87798a7831b1c8f79033015 /Objects/bytesobject.c
parent78532baeabc4234e3894c775f2bb7e0a21c12e0e (diff)
downloadcpython-abc387747dc573e05a4b31387797a0272062b2ef.zip
cpython-abc387747dc573e05a4b31387797a0272062b2ef.tar.gz
cpython-abc387747dc573e05a4b31387797a0272062b2ef.tar.bz2
Add bytes/bytearray.maketrans() to mirror str.maketrans(), and deprecate
string.maketrans() which actually works on bytes. (Also closes #5675.)
Diffstat (limited to 'Objects/bytesobject.c')
-rw-r--r--Objects/bytesobject.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index d5c2bea..1239680 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -1950,6 +1950,12 @@ string_translate(PyBytesObject *self, PyObject *args)
}
+static PyObject *
+string_maketrans(PyObject *null, PyObject *args)
+{
+ return _Py_bytes_maketrans(args);
+}
+
#define FORWARD 1
#define REVERSE -1
@@ -2851,6 +2857,8 @@ string_methods[] = {
{"ljust", (PyCFunction)stringlib_ljust, METH_VARARGS, ljust__doc__},
{"lower", (PyCFunction)stringlib_lower, METH_NOARGS, _Py_lower__doc__},
{"lstrip", (PyCFunction)string_lstrip, METH_VARARGS, lstrip__doc__},
+ {"maketrans", (PyCFunction)string_maketrans, METH_VARARGS|METH_STATIC,
+ _Py_maketrans__doc__},
{"partition", (PyCFunction)string_partition, METH_O, partition__doc__},
{"replace", (PyCFunction)string_replace, METH_VARARGS, replace__doc__},
{"rfind", (PyCFunction)string_rfind, METH_VARARGS, rfind__doc__},