-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
hashlib.HASH objects should officially expose the hash name #62732
Comments
In hashlib, the HASH objects currently supply a 'name' attribute, reflecting the name used to initialize the hash object, and they have since Python 2.5. However, this interface is not published so isn't honored by other platforms (namely pypy). I propose the '.name' attribute be formally added to the documentation to reflect the actual implementation. I suggest this change be considered as a bugfix release if the original intention was for the '.name' attribute to be public (as it's a bug in the documentation if the intended and implemented interface isn't fully documented). I plan to do some research to ascertain the intention of this attribute (as can be inferred from tests and the source). For now, I'll assume Python 3.4 only. Any comments or suggestions welcome. |
Sounds like a good idea. |
fwiw pypy 2 supports HASH.name but the older 1.9 (still part of some Linux distributions) did not. |
It's not obvious to me if the authors originally intended to have the 'name' attribute as a formal interface, so I've decided the change should probably be added to Python 3.4. Here's a diff I've put together: http://paste.jaraco.com/tMdQ2 It updates the documentation and adds a test to guarantee the interface. I'm unsure about the RST syntax, so I would appreciate a review of the syntax there. Also, I haven't run the test yet, but I'll do that at a later date. |
New changeset 238c37e4c395 by Jason R. Coombs in branch 'default': |
I've confirmed the tests pass and the updated documentation renders nicely and without warnings. These changes now make the name attribute officially-supported and tested. |
I added some tests in 5fbf23e947d8 and found a bug in the _sha1 module, too. |
The builtin hash algorithms still had upper case names. I fixed it in |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: