remove "from past.builtins import long"

This commit is contained in:
Alexandre Detiste 2024-02-28 01:07:08 +01:00
parent 0e5b6daa38
commit 2243ce3187
10 changed files with 13 additions and 34 deletions

View File

@ -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)

View File

@ -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")

View File

@ -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

View File

@ -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)

View File

@ -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):

View File

@ -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"<foo\(\) at test_humanreadable.py:\d+>")
self.failUnlessEqual(hr(self.test_repr),
"<bound method HumanReadable.test_repr of <allmydata.test.test_humanreadable.HumanReadable testMethod=test_repr>>")
self.failUnlessEqual(hr(long(1)), "1")
self.failUnlessEqual(hr(1), "1")
self.assertIn(hr(10**40),
["100000000000000000...000000000000000000",
"100000000000000000...0000000000000000000"])

View File

@ -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):

View File

@ -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):

View File

@ -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):

View File

@ -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