summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--immutables/__init__.py3
-rw-r--r--immutables/_map.c2
-rw-r--r--immutables/map.py4
-rw-r--r--tests/test_map.py4
4 files changed, 12 insertions, 1 deletions
diff --git a/immutables/__init__.py b/immutables/__init__.py
index d598413..e900c2b 100644
--- a/immutables/__init__.py
+++ b/immutables/__init__.py
@@ -2,6 +2,9 @@ try:
from ._map import Map
except ImportError:
from .map import Map
+else:
+ import collections.abc as _abc
+ _abc.Mapping.register(Map)
__all__ = 'Map',
diff --git a/immutables/_map.c b/immutables/_map.c
index 3ed0393..be82cd9 100644
--- a/immutables/_map.c
+++ b/immutables/_map.c
@@ -3032,7 +3032,7 @@ static PyMappingMethods Map_as_mapping = {
PyTypeObject _Map_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
- "Map",
+ "immutables._map.Map",
sizeof(MapObject),
.tp_methods = Map_methods,
.tp_as_mapping = &Map_as_mapping,
diff --git a/immutables/map.py b/immutables/map.py
index b6d55dc..83c02bc 100644
--- a/immutables/map.py
+++ b/immutables/map.py
@@ -1,3 +1,4 @@
+import collections.abc
import reprlib
@@ -457,3 +458,6 @@ class Map:
buf = []
self.__root.dump(buf, 0)
return '\n'.join(buf)
+
+
+collections.abc.Mapping.register(Map)
diff --git a/tests/test_map.py b/tests/test_map.py
index 3e7633a..7af9513 100644
--- a/tests/test_map.py
+++ b/tests/test_map.py
@@ -1,3 +1,4 @@
+import collections.abc
import gc
import random
import unittest
@@ -795,6 +796,9 @@ class BaseMapTest:
with HaskKeyCrasher(error_on_hash=True):
hash(m)
+ def test_abc_1(self):
+ self.assertTrue(issubclass(self.Map, collections.abc.Mapping))
+
class PyMapTest(BaseMapTest, unittest.TestCase):