aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2011-02-22 21:55:51 +0000
committerBrett Cannon <bcannon@gmail.com>2011-02-22 21:55:51 +0000
commitcfbcdbbbf2020e6719b368ef5701d2c90b938c4f (patch)
treec7f1ac9b8c3b28959ab1bbcaad2f50b847d84a13 /Lib/crypt.py
parentMake Lib/crypt.py meet PEP 8 standards. This also led to a tweak in the new API (diff)
downloadcpython-cfbcdbbbf2020e6719b368ef5701d2c90b938c4f.tar.gz
cpython-cfbcdbbbf2020e6719b368ef5701d2c90b938c4f.tar.bz2
cpython-cfbcdbbbf2020e6719b368ef5701d2c90b938c4f.zip
A crypt algorithm may not be available by returning None.
Diffstat (limited to 'Lib/crypt.py')
-rw-r--r--Lib/crypt.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/crypt.py b/Lib/crypt.py
index e027d2c92c3..e65b0cbe4d4 100644
--- a/Lib/crypt.py
+++ b/Lib/crypt.py
@@ -53,5 +53,10 @@ METHOD_MD5 = _Method('MD5', '1', 8, 34)
METHOD_SHA256 = _Method('SHA256', '5', 16, 63)
METHOD_SHA512 = _Method('SHA512', '6', 16, 106)
-methods = [METHOD_SHA512, METHOD_SHA256, METHOD_MD5, METHOD_CRYPT]
-methods[:-1] = [m for m in methods[:-1] if len(crypt('', m)) == m.total_size]
+methods = []
+for _method in (METHOD_SHA512, METHOD_SHA256, METHOD_MD5):
+ _result = crypt('', _method)
+ if _result and len(_result) == _method.total_size:
+ methods.append(_method)
+methods.append(METHOD_CRYPT)
+del _result, _method