Skip to content

Commit 3f13d37

Browse files
committed
Additional Python 3 compatibility fixes
1 parent ff41a57 commit 3f13d37

File tree

8 files changed

+19
-13
lines changed

8 files changed

+19
-13
lines changed

.travis.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ language: python
22
python:
33
- "2.6"
44
- "2.7"
5+
- "3.2"
6+
- "3.3"
7+
- "3.4"
58
install:
6-
- pip install -r requirements/dev.txt --use-mirrors
9+
- pip install -r requirements/dev.txt
10+
- if [[ $TRAVIS_PYTHON_VERSION == 2* ]]; then pip install unittest2; fi
711
script: nosetests

pygithub3/core/json/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
except ImportError:
1010
import json
1111

12+
import six
13+
1214
GITHUB_DATE_FORMAT = '%Y-%m-%dT%H:%M:%SZ'
1315

1416

@@ -21,7 +23,7 @@ def default(self, o):
2123

2224

2325
def gh_decoder_hook(dict_):
24-
for k, v in dict_.iteritems():
26+
for k, v in six.iteritems(dict_):
2527
try:
2628
date = datetime.strptime(v, GITHUB_DATE_FORMAT)
2729
dict_[k] = date

pygithub3/core/result/link.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
#!/usr/bin/env python
22
# -*- encoding: utf-8 -*-
33

4-
try:
5-
# Python 3
6-
from urllib.parse import urlparse, parse_qs
7-
except ImportError:
8-
from urlparse import urlparse, parse_qs
9-
4+
from six.moves.urllib.parse import urlparse, parse_qs
105

116
from pygithub3.core.third_libs.link_header import parse_link_value
127

pygithub3/core/result/smart.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env python
22
# -*- encoding: utf-8 -*-
33

4+
import six
5+
46
from . import base
57
from .link import Link
68

@@ -105,6 +107,6 @@ def get_page(self, page):
105107
106108
:param int page: Page number
107109
"""
108-
if page in range(1, self.pages + 1):
110+
if page in six.moves.range(1, self.pages + 1):
109111
return base.Page(self.getter, page)
110112
return None

pygithub3/requests/users/emails.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
import re
55

6+
import six
7+
68
from . import Request, ValidationError
79

810
# Src: http://code.djangoproject.com/svn/django/trunk/django/core/validators.py
@@ -30,7 +32,7 @@ def is_email(email):
3032
raise ValidationError("'%s' request needs emails"
3133
% (self.__class__.__name__))
3234

33-
return tuple([ele for ele in self.body if is_email(ele)])
35+
return tuple(six.moves.filter(is_email, self.body))
3436

3537

3638
class Delete(Request):

pygithub3/tests/core/test_json.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class TestJson(TestCase):
2020
json_ = '{"date_fake": "some_fake", "list": [1, 2, 3], "date_ok": "2008-01-14T04:33:35Z", "nested_dict": {"with_date": "2008-01-14T04:33:35Z"}}'
2121

2222
def test_encoder(self):
23-
to_json = json.dumps(self.dict_)
24-
self.assertEquals(to_json, self.json_)
23+
dict_ = json.loads(json.dumps(self.dict_))
24+
self.assertEquals(self.dict_, dict_)
2525

2626
def test_decoder(self):
2727
to_dict = json.loads(self.json_)

requirements/dev.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22

33
nose
44
mock
5-
unittest2
65
sphinx

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
'Programming Language :: Python :: 2.7',
3939
'Programming Language :: Python :: 3',
4040
'Programming Language :: Python :: 3.2',
41+
'Programming Language :: Python :: 3.3',
42+
'Programming Language :: Python :: 3.4',
4143
'License :: OSI Approved :: ISC License (ISCL)',
4244
'Operating System :: OS Independent',
4345
'Development Status :: 2 - Pre-Alpha',

0 commit comments

Comments
 (0)