summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-05-22 08:13:20 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-05-22 08:13:20 (GMT)
commite79ec70801e410de9c3110ffe78f98e08114ae16 (patch)
tree4dffcd5f09a018f6b67feaeab43963aed6726eab /Objects
parent5cbd8331ff567ee568713dc5e63820ffb453ac4b (diff)
parent08d230a5408e9fac3adbb357f5fb4a43958991d4 (diff)
downloadcpython-e79ec70801e410de9c3110ffe78f98e08114ae16.zip
cpython-e79ec70801e410de9c3110ffe78f98e08114ae16.tar.gz
cpython-e79ec70801e410de9c3110ffe78f98e08114ae16.tar.bz2
Issue #24257: Fixed incorrect uses of PyObject_IsInstance().
Fixed segmentation fault in sqlite3.Row constructor with faked cursor type. Fixed system error in the comparison of faked types.SimpleNamespace.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/genobject.c5
-rw-r--r--Objects/namespaceobject.c7
2 files changed, 5 insertions, 7 deletions
diff --git a/Objects/genobject.c b/Objects/genobject.c
index 3c32e7b..555e4fd 100644
--- a/Objects/genobject.c
+++ b/Objects/genobject.c
@@ -442,8 +442,7 @@ _PyGen_FetchStopIterationValue(PyObject **pvalue) {
PyErr_Fetch(&et, &ev, &tb);
if (ev) {
/* exception will usually be normalised already */
- if (Py_TYPE(ev) == (PyTypeObject *) et
- || PyObject_IsInstance(ev, PyExc_StopIteration)) {
+ if (PyObject_TypeCheck(ev, (PyTypeObject *) et)) {
value = ((PyStopIterationObject *)ev)->value;
Py_INCREF(value);
Py_DECREF(ev);
@@ -453,7 +452,7 @@ _PyGen_FetchStopIterationValue(PyObject **pvalue) {
} else {
/* normalisation required */
PyErr_NormalizeException(&et, &ev, &tb);
- if (!PyObject_IsInstance(ev, PyExc_StopIteration)) {
+ if (!PyObject_TypeCheck(ev, (PyTypeObject *)PyExc_StopIteration)) {
PyErr_Restore(et, ev, tb);
return -1;
}
diff --git a/Objects/namespaceobject.c b/Objects/namespaceobject.c
index 720ac0d..3d27a95 100644
--- a/Objects/namespaceobject.c
+++ b/Objects/namespaceobject.c
@@ -164,12 +164,11 @@ namespace_clear(_PyNamespaceObject *ns)
static PyObject *
namespace_richcompare(PyObject *self, PyObject *other, int op)
{
- if (PyObject_IsInstance(self, (PyObject *)&_PyNamespace_Type) &&
- PyObject_IsInstance(other, (PyObject *)&_PyNamespace_Type))
+ if (PyObject_TypeCheck(self, &_PyNamespace_Type) &&
+ PyObject_TypeCheck(other, &_PyNamespace_Type))
return PyObject_RichCompare(((_PyNamespaceObject *)self)->ns_dict,
((_PyNamespaceObject *)other)->ns_dict, op);
- Py_INCREF(Py_NotImplemented);
- return Py_NotImplemented;
+ Py_RETURN_NOTIMPLEMENTED;
}