-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
self._handle is not defined in __del__ #299
Labels
Comments
Thanks @bryanwweber! Yes, let's move the |
pjbull
pushed a commit
that referenced
this issue
Dec 15, 2022
* Move _handle attribute up in CloudPath __init__ The _handle attribute needs to be set before any code can raise an exception. This is because if something tries to call __del__ after the exception as the process is exiting, _handle must be set to avoid an AttributeError in __del__. Resolves #299. * Formatting Co-authored-by: Bryan Weber <bweber@rebelliondefense.com>
Merged
pjbull
added a commit
that referenced
this issue
Dec 15, 2022
* Move _handle attribute up in CloudPath __init__ The _handle attribute needs to be set before any code can raise an exception. This is because if something tries to call __del__ after the exception as the process is exiting, _handle must be set to avoid an AttributeError in __del__. Resolves #299. * Formatting Co-authored-by: Bryan Weber <bweber@rebelliondefense.com> Co-authored-by: Bryan Weber <bryan.w.weber@gmail.com> Co-authored-by: Bryan Weber <bweber@rebelliondefense.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello! Thank you for this awesome package. I've been debugging some errors in pytest fixtures lately, specifically
ClientMismatchError
s (which are my fault, notcloudpathlib
). Due to causing this error, theself._handle
attribute is never set, so whenpytest
tears the test down and calls__del__
onCloudPath
, there is a further exception raised which pytest leaves a note about. The fix is fairly simple, it should be enough to move the definition of theself._handle
attribute to the top of__init__
, or else use atry/except
block in__del__
to catch this situation. Are you open to a patch for this?Sample traceback:
This is also documented in pytest here: https://docs.pytest.org/en/7.1.x/how-to/failures.html#warning-about-unraisable-exceptions-and-unhandled-thread-exceptions
The text was updated successfully, but these errors were encountered: