py34 and py27 compat

This commit is contained in:
Piper Merriam 2017-02-02 16:33:39 -07:00
parent 712fc4c457
commit 782bd7329a
4 changed files with 11 additions and 2 deletions

View File

@ -1,5 +1,4 @@
import hashlib
import collections
from .types import (
is_boolean,
@ -13,6 +12,9 @@ from .types import (
from .string import (
force_bytes,
)
from .compat import (
Generator,
)
def generate_cache_key(value):
@ -31,7 +33,7 @@ def generate_cache_key(value):
for key
in sorted(value.keys())
))
elif is_array(value) or isinstance(value, collections.Generator):
elif is_array(value) or isinstance(value, Generator):
return generate_cache_key("".join((
generate_cache_key(item)
for item

View File

@ -6,11 +6,13 @@ if sys.version_info.major == 2:
from .compat_py2 import (
urlparse,
urlunparse,
Generator,
)
else:
from .compat_py3 import ( # noqa: #401
urlparse,
urlunparse,
Generator,
)

View File

@ -2,3 +2,4 @@ from urlparse import ( # noqa: F401
urlparse,
urlunparse,
)
Generator = type(_ for _ in tuple())

View File

@ -1,4 +1,8 @@
import collections
from urllib.parse import ( # noqa: F401
urlparse,
urlunparse,
)
Generator = collections.Generator