New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
os.getcwd fails for long path names on linux #46974
Comments
$ python -c "print len('`pwd`'); import os; print os.getcwd()"
1174
Traceback (most recent call last):
File "<string>", line 1, in ?
OSError: [Errno 34] Numerical result out of range
$ The getcwd man page documents the ERANGE failure and suggests that the |
Why isn't the buffer length MAX_PATH anyway? |
It should be MAX_PATH. All path related functions should use MAX_PATH as |
MAX_PATH is a compile time constant which, like FD_BITS for select(), Using that as default initial size is OK, but handling ERANGE is still a |
This affects OS X too. I'm attaching two patches - one uses malloc to build a bigger string if |
Here's a patch to add a test that fails with Python 2.5 on OS X, but |
Went for the malloc only patch. Just fixed a small detail (weird corner The test could be better (no necessity of using a recursive function, it Commited in r64452. |
This bug occurred in posix_getcwd() and is being fixed. posix_getcwdu(PyObject *self, PyObject *noargs)
{
char buf[1026];
...
#if defined(PYOS_OS2) && defined(PYCC_GCC)
res = _getcwd2(buf, sizeof buf);
#else
res = getcwd(buf, sizeof buf);
#endif
...
} In my opinion, the fixed length buf should be discarded and instead |
Please open a new issue; and a patch is welcome. |
Amaury, Created bpo-6817 with a patch. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: