blob: b0e9d2215f4bd1eb87978f6f114ae935faea888a [file] [log] [blame]
Andrew Geissler9aee5002022-03-30 16:27:02 +00001From 9b939c0b534c1b7958fa0a3c7aedf30bca910431 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
3Date: Mon, 7 Jun 2021 23:23:47 +0200
4Subject: [PATCH] Python 3.10+ fix: Use collections.abc.Callable instead of
5 collections.Callable
6
7The deprecated aliases to Collections Abstract Base Classes were removed from
8the collections module in Python 3.10.
9https://docs.python.org/3.10/whatsnew/changelog.html#python-3-10-0-alpha-5
10https://bugs.python.org/issue37324
11---
12 slip/dbus/polkit.py | 6 +++---
13 slip/util/hookable.py | 6 +++---
14 2 files changed, 6 insertions(+), 6 deletions(-)
15
16diff --git a/slip/dbus/polkit.py b/slip/dbus/polkit.py
17index 128e8ce..320676d 100644
18--- a/slip/dbus/polkit.py
19+++ b/slip/dbus/polkit.py
20@@ -26,7 +26,7 @@
21
22 from __future__ import absolute_import
23
24-import collections
25+import collections.abc
26 import dbus
27 from decorator import decorator
28 from functools import reduce
29@@ -103,14 +103,14 @@ class MyProxy(object):
30 def some_method(self, ...):
31 ..."""
32
33- assert(func is None or isinstance(func, collections.Callable))
34+ assert(func is None or isinstance(func, collections.abc.Callable))
35
36 assert(
37 authfail_result in (None, AUTHFAIL_DONTCATCH) or
38 authfail_exception is None)
39 assert(
40 authfail_callback is None or
41- isinstance(authfail_callback, collections.Callable))
42+ isinstance(authfail_callback, collections.abc.Callable))
43 assert(
44 authfail_exception is None or
45 issubclass(authfail_exception, Exception))
46diff --git a/slip/util/hookable.py b/slip/util/hookable.py
47index 89c7392..0cd9967 100644
48--- a/slip/util/hookable.py
49+++ b/slip/util/hookable.py
50@@ -23,7 +23,7 @@
51 """This module contains variants of certain base types which call registered
52 hooks on changes."""
53
54-import collections
55+import collections.abc
56 from six import with_metaclass
57
58 __all__ = ["Hookable", "HookableSet"]
59@@ -67,7 +67,7 @@ class _HookEntry(object):
60
61 def __init__(self, hook, args, kwargs, hookable=None):
62
63- assert(isinstance(hook, collections.Callable))
64+ assert(isinstance(hook, collections.abc.Callable))
65 assert(isinstance(hookable, Hookable))
66
67 for n, x in enumerate(args):
68@@ -174,7 +174,7 @@ def add_hook_hookable(self, hook, *args, **kwargs):
69 self.__add_hook(hook, self, *args, **kwargs)
70
71 def __add_hook(self, hook, _hookable, *args, **kwargs):
72- assert isinstance(hook, collections.Callable)
73+ assert isinstance(hook, collections.abc.Callable)
74 assert isinstance(_hookable, Hookable)
75 hookentry = _HookEntry(hook, args, kwargs, hookable=_hookable)
76 self.__hooks__.add(hookentry)