aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/utils.py
diff options
context:
space:
mode:
authordirkf <fieldhouse@gmx.net>2023-07-13 20:14:50 +0100
committerdirkf <fieldhouse@gmx.net>2023-07-18 10:50:46 +0100
commit1d8d5a93f7187438587c3a754b53fdf30322cef0 (patch)
tree742e29d44245efcb5db44a0a5e70b5c9675c4074 /youtube_dl/utils.py
parent1634b1d61efa36c31c86b8c64c88dc297a7af28a (diff)
[test] Fixes for old Pythons
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r--youtube_dl/utils.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index ac6c81465..494f8341b 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -6198,7 +6198,8 @@ def traverse_obj(obj, *paths, **kwargs):
elif isinstance(obj, compat_re_Match):
result = None
if isinstance(key, int) or casesense:
- result = lookup_or_none(obj, key, getter=compat_re_Match.group)
+ # Py 2.6 doesn't have methods in the Match class/type
+ result = lookup_or_none(obj, key, getter=lambda _, k: obj.group(k))
elif isinstance(key, str):
result = next((v for k, v in obj.groupdict().items()
@@ -6246,7 +6247,10 @@ def traverse_obj(obj, *paths, **kwargs):
if __debug__ and callable(key):
# Verify function signature
- inspect.getcallargs(key, None, None)
+ args = inspect.getargspec(key)
+ if len(args.args) != 2:
+ # crash differently in 2.6 !
+ inspect.getcallargs(key, None, None)
new_objs = []
for obj in objs: