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 Gabriele Tornetta
Recipients Gabriele Tornetta, christian.heimes
Date 2021-01-01.13:34:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1609508089.79.0.236161571076.issue42796@roundup.psfhosted.org>
In-reply-to
Content
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)
~~~
History
Date User Action Args
2021-01-01 13:34:49Gabriele Tornettasetrecipients: + Gabriele Tornetta, christian.heimes
2021-01-01 13:34:49Gabriele Tornettasetmessageid: <1609508089.79.0.236161571076.issue42796@roundup.psfhosted.org>
2021-01-01 13:34:49Gabriele Tornettalinkissue42796 messages
2021-01-01 13:34:49Gabriele Tornettacreate