Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e69a08e

Browse files
committed
Fix for bug #1442 pythonstartup addition of minor error checking
Python failed to report an error when it wasn't able to open the PYTHONSTARTUP file.
1 parent 9a68f8c commit e69a08e

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

Modules/main.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,16 @@ static void RunStartupFile(PyCompilerFlags *cf)
132132
(void) PyRun_SimpleFileExFlags(fp, startup, 0, cf);
133133
PyErr_Clear();
134134
fclose(fp);
135+
} else {
136+
int save_errno;
137+
138+
save_errno = errno;
139+
PySys_WriteStderr("Could not open PYTHONSTARTUP\n");
140+
errno = save_errno;
141+
PyErr_SetFromErrnoWithFilename(PyExc_IOError,
142+
startup);
143+
PyErr_Print();
144+
PyErr_Clear();
135145
}
136146
}
137147
}

0 commit comments

Comments
 (0)