Commits

Denis Bilenko committed 770814c

test_ssl.py: do not use ImportError to detect python3. do the right import from the start.

Comments (0)

Files changed (1)

greentest/test_ssl.py

 import errno
 import pprint
 
-try:
+if sys.version_info[0] == 3:
     from urllib import request as urllib
-except:
+    from urllib import parse as urlparse
+    from http.server import HTTPServer, SimpleHTTPRequestHandler
+else:
     import urllib
-
-try:
     import urlparse
-except ImportError:
-    from urllib import parse as urlparse
+    from BaseHTTPServer import HTTPServer
+    from SimpleHTTPServer import SimpleHTTPRequestHandler
 
 import traceback
 import weakref
 
 try:
-    from BaseHTTPServer import HTTPServer
-    from SimpleHTTPServer import SimpleHTTPRequestHandler
-except ImportError:
-    from http.server import HTTPServer, SimpleHTTPRequestHandler
-
-try:
     bytearray
 except NameError:
     bytearray = None