Eryk Sun <eryk...@gmail.com> added the comment:

> Alternatively, can't we just os.chdir(self._old_cwd) in __enter__ and 
> preemptively fail? 

If the context manager isn't going to address the long-path case reliably using 
either a file-descriptor approach or repeated relative chdir() calls, then I 
think failing early like this is the next best choice.

The previous directory getting deleted is a random environment error, which can 
be left up to the caller. In POSIX, it might be avoidable using a 
file-descriptor approach, but POSIX doesn't actually guarantee that fchdir() 
will succeed if the file descriptor refers to a deleted directory.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue45545>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to