Opened 4 years ago

Closed 4 years ago

#31985 closed Cleanup/optimization (fixed)

salted_hmac() docstring shouldn't mention hashlib.new().

Reported by: Francisco Couzo Owned by: Francisco Couzo
Component: Utilities Version: 3.1
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

On its documentation, it mentions "any algorithm name supported by hashlib.new() can be passed",
but this is not true, algorithms supported by hashlib.new() may not accessible through getattr,
This was mentioned here:
https://github.com/django/django/pull/12291#discussion_r364348132
But it wasn't addressed.

Either we can make salted_hmac use hashlib.new (which is discouraged by python's documentation).
Or change the documentation to not mentioned hashlib.new.

Change History (5)

comment:1 by Mariusz Felisiak, 4 years ago

Component: UncategorizedUtilities
Easy pickings: set
Summary: salted_hmac incorrect documentationsalted_hmac docstring shouldn't mention hashlib.new().
Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

Agreed. I would remove new() from the docstring:

-    but any algorithm name supported by hashlib.new() can be passed.
+    but any algorithm name supported by hashlib can be passed.

comment:2 by Mariusz Felisiak, 4 years ago

Summary: salted_hmac docstring shouldn't mention hashlib.new().salted_hmac() docstring shouldn't mention hashlib.new().

comment:3 by Francisco Couzo, 4 years ago

Owner: changed from nobody to Francisco Couzo
Status: newassigned

I can make the PR

comment:4 by Francisco Couzo, 4 years ago

Has patch: set

comment:5 by GitHub <noreply@…>, 4 years ago

Resolution: fixed
Status: assignedclosed

In 5ea1621:

Fixed #31985 -- Corrected salted_hmac()'s docstring about supported algorithms.

salted_hmac() validates supported algorithms by checking hashlib
methods.

Note: See TracTickets for help on using tickets.
Back to Top