Commit 673cd824 authored by Neal Norwitz's avatar Neal Norwitz

Fix SF # 624982, Potential AV in slot_sq_item, by Greg Chapman

Don't crash when getting value of a property raises an exception
parent 9def6a3a
...@@ -1814,6 +1814,18 @@ def properties(): ...@@ -1814,6 +1814,18 @@ def properties():
raise TestFailed("expected TypeError from trying to set " raise TestFailed("expected TypeError from trying to set "
"readonly %r attr on a property" % attr) "readonly %r attr on a property" % attr)
class D(object):
__getitem__ = property(lambda s: 1/0)
d = D()
try:
for i in d:
str(i)
except ZeroDivisionError:
pass
else:
raise TestFailed, "expected ZeroDivisionError from bad property"
def supers(): def supers():
if verbose: print "Testing super..." if verbose: print "Testing super..."
......
...@@ -3145,8 +3145,12 @@ slot_sq_item(PyObject *self, int i) ...@@ -3145,8 +3145,12 @@ slot_sq_item(PyObject *self, int i)
if (func != NULL) { if (func != NULL) {
if ((f = func->ob_type->tp_descr_get) == NULL) if ((f = func->ob_type->tp_descr_get) == NULL)
Py_INCREF(func); Py_INCREF(func);
else else {
func = f(func, self, (PyObject *)(self->ob_type)); func = f(func, self, (PyObject *)(self->ob_type));
if (func == NULL) {
return NULL;
}
}
ival = PyInt_FromLong(i); ival = PyInt_FromLong(i);
if (ival != NULL) { if (ival != NULL) {
args = PyTuple_New(1); args = PyTuple_New(1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment