summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-09-19 06:00:15 (GMT)
committerRaymond Hettinger <python@rcn.com>2004-09-19 06:00:15 (GMT)
commit1be1a79ff996cda1c5f780d2409406d6ba88b36d (patch)
tree017ef092f9c0fcccac92febeac2019b39bc03cff /Objects
parent8b4e886ed9274c77d1895f1b1d61f8e60a2b3463 (diff)
downloadcpython-1be1a79ff996cda1c5f780d2409406d6ba88b36d.zip
cpython-1be1a79ff996cda1c5f780d2409406d6ba88b36d.tar.gz
cpython-1be1a79ff996cda1c5f780d2409406d6ba88b36d.tar.bz2
SF bug #1030557: PyMapping_Check crashes when argument is NULL
Make PySequence_Check() and PyMapping_Check() handle NULL inputs. This goes beyond what most of the other checks do, but it is nice defensive programming and solves the OP's problem.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/abstract.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index bc36c6f..377f359 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -1085,7 +1085,7 @@ PyNumber_Float(PyObject *o)
int
PySequence_Check(PyObject *s)
{
- if (PyInstance_Check(s))
+ if (s && PyInstance_Check(s))
return PyObject_HasAttrString(s, "__getitem__");
return s != NULL && s->ob_type->tp_as_sequence &&
s->ob_type->tp_as_sequence->sq_item != NULL;
@@ -1629,7 +1629,7 @@ PySequence_Index(PyObject *s, PyObject *o)
int
PyMapping_Check(PyObject *o)
{
- if (PyInstance_Check(o))
+ if (o && PyInstance_Check(o))
return PyObject_HasAttrString(o, "__getitem__");
return o && o->ob_type->tp_as_mapping &&