Mercurial > cpython-lru_cache-weakref
comparison Python/errors.c @ 74007:51412b4b81ae
Issue #13560: os.strerror() now uses the current locale encoding instead of UTF-8
| author | Victor Stinner <victor.stinner@haypocalc.com> |
|---|---|
| date | Sat, 17 Dec 2011 04:45:09 +0100 |
| parents | 021e5bb297d1 |
| children | 07802351ccad |
comparison
equal
deleted
inserted
replaced
| 74006:88198b93ff2f | 74007:51412b4b81ae |
|---|---|
| 341 PyErr_SetFromErrnoWithFilenameObject(PyObject *exc, PyObject *filenameObject) | 341 PyErr_SetFromErrnoWithFilenameObject(PyObject *exc, PyObject *filenameObject) |
| 342 { | 342 { |
| 343 PyObject *message; | 343 PyObject *message; |
| 344 PyObject *v, *args; | 344 PyObject *v, *args; |
| 345 int i = errno; | 345 int i = errno; |
| 346 #ifndef MS_WINDOWS | 346 #ifdef MS_WINDOWS |
| 347 char *s; | |
| 348 #else | |
| 349 WCHAR *s_buf = NULL; | 347 WCHAR *s_buf = NULL; |
| 350 #endif /* Unix/Windows */ | 348 #endif /* Unix/Windows */ |
| 351 | 349 |
| 352 #ifdef EINTR | 350 #ifdef EINTR |
| 353 if (i == EINTR && PyErr_CheckSignals()) | 351 if (i == EINTR && PyErr_CheckSignals()) |
| 354 return NULL; | 352 return NULL; |
| 355 #endif | 353 #endif |
| 356 | 354 |
| 357 #ifndef MS_WINDOWS | 355 #ifndef MS_WINDOWS |
| 358 if (i == 0) | 356 if (i != 0) { |
| 359 s = "Error"; /* Sometimes errno didn't get set */ | 357 char *s = strerror(i); |
| 360 else | 358 message = PyUnicode_DecodeLocale(s, 1); |
| 361 s = strerror(i); | 359 } |
| 362 message = PyUnicode_DecodeUTF8(s, strlen(s), "ignore"); | 360 else { |
| 361 /* Sometimes errno didn't get set */ | |
| 362 message = PyUnicode_FromString("Error"); | |
| 363 } | |
| 363 #else | 364 #else |
| 364 if (i == 0) | 365 if (i == 0) |
| 365 message = PyUnicode_FromString("Error"); /* Sometimes errno didn't get set */ | 366 message = PyUnicode_FromString("Error"); /* Sometimes errno didn't get set */ |
| 366 else | 367 else |
| 367 { | 368 { |
