This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients barry, eryksun, ucodery
Date 2021-10-21.04:56:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1634792177.13.0.807964548979.issue45545@roundup.psfhosted.org>
In-reply-to
Content
> # I thought this would have to be 16, i.e. a path length over 4096, PATH_MAX
> # but seemingly just crossing 1050 is enough to fail

If os.pathconf() and PC_PATH_MAX are supported, the maximum allowed length of an absolute path is os.pathconf('/', os.pathconf_names['PC_PATH_MAX']). I think it also depends on the mounted filesystems that the path traverses.

If os.chdir is in os.supports_fd, the context manager can use dirfd = os.open(os.getcwd(), os.O_RDONLY). Using an fd should also work around the deleted directory case, though POSIX doesn't specify whether fchdir() succeeds in this case. It does in Linux, and the resulting state is the same as deleting the current working directory.

In Windows, SetCurrentDirectoryW() resolves the full path. So the result from os.getcwd() should always work with os.chdir(). The context manager could prevent the original directory from getting deleted by opening it without delete sharing (e.g. via _winapi.CreateFile). Though it may be more reasonable to just let it fail to restore the original working directory.
History
Date User Action Args
2021-10-21 04:56:17eryksunsetrecipients: + eryksun, barry, ucodery
2021-10-21 04:56:17eryksunsetmessageid: <1634792177.13.0.807964548979.issue45545@roundup.psfhosted.org>
2021-10-21 04:56:17eryksunlinkissue45545 messages
2021-10-21 04:56:16eryksuncreate