fsmonitor: migrate Python ABCs from collections to collections.abc
The Collections Abstract Base Classes in the collections module are
deprecated since Python 3.3 in favor of collections.abc, and removed
in Python 3.10.
--- a/hgext/fsmonitor/pywatchman/pybser.py Thu Sep 15 01:48:38 2022 +0200
+++ b/hgext/fsmonitor/pywatchman/pybser.py Fri Sep 09 12:45:26 2022 -0700
@@ -36,6 +36,7 @@
from . import compat
+abc = collections.abc
BSER_ARRAY = b"\x00"
BSER_OBJECT = b"\x01"
@@ -207,9 +208,7 @@
self.ensure_size(needed)
struct.pack_into(b"=cd", self.buf, self.wpos, BSER_REAL, val)
self.wpos += needed
- elif isinstance(val, collections.Mapping) and isinstance(
- val, collections.Sized
- ):
+ elif isinstance(val, abc.Mapping) and isinstance(val, abc.Sized):
val_len = len(val)
size = _int_size(val_len)
needed = 2 + size
@@ -260,9 +259,7 @@
for k, v in iteritems:
self.append_string(k)
self.append_recursive(v)
- elif isinstance(val, collections.Iterable) and isinstance(
- val, collections.Sized
- ):
+ elif isinstance(val, abc.Iterable) and isinstance(val, abc.Sized):
val_len = len(val)
size = _int_size(val_len)
needed = 2 + size