Merge pull request #220 from rctay/rc/191-ssl-gae
googleapiclient.http: guard when importing ssl.
diff --git a/googleapiclient/http.py b/googleapiclient/http.py
index ed074cb..f9d6a55 100644
--- a/googleapiclient/http.py
+++ b/googleapiclient/http.py
@@ -38,11 +38,18 @@
import os
import random
import socket
-import ssl
import sys
import time
import uuid
+# TODO(issue 221): Remove this conditional import jibbajabba.
+try:
+ import ssl
+except ImportError:
+ _ssl_SSLError = object()
+else:
+ _ssl_SSLError = ssl.SSLError
+
from email.generator import Generator
from email.mime.multipart import MIMEMultipart
from email.mime.nonmultipart import MIMENonMultipart
@@ -146,7 +153,7 @@
exception = None
resp, content = http.request(uri, method, *args, **kwargs)
# Retry on SSL errors and socket timeout errors.
- except ssl.SSLError as ssl_error:
+ except _ssl_SSLError as ssl_error:
exception = ssl_error
except socket.error as socket_error:
# errno's contents differ by platform, so we have to match by name.