On 4/11/22, Chris Angelico <ros...@gmail.com> wrote: > > Which raises the question: what if the current directory no longer has > a path name? Or is that simply not possible on Windows?
The process working directory is opened without FILE_SHARE_DELETE sharing. This prevents opening the directory with DELETE access from any security context in user mode, even by the SYSTEM account. If the handle for the working directory is forcefully closed (e.g. via Process Explorer) and the directory is deleted, then accessing a relative path in the affected process fails with ERROR_INVALID_HANDLE (6) until the working directory is changed to a valid directory. > (Don't even get me started on prefixing paths with \\?\ and what that > changes. Windows has bizarre backward compatibility constraints.) Paths prefixed by \\?\ or \\.\ are not supported for the process working directory and should not be used in this case. The Windows API is buggy if the working directory is set to a prefixed path. For example, it fails to identify a drive such as r"\\?\C:" or r"\\?\UNC\server\share" in the working directory, in which case a rooted path such as r"\spam" can't be accessed. _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/5A4RYPI6T7FHGRP7KOEL2ISQHHNUPLCJ/ Code of Conduct: http://python.org/psf/codeofconduct/