From 2243ce3187f3519ff2e92a46202e983f1fdcb91d Mon Sep 17 00:00:00 2001 From: Alexandre Detiste Date: Wed, 28 Feb 2024 01:07:08 +0100 Subject: [PATCH] remove "from past.builtins import long" --- src/allmydata/interfaces.py | 3 +-- src/allmydata/introducer/client.py | 4 +--- src/allmydata/introducer/server.py | 3 +-- src/allmydata/test/mutable/util.py | 6 ++---- src/allmydata/test/test_dirnode.py | 4 +--- src/allmydata/test/test_humanreadable.py | 4 +--- src/allmydata/test/test_spans.py | 11 +++-------- src/allmydata/test/test_time_format.py | 4 +--- src/allmydata/util/netstring.py | 4 +--- src/allmydata/web/status.py | 4 +--- 10 files changed, 13 insertions(+), 34 deletions(-) diff --git a/src/allmydata/interfaces.py b/src/allmydata/interfaces.py index 96fccb958..1cfbb577e 100644 --- a/src/allmydata/interfaces.py +++ b/src/allmydata/interfaces.py @@ -8,7 +8,6 @@ Note that for RemoteInterfaces, the __remote_name__ needs to be a native string from future.utils import native_str -from past.builtins import long from typing import Dict from zope.interface import Interface, Attribute @@ -2774,7 +2773,7 @@ class RIEncryptedUploadable(RemoteInterface): return Offset def get_all_encoding_parameters(): - return (int, int, int, long) + return (int, int, int, int) def read_encrypted(offset=Offset, length=ReadSize): return ListOf(bytes) diff --git a/src/allmydata/introducer/client.py b/src/allmydata/introducer/client.py index e6eab3b9f..fd605dd1d 100644 --- a/src/allmydata/introducer/client.py +++ b/src/allmydata/introducer/client.py @@ -2,8 +2,6 @@ Ported to Python 3. """ -from past.builtins import long - from six import ensure_text, ensure_str import time @@ -304,7 +302,7 @@ class IntroducerClient(service.Service, Referenceable): if "seqnum" in old: # must beat previous sequence number to replace if ("seqnum" not in ann - or not isinstance(ann["seqnum"], (int,long))): + or not isinstance(ann["seqnum"], int)): self.log("not replacing old announcement, no valid seqnum: %s" % (ann,), parent=lp2, level=log.NOISY, umid="zFGH3Q") diff --git a/src/allmydata/introducer/server.py b/src/allmydata/introducer/server.py index 157a1b73c..10048c55e 100644 --- a/src/allmydata/introducer/server.py +++ b/src/allmydata/introducer/server.py @@ -4,7 +4,6 @@ Ported to Python 3. from __future__ import annotations -from past.builtins import long from six import ensure_text import time, os.path, textwrap @@ -262,7 +261,7 @@ class IntroducerService(service.MultiService, Referenceable): # type: ignore[mi if "seqnum" in old_ann: # must beat previous sequence number to replace if ("seqnum" not in ann - or not isinstance(ann["seqnum"], (int,long))): + or not isinstance(ann["seqnum"], int)): self.log("not replacing old ann, no valid seqnum", level=log.NOISY, umid="ySbaVw") self._debug_counts["inbound_no_seqnum"] += 1 diff --git a/src/allmydata/test/mutable/util.py b/src/allmydata/test/mutable/util.py index 5a2a6a8f8..fd1fc2970 100644 --- a/src/allmydata/test/mutable/util.py +++ b/src/allmydata/test/mutable/util.py @@ -4,8 +4,6 @@ Ported to Python 3. from future.utils import bchr -from past.builtins import long - from io import BytesIO import attr from twisted.internet import defer, reactor @@ -129,8 +127,8 @@ class FakeStorageServer(object): continue vector = response[shnum] = [] for (offset, length) in readv: - assert isinstance(offset, (int, long)), offset - assert isinstance(length, (int, long)), length + assert isinstance(offset, int), offset + assert isinstance(length, int), length vector.append(shares[shnum][offset:offset+length]) return response d.addCallback(_read) diff --git a/src/allmydata/test/test_dirnode.py b/src/allmydata/test/test_dirnode.py index 2ef57b0af..30fba005f 100644 --- a/src/allmydata/test/test_dirnode.py +++ b/src/allmydata/test/test_dirnode.py @@ -3,8 +3,6 @@ Ported to Python 3. """ -from past.builtins import long - import time import unicodedata from zope.interface import implementer @@ -1854,7 +1852,7 @@ class DeepStats(testutil.ReallyEqualMixin, unittest.TestCase): (101, 316, 216), (317, 1000, 684), (1001, 3162, 99), - (long(3162277660169), long(10000000000000), 1), + (3162277660169, 10000000000000, 1), ]) class UCWEingMutableFileNode(MutableFileNode): diff --git a/src/allmydata/test/test_humanreadable.py b/src/allmydata/test/test_humanreadable.py index 1ae95145e..277abc283 100644 --- a/src/allmydata/test/test_humanreadable.py +++ b/src/allmydata/test/test_humanreadable.py @@ -4,8 +4,6 @@ Tests for allmydata.util.humanreadable. This module has been ported to Python 3. """ -from past.builtins import long - from twisted.trial import unittest from allmydata.util import humanreadable @@ -26,7 +24,7 @@ class HumanReadable(unittest.TestCase): self.assertRegex(hr(foo), r"") self.failUnlessEqual(hr(self.test_repr), ">") - self.failUnlessEqual(hr(long(1)), "1") + self.failUnlessEqual(hr(1), "1") self.assertIn(hr(10**40), ["100000000000000000...000000000000000000", "100000000000000000...0000000000000000000"]) diff --git a/src/allmydata/test/test_spans.py b/src/allmydata/test/test_spans.py index e6e510e5d..578075e8d 100644 --- a/src/allmydata/test/test_spans.py +++ b/src/allmydata/test/test_spans.py @@ -2,8 +2,6 @@ Tests for allmydata.util.spans. """ -from past.builtins import long - import binascii import hashlib @@ -116,9 +114,6 @@ class ByteSpans(unittest.TestCase): s1 = Spans(3, 4) # 3,4,5,6 self._check1(s1) - s1 = Spans(long(3), long(4)) # 3,4,5,6 - self._check1(s1) - s2 = Spans(s1) self._check1(s2) @@ -446,9 +441,9 @@ class StringSpans(unittest.TestCase): self.failUnlessEqual(ds.get(2, 4), b"fear") ds = klass() - ds.add(long(2), b"four") - ds.add(long(3), b"ea") - self.failUnlessEqual(ds.get(long(2), long(4)), b"fear") + ds.add(2, b"four") + ds.add(3, b"ea") + self.failUnlessEqual(ds.get(2, 4), b"fear") def do_scan(self, klass): diff --git a/src/allmydata/test/test_time_format.py b/src/allmydata/test/test_time_format.py index 0b409feed..f3b9a8990 100644 --- a/src/allmydata/test/test_time_format.py +++ b/src/allmydata/test/test_time_format.py @@ -2,8 +2,6 @@ Tests for allmydata.util.time_format. """ -from past.builtins import long - import time from twisted.trial import unittest @@ -103,7 +101,7 @@ class TimeFormat(unittest.TestCase, TimezoneMixin): def test_parse_date(self): p = time_format.parse_date self.failUnlessEqual(p("2010-02-21"), 1266710400) - self.failUnless(isinstance(p("2009-03-18"), (int, long)), p("2009-03-18")) + self.failUnless(isinstance(p("2009-03-18"), int), p("2009-03-18")) self.failUnlessEqual(p("2009-03-18"), 1237334400) def test_format_time(self): diff --git a/src/allmydata/util/netstring.py b/src/allmydata/util/netstring.py index db913172f..ee7849b5f 100644 --- a/src/allmydata/util/netstring.py +++ b/src/allmydata/util/netstring.py @@ -4,8 +4,6 @@ Netstring encoding and decoding. Ported to Python 3. """ -from past.builtins import long - try: from typing import Optional, Tuple, List # noqa: F401 except ImportError: @@ -27,7 +25,7 @@ def split_netstring(data, numstrings, data does not exactly equal 'required_trailer'.""" assert isinstance(data, bytes) assert required_trailer is None or isinstance(required_trailer, bytes) - assert isinstance(position, (int, long)), (repr(position), type(position)) + assert isinstance(position, int), (repr(position), type(position)) elements = [] assert numstrings >= 0 while position < len(data): diff --git a/src/allmydata/web/status.py b/src/allmydata/web/status.py index 07d0256e8..1737a4d1b 100644 --- a/src/allmydata/web/status.py +++ b/src/allmydata/web/status.py @@ -2,8 +2,6 @@ Ported to Python 3. """ -from past.builtins import long - import itertools import hashlib import re @@ -1393,7 +1391,7 @@ class StatusElement(Element): size = op.get_size() if size is None: size = "(unknown)" - elif isinstance(size, (int, long, float)): + elif isinstance(size, (int, float)): size = abbreviate_size(size) result["total_size"] = size