summaryrefslogtreecommitdiffstats
path: root/Modules/binascii.c
diff options
context:
space:
mode:
authorZachary Ware <zachary.ware@gmail.com>2015-01-20 19:59:46 (GMT)
committerZachary Ware <zachary.ware@gmail.com>2015-01-20 19:59:46 (GMT)
commitb176d40398f4a6f15fc3f63ef55fb064eca13ee3 (patch)
treefe7c0b7e087391e85c962fc78c7ada63f5758b24 /Modules/binascii.c
parent5a494f6ad850b7d2a4a5007fc27a1a1614a2c2a0 (diff)
downloadcpython-b176d40398f4a6f15fc3f63ef55fb064eca13ee3.zip
cpython-b176d40398f4a6f15fc3f63ef55fb064eca13ee3.tar.gz
cpython-b176d40398f4a6f15fc3f63ef55fb064eca13ee3.tar.bz2
Issue #23280: Fix docstrings for binascii.(un)hexlify
Diffstat (limited to 'Modules/binascii.c')
-rw-r--r--Modules/binascii.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/Modules/binascii.c b/Modules/binascii.c
index 42d08de..86b63bb 100644
--- a/Modules/binascii.c
+++ b/Modules/binascii.c
@@ -1147,6 +1147,20 @@ binascii_b2a_hex_impl(PyModuleDef *module, Py_buffer *data)
return retval;
}
+/*[clinic input]
+binascii.hexlify = binascii.b2a_hex
+
+Hexadecimal representation of binary data.
+
+The return value is a bytes object.
+[clinic start generated code]*/
+
+static PyObject *
+binascii_hexlify_impl(PyModuleDef *module, Py_buffer *data)
+/*[clinic end generated code: output=6098440091fb61dc input=2e3afae7f083f061]*/
+{
+ return binascii_b2a_hex_impl(module, data);
+}
static int
to_int(int c)
@@ -1221,6 +1235,21 @@ binascii_a2b_hex_impl(PyModuleDef *module, Py_buffer *hexstr)
return NULL;
}
+/*[clinic input]
+binascii.unhexlify = binascii.a2b_hex
+
+Binary data of hexadecimal representation.
+
+hexstr must contain an even number of hex digits (upper or lower case).
+[clinic start generated code]*/
+
+static PyObject *
+binascii_unhexlify_impl(PyModuleDef *module, Py_buffer *hexstr)
+/*[clinic end generated code: output=17cec7544499803e input=dd8c012725f462da]*/
+{
+ return binascii_a2b_hex_impl(module, hexstr);
+}
+
static int table_hex[128] = {
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
@@ -1535,10 +1564,8 @@ static struct PyMethodDef binascii_module_methods[] = {
BINASCII_B2A_HQX_METHODDEF
BINASCII_A2B_HEX_METHODDEF
BINASCII_B2A_HEX_METHODDEF
- {"unhexlify", (PyCFunction)binascii_a2b_hex, METH_VARARGS,
- binascii_a2b_hex__doc__},
- {"hexlify", (PyCFunction)binascii_b2a_hex, METH_VARARGS,
- binascii_b2a_hex__doc__},
+ BINASCII_HEXLIFY_METHODDEF
+ BINASCII_UNHEXLIFY_METHODDEF
BINASCII_RLECODE_HQX_METHODDEF
BINASCII_RLEDECODE_HQX_METHODDEF
BINASCII_CRC_HQX_METHODDEF