From b83e3091a7febd715cc0502dc154e43edb2d44f1 Mon Sep 17 00:00:00 2001 From: Jan Pokorný Date: Jan 17 2020 14:20:25 +0000 Subject: compat: Python 3.9 no longer offers collections.Mutable* ABCs Solution is to move over onto collections.abc dedicated submodule that hosts these exclusively since 3.9. References: https://docs.python.org/3/whatsnew/3.3.html#collections https://docs.python.org/3/whatsnew/3.7.html#id3 https://docs.python.org/3.7/library/collections.html#collections-container-datatypes https://docs.python.org/3.9/whatsnew/3.9.html#removed Signed-off-by: Jan Pokorný --- diff --git a/command.py b/command.py index 1330bef..92cdf22 100644 --- a/command.py +++ b/command.py @@ -1,11 +1,14 @@ # -*- coding: UTF-8 -*- -# Copyright 2017 Red Hat, Inc. +# Copyright 2020 Red Hat, Inc. # Part of clufter project # Licensed under GPLv2+ (a copy included | http://gnu.org/licenses/gpl-2.0.txt) """Base command stuff (TBD)""" __author__ = "Jan Pokorný " -from collections import MutableMapping +try: + from collections.abc import MutableMapping +except ImportError: + from collections import MutableMapping try: from itertools import zip_longest except ImportError: # PY2 backward compatibility diff --git a/command_context.py b/command_context.py index c7331ea..b6135df 100644 --- a/command_context.py +++ b/command_context.py @@ -1,11 +1,14 @@ # -*- coding: UTF-8 -*- -# Copyright 2017 Red Hat, Inc. +# Copyright 2020 Red Hat, Inc. # Part of clufter project # Licensed under GPLv2+ (a copy included | http://gnu.org/licenses/gpl-2.0.txt) """Command context, i.e., state distributed along filters chain""" __author__ = "Jan Pokorný " -from collections import MutableMapping +try: + from collections.abc import MutableMapping +except ImportError: + from collections import MutableMapping from logging import getLogger from .error import ClufterError diff --git a/filters/cmd_wrap.py b/filters/cmd_wrap.py index 89c9829..0166b68 100644 --- a/filters/cmd_wrap.py +++ b/filters/cmd_wrap.py @@ -1,5 +1,5 @@ # -*- coding: UTF-8 -*- -# Copyright 2017 Red Hat, Inc. +# Copyright 2020 Red Hat, Inc. # Part of clufter project # Licensed under GPLv2+ (a copy included | http://gnu.org/licenses/gpl-2.0.txt) """cmd-wrap filter""" @@ -12,7 +12,11 @@ from ..utils_2to3 import bytes_enc, str_enc, xrange from ..utils_func import add_item from ..utils_prog import FancyOutput -from collections import MutableMapping, defaultdict +try: + from collections.abc import MutableMapping +except ImportError: + from collections import MutableMapping +from collections import defaultdict from logging import getLogger from os import getenv, isatty from sys import maxsize diff --git a/protocol.py b/protocol.py index e41fc57..3334324 100644 --- a/protocol.py +++ b/protocol.py @@ -1,11 +1,14 @@ # -*- coding: UTF-8 -*- -# Copyright 2017 Red Hat, Inc. +# Copyright 2020 Red Hat, Inc. # Part of clufter project # Licensed under GPLv2+ (a copy included | http://gnu.org/licenses/gpl-2.0.txt) """Base protocol stuff (metaclass, etc.)""" __author__ = "Jan Pokorný " -from collections import MutableMapping +try: + from collections.abc import MutableMapping +except ImportError: + from collections import MutableMapping from logging import getLogger from .plugin_registry import PluginRegistry diff --git a/utils_prog.py b/utils_prog.py index c427791..e39a141 100644 --- a/utils_prog.py +++ b/utils_prog.py @@ -1,12 +1,15 @@ # -*- coding: UTF-8 -*- -# Copyright 2017 Red Hat, Inc. +# Copyright 2020 Red Hat, Inc. # Part of clufter project # Licensed under GPLv2+ (a copy included | http://gnu.org/licenses/gpl-2.0.txt) """Program-specific commons""" __author__ = "Jan Pokorný " import logging -from collections import Mapping, MutableMapping, MutableSequence, MutableSet +try: + from collections.abc import Mapping, MutableMapping, MutableSequence, MutableSet +except ImportError: + from collections import Mapping, MutableMapping, MutableSequence, MutableSet from functools import reduce from optparse import Option from os import environ, fdopen, isatty, pathsep