Skip to content

Commit adc8ea7

Browse files
committed
update : other parts of the code updated.
1 parent 8fe84d6 commit adc8ea7

1 file changed

Lines changed: 26 additions & 12 deletions

File tree

Objects/exceptions.c

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2392,22 +2392,36 @@ OSError_str(PyObject *op)
23922392
self->strerror ? self->strerror: Py_None);
23932393
#endif
23942394
if (self->filename) {
2395+
PyObject *myerrno = OSError_format_errno(self->myerrno);
2396+
if (myerrno == NULL) {
2397+
return NULL;
2398+
}
2399+
PyObject *res;
23952400
if (self->filename2) {
2396-
return PyUnicode_FromFormat("[Errno %S] %S: %R -> %R",
2397-
OR_NONE(self->myerrno),
2398-
OR_NONE(self->strerror),
2399-
self->filename,
2400-
self->filename2);
2401+
res = PyUnicode_FromFormat("[Errno %S] %S: %R -> %R",
2402+
myerrno,
2403+
OR_NONE(self->strerror),
2404+
self->filename,
2405+
self->filename2);
24012406
} else {
2402-
return PyUnicode_FromFormat("[Errno %S] %S: %R",
2403-
OR_NONE(self->myerrno),
2404-
OR_NONE(self->strerror),
2405-
self->filename);
2407+
res = PyUnicode_FromFormat("[Errno %S] %S: %R",
2408+
myerrno,
2409+
OR_NONE(self->strerror),
2410+
self->filename);
2411+
}
2412+
Py_DECREF(myerrno);
2413+
return res;
2414+
}
2415+
if (self->myerrno && self->strerror) {
2416+
PyObject *myerrno = OSError_format_errno(self->myerrno);
2417+
if (myerrno == NULL) {
2418+
return NULL;
24062419
}
2420+
PyObject *res = PyUnicode_FromFormat("[Errno %S] %S",
2421+
myerrno, self->strerror);
2422+
Py_DECREF(myerrno);
2423+
return res;
24072424
}
2408-
if (self->myerrno && self->strerror)
2409-
return PyUnicode_FromFormat("[Errno %S] %S",
2410-
self->myerrno, self->strerror);
24112425
return BaseException_str(op);
24122426
}
24132427

0 commit comments

Comments
 (0)