diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-12-16 11:29:37 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-12-16 11:29:37 (GMT) |
commit | ab0e9f7089c04df546af6cacbc8751247cf4020a (patch) | |
tree | 3494351a976a17a62146a3ddd365fe2b5936fca4 /Modules/main.c | |
parent | e2b2bf55b30299e310b246b5b4b6f5a5f66e75b2 (diff) | |
parent | c345ce1a69b3c4a46d87ef56d859bc70abfc74b4 (diff) | |
download | cpython-ab0e9f7089c04df546af6cacbc8751247cf4020a.zip cpython-ab0e9f7089c04df546af6cacbc8751247cf4020a.tar.gz cpython-ab0e9f7089c04df546af6cacbc8751247cf4020a.tar.bz2 |
Issue #10350: Read and save errno before calling a function which might overwrite it.
Original patch by Hallvard B Furuseth.
Diffstat (limited to 'Modules/main.c')
-rw-r--r-- | Modules/main.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Modules/main.c b/Modules/main.c index 747c12f..d4c3314 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -655,13 +655,14 @@ Py_Main(int argc, wchar_t **argv) if (fp == NULL) { char *cfilename_buffer; const char *cfilename; + int err = errno; cfilename_buffer = _Py_wchar2char(filename, NULL); if (cfilename_buffer != NULL) cfilename = cfilename_buffer; else cfilename = "<unprintable file name>"; fprintf(stderr, "%ls: can't open file '%s': [Errno %d] %s\n", - argv[0], cfilename, errno, strerror(errno)); + argv[0], cfilename, err, strerror(err)); if (cfilename_buffer) PyMem_Free(cfilename_buffer); return 2; |