Commit 0970859b authored by Kevin Modzelewski's avatar Kevin Modzelewski

Try to fix import star

parent 0682ccb0
......@@ -466,7 +466,7 @@ static PyObject* lookup_maybe(PyObject* self, const char* attrstr, PyObject** at
return NULL;
}
}
return incref(obj);
return NULL;
}
extern "C" PyObject* _PyObject_LookupSpecial(PyObject* self, const char* attrstr, PyObject** attrobj) noexcept {
......
......@@ -930,6 +930,7 @@ struct ExcInfo {
Box* type, *value, *traceback;
constexpr ExcInfo(Box* type, Box* value, Box* traceback) : type(type), value(value), traceback(traceback) {}
void clear();
bool matches(BoxedClass* cls) const;
void printExcAndTraceback() const;
};
......
......@@ -6817,15 +6817,18 @@ extern "C" Box* importStar(Box* _from_module, Box* to_globals) {
while (true) {
Box* attr_name;
try {
attr_name
= runtimeCallInternal2<CXX, NOT_REWRITABLE>(all_getitem, NULL, ArgPassSpec(2), all, boxInt(idx));
attr_name = runtimeCallInternal2<CXX, NOT_REWRITABLE>(all_getitem, NULL, ArgPassSpec(2), all,
autoDecref(boxInt(idx)));
} catch (ExcInfo e) {
if (e.matches(IndexError))
if (e.matches(IndexError)) {
e.clear();
break;
}
throw e;
}
idx++;
AUTO_DECREF(attr_name);
attr_name = coerceUnicodeToStr<CXX>(attr_name);
if (attr_name->cls != str_cls) {
......@@ -6840,9 +6843,9 @@ extern "C" Box* importStar(Box* _from_module, Box* to_globals) {
if (!attr_value)
raiseExcHelper(AttributeError, "'module' object has no attribute '%s'", casted_attr_name->data());
setGlobal(to_globals, casted_attr_name, attr_value);
setGlobal(to_globals, casted_attr_name, incref(attr_value));
}
return None;
return incref(None);
}
HCAttrs* module_attrs = from_module->getHCAttrsPtr();
......@@ -6850,10 +6853,10 @@ extern "C" Box* importStar(Box* _from_module, Box* to_globals) {
if (p.first->data()[0] == '_')
continue;
setGlobal(to_globals, p.first, module_attrs->attr_list->attrs[p.second]);
setGlobal(to_globals, p.first, incref(module_attrs->attr_list->attrs[p.second]));
}
return None;
return incref(None);
}
// TODO Make these fast, do inline caches and stuff
......
......@@ -1328,6 +1328,11 @@ inline Box* Box::getattrString(const char* attr) {
}
}
inline void ExcInfo::clear() {
Py_DECREF(type);
Py_DECREF(value);
Py_DECREF(traceback); // XDECREF?
}
} // namespace pyston
#endif
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