summaryrefslogtreecommitdiff
path: root/Objects/bytesobject.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-07-01 17:22:31 +0300
committerSerhiy Storchaka <storchaka@gmail.com>2016-07-01 17:22:31 +0300
commit0855e706aa7fed842e18b0ce14e18d6574318643 (patch)
tree2fa36bacf92f87ea7361122e8a49d8690c7d5e1b /Objects/bytesobject.c
parentcf8b42e9043766338c0b16d0dca3ed5ca70a812d (diff)
downloadcpython-git-0855e706aa7fed842e18b0ce14e18d6574318643.tar.gz
Issue #27007: The fromhex() class methods of bytes and bytearray subclasses
now return an instance of corresponding subclass.
Diffstat (limited to 'Objects/bytesobject.c')
-rw-r--r--Objects/bytesobject.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index 83776aa113..8ad2782934 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -2303,7 +2303,12 @@ static PyObject *
bytes_fromhex_impl(PyTypeObject *type, PyObject *string)
/*[clinic end generated code: output=0973acc63661bb2e input=bf4d1c361670acd3]*/
{
- return _PyBytes_FromHex(string, 0);
+ PyObject *result = _PyBytes_FromHex(string, 0);
+ if (type != &PyBytes_Type && result != NULL) {
+ Py_SETREF(result, PyObject_CallFunctionObjArgs((PyObject *)type,
+ result, NULL));
+ }
+ return result;
}
PyObject*