bpo-27729: Give a better error msg when a file path is too long on Windows

This commit is contained in:
Zackery Spytz 2020-06-12 15:29:36 -06:00
parent 80d827c3cb
commit 48d7a3e7e3
2 changed files with 6 additions and 1 deletions

View File

@ -0,0 +1 @@
Give a better error message when a file path is too long on Windows.

View File

@ -700,7 +700,11 @@ PyErr_SetFromErrnoWithFilenameObjects(PyObject *exc, PyObject *filenameObject, P
table, we use it, otherwise we assume it really _is_
a Win32 error code
*/
if (i > 0 && i < _sys_nerr) {
if (i == ENOENT && GetLastError() == ERROR_PATH_NOT_FOUND) {
message = PyUnicode_FromString("No such path or path exceeds "
"maximum allowed length");
}
else if (i > 0 && i < _sys_nerr) {
message = PyUnicode_FromString(_sys_errlist[i]);
}
else {