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 barry
Recipients FFY00, barry, eryksun, ucodery
Date 2021-10-26.04:48:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <9BB1C624-10A5-41CB-9B97-186334ED3634@python.org>
In-reply-to <1635219086.11.0.0989524719053.issue45545@roundup.psfhosted.org>
Content
> A LBYL won't always raise errors early as you point out. It will give earlier warnings for a lot of cases, but makes contextlib.chdir usable in less places than os.chdir.
> Some return paths will always be errors, and some will be technically recoverable but too difficult to detect and or fragile. That's why I think any solution should incorporate the `ignore_errors` flag. Its pretty ugly to wrap a context manager in a try: except: just because you were trying to clean up after whatever you were doing but the cwd changed in unexpected ways, maybe out of your control.

How common do you expect such errors to be though?  Do you expect them to be more or less common than with os.chdir()?  Do you expect the mitigations to be any different than with a failing os.chdir()?

I’ve certainly written a chdir context manager several times and for the use cases I care about, I’ve never had such a failure, at least not one that wasn’t caused by some other underlying bug, which I was glad wasn’t silenced.
History
Date User Action Args
2021-10-26 04:48:06barrysetrecipients: + barry, eryksun, FFY00, ucodery
2021-10-26 04:48:06barrylinkissue45545 messages
2021-10-26 04:48:06barrycreate