From fb62ca3fb2bece331ea35b1de9ddc81b39b3276e Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Sat, 8 Sep 2012 19:17:16 +0200 Subject: [PATCH] Support Python 2.5 again (issue #73) --- github/Requester.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/github/Requester.py b/github/Requester.py index 72416785..c1ede174 100644 --- a/github/Requester.py +++ b/github/Requester.py @@ -15,10 +15,13 @@ import httplib import base64 import urllib import urlparse +import sys -try: +atLeastPython26 = sys.hexversion >= 0x02060000 + +if atLeastPython26: import json -except ImportError: #pragma no cover: only for Python 2.5 +else: #pragma no cover import simplejson as json #pragma no cover import GithubException @@ -78,7 +81,10 @@ class Requester: if self.__authorizationHeader is not None: headers[ "Authorization" ] = self.__authorizationHeader - cnx = self.__connectionClass( host = self.__hostname, port = self.__port, strict = True, timeout = self.__timeout ) + if atLeastPython26: + cnx = self.__connectionClass( host = self.__hostname, port = self.__port, strict = True, timeout = self.__timeout ) + else: #pragma no cover + cnx = self.__connectionClass( host = self.__hostname, port = self.__port, strict = True ) #pragma no cover cnx.request( verb, self.__completeUrl( url, parameters ),