Gabriele Tornetta <phoenix1...@gmail.com> added the comment:

That makes sense, but I wonder what the "right" behaviour should be in this 
case. Surely the infinite recursion should be fixed at the very minimum. 
Perhaps the code on Windows could be enhanced to catch the case whereby one is 
trying to delete the cwd and do something like chdir('..') and then delete the 
temp folder. However, I suspect that something like this still wouldn't be 
enough. For example, this works fine

~~~ python
def test_chdir():
    with tempfile.TemporaryDirectory() as tempdir:
        old = os.getcwd()
        os.chdir(tempdir)
        os.chdir(old)
~~~

whereas this doesn't (same stacktrace as the original case)

~~~ python
def test_chdir():
    with tempfile.TemporaryDirectory() as tempdir:
        old = os.getcwd()
        os.chdir(tempdir)
        with open(os.path.join(tempdir, "delme")) as fout:
            fout.write("Hello")
        os.chdir(old)
~~~

----------

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

Reply via email to