Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Check our call to PyObject_GetAttrString() to make sure it returns a …

…non-NULL value

Should resolve issue: #6

Change-Id: Ie1fd42a9719d50e0baa600e3563ac50159201dc9
  • Loading branch information...
commit e8352935d01dbf1f20a8bc6aecc3c40592508435 1 parent 86229c1
@rtyler authored
Showing with 25 additions and 14 deletions.
  1. +25 −14 cheetah/c/_namemapper.c
View
39 cheetah/c/_namemapper.c
@@ -179,25 +179,36 @@ static PyObject *PyNamemapper_valueForName(PyObject *obj, char *nameChunks[], in
}
return NULL;
}
-
+
if (PyMapping_Check(currentVal) && PyMapping_HasKeyString(currentVal, currentKey)) {
nextVal = PyMapping_GetItemString(currentVal, currentKey);
- }
+ }
+
else {
- PyObject *exc;
- nextVal = PyObject_GetAttrString(currentVal, currentKey);
- exc = PyErr_Occurred();
- if (exc != NULL) {
- // if exception == AttributeError, report our own exception
- if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
- setNotFoundException(currentKey, currentVal);
+ PyObject *exc;
+ nextVal = PyObject_GetAttrString(currentVal, currentKey);
+ exc = PyErr_Occurred();
+
+ if (exc != NULL) {
+ // if exception == AttributeError, report our own exception
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ setNotFoundException(currentKey, currentVal);
+ }
+ // any exceptions results in failure
+ if (i > 0) {
+ Py_DECREF(currentVal);
+ }
+ return NULL;
}
- // any exceptions results in failure
- if (i > 0) {
- Py_DECREF(currentVal);
+
+ if (nextVal == NULL) {
+ setNotFoundException(currentKey, currentVal);
+ // any exceptions results in failure
+ if (i > 0) {
+ Py_DECREF(currentVal);
+ }
+ return NULL;
}
- return NULL;
- }
}
if (i > 0) {
Py_DECREF(currentVal);
Please sign in to comment.
Something went wrong with that request. Please try again.