Fix previous_functions when it contains Variables

This commit is contained in:
Sam Gross
2017-02-16 12:22:05 -08:00
committed by Soumith Chintala
parent 7117a9012e
commit dd844f741b
3 changed files with 27 additions and 5 deletions

View File

@ -932,9 +932,10 @@ PyObject *THPFunction_previous_functions(THPFunction *self, void *_unused)
return NULL;
for (int i = 0; i < size; i++) {
THPObjectPtr fn_tuple = PyTuple_New(2);
if (!fn_tuple)
return NULL;
PyTuple_SET_ITEM(fn_tuple.get(), 0, functionToPyObject(prev_fns[i].first));
if (!fn_tuple) return NULL;
PyObject* fn = functionToPyObject(prev_fns[i].first);
if (!fn) return NULL;
PyTuple_SET_ITEM(fn_tuple.get(), 0, fn);
PyTuple_SET_ITEM(fn_tuple.get(), 1, PyInt_FromLong(prev_fns[i].second));
PyTuple_SET_ITEM(result.get(), i, fn_tuple.release());
}