-
Notifications
You must be signed in to change notification settings - Fork 696
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
_recattrs.py: take into account exception coming from other classes #905
Conversation
Hi @ncoudene, thanks for the improvement! You're right that Would you mind updating the PR to catch Also, implementing an unit test would be a nice addition. You can copy the test here but replace or extend loguru/tests/test_add_option_enqueue.py Lines 235 to 254 in d379fed
|
Hi @Delgan, I updated the PR with your requests :
Unfortunately the push to codecov seems to have failed. |
tests/test_add_option_enqueue.py
Outdated
@@ -12,7 +12,12 @@ | |||
|
|||
class NotPicklable: | |||
def __getstate__(self): | |||
raise pickle.PicklingError("You shall not serialize me!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update, however this is not exactly what I had in mind, sorry for the confusion.
With this change, we simulate a generic Exception
occurring during pickle.dumps()
. The TypeError()
and pickle.PicklingError()
in the list are just arguments of the Exception
and are not actually very relevant to the test.
I actually expected two distinct test cases:
- one with
NotPicklable
causing apickle.PicklingError()
(the common case) ; - another test with
NotPicklable
causing aTypeError()
(the improvement you suggested).
In this way, we cover different possible cases of error that can happen.
However, I understand that you might not be very familiar with the code base. I would suggest that you simply duplicate the original NotPicklable
error and create a new NotPicklableTypeError
class (which raises a TypeError
instead of pickle.PicklingError
). Then you could also duplicate test_caught_exception_queue_put()
and test_not_caught_exception_queue_put()
to test against this new NotPicklableTypeError()
class.
Duplication is fine, I'll find a way to factorize it eventually, but we can keep it simple for now.
Hi @ncoudene. Thanks for taking the time to update the PR, I've left a comment to clarify how I think testing can be improved. If you don't have the time, let me know, I can always update your branch on my end. Regarding the |
Hi @Delgan , I revert my change and add the change you asked. Codecov (or github actions) seems buggy. Let me know if you have some comments. |
Great, thanks for taking the time to update the PR. Looks perfect. 👍 However, I think something went wrong during your |
Hello and thank you for this great module !
Recently I have beginning to use loguru with an 'aiohttp' project and I have beginning to encounter some annoying exception coming from loguru :
With the proposed patch it seems to work flawlessly again.
Let me know if it seems fine to you too.