mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-12-22 08:47:41 +00:00
[compat] Replace deficient ChainMap class in Py3.3 and earlier
This commit is contained in:
parent
4c6fba3765
commit
0f6422590e
1 changed files with 5 additions and 1 deletions
|
@ -3004,8 +3004,11 @@ except ImportError:
|
||||||
# new class in collections
|
# new class in collections
|
||||||
try:
|
try:
|
||||||
from collections import ChainMap as compat_collections_chain_map
|
from collections import ChainMap as compat_collections_chain_map
|
||||||
|
# Py3.3's ChainMap is deficient
|
||||||
|
if sys.version_info <= (3, 3):
|
||||||
|
raise ImportError
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# Py < 3.3
|
# Py <= 3.3
|
||||||
class compat_collections_chain_map(compat_collections_abc.MutableMapping):
|
class compat_collections_chain_map(compat_collections_abc.MutableMapping):
|
||||||
|
|
||||||
maps = [{}]
|
maps = [{}]
|
||||||
|
@ -3060,6 +3063,7 @@ except ImportError:
|
||||||
def parents(self):
|
def parents(self):
|
||||||
return compat_collections_chain_map(*(self.maps[1:]))
|
return compat_collections_chain_map(*(self.maps[1:]))
|
||||||
|
|
||||||
|
|
||||||
# Pythons disagree on the type of a pattern (RegexObject, _sre.SRE_Pattern, Pattern, ...?)
|
# Pythons disagree on the type of a pattern (RegexObject, _sre.SRE_Pattern, Pattern, ...?)
|
||||||
compat_re_Pattern = type(re.compile(''))
|
compat_re_Pattern = type(re.compile(''))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue