mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Issue #10350: Read and save errno before calling a function which might overwrite it.
Original patch by Hallvard B Furuseth.
This commit is contained in:
parent
87448819ab
commit
c345ce1a69
7 changed files with 33 additions and 12 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue