Skip to content

Commit 190c9a5

Browse files
BeyondEviluntitaker
authored andcommitted
Fix collections import DeprecationWarning (#165)
* Fix collections import DeprecationWarning * blacks trailing comma...
1 parent 256e179 commit 190c9a5

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

sentry_sdk/utils.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from contextlib import contextmanager
77
from datetime import datetime
8-
from collections import Mapping, Sequence
98

109
from sentry_sdk._compat import (
1110
urlparse,
@@ -14,13 +13,22 @@
1413
string_types,
1514
number_types,
1615
int_types,
16+
PY2,
1717
)
1818

19+
if PY2:
20+
# Importing ABCs from collections is deprecated, and will stop working in 3.8
21+
# https://github.com/python/cpython/blob/master/Lib/collections/__init__.py#L49
22+
from collections import Mapping, Sequence
23+
else:
24+
# New in 3.3
25+
# https://docs.python.org/3/library/collections.abc.html
26+
from collections.abc import Mapping, Sequence
1927

2028
epoch = datetime(1970, 1, 1)
2129

2230

23-
# The logger is created here but initializde in the debug support module
31+
# The logger is created here but initialized in the debug support module
2432
logger = logging.getLogger("sentry_sdk.errors")
2533

2634

0 commit comments

Comments
 (0)