-
Notifications
You must be signed in to change notification settings - Fork 148
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
Defining an __eq__ method on LoLException caused it to become unhashable #46
Comments
In my clone of Riot-Watcher, I added a I would start a PR for this if I was sure it was a legit fix, but I don't know how this will affect other uses of LoLException; it just solves the issue for me. 😺 |
Yeah I was thinking of implementing it the same way. Wasn't sure if it On Tue, Dec 1, 2015, 3:13 PM Edward T. Chen notifications@github.com
|
Fixed in #49 |
finally got around to merging. fixed with merge. |
Relevant source: https://github.com/pseudonym117/Riot-Watcher/blob/master/riotwatcher/riotwatcher.py#L179-L188
The biggest problem w/this for me -- although I imagine it could apply to a lot of other users -- is illustrated by the following example:
The
exception
method of python logger objects automatically includes the raised exception in output.However, LoLException is unhashable, which causes a
Logging error
to occur.I have never run into an issue like this before, but a cursory googling reveals the following solution:
http://stackoverflow.com/questions/1608842/types-that-define-eq-are-unhashable-in-python-3-x
Sure enough, removing the
__eq__
and__ne__
methods from LoLException makes the exception loggable vialogger.exception
. To paraphrase the SO answer, if you wish to keep__eq__
the solution seems like simply defining__hash__
.Official docs on
__hash__
: https://docs.python.org/3/reference/datamodel.html#object.__hash__As an aside, this is also problematic for task queues like
celery
that must work w/raised exceptions during the processing of jobs, e.g. to retry a task that failed due to a rate limit exceeded error, etc.The text was updated successfully, but these errors were encountered: