diff --git a/src/foolscap/banana.py b/src/foolscap/banana.py index 77b1a81..5ada2b3 100644 --- a/src/foolscap/banana.py +++ b/src/foolscap/banana.py @@ -22,7 +22,7 @@ def int2b128(integer, stream): if integer == 0: - stream(six.int2byte(0)) + stream(b'\0') return assert integer > 0, "can only encode positive integers" while integer: diff --git a/src/foolscap/copyable.py b/src/foolscap/copyable.py index 13377d6..ba9c9a7 100644 --- a/src/foolscap/copyable.py +++ b/src/foolscap/copyable.py @@ -340,8 +340,7 @@ class RemoteCopyOldStyle(_RemoteCopyBase): # classes do not do metaclass magic copytype = None -@six.add_metaclass(RemoteCopyClass) -class RemoteCopy(_RemoteCopyBase, object): +class RemoteCopy(_RemoteCopyBase, metaclass=RemoteCopyClass): # Set 'copytype' to a unique string that is shared between the # sender-side Copyable and the receiver-side RemoteCopy. This RemoteCopy # subclass will be auto-registered using the 'copytype' name. Set diff --git a/src/foolscap/pb.py b/src/foolscap/pb.py index 236b089..b80e2ba 100644 --- a/src/foolscap/pb.py +++ b/src/foolscap/pb.py @@ -513,7 +513,7 @@ def listenOn(self, what, _test_options={}): "port numbers instead") warn(warningString, DeprecationWarning, stacklevel=2) - if isinstance(what, six.string_types) and re.search(r"^\d+$", what): + if isinstance(what, str) and re.search(r"^\d+$", what): warn("Tub.listenOn('12345') was deprecated " "in Foolscap 0.12.0; please use qualified endpoint " "descriptions like 'tcp:12345'", diff --git a/src/foolscap/remoteinterface.py b/src/foolscap/remoteinterface.py index 7e6111d..9de55b6 100644 --- a/src/foolscap/remoteinterface.py +++ b/src/foolscap/remoteinterface.py @@ -1,5 +1,4 @@ -import six import types import inspect from zope.interface import interface, providedBy, implementer @@ -414,5 +413,5 @@ def _makeConstraint(t): # See # https://github.com/warner/foolscap/pull/76/commits/ff3b9e8c1e4fa13701273a2143ba80b1e58f47cf#r549428977 # for more background on the use of add_metaclass here. -class RemoteInterface(six.with_metaclass(RemoteInterfaceClass, interface.Interface)): +class RemoteInterface(interface.Interface, metaclass=RemoteInterfaceClass): pass diff --git a/src/foolscap/slicer.py b/src/foolscap/slicer.py index 40651f4..d2f2196 100644 --- a/src/foolscap/slicer.py +++ b/src/foolscap/slicer.py @@ -19,9 +19,8 @@ def __init__(self, name, bases, dict): if typ: registerAdapter(self, typ, tokens.ISlicer) -@six.add_metaclass(SlicerClass) @implementer(tokens.ISlicer) -class BaseSlicer(object): +class BaseSlicer(metaclass=SlicerClass): slices = None parent = None @@ -146,9 +145,8 @@ def __init__(self, name, bases, dict): if opentype: registerUnslicer(opentype, self, reg) -@six.add_metaclass(UnslicerClass) @implementer(tokens.IUnslicer) -class BaseUnslicer(object): +class BaseUnslicer(metaclass=UnslicerClass): opentype = None def __init__(self): diff --git a/src/foolscap/test/test_banana.py b/src/foolscap/test/test_banana.py index f15baf8..85409aa 100644 --- a/src/foolscap/test/test_banana.py +++ b/src/foolscap/test/test_banana.py @@ -142,7 +142,7 @@ def untokenize(tokens): elif isinstance(t, float): data.append(FLOAT) data.append(struct.pack("!d", t)) - elif isinstance(t, six.string_types) or isinstance(t, bytes): + elif isinstance(t, (str, bytes)): t = six.ensure_binary(t) int2b128(len(t), data.append) data.append(STRING) diff --git a/src/foolscap/tokens.py b/src/foolscap/tokens.py index 9865606..3d87af9 100644 --- a/src/foolscap/tokens.py +++ b/src/foolscap/tokens.py @@ -1,25 +1,24 @@ -import six from twisted.python.failure import Failure from zope.interface import Attribute, Interface # delimiter characters. -LIST = six.int2byte(0x80) # old -INT = six.int2byte(0x81) -STRING = six.int2byte(0x82) -NEG = six.int2byte(0x83) -FLOAT = six.int2byte(0x84) +LIST = b'\x80' # old +INT = b'\x81' +STRING = b'\x82' +NEG = b'\x83' +FLOAT = b'\x84' # "optional" -- these might be refused by a low-level implementation. -LONGINT = six.int2byte(0x85) # old -LONGNEG = six.int2byte(0x86) # old +LONGINT = b'\x85' # old +LONGNEG = b'\x86' # old # really optional; this is is part of the 'pb' vocabulary -VOCAB = six.int2byte(0x87) +VOCAB = b'\x87' # newbanana tokens -OPEN = six.int2byte(0x88) -CLOSE = six.int2byte(0x89) -ABORT = six.int2byte(0x8A) -ERROR = six.int2byte(0x8D) -PING = six.int2byte(0x8E) -PONG = six.int2byte(0x8F) +OPEN = b'\x88' +CLOSE = b'\x89' +ABORT = b'\x8A' +ERROR = b'\x8D' +PING = b'\x8E' +PONG = b'\x8F' tokenNames = { LIST: "LIST",