Skip to content

Commit 0797e65

Browse files
committed
Dump to specified filepath
1 parent 3ed8850 commit 0797e65

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

Modules/_testinternalcapi.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,17 +2077,14 @@ has_deferred_refcount(PyObject *self, PyObject *op)
20772077
}
20782078

20792079
static PyObject *
2080-
dump_executors(PyObject *self, PyObject *Py_UNUSED(ignored))
2081-
{
2082-
# ifdef MS_WINDOWS
2083-
const char *dirname = "c:\\temp\\py_stats\\";
2084-
# else
2085-
const char *dirname = "/tmp/py_stats/";
2086-
# endif
2087-
char buf[64];
2088-
sprintf(buf, "%s%s.gv", dirname, "executor_dump");
2089-
FILE *out = fopen(buf, "w");
2080+
dump_executors(PyObject *self, PyObject *filepath)
2081+
{
2082+
FILE *out = _Py_fopen_obj(filepath, "wb");
2083+
if (out == NULL) {
2084+
return NULL;
2085+
}
20902086
_PyDumpExecutors(out);
2087+
fclose(out);
20912088
Py_RETURN_NONE;
20922089
}
20932090

@@ -2189,7 +2186,7 @@ static PyMethodDef module_functions[] = {
21892186
{"get_static_builtin_types", get_static_builtin_types, METH_NOARGS},
21902187
{"identify_type_slot_wrappers", identify_type_slot_wrappers, METH_NOARGS},
21912188
{"has_deferred_refcount", has_deferred_refcount, METH_O},
2192-
{"dump_executors", dump_executors, METH_NOARGS},
2189+
{"dump_executors", dump_executors, METH_O},
21932190
{NULL, NULL} /* sentinel */
21942191
};
21952192

Python/optimizer.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1800,7 +1800,6 @@ _PyDumpExecutors(FILE *out)
18001800
exec = exec->vm_data.links.next;
18011801
}
18021802
fprintf(out, "}\n\n");
1803-
fclose(out);
18041803
}
18051804

18061805
#endif /* _Py_TIER2 */

0 commit comments

Comments
 (0)