summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-11-25 13:53:19 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-11-25 13:53:19 (GMT)
commitbb6e4a0b31402f2e242f8f4be9a26e07d3dcc1b7 (patch)
tree552f1bdf983de7b8957bb65597c691c932d063db /Objects
parentdde0815c359fc321b0e7a94f885132e2e77534a1 (diff)
parentf9afda57ad7d0394531982b2c9de8301c5a54e45 (diff)
downloadcpython-bb6e4a0b31402f2e242f8f4be9a26e07d3dcc1b7.zip
cpython-bb6e4a0b31402f2e242f8f4be9a26e07d3dcc1b7.tar.gz
cpython-bb6e4a0b31402f2e242f8f4be9a26e07d3dcc1b7.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')
-rw-r--r--Objects/bytesobject.c8
-rw-r--r--Objects/floatobject.c2
-rw-r--r--Objects/longobject.c2
3 files changed, 6 insertions, 6 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index 6a9e062..cbdac86 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -3291,7 +3291,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)
@@ -3306,7 +3306,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;
@@ -3556,7 +3556,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;
@@ -3565,7 +3565,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) {
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index b8d6f2b..d92bec3 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -1568,7 +1568,7 @@ float_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
tmp = float_new(&PyFloat_Type, args, kwds);
if (tmp == NULL)
return NULL;
- assert(PyFloat_CheckExact(tmp));
+ assert(PyFloat_Check(tmp));
newobj = type->tp_alloc(type, 0);
if (newobj == NULL) {
Py_DECREF(tmp);
diff --git a/Objects/longobject.c b/Objects/longobject.c
index 2cc1585..d05de8b 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -4675,7 +4675,7 @@ long_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
tmp = (PyLongObject *)long_new(&PyLong_Type, args, kwds);
if (tmp == NULL)
return NULL;
- assert(PyLong_CheckExact(tmp));
+ assert(PyLong_Check(tmp));
n = Py_SIZE(tmp);
if (n < 0)
n = -n;