Skip to content

Commit

Permalink
[compat] Replace deficient ChainMap class in Py3.3 and earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkf committed Aug 26, 2022
1 parent 4c6fba3 commit 0f64225
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion youtube_dl/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -3004,8 +3004,11 @@ def unpack(self, string):
# new class in collections
try:
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:
# Py < 3.3
# Py <= 3.3
class compat_collections_chain_map(compat_collections_abc.MutableMapping):

maps = [{}]
Expand Down Expand Up @@ -3060,6 +3063,7 @@ def new_child(self, m=None, **kwargs):
def parents(self):
return compat_collections_chain_map(*(self.maps[1:]))


# Pythons disagree on the type of a pattern (RegexObject, _sre.SRE_Pattern, Pattern, ...?)
compat_re_Pattern = type(re.compile(''))

Expand Down

0 comments on commit 0f64225

Please sign in to comment.