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