From 0855e706aa7fed842e18b0ce14e18d6574318643 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Fri, 1 Jul 2016 17:22:31 +0300 Subject: Issue #27007: The fromhex() class methods of bytes and bytearray subclasses now return an instance of corresponding subclass. --- Objects/bytesobject.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Objects/bytesobject.c') 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* -- cgit v1.2.1