Skip to content

Commit c64b170

Browse files
authored
Merge pull request #69 from hugovk/fix-deprecation
Fix ImportError in Python 3.9
2 parents 8e2c948 + a948e93 commit c64b170

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

doc/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@ OpenSlide objects
9999
.. attribute:: properties
100100

101101
Metadata about the slide, in the form of a
102-
:class:`Mapping <collections.Mapping>` from OpenSlide property name to
102+
:class:`~collections.abc.Mapping` from OpenSlide property name to
103103
property value. Property values are always strings. OpenSlide
104104
provides some :ref:`standard properties <Standard properties>`, plus
105105
additional properties that vary by slide format.
106106

107107
.. attribute:: associated_images
108108

109109
Images, such as label or macro images, which are associated with this
110-
slide. This is a :class:`Mapping <collections.Mapping>` from image
110+
slide. This is a :class:`~collections.abc.Mapping` from image
111111
name to RGBA :class:`Image <PIL.Image.Image>`.
112112

113113
Unlike in the C interface, these images are not premultiplied.

openslide/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,15 @@
2323
"""
2424

2525
from __future__ import division, print_function
26-
from collections import Mapping
2726
from PIL import Image
2827

28+
try:
29+
# Python 3.3+
30+
from collections.abc import Mapping
31+
except ImportError:
32+
# Python 2
33+
from collections import Mapping
34+
2935
from openslide import lowlevel
3036

3137
# For the benefit of library users

0 commit comments

Comments
 (0)