Commit c6994906 authored by Marius Wachtler's avatar Marius Wachtler

fix a leak in interactive mode, -m mode and a leak when calling tp_setattr

parent 62300c69
......@@ -732,6 +732,9 @@ _PyIO_trap_eintr(void)
if (eintr_int == NULL) {
eintr_int = PyLong_FromLong(EINTR);
assert(eintr_int != NULL);
// Pyston change:
PyGC_RegisterStaticConstant(eintr_int);
}
if (!PyErr_ExceptionMatches(PyExc_EnvironmentError))
return 0;
......
......@@ -476,7 +476,7 @@ static int main(int argc, char** argv) noexcept {
}
} else if (module != NULL) {
// TODO: CPython uses the same main module for all code paths
main_module = createModule(boxString("__main__"), "<string>");
main_module = createModule(autoDecref(boxString("__main__")), "<string>");
rtncode = (RunModule(module, 1) != 0);
} else {
main_module = createModule(autoDecref(boxString("__main__")), fn ? fn : "<stdin>");
......@@ -526,6 +526,8 @@ static int main(int argc, char** argv) noexcept {
PyObject* v = PyImport_ImportModule("readline");
if (!v)
PyErr_Clear();
else
Py_CLEAR(v);
printf("Pyston v%d.%d.%d (rev " STRINGIFY(GITREV) ")", PYSTON_VERSION_MAJOR, PYSTON_VERSION_MINOR,
PYSTON_VERSION_MICRO);
......
......@@ -987,8 +987,6 @@ extern "C" int PyRun_InteractiveOneFlags(FILE* fp, const char* filename, PyCompi
// Pyston change:
// d = PyModule_GetDict(m);
// v = run_mod(mod, filename, d, d, flags, arena);
v = None;
Py_INCREF(v);
assert(PyModule_Check(m));
bool failed = false;
try {
......@@ -1005,7 +1003,9 @@ extern "C" int PyRun_InteractiveOneFlags(FILE* fp, const char* filename, PyCompi
PyErr_Print();
return -1;
}
Py_DECREF(v);
// Pyston change: we dont't have v
// Py_DECREF(v);
if (Py_FlushLine())
PyErr_Clear();
return 0;
......
......@@ -3120,6 +3120,7 @@ extern "C" void setattr(Box* obj, BoxedString* attr, STOLEN(Box*) attr_val) {
STAT_TIMER(t1, "us_timer_slowpath_tpsetattr", 10);
assert(attr->data()[attr->size()] == '\0');
AUTO_DECREF(attr_val);
int rtn = obj->cls->tp_setattr(obj, const_cast<char*>(attr->data()), attr_val);
if (rtn)
throwCAPIException();
......
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