Browse Source

Update backports_abc 0.4 to 0.5.

pull/867/head
JackDandy 8 years ago
parent
commit
6444f078c2
  1. 1
      CHANGES.md
  2. 20
      lib/backports_abc.py

1
CHANGES.md

@ -8,6 +8,7 @@
* Add lazyload package 3.0.0 (2e318b1) * Add lazyload package 3.0.0 (2e318b1)
* Change improve add show search results by comparing search term to an additional unidecoded result set * Change improve add show search results by comparing search term to an additional unidecoded result set
* Change webserver startup to correctly use xheaders in reverse proxy or load balance set-ups * Change webserver startup to correctly use xheaders in reverse proxy or load balance set-ups
* Update backports_abc 0.4 to 0.5
[develop changelog] [develop changelog]

20
lib/backports_abc.py

@ -21,6 +21,20 @@ except ImportError:
import collections as _collections_abc import collections as _collections_abc
def get_mro(cls):
try:
return cls.__mro__
except AttributeError:
return old_style_mro(cls)
def old_style_mro(cls):
yield cls
for base in cls.__bases__:
for c in old_style_mro(base):
yield c
def mk_gen(): def mk_gen():
from abc import abstractmethod from abc import abstractmethod
@ -63,7 +77,7 @@ def mk_gen():
@classmethod @classmethod
def __subclasshook__(cls, C): def __subclasshook__(cls, C):
if cls is Generator: if cls is Generator:
mro = C.__mro__ mro = get_mro(C)
for method in required_methods: for method in required_methods:
for base in mro: for base in mro:
if method in base.__dict__: if method in base.__dict__:
@ -88,7 +102,7 @@ def mk_awaitable():
@classmethod @classmethod
def __subclasshook__(cls, C): def __subclasshook__(cls, C):
if cls is Awaitable: if cls is Awaitable:
for B in C.__mro__: for B in get_mro(C):
if '__await__' in B.__dict__: if '__await__' in B.__dict__:
if B.__dict__['__await__']: if B.__dict__['__await__']:
return True return True
@ -144,7 +158,7 @@ def mk_coroutine():
@classmethod @classmethod
def __subclasshook__(cls, C): def __subclasshook__(cls, C):
if cls is Coroutine: if cls is Coroutine:
mro = C.__mro__ mro = get_mro(C)
for method in ('__await__', 'send', 'throw', 'close'): for method in ('__await__', 'send', 'throw', 'close'):
for base in mro: for base in mro:
if method in base.__dict__: if method in base.__dict__:

Loading…
Cancel
Save