Skip to content

Commit e3bc72d

Browse files
committed
Some basic Python 3 fixes
Summary: - Add 'six>=1.4.1' to dependencies (for six.moves.urllib.parse) - Explicit relative imports - Replace sys.maxint with 2**64-1 (maybe we should do something smarter?) - Replace deprecated 'except' syntax with 'except...as' - Mandatory parens around the argument to print() Test Plan: The Flask server now starts under Python 3.4.1. I haven't tested it beyond that yet. Reviewers: charles Reviewed By: charles Differential Revision: https://review.inboxapp.com/D372
1 parent c71a798 commit e3bc72d

7 files changed

Lines changed: 13 additions & 10 deletions

File tree

examples/server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ def index():
5151
try:
5252
# Get the latest message from namespace zero.
5353
message = client.namespaces[0].messages.first()
54-
except Exception, e:
55-
print e.message
54+
except Exception as e:
55+
print(e.message)
5656

5757
# Format the output
5858
text = "<html><h1>Here's a message from your Inbox:</h1><b>From:</b> "

inbox/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from client import APIClient
1+
from .client import APIClient
22

33
__all__ = ['APIClient']

inbox/client.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import requests
2+
import six
23
import json
34
from base64 import b64encode
45
from collections import namedtuple
5-
from urllib import urlencode
6-
from util import url_concat, generate_id
7-
from restful_model_collection import RestfulModelCollection
8-
from models import Namespace
6+
from six.moves.urllib.parse import urlencode
7+
from .util import url_concat, generate_id
8+
from .restful_model_collection import RestfulModelCollection
9+
from .models import Namespace
910

1011
API_SERVER = "https://api.inboxapp.com"
1112

inbox/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from restful_model_collection import RestfulModelCollection
1+
from .restful_model_collection import RestfulModelCollection
22

33

44
class InboxAPIObject(dict):

inbox/restful_model_collection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from sys import maxint
21
from copy import deepcopy
32

43
CHUNK_SIZE = 50
@@ -32,6 +31,7 @@ def first(self):
3231
return self._get_model_collection(0, 1)[0]
3332

3433
def all(self):
34+
maxint = 2**64-1 # XXX
3535
return self.range(0, maxint)
3636

3737
def where(self, **kwargs):

inbox/util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from urllib import urlencode
1+
import six
2+
from six.moves.urllib.parse import urlencode
23
from uuid import uuid4
34
from struct import unpack
45

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
install_requires = [
99
"requests>=2.3.0",
10+
"six>=1.4.1",
1011
],
1112
dependency_links = [],
1213

0 commit comments

Comments
 (0)