diff --git a/src/calibre/constants.py b/src/calibre/constants.py index 330ef1e0e1..b0b9002de2 100644 --- a/src/calibre/constants.py +++ b/src/calibre/constants.py @@ -2,7 +2,7 @@ # vim:fileencoding=utf-8 # License: GPLv3 Copyright: 2015, Kovid Goyal from polyglot.builtins import map, unicode_type, environ_item, hasenv, getenv -import sys, locale, codecs, os, collections +import sys, locale, codecs, os, collections, collections.abc __appname__ = 'calibre' numeric_version = (5, 21, 0) @@ -291,7 +291,7 @@ if iswindows: from calibre_extensions import winutil -class Plugins(collections.Mapping): +class Plugins(collections.abc.Mapping): def __iter__(self): from importlib.resources import contents diff --git a/src/calibre/db/cache.py b/src/calibre/db/cache.py index 958da81fa1..d0fa2403b9 100644 --- a/src/calibre/db/cache.py +++ b/src/calibre/db/cache.py @@ -12,7 +12,8 @@ import random import shutil import sys import traceback -from collections import MutableSet, Set, defaultdict +from collections import defaultdict +from collections.abc import MutableSet, Set from functools import partial, wraps from io import BytesIO from threading import Lock diff --git a/src/calibre/db/lazy.py b/src/calibre/db/lazy.py index d2b7398f24..d67ec8397c 100644 --- a/src/calibre/db/lazy.py +++ b/src/calibre/db/lazy.py @@ -8,7 +8,7 @@ __docformat__ = 'restructuredtext en' import weakref from functools import wraps -from collections import MutableMapping, MutableSequence +from collections.abc import MutableMapping, MutableSequence from copy import deepcopy from calibre.ebooks.metadata.book.base import Metadata, SIMPLE_GET, TOP_LEVEL_IDENTIFIERS, NULL_VALUES, ALL_METADATA_FIELDS diff --git a/src/calibre/test_build.py b/src/calibre/test_build.py index 799bc02179..5c58ff5431 100644 --- a/src/calibre/test_build.py +++ b/src/calibre/test_build.py @@ -48,7 +48,7 @@ class BuildTest(unittest.TestCase): def test_loaders(self): import importlib - ldr = importlib.import_module('calibre').__spec__.loader + ldr = importlib.import_module('calibre').__spec__.loader.get_resource_reader() self.assertIn('ebooks', ldr.contents()) try: raw = ldr.open_resource('__init__.py').read() diff --git a/src/calibre/utils/dbus_service.py b/src/calibre/utils/dbus_service.py index e04b6524b6..fb38136daf 100644 --- a/src/calibre/utils/dbus_service.py +++ b/src/calibre/utils/dbus_service.py @@ -33,7 +33,7 @@ import sys import logging import threading import traceback -from collections import Sequence +from collections.abc import Sequence import _dbus_bindings from dbus import ( diff --git a/src/calibre/utils/run_tests.py b/src/calibre/utils/run_tests.py index 673de4bcc4..2b5034b01b 100644 --- a/src/calibre/utils/run_tests.py +++ b/src/calibre/utils/run_tests.py @@ -3,7 +3,7 @@ # License: GPLv3 Copyright: 2016, Kovid Goyal -import unittest, functools, importlib +import unittest, functools, importlib, importlib.resources from calibre.utils.monotonic import monotonic @@ -54,8 +54,7 @@ class TestResult(unittest.TextTestResult): def find_tests_in_package(package, excludes=('main.py',)): - loader = importlib.import_module(package).__spec__.loader - items = list(loader.contents()) + items = list(importlib.resources.contents(package)) suits = [] excludes = set(excludes) | {x + 'c' for x in excludes} seen = set() diff --git a/src/css_selectors/ordered_set.py b/src/css_selectors/ordered_set.py index 369d3e122d..51c30c2eb2 100644 --- a/src/css_selectors/ordered_set.py +++ b/src/css_selectors/ordered_set.py @@ -5,7 +5,7 @@ __license__ = 'GPL v3' __copyright__ = '2015, Kovid Goyal ' -import collections +import collections.abc from polyglot.builtins import string_or_bytes SLICE_ALL = slice(None) @@ -23,7 +23,7 @@ def is_iterable(obj): return hasattr(obj, '__iter__') and not isinstance(obj, string_or_bytes) -class OrderedSet(collections.MutableSet): +class OrderedSet(collections.abc.MutableSet): """ An OrderedSet is a custom MutableSet that remembers its order, so that every entry has an index that can be looked up.