-
Notifications
You must be signed in to change notification settings - Fork 230
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
RFC Deprecate encoding of detached parts #507
Conversation
src/nacl/signing.py
Outdated
The signature contained within the :class:`SignedMessage`, | ||
encoded as requested on signature generation | ||
""" | ||
warn("Deprecated attribute") |
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.
This is an absolutely terrible warning message. It doesn't tell the user (or developer) which attribute is deprecated (is it signature
? message
? raw_signature
? raw_message
? __get__
? __mro__
? __getattr__
?), and it doesn't hint at what the correct, non-deprecated replacements are.
A much better warning message would be "Use of the signature property is deprecated. Please update your code to use the raw_signature attribute instead, and decode it properly."
Same for the message
property below.
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.
@blag while I appreciate your interest in pynacl, before investing more time in this change, we must agree it goes in the right direction for our users.
The intent is to just deprecate the encoded parts, while keeping the raw parts for advanced usage, therefore I only added warnings on access to .message and .signature.
If @pyca/pynacl-core find some merit in this proposal, I'll be grateful for better message suggestion.
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 fixing the warning message - looks much better now! 😄
src/nacl/utils.py
Outdated
@@ -19,6 +19,14 @@ | |||
import six | |||
|
|||
|
|||
class PyNaclWarning(UserWarning): |
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.
This is unnecessary. While warnings in Python appear like they are exceptions, the two are handled very differently.
The reason to have a base exception class for library exceptions is to allow users to catch only those exceptions.
But there already exists the warnings.filterwarnings
mechanism to filter out warnings, and you can filter out warnings by their module.
So this simply (poorly) duplicates a built-in Python feature.
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.
Right, will remove if we all agree this should go on.
and add a warning in case of encoded signature. Rephrase the warnings on access to SignedMessage's encoded attributes
Just for completeness, I'm adding a transcript of a simple sign/verify session showing that
|
OK, with the last couple of commits I think the proposal is complete. I'd like to know if there is some agreement in @pyca/pynacl-core to follow this route, or someone thinks it would be better to keep the encoded attributes instead. |
@dstufft, would you mind taking a look at these proposed changes and give your opinion? |
@reaperhulk could you please take a look at this too? |
@reaperhulk @dstufft @blag @pyca/pynacl-core
and a similar change in VerifyKey, but I fear such a change would cause more disruptions for our downstream users. |
Okay, I've finally thought about this a bit (sorry about the delay). Our ultimate goal is to get to a world where we only deal in bytes so I think marking all The |
Closing since #523 seems more useful. |
@blag @pyca/pynacl-core This is a follow-up to the revert of #504, to show a real proposal instead of some hand-waving... I think this way we gain a clear path to deprecate the encoded parts, while keeping the capability to encode the full signed message, which someone seems to find useful in simple cases.