-
Notifications
You must be signed in to change notification settings - Fork 330
🚫🥒 do not pickle the unpickleable RWLock #199
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
Conversation
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.
Could you add a test case to verify that the object is pickleable? and that unpickling gives an equal object?
also |
Thanks for the response! While writing the test, I cannot get equality comparisons working for PointJacobi objects. Debugging
Any idea what I'm doing wrong? |
I figured out my question on the equality comparison of PointJacobi. CurveFp has
|
…ing to acquire the lock, it now returns None. Think that's fine or prefer something else? Added `__ne__` for CurveFp. I think `test_inaquality_points_diff_types` from test_ellipticcurve.py was not actually testing equality. Because there was no `__ne__`, it was falling back to identity comparison, causing the test to pass. Now that there's a `__ne__`, it was getting NotImplemented which surprisingly bool casts to True. I changed the `__eq__` to return False for different types. Fix typo in `test_inaquality_points_diff_types` name. As requested, ran black on modified files. It reformmated some lines I hadn't modified.
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.
It reformmated some lines I hadn't modified
likely new version, that's ok
For __ne__ use == instead of __eq__ so it handles NotImplemented when the types are different. Remove the not needed state declaration.
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.
Looks good, thank you!
This is to fix the
can't pickle thread.lock objects
error when attempting to pickle something such as anecdsa.keys.VerifyingKey
Alternatively, the custom getstate and setstate could be within the RWLock class.