raise the import error exception when package is missing
authorrichardpenman
Tue, 22 May 2018 11:09:53 -0400
changeset 178 06e9b88e0c20
parent 177 7030835bcf5e
child 180 08cfbab35d0b
raise the import error exception when package is missing
whois/whois.py
--- a/whois/whois.py	Tue May 08 08:47:28 2018 -0400
+++ b/whois/whois.py	Tue May 22 11:09:53 2018 -0400
@@ -100,11 +100,10 @@
         if "SOCKS" in os.environ:
              try:
                   import socks
-             except Exception as e:
-                  print(str(e))
-                  print("You need to install the Python socks module.  Install PIP (https://bootstrap.pypa.io/get-pip.py).  Then 'pip install PySocks' ")
-                  sys.exit(0)
-             socksproxy,port = os.environ["SOCKS"].split(":")
+             except ImportError as e:
+                  print("You need to install the Python socks module. Install PIP (https://bootstrap.pypa.io/get-pip.py) and then 'pip install PySocks'")
+                  raise e
+             socksproxy, port = os.environ["SOCKS"].split(":")
              s = socks.socksocket()
              s.set_proxy(socks.SOCKS5, socksproxy, int(port))
         else: