From f4e725f224b864bf9bf405ff7f863cda46fca1cd Mon Sep 17 00:00:00 2001 From: shireenrao Date: Thu, 8 Aug 2019 16:02:49 -0400 Subject: bpo-25172: Raise appropriate ImportError msg when crypt module used on Windows (GH-15149) --- Lib/crypt.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'Lib/crypt.py') diff --git a/Lib/crypt.py b/Lib/crypt.py index b0e47f430c..8846602d76 100644 --- a/Lib/crypt.py +++ b/Lib/crypt.py @@ -1,6 +1,15 @@ """Wrapper to the POSIX crypt library call and associated functionality.""" -import _crypt +import sys as _sys + +try: + import _crypt +except ModuleNotFoundError: + if _sys.platform == 'win32': + raise ImportError("The crypt module is not supported on Windows") + else: + raise ImportError("The required _crypt module was not built as part of CPython") + import string as _string from random import SystemRandom as _SystemRandom from collections import namedtuple as _namedtuple -- cgit v1.2.1