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)
