diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-12-16 11:28:32 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-12-16 11:28:32 (GMT) |
commit | c345ce1a69b3c4a46d87ef56d859bc70abfc74b4 (patch) | |
tree | 5481a8c3e31ae8a423aed9199a1fe2b22694d1c0 /Modules/main.c | |
parent | 87448819abd4900bcb36857c6706d8562c97a099 (diff) | |
download | cpython-c345ce1a69b3c4a46d87ef56d859bc70abfc74b4.zip cpython-c345ce1a69b3c4a46d87ef56d859bc70abfc74b4.tar.gz cpython-c345ce1a69b3c4a46d87ef56d859bc70abfc74b4.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 fcd9330..5a985a5 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -654,13 +654,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; |