From c0f420bf7d7659ee110432f7cbb0233554dfd32a Mon Sep 17 00:00:00 2001 From: Eli Collins Date: Thu, 12 Apr 2012 21:52:26 -0400 Subject: assorted bugfixes, tweaks, and tests added; based on coverage examination * test os_crypt backend has functional fallback * test handler methods accept all unicode/bytes combinations for secret & hash * fixed some incorrect error messages & types being caught & raised * other minor cleanups --- passlib/handlers/md5_crypt.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'passlib/handlers/md5_crypt.py') diff --git a/passlib/handlers/md5_crypt.py b/passlib/handlers/md5_crypt.py index 9441bbc..c963155 100644 --- a/passlib/handlers/md5_crypt.py +++ b/passlib/handlers/md5_crypt.py @@ -68,14 +68,13 @@ def _raw_md5_crypt(pwd, salt, use_apr=False): #===================================================================== #validate secret + # XXX: not sure what official unicode policy is, using this as default if isinstance(pwd, unicode): - # XXX: not sure what official unicode policy is, using this as default pwd = pwd.encode("utf-8") - elif not isinstance(pwd, bytes): - raise TypeError("password must be bytes or unicode") + assert isinstance(pwd, bytes), "pwd not unicode or bytes" pwd_len = len(pwd) - #validate salt + #validate salt - should have been taken care of by caller assert isinstance(salt, unicode), "salt not unicode" salt = salt.encode("ascii") assert len(salt) < 9, "salt too large" -- cgit v1.2.1