Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

Commit adb491e

Browse files
committed
Fix collections.abc imports for python 3.7.
1 parent 18b629b commit adb491e

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

hyper/common/headers.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55
66
Contains hyper's structures for storing and working with HTTP headers.
77
"""
8-
import collections
8+
try:
9+
from collections.abc import MutableMapping
10+
except ImportError: # pragma: no cover
11+
# Python 2.7 compatibility
12+
from collections import MutableMapping
913

1014
from hyper.common.util import to_bytestring, to_bytestring_tuple
1115

1216

13-
class HTTPHeaderMap(collections.MutableMapping):
17+
class HTTPHeaderMap(MutableMapping):
1418
"""
1519
A structure that contains HTTP headers.
1620

hyper/http11/connection.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@
1010
import socket
1111
import base64
1212

13-
from collections import Iterable, Mapping
13+
try:
14+
from collections.abc import Iterable, Mapping
15+
except ImportError: # pragma: no cover
16+
# Python 2.7 compatibility
17+
from collections import Iterable, Mapping
1418

15-
import collections
1619
from hyperframe.frame import SettingsFrame
1720

1821
from .response import HTTP11Response
@@ -390,7 +393,7 @@ def _send_body(self, body, body_type):
390393
return
391394

392395
# Iterables that set a specific content length.
393-
elif isinstance(body, collections.Iterable):
396+
elif isinstance(body, Iterable):
394397
for item in body:
395398
try:
396399
self._sock.send(item)

0 commit comments

Comments
 (0)