diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-25 13:52:04 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-25 13:52:04 (GMT) |
commit | f9afda57ad7d0394531982b2c9de8301c5a54e45 (patch) | |
tree | 8a09bb1aa816b4daf6777e630333dfece309cdb5 /Objects/bytesobject.c | |
parent | c5f3b4285a8f3f90305d777a88a856a623c22cb1 (diff) | |
parent | 15095800a381a396cbc077cb5320203a8feae51a (diff) | |
download | cpython-f9afda57ad7d0394531982b2c9de8301c5a54e45.zip cpython-f9afda57ad7d0394531982b2c9de8301c5a54e45.tar.gz cpython-f9afda57ad7d0394531982b2c9de8301c5a54e45.tar.bz2 |
Issue #24731: Fixed crash on converting objects with special methods
__bytes__, __trunc__, and __float__ returning instances of subclasses of
bytes, int, and float to subclasses of bytes, int, and float correspondingly.
Diffstat (limited to 'Objects/bytesobject.c')
-rw-r--r-- | Objects/bytesobject.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index 08275ad..8e09849 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -3146,7 +3146,7 @@ static PyNumberMethods bytes_as_number = { }; static PyObject * -str_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds); +bytes_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds); static PyObject * bytes_new(PyTypeObject *type, PyObject *args, PyObject *kwds) @@ -3161,7 +3161,7 @@ bytes_new(PyTypeObject *type, PyObject *args, PyObject *kwds) _Py_IDENTIFIER(__bytes__); if (type != &PyBytes_Type) - return str_subtype_new(type, args, kwds); + return bytes_subtype_new(type, args, kwds); if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oss:bytes", kwlist, &x, &encoding, &errors)) return NULL; @@ -3388,7 +3388,7 @@ PyBytes_FromObject(PyObject *x) } static PyObject * -str_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +bytes_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { PyObject *tmp, *pnew; Py_ssize_t n; @@ -3397,7 +3397,7 @@ str_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds) tmp = bytes_new(&PyBytes_Type, args, kwds); if (tmp == NULL) return NULL; - assert(PyBytes_CheckExact(tmp)); + assert(PyBytes_Check(tmp)); n = PyBytes_GET_SIZE(tmp); pnew = type->tp_alloc(type, n); if (pnew != NULL) { |