Issue 7418: hashlib : the names of the different hash algorithms (original) (raw)

Created on 2009-12-01 14:04 by chaica_, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
algorithms_constant_attribute_in_hashlib_module.diff chaica_,2009-12-01 14:04
algorithms_constant_attribute_in_hashlib_module_update1.diff chaica_,2009-12-02 09:05 Patch for the hashlib module - update 1
Messages (13)
msg95857 - (view) Author: Carl Chenet (chaica_) Date: 2009-12-01 14:04
Hi, The hashlib module could provide a tuple offering the names of the different hash algorithms which are guaranteed to be supported. The expected result: >>> import hashlib >>> hashlib.algorithms ('md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512') Here is a patch to do so. It also provides an update for the hashlib documentation and a test case. Bye, Carl Chenet
msg95860 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2009-12-01 15:20
I guess you missed the quotes. $ ./python foo.py Traceback (most recent call last): File "foo.py", line 2, in from hashlib import * TypeError: attribute name must be string, not 'tuple'
msg95899 - (view) Author: Carl Chenet (chaica_) Date: 2009-12-02 08:58
flox : You're right, sorry about that. Here is a fixed patch.
msg95900 - (view) Author: Carl Chenet (chaica_) Date: 2009-12-02 09:05
The fixed file : algorithms_constant_attribute_in_hashlib_module_update1.diff
msg96854 - (view) Author: Carl Chenet (chaica_) Date: 2009-12-24 12:07
Hi, Maybe you have some ideas on this patch? I think it could be a nice feature e.g in my app I need to support every hash algorithms available so with optparse module it is possible to write something like : for __hashtype in ('md5', 'sha1', 'sha224','sha256','sha384','sha512'): __parser.add_option('--{}'.format(__hashtype), dest='hashtype', action='store_const', const='{}'.format(__hashtype), help='use the {} hash algorithm type'.format(__hashtype)) __options, _ = __parser.parse_args() And it would be better if this tuple could be provided by the hashlib module itself, making the code more evolutive.
msg99147 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2010-02-10 02:11
I'll be taking a look at this patch during the sprints at Pycon. Will get back to you soonish :-)
msg99155 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2010-02-10 05:21
I'll be taking a look at this patch during the sprints at Pycon. Will get back to you soonish :-)
msg100236 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2010-03-01 02:05
applied, it'll appear in 2.7 and 3.2. r78528 and r78529.
msg115684 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-09-06 01:49
Could the module also grow an attribute listing all available algos, or non-guaranteed algos? (Please tell me if I should open a new report.)
msg115688 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2010-09-06 03:19
Sounds like a good idea. frozensets for both.
msg115689 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-09-06 03:21
Thanks for the reply. Reopening. I cannot propose a patch since I don’t know how to introspect OpenSSL (or how to write C, for that matter).
msg115693 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2010-09-06 08:34
Implemented in py3k r84554.
msg115727 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-09-06 18:43
Great, thank you!
History
Date User Action Args
2022-04-11 14:56:55 admin set github: 51667
2010-09-06 18:43:24 eric.araujo set resolution: accepted -> fixedmessages: + stage: needs patch -> resolved
2010-09-06 08:34:47 gregory.p.smith set status: open -> closedmessages: +
2010-09-06 03:21:27 eric.araujo set status: closed -> openmessages: + stage: needs patch
2010-09-06 03:19:03 gregory.p.smith set messages: +
2010-09-06 01:49:46 eric.araujo set nosy: + eric.araujomessages: +
2010-03-01 02:05:40 gregory.p.smith set status: open -> closedresolution: acceptedmessages: +
2010-03-01 02:00:14 gregory.p.smith set assignee: rhettinger -> gregory.p.smithnosy: + gregory.p.smith
2010-02-10 09:28:14 pitrou set nosy: + gps
2010-02-10 05:21:25 rhettinger set messages: +
2010-02-10 02:11:27 rhettinger set messages: +
2009-12-24 12:07:59 chaica_ set messages: +
2009-12-02 09:05:53 chaica_ set files: + algorithms_constant_attribute_in_hashlib_module_update1.diffmessages: +
2009-12-02 09:01:52 chaica_ set files: - algorithms_constant_value_in_hashlib_module.diff
2009-12-02 08:58:45 chaica_ set files: + algorithms_constant_value_in_hashlib_module.diffmessages: +
2009-12-01 17:24:29 rhettinger set assignee: rhettingernosy: + rhettinger
2009-12-01 15:20:31 flox set nosy: + floxmessages: +
2009-12-01 14:04:27 chaica_ create