# HG changeset patch # User Martin von Zweigbergk # Date 1662752726 25200 # Node ID 59a72267f5ce0ae5e3612a35b6b4c08e11bba46a # Parent c96ed4029fda63c7a5eec15f29d914d7473e2bbb 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. diff -r c96ed4029fda -r 59a72267f5ce hgext/fsmonitor/pywatchman/pybser.py --- 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