Skip to content

Commit 76e2734

Browse files
committed
Re-add Python 2.7 support and enable testing on PyPy3.5
This partially reverts commit 164dcc3.
1 parent 73dead9 commit 76e2734

File tree

9 files changed

+34
-24
lines changed

9 files changed

+34
-24
lines changed

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
sudo: false
12
language: python
23
matrix:
34
include:
5+
- python: 2.7
6+
env: TOXENV=py27
47
- python: 3.4
58
env: TOXENV=py34
69
- python: 3.5
@@ -10,6 +13,11 @@ matrix:
1013
- python: 3.7
1114
env: TOXENV=py37
1215
dist: xenial
16+
- python: pypy3.5
17+
env: TOXENV=pypy3
18+
allow_failures:
19+
- python: 2.7
20+
env: TOXENV=py27
1321

1422
install:
1523
- pip install tox

CONTRIBUTING.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Before you submit a pull request, check that it meets these guidelines:
101101
2. If the pull request adds functionality, the docs should be updated. Put
102102
your new functionality into a function with a docstring, and add the
103103
feature to the list in README.rst.
104-
3. The pull request should work for Python 3.4+ and PyPy. Check
104+
3. The pull request should work for Python 2.7, 3.4+ and PyPy3. Check
105105
https://travis-ci.org/multiformats/py-multiaddr/pull_requests
106106
and make sure that the tests pass for all supported Python versions.
107107

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ lint:
5252
flake8 multiaddr/* tests/*
5353

5454
test:
55-
TOXENV=py37 tox
55+
TOXENV=py27 tox
5656

5757
test-all:
5858
tox

docs/conf.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
master_doc = 'index'
5656

5757
# General information about the project.
58-
project = 'Multiaddr'
59-
copyright = '2016, Steven Buss'
58+
project = u'Multiaddr'
59+
copyright = u'2016, Steven Buss'
6060

6161
# The version info for the project you're documenting, acts as replacement
6262
# for |version| and |release|, also used in various other places throughout
@@ -209,8 +209,8 @@
209209
# [howto/manual]).
210210
latex_documents = [
211211
('index', 'multiaddr.tex',
212-
'Multiaddr Documentation',
213-
'Steven Buss', 'manual'),
212+
u'Multiaddr Documentation',
213+
u'Steven Buss', 'manual'),
214214
]
215215

216216
# The name of an image file (relative to this directory) to place at
@@ -240,8 +240,8 @@
240240
# (source start file, name, description, authors, manual section).
241241
man_pages = [
242242
('index', 'multiaddr',
243-
'Multiaddr Documentation',
244-
['Steven Buss'], 1)
243+
u'Multiaddr Documentation',
244+
[u'Steven Buss'], 1)
245245
]
246246

247247
# If true, show URL addresses after external links.
@@ -255,8 +255,8 @@
255255
# dir menu entry, description, category)
256256
texinfo_documents = [
257257
('index', 'multiaddr',
258-
'Multiaddr Documentation',
259-
'Steven Buss',
258+
u'Multiaddr Documentation',
259+
u'Steven Buss',
260260
'multiaddr',
261261
'One line description of project.',
262262
'Miscellaneous'),

multiaddr/multiaddr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ProtocolNotFoundException(Exception):
1313
pass
1414

1515

16-
class Multiaddr:
16+
class Multiaddr(object):
1717
"""Multiaddr is a representation of multiple nested internet addresses.
1818
1919
Multiaddr is a cross-protocol, cross-platform format for representing

multiaddr/protocols.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
LENGTH_PREFIXED_VAR_SIZE = -1
6868

6969

70-
class Protocol:
70+
class Protocol(object):
7171
__slots__ = [
7272
"code", # int
7373
"size", # int (-1 indicates a length-prefixed variable size)
@@ -77,13 +77,13 @@ class Protocol:
7777
]
7878

7979
def __init__(self, code, size, name, vcode, path=False):
80-
if not isinstance(code, int):
80+
if not isinstance(code, six.integer_types):
8181
raise ValueError("code must be an integer")
82-
if not isinstance(size, int):
82+
if not isinstance(size, six.integer_types):
8383
raise ValueError("size must be an integer")
84-
if not isinstance(name, str):
84+
if not isinstance(name, six.string_types):
8585
raise ValueError("name must be a string")
86-
if not isinstance(vcode, bytes):
86+
if not isinstance(vcode, six.binary_type):
8787
raise ValueError("vcode must be binary")
8888
if not isinstance(path, bool):
8989
raise ValueError("path must be a boolean")
@@ -179,8 +179,8 @@ def read_varint_code(buf):
179179
Protocol(P_UNIX, LENGTH_PREFIXED_VAR_SIZE, 'unix', code_to_varint(P_UNIX), path=True),
180180
]
181181

182-
_names_to_protocols = {proto.name: proto for proto in PROTOCOLS}
183-
_codes_to_protocols = {proto.code: proto for proto in PROTOCOLS}
182+
_names_to_protocols = dict((proto.name, proto) for proto in PROTOCOLS)
183+
_codes_to_protocols = dict((proto.code, proto) for proto in PROTOCOLS)
184184

185185

186186
def add_protocol(proto):

setup.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,20 @@
3636
license='MIT License',
3737
zip_safe=False,
3838
keywords='multiaddr',
39-
python_requires='>=3.4',
39+
python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*',
4040
classifiers=[
4141
'Development Status :: 2 - Pre-Alpha',
4242
'Intended Audience :: Developers',
4343
'License :: OSI Approved :: MIT License',
4444
'Natural Language :: English',
45+
'Programming Language :: Python :: 2',
46+
'Programming Language :: Python :: 2.7',
4547
'Programming Language :: Python :: 3',
48+
'Programming Language :: Python :: 3.3',
4649
'Programming Language :: Python :: 3.4',
4750
'Programming Language :: Python :: 3.5',
4851
'Programming Language :: Python :: 3.6',
4952
'Programming Language :: Python :: 3.7',
50-
'Programming Language :: Python :: 3 :: Only',
5153
],
5254
setup_requires=[
5355
'pytest-runner',

tests/test_protocols.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def test_invalid_name(valid_params, invalid_name):
5353
protocols.Protocol(**valid_params)
5454

5555

56-
@pytest.mark.parametrize("invalid_vcode", [3, 'a3'])
56+
@pytest.mark.parametrize("invalid_vcode", [3, u'a3'])
5757
def test_invalid_vcode(valid_params, invalid_vcode):
5858
valid_params['vcode'] = invalid_vcode
5959
with pytest.raises(ValueError):
@@ -67,7 +67,7 @@ def test_invalid_path(valid_params, invalid_path):
6767
protocols.Protocol(**valid_params)
6868

6969

70-
@pytest.mark.parametrize("name", ["foo-str", "foo-u"])
70+
@pytest.mark.parametrize("name", ["foo-str", u"foo-u"])
7171
def test_valid_names(valid_params, name):
7272
valid_params['name'] = name
7373
test_valid(valid_params)

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[tox]
2-
envlist = py34, py35, py36, py37
2+
envlist = py27, py34, py35, py36, py37, pypy3
33

44
[testenv]
55
setenv =
66
PYTHONPATH = {toxinidir}:{toxinidir}/multiaddr
7-
commands = pytest --cov=./
7+
commands = py.test --cov=./
88

99
; If you want to make tox run the tests with the same versions, create a
1010
; requirements.txt with the pinned versions and uncomment the following lines:

0 commit comments

Comments
 (0)