From 7d360fb0f7f1d9821e556bd1e1251bd958b4461d Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Tue, 20 Jan 2015 15:48:50 +0000 Subject: [PATCH] py26 and py3 compatibility updates. --- jira/client.py | 10 +++++----- setup.py | 9 ++++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/jira/client.py b/jira/client.py index 1b456f02b..263bb4a7b 100755 --- a/jira/client.py +++ b/jira/client.py @@ -56,9 +56,6 @@ # if encoding != 'UTF8': # warnings.warn("Python default encoding is '%s' instead of 'UTF8' which means that there is a big change of having problems. Possible workaround http://stackoverflow.com/a/17628350/99834" % encoding) -# we do want to log warrning from our code -logging.captureWarnings(True) - def translate_resource_args(func): """ @@ -217,8 +214,11 @@ def __init__(self, server=None, options=None, basic_auth=None, oauth=None, valid def _check_update_(self): # check if the current version of the library is outdated import json - import urllib2 - response = urllib2.urlopen( + try: + from urllib.request import urlopen + except ImportError: + from urllib2 import urlopen + response = urlopen( "http://pypi.python.org/pypi/jira/json") data = json.load(response) released_version = data['info']['version'] diff --git a/setup.py b/setup.py index 3af1e4c4a..cecc95fa1 100755 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ base_path = os.path.dirname(__file__) fp = open(os.path.join(base_path, NAME, 'version.py')) __version__ = re.compile(r".*__version__ = '(.*?)'", - re.S).match(fp.read()).group(1) + re.S).match(fp.read()).group(1) fp.close() @@ -91,8 +91,11 @@ def finalize_options(self): def run(self): import json - import urllib2 - response = urllib2.urlopen( + try: + from urllib.request import urlopen + except ImportError: + from urllib2 import urlopen + response = urlopen( "http://pypi.python.org/pypi/%s/json" % NAME) data = json.load(response) released_version = data['info']['version']