From e9a975d9c4915b202bae85f7192f7aae9c581700 Mon Sep 17 00:00:00 2001 From: Rick Hanlon II Date: Wed, 29 Jul 2015 19:13:50 -0400 Subject: [PATCH 1/4] Update README to only support python 2.5+ --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3dca1e34..870d69ca 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ This code was originally forked from [Leah Culver and Andy Smith's oauth.py code](http://github.com/leah/python-oauth/). Some of the tests come from a [fork by Vic Fryzel](http://github.com/shellsage/python-oauth), while a revamped Request class and more tests were merged in from [Mark Paschal's fork](http://github.com/markpasc/python-oauth). A number of notable differences exist between this code and its forefathers: +* Compatible with Python 2.5+. * 100% unit test coverage. * The DataStore object has been completely ripped out. While creating unit tests for the library I found several substantial bugs with the implementation and confirmed with Andy Smith that it was never fully baked. * Classes are no longer prefixed with OAuth. * The Request class now extends from dict. -* The library is likely no longer compatible with Python 2.3. * The Client class works and extends from httplib2. It's a thin wrapper that handles automatically signing any normal HTTP request you might wish to make. # Signing a Request From 36d4e82a37ac79819b9ef53f413beafdb7e9ac97 Mon Sep 17 00:00:00 2001 From: Rick Hanlon II Date: Fri, 31 Jul 2015 14:27:47 -0400 Subject: [PATCH 2/4] Update README to support 2.6 and up --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 870d69ca..8302c807 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This code was originally forked from [Leah Culver and Andy Smith's oauth.py code](http://github.com/leah/python-oauth/). Some of the tests come from a [fork by Vic Fryzel](http://github.com/shellsage/python-oauth), while a revamped Request class and more tests were merged in from [Mark Paschal's fork](http://github.com/markpasc/python-oauth). A number of notable differences exist between this code and its forefathers: -* Compatible with Python 2.5+. +* Compatible with Python 2.6 and up. * 100% unit test coverage. * The DataStore object has been completely ripped out. While creating unit tests for the library I found several substantial bugs with the implementation and confirmed with Andy Smith that it was never fully baked. * Classes are no longer prefixed with OAuth. From d49874ffdca6d882186dada4c035d2323264f14f Mon Sep 17 00:00:00 2001 From: Rick Hanlon II Date: Fri, 31 Jul 2015 14:29:29 -0400 Subject: [PATCH 3/4] Remove support for pre-python 2.5 libraries --- oauth2/__init__.py | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/oauth2/__init__.py b/oauth2/__init__.py index 835270e3..9daf7ea7 100644 --- a/oauth2/__init__.py +++ b/oauth2/__init__.py @@ -31,19 +31,8 @@ import binascii import httplib2 -try: - from urlparse import parse_qs - parse_qs # placate pyflakes -except ImportError: - # fall back for Python 2.5 - from cgi import parse_qs - -try: - from hashlib import sha1 - sha = sha1 -except ImportError: - # hashlib was added in Python 2.5 - import sha +from urlparse import parse_qs +from hashlib import sha1 as sha import _version From f1426938512828e761d3bfab2ec4ca87062c3495 Mon Sep 17 00:00:00 2001 From: Rick Hanlon II Date: Fri, 31 Jul 2015 14:30:48 -0400 Subject: [PATCH 4/4] Use 2.6+ style exception syntax --- oauth2/__init__.py | 8 ++++---- tests/test_oauth.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/oauth2/__init__.py b/oauth2/__init__.py index 9daf7ea7..1a629c39 100644 --- a/oauth2/__init__.py +++ b/oauth2/__init__.py @@ -91,7 +91,7 @@ def to_unicode(s): raise TypeError('You are required to pass either unicode or string here, not: %r (%s)' % (type(s), s)) try: s = s.decode('utf-8') - except UnicodeDecodeError, le: + except UnicodeDecodeError as le: raise TypeError('You are required to pass either a unicode object or a utf-8 string here. You passed a Python string object which contained non-utf-8: %r. The UnicodeDecodeError that resulted from attempting to interpret it as utf-8 was: %s' % (s, le,)) return s @@ -120,7 +120,7 @@ def to_unicode_optional_iterator(x): try: l = list(x) - except TypeError, e: + except TypeError as e: assert 'is not iterable' in str(e) return x else: @@ -136,7 +136,7 @@ def to_utf8_optional_iterator(x): try: l = list(x) - except TypeError, e: + except TypeError as e: assert 'is not iterable' in str(e) return x else: @@ -449,7 +449,7 @@ def get_normalized_parameters(self): else: try: value = list(value) - except TypeError, e: + except TypeError as e: assert 'is not iterable' in str(e) items.append((to_utf8_if_string(key), to_utf8_if_string(value))) else: diff --git a/tests/test_oauth.py b/tests/test_oauth.py index 099e5794..f8a74482 100644 --- a/tests/test_oauth.py +++ b/tests/test_oauth.py @@ -49,19 +49,19 @@ class TestError(unittest.TestCase): def test_message(self): try: raise oauth.Error - except oauth.Error, e: + except oauth.Error as e: self.assertEqual(e.message, 'OAuth error occurred.') msg = 'OMG THINGS BROKE!!!!' try: raise oauth.Error(msg) - except oauth.Error, e: + except oauth.Error as e: self.assertEqual(e.message, msg) def test_str(self): try: raise oauth.Error - except oauth.Error, e: + except oauth.Error as e: self.assertEquals(str(e), 'OAuth error occurred.') class TestGenerateFunctions(unittest.TestCase): @@ -286,7 +286,7 @@ def test_deleter(self): self.fail("AttributeError should have been raised on empty url.") except AttributeError: pass - except Exception, e: + except Exception as e: self.fail(str(e)) def test_url(self):