summaryrefslogtreecommitdiffstats
path: root/Objects/bytesobject.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-04-03 20:53:51 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-04-03 20:53:51 (GMT)
commit1009bf18b38a8d36298575191dd8fdf43f8f9097 (patch)
tree18860fdef30c931dc2ea177059e96b69a49fa04f /Objects/bytesobject.c
parent0759f84d6260bad1234b802212e73fdc5873d261 (diff)
downloadcpython-1009bf18b38a8d36298575191dd8fdf43f8f9097.zip
cpython-1009bf18b38a8d36298575191dd8fdf43f8f9097.tar.gz
cpython-1009bf18b38a8d36298575191dd8fdf43f8f9097.tar.bz2
Issue #23501: Argumen Clinic now generates code into separate files by default.
Diffstat (limited to 'Objects/bytesobject.c')
-rw-r--r--Objects/bytesobject.c522
1 files changed, 16 insertions, 506 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index 27d6472..b6089dd 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -12,6 +12,8 @@ class bytes "PyBytesObject*" "&PyBytes_Type"
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=1a1d9102afc1b00c]*/
+#include "clinic/bytesobject.c.h"
+
#ifdef COUNT_ALLOCS
Py_ssize_t null_strings, one_strings;
#endif
@@ -1614,47 +1616,9 @@ bytes.split
Return a list of the sections in the bytes, using sep as the delimiter.
[clinic start generated code]*/
-PyDoc_STRVAR(bytes_split__doc__,
-"split($self, /, sep=None, maxsplit=-1)\n"
-"--\n"
-"\n"
-"Return a list of the sections in the bytes, using sep as the delimiter.\n"
-"\n"
-" sep\n"
-" The delimiter according which to split the bytes.\n"
-" None (the default value) means split on ASCII whitespace characters\n"
-" (space, tab, return, newline, formfeed, vertical tab).\n"
-" maxsplit\n"
-" Maximum number of splits to do.\n"
-" -1 (the default value) means no limit.");
-
-#define BYTES_SPLIT_METHODDEF \
- {"split", (PyCFunction)bytes_split, METH_VARARGS|METH_KEYWORDS, bytes_split__doc__},
-
-static PyObject *
-bytes_split_impl(PyBytesObject*self, PyObject *sep, Py_ssize_t maxsplit);
-
-static PyObject *
-bytes_split(PyBytesObject*self, PyObject *args, PyObject *kwargs)
-{
- PyObject *return_value = NULL;
- static char *_keywords[] = {"sep", "maxsplit", NULL};
- PyObject *sep = Py_None;
- Py_ssize_t maxsplit = -1;
-
- if (!PyArg_ParseTupleAndKeywords(args, kwargs,
- "|On:split", _keywords,
- &sep, &maxsplit))
- goto exit;
- return_value = bytes_split_impl(self, sep, maxsplit);
-
-exit:
- return return_value;
-}
-
static PyObject *
bytes_split_impl(PyBytesObject*self, PyObject *sep, Py_ssize_t maxsplit)
-/*[clinic end generated code: output=c80a47afdd505975 input=8b809b39074abbfa]*/
+/*[clinic end generated code: output=8bde44dacb36ef2e input=8b809b39074abbfa]*/
{
Py_ssize_t len = PyBytes_GET_SIZE(self), n;
const char *s = PyBytes_AS_STRING(self), *sub;
@@ -1692,48 +1656,9 @@ If the separator is not found, returns a 3-tuple containing the original bytes
object and two empty bytes objects.
[clinic start generated code]*/
-PyDoc_STRVAR(bytes_partition__doc__,
-"partition($self, sep, /)\n"
-"--\n"
-"\n"
-"Partition the bytes into three parts using the given separator.\n"
-"\n"
-"This will search for the separator sep in the bytes. If the separator is found,\n"
-"returns a 3-tuple containing the part before the separator, the separator\n"
-"itself, and the part after it.\n"
-"\n"
-"If the separator is not found, returns a 3-tuple containing the original bytes\n"
-"object and two empty bytes objects.");
-
-#define BYTES_PARTITION_METHODDEF \
- {"partition", (PyCFunction)bytes_partition, METH_VARARGS, bytes_partition__doc__},
-
-static PyObject *
-bytes_partition_impl(PyBytesObject *self, Py_buffer *sep);
-
-static PyObject *
-bytes_partition(PyBytesObject *self, PyObject *args)
-{
- PyObject *return_value = NULL;
- Py_buffer sep = {NULL, NULL};
-
- if (!PyArg_ParseTuple(args,
- "y*:partition",
- &sep))
- goto exit;
- return_value = bytes_partition_impl(self, &sep);
-
-exit:
- /* Cleanup for sep */
- if (sep.obj)
- PyBuffer_Release(&sep);
-
- return return_value;
-}
-
static PyObject *
bytes_partition_impl(PyBytesObject *self, Py_buffer *sep)
-/*[clinic end generated code: output=3006727cfbf83aa4 input=bc855dc63ca949de]*/
+/*[clinic end generated code: output=f532b392a17ff695 input=bc855dc63ca949de]*/
{
return stringlib_partition(
(PyObject*) self,
@@ -1759,48 +1684,9 @@ If the separator is not found, returns a 3-tuple containing two empty bytes
objects and the original bytes object.
[clinic start generated code]*/
-PyDoc_STRVAR(bytes_rpartition__doc__,
-"rpartition($self, sep, /)\n"
-"--\n"
-"\n"
-"Partition the bytes into three parts using the given separator.\n"
-"\n"
-"This will search for the separator sep in the bytes, starting and the end. If\n"
-"the separator is found, returns a 3-tuple containing the part before the\n"
-"separator, the separator itself, and the part after it.\n"
-"\n"
-"If the separator is not found, returns a 3-tuple containing two empty bytes\n"
-"objects and the original bytes object.");
-
-#define BYTES_RPARTITION_METHODDEF \
- {"rpartition", (PyCFunction)bytes_rpartition, METH_VARARGS, bytes_rpartition__doc__},
-
-static PyObject *
-bytes_rpartition_impl(PyBytesObject *self, Py_buffer *sep);
-
-static PyObject *
-bytes_rpartition(PyBytesObject *self, PyObject *args)
-{
- PyObject *return_value = NULL;
- Py_buffer sep = {NULL, NULL};
-
- if (!PyArg_ParseTuple(args,
- "y*:rpartition",
- &sep))
- goto exit;
- return_value = bytes_rpartition_impl(self, &sep);
-
-exit:
- /* Cleanup for sep */
- if (sep.obj)
- PyBuffer_Release(&sep);
-
- return return_value;
-}
-
static PyObject *
bytes_rpartition_impl(PyBytesObject *self, Py_buffer *sep)
-/*[clinic end generated code: output=57b169dc47fa90e8 input=6588fff262a9170e]*/
+/*[clinic end generated code: output=191b114cbb028e50 input=6588fff262a9170e]*/
{
return stringlib_rpartition(
(PyObject*) self,
@@ -1817,49 +1703,9 @@ Return a list of the sections in the bytes, using sep as the delimiter.
Splitting is done starting at the end of the bytes and working to the front.
[clinic start generated code]*/
-PyDoc_STRVAR(bytes_rsplit__doc__,
-"rsplit($self, /, sep=None, maxsplit=-1)\n"
-"--\n"
-"\n"
-"Return a list of the sections in the bytes, using sep as the delimiter.\n"
-"\n"
-" sep\n"
-" The delimiter according which to split the bytes.\n"
-" None (the default value) means split on ASCII whitespace characters\n"
-" (space, tab, return, newline, formfeed, vertical tab).\n"
-" maxsplit\n"
-" Maximum number of splits to do.\n"
-" -1 (the default value) means no limit.\n"
-"\n"
-"Splitting is done starting at the end of the bytes and working to the front.");
-
-#define BYTES_RSPLIT_METHODDEF \
- {"rsplit", (PyCFunction)bytes_rsplit, METH_VARARGS|METH_KEYWORDS, bytes_rsplit__doc__},
-
-static PyObject *
-bytes_rsplit_impl(PyBytesObject*self, PyObject *sep, Py_ssize_t maxsplit);
-
-static PyObject *
-bytes_rsplit(PyBytesObject*self, PyObject *args, PyObject *kwargs)
-{
- PyObject *return_value = NULL;
- static char *_keywords[] = {"sep", "maxsplit", NULL};
- PyObject *sep = Py_None;
- Py_ssize_t maxsplit = -1;
-
- if (!PyArg_ParseTupleAndKeywords(args, kwargs,
- "|On:rsplit", _keywords,
- &sep, &maxsplit))
- goto exit;
- return_value = bytes_rsplit_impl(self, sep, maxsplit);
-
-exit:
- return return_value;
-}
-
static PyObject *
bytes_rsplit_impl(PyBytesObject*self, PyObject *sep, Py_ssize_t maxsplit)
-/*[clinic end generated code: output=f86feddedbd7b26d input=0f86c9f28f7d7b7b]*/
+/*[clinic end generated code: output=0b6570b977911d88 input=0f86c9f28f7d7b7b]*/
{
Py_ssize_t len = PyBytes_GET_SIZE(self), n;
const char *s = PyBytes_AS_STRING(self), *sub;
@@ -1896,24 +1742,9 @@ The result is returned as a new bytes object.
Example: b'.'.join([b'ab', b'pq', b'rs']) -> b'ab.pq.rs'.
[clinic start generated code]*/
-PyDoc_STRVAR(bytes_join__doc__,
-"join($self, iterable_of_bytes, /)\n"
-"--\n"
-"\n"
-"Concatenate any number of bytes objects.\n"
-"\n"
-"The bytes whose method is called is inserted in between each pair.\n"
-"\n"
-"The result is returned as a new bytes object.\n"
-"\n"
-"Example: b\'.\'.join([b\'ab\', b\'pq\', b\'rs\']) -> b\'ab.pq.rs\'.");
-
-#define BYTES_JOIN_METHODDEF \
- {"join", (PyCFunction)bytes_join, METH_O, bytes_join__doc__},
-
static PyObject *
bytes_join(PyBytesObject*self, PyObject *iterable_of_bytes)
-/*[clinic end generated code: output=e541a14a8da97908 input=7fe377b95bd549d2]*/
+/*[clinic end generated code: output=634aff14764ff997 input=7fe377b95bd549d2]*/
{
return stringlib_bytes_join((PyObject*)self, iterable_of_bytes);
}
@@ -2170,39 +2001,9 @@ Strip leading and trailing bytes contained in the argument.
If the argument is omitted or None, strip leading and trailing ASCII whitespace.
[clinic start generated code]*/
-PyDoc_STRVAR(bytes_strip__doc__,
-"strip($self, bytes=None, /)\n"
-"--\n"
-"\n"
-"Strip leading and trailing bytes contained in the argument.\n"
-"\n"
-"If the argument is omitted or None, strip leading and trailing ASCII whitespace.");
-
-#define BYTES_STRIP_METHODDEF \
- {"strip", (PyCFunction)bytes_strip, METH_VARARGS, bytes_strip__doc__},
-
-static PyObject *
-bytes_strip_impl(PyBytesObject *self, PyObject *bytes);
-
-static PyObject *
-bytes_strip(PyBytesObject *self, PyObject *args)
-{
- PyObject *return_value = NULL;
- PyObject *bytes = Py_None;
-
- if (!PyArg_UnpackTuple(args, "strip",
- 0, 1,
- &bytes))
- goto exit;
- return_value = bytes_strip_impl(self, bytes);
-
-exit:
- return return_value;
-}
-
static PyObject *
bytes_strip_impl(PyBytesObject *self, PyObject *bytes)
-/*[clinic end generated code: output=c8234a599ba5ec35 input=37daa5fad1395d95]*/
+/*[clinic end generated code: output=c7c228d3bd104a1b input=37daa5fad1395d95]*/
{
return do_argstrip(self, BOTHSTRIP, bytes);
}
@@ -2219,39 +2020,9 @@ Strip leading bytes contained in the argument.
If the argument is omitted or None, strip leading ASCII whitespace.
[clinic start generated code]*/
-PyDoc_STRVAR(bytes_lstrip__doc__,
-"lstrip($self, bytes=None, /)\n"
-"--\n"
-"\n"
-"Strip leading bytes contained in the argument.\n"
-"\n"
-"If the argument is omitted or None, strip leading ASCII whitespace.");
-
-#define BYTES_LSTRIP_METHODDEF \
- {"lstrip", (PyCFunction)bytes_lstrip, METH_VARARGS, bytes_lstrip__doc__},
-
-static PyObject *
-bytes_lstrip_impl(PyBytesObject *self, PyObject *bytes);
-
-static PyObject *
-bytes_lstrip(PyBytesObject *self, PyObject *args)
-{
- PyObject *return_value = NULL;
- PyObject *bytes = Py_None;
-
- if (!PyArg_UnpackTuple(args, "lstrip",
- 0, 1,
- &bytes))
- goto exit;
- return_value = bytes_lstrip_impl(self, bytes);
-
-exit:
- return return_value;
-}
-
static PyObject *
bytes_lstrip_impl(PyBytesObject *self, PyObject *bytes)
-/*[clinic end generated code: output=529e8511ab6f1115 input=88811b09dfbc2988]*/
+/*[clinic end generated code: output=28602e586f524e82 input=88811b09dfbc2988]*/
{
return do_argstrip(self, LEFTSTRIP, bytes);
}
@@ -2268,39 +2039,9 @@ Strip trailing bytes contained in the argument.
If the argument is omitted or None, strip trailing ASCII whitespace.
[clinic start generated code]*/
-PyDoc_STRVAR(bytes_rstrip__doc__,
-"rstrip($self, bytes=None, /)\n"
-"--\n"
-"\n"
-"Strip trailing bytes contained in the argument.\n"
-"\n"
-"If the argument is omitted or None, strip trailing ASCII whitespace.");
-
-#define BYTES_RSTRIP_METHODDEF \
- {"rstrip", (PyCFunction)bytes_rstrip, METH_VARARGS, bytes_rstrip__doc__},
-
-static PyObject *
-bytes_rstrip_impl(PyBytesObject *self, PyObject *bytes);
-
-static PyObject *
-bytes_rstrip(PyBytesObject *self, PyObject *args)
-{
- PyObject *return_value = NULL;
- PyObject *bytes = Py_None;
-
- if (!PyArg_UnpackTuple(args, "rstrip",
- 0, 1,
- &bytes))
- goto exit;
- return_value = bytes_rstrip_impl(self, bytes);
-
-exit:
- return return_value;
-}
-
static PyObject *
bytes_rstrip_impl(PyBytesObject *self, PyObject *bytes)
-/*[clinic end generated code: output=e98730bd133e6593 input=8f93c9cd361f0140]*/
+/*[clinic end generated code: output=547e3815c95447da input=8f93c9cd361f0140]*/
{
return do_argstrip(self, RIGHTSTRIP, bytes);
}
@@ -2371,53 +2112,9 @@ All characters occurring in the optional argument deletechars are removed.
The remaining characters are mapped through the given translation table.
[clinic start generated code]*/
-PyDoc_STRVAR(bytes_translate__doc__,
-"translate(table, [deletechars])\n"
-"Return a copy with each character mapped by the given translation table.\n"
-"\n"
-" table\n"
-" Translation table, which must be a bytes object of length 256.\n"
-"\n"
-"All characters occurring in the optional argument deletechars are removed.\n"
-"The remaining characters are mapped through the given translation table.");
-
-#define BYTES_TRANSLATE_METHODDEF \
- {"translate", (PyCFunction)bytes_translate, METH_VARARGS, bytes_translate__doc__},
-
-static PyObject *
-bytes_translate_impl(PyBytesObject *self, PyObject *table, int group_right_1, PyObject *deletechars);
-
-static PyObject *
-bytes_translate(PyBytesObject *self, PyObject *args)
-{
- PyObject *return_value = NULL;
- PyObject *table;
- int group_right_1 = 0;
- PyObject *deletechars = NULL;
-
- switch (PyTuple_GET_SIZE(args)) {
- case 1:
- if (!PyArg_ParseTuple(args, "O:translate", &table))
- goto exit;
- break;
- case 2:
- if (!PyArg_ParseTuple(args, "OO:translate", &table, &deletechars))
- goto exit;
- group_right_1 = 1;
- break;
- default:
- PyErr_SetString(PyExc_TypeError, "bytes.translate requires 1 to 2 arguments");
- goto exit;
- }
- return_value = bytes_translate_impl(self, table, group_right_1, deletechars);
-
-exit:
- return return_value;
-}
-
static PyObject *
bytes_translate_impl(PyBytesObject *self, PyObject *table, int group_right_1, PyObject *deletechars)
-/*[clinic end generated code: output=f0f29a57f41df5d8 input=d8fa5519d7cc4be7]*/
+/*[clinic end generated code: output=0ddd2cef4f4918f2 input=d8fa5519d7cc4be7]*/
{
char *input, *output;
Py_buffer table_view = {NULL, NULL};
@@ -2547,50 +2244,9 @@ the same position in to.
The bytes objects frm and to must be of the same length.
[clinic start generated code]*/
-PyDoc_STRVAR(bytes_maketrans__doc__,
-"maketrans(frm, to, /)\n"
-"--\n"
-"\n"
-"Return a translation table useable for the bytes or bytearray translate method.\n"
-"\n"
-"The returned table will be one where each byte in frm is mapped to the byte at\n"
-"the same position in to.\n"
-"\n"
-"The bytes objects frm and to must be of the same length.");
-
-#define BYTES_MAKETRANS_METHODDEF \
- {"maketrans", (PyCFunction)bytes_maketrans, METH_VARARGS|METH_STATIC, bytes_maketrans__doc__},
-
-static PyObject *
-bytes_maketrans_impl(Py_buffer *frm, Py_buffer *to);
-
-static PyObject *
-bytes_maketrans(void *null, PyObject *args)
-{
- PyObject *return_value = NULL;
- Py_buffer frm = {NULL, NULL};
- Py_buffer to = {NULL, NULL};
-
- if (!PyArg_ParseTuple(args,
- "y*y*:maketrans",
- &frm, &to))
- goto exit;
- return_value = bytes_maketrans_impl(&frm, &to);
-
-exit:
- /* Cleanup for frm */
- if (frm.obj)
- PyBuffer_Release(&frm);
- /* Cleanup for to */
- if (to.obj)
- PyBuffer_Release(&to);
-
- return return_value;
-}
-
static PyObject *
bytes_maketrans_impl(Py_buffer *frm, Py_buffer *to)
-/*[clinic end generated code: output=7df47390c476ac60 input=de7a8fc5632bb8f1]*/
+/*[clinic end generated code: output=a36f6399d4b77f6f input=de7a8fc5632bb8f1]*/
{
return _Py_bytes_maketrans(frm, to);
}
@@ -3104,53 +2760,9 @@ If the optional argument count is given, only the first count occurrences are
replaced.
[clinic start generated code]*/
-PyDoc_STRVAR(bytes_replace__doc__,
-"replace($self, old, new, count=-1, /)\n"
-"--\n"
-"\n"
-"Return a copy with all occurrences of substring old replaced by new.\n"
-"\n"
-" count\n"
-" Maximum number of occurrences to replace.\n"
-" -1 (the default value) means replace all occurrences.\n"
-"\n"
-"If the optional argument count is given, only the first count occurrences are\n"
-"replaced.");
-
-#define BYTES_REPLACE_METHODDEF \
- {"replace", (PyCFunction)bytes_replace, METH_VARARGS, bytes_replace__doc__},
-
-static PyObject *
-bytes_replace_impl(PyBytesObject*self, Py_buffer *old, Py_buffer *new, Py_ssize_t count);
-
-static PyObject *
-bytes_replace(PyBytesObject*self, PyObject *args)
-{
- PyObject *return_value = NULL;
- Py_buffer old = {NULL, NULL};
- Py_buffer new = {NULL, NULL};
- Py_ssize_t count = -1;
-
- if (!PyArg_ParseTuple(args,
- "y*y*|n:replace",
- &old, &new, &count))
- goto exit;
- return_value = bytes_replace_impl(self, &old, &new, count);
-
-exit:
- /* Cleanup for old */
- if (old.obj)
- PyBuffer_Release(&old);
- /* Cleanup for new */
- if (new.obj)
- PyBuffer_Release(&new);
-
- return return_value;
-}
-
static PyObject *
bytes_replace_impl(PyBytesObject*self, Py_buffer *old, Py_buffer *new, Py_ssize_t count)
-/*[clinic end generated code: output=f07bd9ecf29ee8d8 input=b2fbbf0bf04de8e5]*/
+/*[clinic end generated code: output=3fe052c3c60cffc2 input=b2fbbf0bf04de8e5]*/
{
return (PyObject *)replace((PyBytesObject *) self,
(const char *)old->buf, old->len,
@@ -3316,48 +2928,9 @@ bytes.decode
Decode the bytes using the codec registered for encoding.
[clinic start generated code]*/
-PyDoc_STRVAR(bytes_decode__doc__,
-"decode($self, /, encoding=\'utf-8\', errors=\'strict\')\n"
-"--\n"
-"\n"
-"Decode the bytes using the codec registered for encoding.\n"
-"\n"
-" encoding\n"
-" The encoding with which to decode the bytes.\n"
-" errors\n"
-" The error handling scheme to use for the handling of decoding errors.\n"
-" The default is \'strict\' meaning that decoding errors raise a\n"
-" UnicodeDecodeError. Other possible values are \'ignore\' and \'replace\'\n"
-" as well as any other name registered with codecs.register_error that\n"
-" can handle UnicodeDecodeErrors.");
-
-#define BYTES_DECODE_METHODDEF \
- {"decode", (PyCFunction)bytes_decode, METH_VARARGS|METH_KEYWORDS, bytes_decode__doc__},
-
-static PyObject *
-bytes_decode_impl(PyBytesObject*self, const char *encoding, const char *errors);
-
-static PyObject *
-bytes_decode(PyBytesObject*self, PyObject *args, PyObject *kwargs)
-{
- PyObject *return_value = NULL;
- static char *_keywords[] = {"encoding", "errors", NULL};
- const char *encoding = NULL;
- const char *errors = NULL;
-
- if (!PyArg_ParseTupleAndKeywords(args, kwargs,
- "|ss:decode", _keywords,
- &encoding, &errors))
- goto exit;
- return_value = bytes_decode_impl(self, encoding, errors);
-
-exit:
- return return_value;
-}
-
static PyObject *
bytes_decode_impl(PyBytesObject*self, const char *encoding, const char *errors)
-/*[clinic end generated code: output=61a80290bbfce696 input=958174769d2a40ca]*/
+/*[clinic end generated code: output=8038751c823b9038 input=958174769d2a40ca]*/
{
return PyUnicode_FromEncodedObject((PyObject*)self, encoding, errors);
}
@@ -3374,41 +2947,9 @@ Line breaks are not included in the resulting list unless keepends is given and
true.
[clinic start generated code]*/
-PyDoc_STRVAR(bytes_splitlines__doc__,
-"splitlines($self, /, keepends=False)\n"
-"--\n"
-"\n"
-"Return a list of the lines in the bytes, breaking at line boundaries.\n"
-"\n"
-"Line breaks are not included in the resulting list unless keepends is given and\n"
-"true.");
-
-#define BYTES_SPLITLINES_METHODDEF \
- {"splitlines", (PyCFunction)bytes_splitlines, METH_VARARGS|METH_KEYWORDS, bytes_splitlines__doc__},
-
-static PyObject *
-bytes_splitlines_impl(PyBytesObject*self, int keepends);
-
-static PyObject *
-bytes_splitlines(PyBytesObject*self, PyObject *args, PyObject *kwargs)
-{
- PyObject *return_value = NULL;
- static char *_keywords[] = {"keepends", NULL};
- int keepends = 0;
-
- if (!PyArg_ParseTupleAndKeywords(args, kwargs,
- "|i:splitlines", _keywords,
- &keepends))
- goto exit;
- return_value = bytes_splitlines_impl(self, keepends);
-
-exit:
- return return_value;
-}
-
static PyObject *
bytes_splitlines_impl(PyBytesObject*self, int keepends)
-/*[clinic end generated code: output=79da057d05d126de input=ddb93e3351080c8c]*/
+/*[clinic end generated code: output=995c3598f7833cad input=ddb93e3351080c8c]*/
{
return stringlib_splitlines(
(PyObject*) self, PyBytes_AS_STRING(self),
@@ -3445,40 +2986,9 @@ Spaces between two numbers are accepted.
Example: bytes.fromhex('B9 01EF') -> b'\\xb9\\x01\\xef'.
[clinic start generated code]*/
-PyDoc_STRVAR(bytes_fromhex__doc__,
-"fromhex($type, string, /)\n"
-"--\n"
-"\n"
-"Create a bytes object from a string of hexadecimal numbers.\n"
-"\n"
-"Spaces between two numbers are accepted.\n"
-"Example: bytes.fromhex(\'B9 01EF\') -> b\'\\\\xb9\\\\x01\\\\xef\'.");
-
-#define BYTES_FROMHEX_METHODDEF \
- {"fromhex", (PyCFunction)bytes_fromhex, METH_VARARGS|METH_CLASS, bytes_fromhex__doc__},
-
-static PyObject *
-bytes_fromhex_impl(PyTypeObject *type, PyObject *string);
-
-static PyObject *
-bytes_fromhex(PyTypeObject *type, PyObject *args)
-{
- PyObject *return_value = NULL;
- PyObject *string;
-
- if (!PyArg_ParseTuple(args,
- "U:fromhex",
- &string))
- goto exit;
- return_value = bytes_fromhex_impl(type, string);
-
-exit:
- return return_value;
-}
-
static PyObject *
bytes_fromhex_impl(PyTypeObject *type, PyObject *string)
-/*[clinic end generated code: output=09e6cbef56cbbb65 input=bf4d1c361670acd3]*/
+/*[clinic end generated code: output=0973acc63661bb2e input=bf4d1c361670acd3]*/
{
PyObject *newstring;
char *buf;