Skip to content

Commit f2647c9

Browse files
committed
Drop restriction that newly created protocol objects must using a known protocol code
1 parent e3bd4bd commit f2647c9

File tree

4 files changed

+2
-13
lines changed

4 files changed

+2
-13
lines changed

multiaddr/codecs/onion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def to_bytes(proto, string):
2626
try:
2727
port = int(addr[1], 10)
2828
except ValueError as exc:
29-
six.raise_from(ValueError("Port number is not an integer"), exc)
29+
six.raise_from(ValueError("Port number is not a base 10 integer"), exc)
3030
if port not in range(1, 65536):
3131
raise ValueError("Port number is not in range(1, 65536)")
3232

multiaddr/multiaddr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Multiaddr(object):
1616
Multiaddr is a cross-protocol, cross-platform format for representing
1717
internet addresses. It emphasizes explicitness and self-description.
1818
19-
Learn more here: http://multiformats.io/multiaddr/
19+
Learn more here: https://multiformats.io/multiaddr/
2020
2121
Multiaddrs have both a binary and string representation.
2222

multiaddr/protocols.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,6 @@ def __init__(self, code, name, codec):
8383
if not isinstance(codec, six.string_types) and not codec is None:
8484
raise TypeError("codec must be a string or None")
8585

86-
#XXX: Why does this exist!?
87-
if code not in _CODES and code != 0:
88-
raise exceptions.ProtocolNotFoundError(code, "code")
89-
9086
self.code = code
9187
self.name = name
9288
self.codec = codec

tests/test_protocols.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,6 @@ def test_invalid_code(valid_params, invalid_code):
3838
with pytest.raises(TypeError):
3939
protocols.Protocol(**valid_params)
4040

41-
@pytest.mark.parametrize("unknown_code", [123])
42-
def test_unknown_code(valid_params, unknown_code):
43-
assert unknown_code not in protocols._CODES
44-
valid_params['code'] = unknown_code
45-
with pytest.raises(exceptions.ProtocolNotFoundError):
46-
protocols.Protocol(**valid_params)
47-
4841

4942
@pytest.mark.parametrize("invalid_name", [123, 1.0])
5043
def test_invalid_name(valid_params, invalid_name):

0 commit comments

Comments
 (0)