1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
|
From f9a65f82c0481ec9e20a71c918a300a0d6354cc2 Mon Sep 17 00:00:00 2001
From: Alexandre Detiste <alexandre.detiste@gmail.com>
Date: Sat, 21 Dec 2024 02:07:01 +0100
Subject: [PATCH 1/4] trim usage of to-be-removed "future" library
---
src/allmydata/scripts/debug.py | 5 +++--
src/allmydata/test/mutable/util.py | 4 +++-
src/allmydata/test/test_download.py | 5 +++--
src/allmydata/test/test_istorageserver.py | 4 ++--
src/allmydata/test/test_storage.py | 4 +++-
5 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/src/allmydata/scripts/debug.py b/src/allmydata/scripts/debug.py
index b6eba842a2..fe75a271e8 100644
--- a/src/allmydata/scripts/debug.py
+++ b/src/allmydata/scripts/debug.py
@@ -2,8 +2,6 @@
Ported to Python 3.
"""
-from future.utils import bchr
-
import struct, time, os, sys
from twisted.python import usage, failure
@@ -22,6 +20,9 @@
from allmydata.util.encodingutil import quote_output
from allmydata.scripts.types_ import SubCommands
+def bchr(s):
+ return bytes([s])
+
class DumpOptions(BaseOptions):
def getSynopsis(self):
return "Usage: tahoe [global-options] debug dump-share SHARE_FILENAME"
diff --git a/src/allmydata/test/mutable/util.py b/src/allmydata/test/mutable/util.py
index fd1fc29700..ae7d93d9cc 100644
--- a/src/allmydata/test/mutable/util.py
+++ b/src/allmydata/test/mutable/util.py
@@ -2,7 +2,6 @@
Ported to Python 3.
"""
-from future.utils import bchr
from io import BytesIO
import attr
@@ -20,6 +19,9 @@
EMPTY_CLIENT_CONFIG,
)
+def bchr(s):
+ return bytes([s])
+
def eventuaaaaaly(res=None):
d = fireEventually(res)
d.addCallback(fireEventually)
diff --git a/src/allmydata/test/test_download.py b/src/allmydata/test/test_download.py
index 709786f0ea..f684d1b329 100644
--- a/src/allmydata/test/test_download.py
+++ b/src/allmydata/test/test_download.py
@@ -2,8 +2,6 @@
Ported to Python 3.
"""
-from future.utils import bchr
-
# system-level upload+download roundtrip test, but using shares created from
# a previous run. This asserts that the current code is capable of decoding
# shares from a previous version.
@@ -29,6 +27,9 @@
from allmydata.codec import CRSDecoder
from foolscap.eventual import eventually, fireEventually, flushEventualQueue
+def bchr(s):
+ return bytes([s])
+
plaintext = b"This is a moderate-sized file.\n" * 10
mutable_plaintext = b"This is a moderate-sized mutable file.\n" * 10
diff --git a/src/allmydata/test/test_istorageserver.py b/src/allmydata/test/test_istorageserver.py
index ded9ac1ac4..1e44476e52 100644
--- a/src/allmydata/test/test_istorageserver.py
+++ b/src/allmydata/test/test_istorageserver.py
@@ -10,8 +10,6 @@
from __future__ import annotations
-from future.utils import bchr
-
from random import Random
from unittest import SkipTest
@@ -31,6 +29,8 @@
# are run in the same order.
_RANDOM = Random(0)
+def bchr(s):
+ return bytes([s])
def _randbytes(length):
# type: (int) -> bytes
diff --git a/src/allmydata/test/test_storage.py b/src/allmydata/test/test_storage.py
index 2964206c7a..378649e02f 100644
--- a/src/allmydata/test/test_storage.py
+++ b/src/allmydata/test/test_storage.py
@@ -5,7 +5,6 @@
"""
from __future__ import annotations
-from future.utils import bchr
from six import ensure_str
from io import (
@@ -20,6 +19,9 @@
from functools import partial
from uuid import uuid4
+def bchr(s):
+ return bytes([s])
+
from testtools.matchers import (
Equals,
NotEquals,
From 095f81041c36e52153220d54923468f56cbbc2ec Mon Sep 17 00:00:00 2001
From: Alexandre Detiste <alexandre.detiste@gmail.com>
Date: Sat, 21 Dec 2024 02:14:26 +0100
Subject: [PATCH 2/4] remove some now useless six.ensure_text
---
src/allmydata/test/cli/test_status.py | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/src/allmydata/test/cli/test_status.py b/src/allmydata/test/cli/test_status.py
index a3921b442a..081afa4aa1 100644
--- a/src/allmydata/test/cli/test_status.py
+++ b/src/allmydata/test/cli/test_status.py
@@ -2,8 +2,6 @@
Ported to Python 3.
"""
-from six import ensure_text
-
import os
import tempfile
from io import BytesIO, StringIO
@@ -139,18 +137,18 @@ def setUp(self):
def test_no_operations(self):
values = [
- StringIO(ensure_text(json.dumps({
+ StringIO(json.dumps({
"active": [],
"recent": [],
- }))),
- StringIO(ensure_text(json.dumps({
+ })),
+ StringIO(json.dumps({
"counters": {
"bytes_downloaded": 0,
},
"stats": {
"node.uptime": 0,
}
- }))),
+ })),
]
def do_http(*args, **kw):
return values.pop(0)
From 510511247527c59893d3f6fae310acadcd0b61ea Mon Sep 17 00:00:00 2001
From: Alexandre Detiste <alexandre.detiste@gmail.com>
Date: Sat, 21 Dec 2024 14:52:08 +0100
Subject: [PATCH 3/4] add newsfragment
---
newsfragments/4152.other | 1 +
1 file changed, 1 insertion(+)
create mode 100644 newsfragments/4152.other
diff --git a/newsfragments/4152.other b/newsfragments/4152.other
new file mode 100644
index 0000000000..c12169c71c
--- /dev/null
+++ b/newsfragments/4152.other
@@ -0,0 +1 @@
+remote more usage of deprecated future library
From 4ac60c5c86ddfcaceff61041453ae6103ffc12f4 Mon Sep 17 00:00:00 2001
From: Alexandre Detiste <alexandre.detiste@gmail.com>
Date: Sat, 21 Dec 2024 14:57:09 +0100
Subject: [PATCH 4/4] vendor cmp()
---
misc/coding_tools/make-canary-files.py | 5 +++--
misc/simulators/simulate_load.py | 6 +++---
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/misc/coding_tools/make-canary-files.py b/misc/coding_tools/make-canary-files.py
index 0184628927..4bc4fdd8f4 100644
--- a/misc/coding_tools/make-canary-files.py
+++ b/misc/coding_tools/make-canary-files.py
@@ -51,13 +51,14 @@
setup.py run_with_pythonpath -p -c 'misc/make-canary-files.py ARGS..'
"""
-from past.builtins import cmp
-
import os, hashlib
from twisted.python import usage
from allmydata.immutable import upload
from allmydata.util import base32
+def cmp(a, b):
+ return (a > b) - (a < b)
+
class Options(usage.Options):
optParameters = [
("convergence", "c", None, "path to NODEDIR/private/convergence"),
diff --git a/misc/simulators/simulate_load.py b/misc/simulators/simulate_load.py
index 9897112078..82cec7cf17 100644
--- a/misc/simulators/simulate_load.py
+++ b/misc/simulators/simulate_load.py
@@ -2,13 +2,13 @@
# WARNING. There is a bug in this script so that it does not simulate the actual Tahoe Two server selection algorithm that it was intended to simulate. See http://allmydata.org/trac/tahoe-lafs/ticket/302 (stop permuting peerlist, use SI as offset into ring instead?)
-
-from past.builtins import cmp
-
import random
SERVER_CAPACITY = 10**12
+def cmp(a, b):
+ return (a > b) - (a < b)
+
class Server(object):
def __init__(self):
self.si = random.randrange(0, 2**31)
|