mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix building with Python 3.10
This commit is contained in:
parent
c9c1029d02
commit
2e272a39d0
@ -2,7 +2,7 @@
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPLv3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
@ -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 (
|
||||
|
@ -3,7 +3,7 @@
|
||||
# License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
|
||||
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()
|
||||
|
@ -5,7 +5,7 @@
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2015, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user