gh-115914: minor cleanup: simplify filename_obj assignment in PyRun_AnyFileExFlags (gh-115916)

This simplifies the code: less lines, easier to read. Logically equivalent, as any compiler likely already determined.
This commit is contained in:
Sergii K 2024-02-25 23:45:38 +03:00 committed by GitHub
parent 84a275c4a2
commit f082a05c67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 4 deletions

View File

@ -89,7 +89,7 @@ int
PyRun_AnyFileExFlags(FILE *fp, const char *filename, int closeit, PyRun_AnyFileExFlags(FILE *fp, const char *filename, int closeit,
PyCompilerFlags *flags) PyCompilerFlags *flags)
{ {
PyObject *filename_obj; PyObject *filename_obj = NULL;
if (filename != NULL) { if (filename != NULL) {
filename_obj = PyUnicode_DecodeFSDefault(filename); filename_obj = PyUnicode_DecodeFSDefault(filename);
if (filename_obj == NULL) { if (filename_obj == NULL) {
@ -97,9 +97,6 @@ PyRun_AnyFileExFlags(FILE *fp, const char *filename, int closeit,
return -1; return -1;
} }
} }
else {
filename_obj = NULL;
}
int res = _PyRun_AnyFileObject(fp, filename_obj, closeit, flags); int res = _PyRun_AnyFileObject(fp, filename_obj, closeit, flags);
Py_XDECREF(filename_obj); Py_XDECREF(filename_obj);
return res; return res;