Message281299
I searched an occurrence of what I'm describing which is already using clinic and there is, at least, one in Modules/binascii.c line 1090:
TL;DR: The idea is to use the `modulename.fnname [as c_basename] = modulename.existing_fn_name` clinic syntax, drop a "This function is also available as …" in the docstring, and check if they return the same thing in the tests.
This way looks good to me, it uses the dedicated syntax which looks right, and I'll drop the `self.assertEqual(self.module.bisect, self.module.bisect_right)` which is an implementation detail, replacing it by tests checking that both have the same behavior.
```
/*[clinic input]
binascii.b2a_hex
data: Py_buffer
/
Hexadecimal representation of binary data.
The return value is a bytes object. This function is also
available as "hexlify()".
[clinic start generated code]*/
static PyObject *
binascii_b2a_hex_impl(PyObject *module, Py_buffer *data)
/*[clinic end generated code: output=92fec1a95c9897a0 input=96423cfa299ff3b1]*/
{
return _Py_strhex_bytes((const char *)data->buf, data->len);
}
/*[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(PyObject *module, Py_buffer *data)
/*[clinic end generated code: output=749e95e53c14880c input=2e3afae7f083f061]*/
{
return _Py_strhex_bytes((const char *)data->buf, data->len);
}
``` |
|
Date |
User |
Action |
Args |
2016-11-20 20:12:56 | mdk | set | recipients:
+ mdk, rhettinger, larry |
2016-11-20 20:12:56 | mdk | set | messageid: <1479672776.7.0.136227196021.issue28754@psf.upfronthosting.co.za> |
2016-11-20 20:12:56 | mdk | link | issue28754 messages |
2016-11-20 20:12:56 | mdk | create | |
|