-
-
Notifications
You must be signed in to change notification settings - Fork 33.4k
Closed
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
/* Parse input from a file and execute it */
int
PyRun_AnyFileExFlags(FILE *fp, const char *filename, int closeit,
PyCompilerFlags *flags)
{
PyObject *filename_obj;
if (filename != NULL) {
filename_obj = PyUnicode_DecodeFSDefault(filename);
if (filename_obj == NULL) {
PyErr_Print();
return -1;
}
}
else {
filename_obj = NULL;
}
int res = _PyRun_AnyFileObject(fp, filename_obj, closeit, flags);
Py_XDECREF(filename_obj);
return res;
}===================== more better =============
/* Parse input from a file and execute it */
int
PyRun_AnyFileExFlags(FILE *fp, const char *filename, int closeit,
PyCompilerFlags *flags)
{
PyObject *filename_obj = NULL;
if (filename != NULL) {
filename_obj = PyUnicode_DecodeFSDefault(filename);
if (filename_obj == NULL) {
PyErr_Print();
return -1;
}
}
int res = _PyRun_AnyFileObject(fp, filename_obj, closeit, flags);
Py_XDECREF(filename_obj);
return res;
}CPython versions tested on:
3.8, 3.9, 3.10, 3.11, 3.12, 3.13, CPython main branch
Operating systems tested on:
Linux, macOS, Windows, Other
Linked PRs
Metadata
Metadata
Assignees
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error