else:
raise ImportError("The required _crypt module was not built as part of CPython")
+import errno
import string as _string
from random import SystemRandom as _SystemRandom
from collections import namedtuple as _namedtuple
method = _Method(name, *args)
globals()['METHOD_' + name] = method
salt = mksalt(method, rounds=rounds)
- result = crypt('', salt)
+ result = None
+ try:
+ result = crypt('', salt)
+ except OSError as e:
+ # Not all libc libraries support all encryption methods.
+ if e.errno == errno.EINVAL:
+ return False
+ raise
if result and len(result) == method.total_size:
methods.append(method)
return True
#else
crypt_result = crypt(word, salt);
#endif
+ if (crypt_result == NULL) {
+ return PyErr_SetFromErrno(PyExc_OSError);
+ }
return Py_BuildValue("s", crypt_result);
}