From 2e856065ead1b399a868e9efa2f0284a290495d3 Mon Sep 17 00:00:00 2001 From: Michael Howitz Date: Tue, 26 Oct 2021 08:59:27 +0200 Subject: [PATCH] Fix deprecation warnings occurring on Python 3.10. --- CHANGES.rst | 2 ++ src/ZODB/FileStorage/FileStorage.py | 4 ++-- src/ZODB/scripts/fsstats.py | 4 ++-- src/ZODB/tests/BasicStorage.py | 6 +++--- src/ZODB/tests/MTStorage.py | 10 +++++----- src/ZODB/tests/testThreadedShutdown.py | 2 +- 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 99fb8070a..c84734f2b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -19,6 +19,8 @@ - Require Python 3 to build the documentation. +- Fix deprecation warnings occurring on Python 3.10. + 5.6.0 (2020-06-11) ================== diff --git a/src/ZODB/FileStorage/FileStorage.py b/src/ZODB/FileStorage/FileStorage.py index 7b84d92a2..2f389e04c 100644 --- a/src/ZODB/FileStorage/FileStorage.py +++ b/src/ZODB/FileStorage/FileStorage.py @@ -2161,7 +2161,7 @@ def write_lock(self): self.writing = False if self.writers > 0: self.writers -= 1 - self._cond.notifyAll() + self._cond.notify_all() @contextlib.contextmanager def get(self): @@ -2186,7 +2186,7 @@ def get(self): if not self._out: with self._cond: if self.writers and not self._out: - self._cond.notifyAll() + self._cond.notify_all() def empty(self): while self._files: diff --git a/src/ZODB/scripts/fsstats.py b/src/ZODB/scripts/fsstats.py index 00379477a..2d86f31ab 100755 --- a/src/ZODB/scripts/fsstats.py +++ b/src/ZODB/scripts/fsstats.py @@ -6,8 +6,8 @@ import six from six.moves import filter -rx_txn = re.compile("tid=([0-9a-f]+).*size=(\d+)") -rx_data = re.compile("oid=([0-9a-f]+) size=(\d+) class=(\S+)") +rx_txn = re.compile(r"tid=([0-9a-f]+).*size=(\d+)") +rx_data = re.compile(r"oid=([0-9a-f]+) size=(\d+) class=(\S+)") def sort_byhsize(seq, reverse=False): L = [(v.size(), k, v) for k, v in seq] diff --git a/src/ZODB/tests/BasicStorage.py b/src/ZODB/tests/BasicStorage.py index 17313ace1..38dd495d0 100644 --- a/src/ZODB/tests/BasicStorage.py +++ b/src/ZODB/tests/BasicStorage.py @@ -209,7 +209,7 @@ def _do_store_in_separate_thread(self, oid, revid, voted): # We'll run the competing trans in a separate thread: thread = threading.Thread(name='T2', target=self._dostore, args=(oid,), kwargs=dict(revid=revid)) - thread.setDaemon(True) + thread.daemon = True thread.start() thread.join(.1) return thread @@ -324,7 +324,7 @@ def check_tid_ordering_w_commit(self): to_join = [] def run_in_thread(func): t = threading.Thread(target=func) - t.setDaemon(True) + t.daemon = True t.start() to_join.append(t) @@ -347,7 +347,7 @@ def callback(tid): def update_attempts(): with attempts_cond: attempts.append(1) - attempts_cond.notifyAll() + attempts_cond.notify_all() @run_in_thread diff --git a/src/ZODB/tests/MTStorage.py b/src/ZODB/tests/MTStorage.py index c7c3327e8..937caa58b 100644 --- a/src/ZODB/tests/MTStorage.py +++ b/src/ZODB/tests/MTStorage.py @@ -50,7 +50,7 @@ class ZODBClientThread(TestThread): def __init__(self, db, test, commits=10, delay=SHORT_DELAY): self.__super_init() - self.setDaemon(1) + self.daemon = True self.db = db self.test = test self.commits = commits @@ -76,7 +76,7 @@ def commit(self, d, num): time.sleep(self.delay) # Return a new PersistentMapping, and store it on the root object under - # the name (.getName()) of the current thread. + # the name of the current thread. def get_thread_dict(self, root): # This is vicious: multiple threads are slamming changes into the # root object, then trying to read the root object, simultaneously @@ -86,7 +86,7 @@ def get_thread_dict(self, root): # around (at most) 1000 times was enough so that a 100-thread test # reliably passed on Tim's hyperthreaded WinXP box (but at the # original 10 retries, the same test reliably failed with 15 threads). - name = self.getName() + name = self.name MAXRETRIES = 1000 for i in range(MAXRETRIES): @@ -129,7 +129,7 @@ def check(self): data, serial = load_current(self.storage, oid) self.test.assertEqual(serial, revid) obj = zodb_unpickle(data) - self.test.assertEqual(obj.value[0], self.getName()) + self.test.assertEqual(obj.value[0], self.name) def pause(self): time.sleep(self.delay) @@ -140,7 +140,7 @@ def oid(self): return oid def dostore(self, i): - data = zodb_pickle(MinPO((self.getName(), i))) + data = zodb_pickle(MinPO((self.name, i))) t = TransactionMetaData() oid = self.oid() self.pause() diff --git a/src/ZODB/tests/testThreadedShutdown.py b/src/ZODB/tests/testThreadedShutdown.py index 030581056..142fcb569 100644 --- a/src/ZODB/tests/testThreadedShutdown.py +++ b/src/ZODB/tests/testThreadedShutdown.py @@ -12,7 +12,7 @@ class ZODBClientThread(threading.Thread): def __init__(self, db, test): threading.Thread.__init__(self) self._exc_info = None - self.setDaemon(True) + self.daemon = True self.db = db self.test = test self.event = threading.Event()