Fix processing of non-string key actions

This commit is contained in:
Kovid Goyal
2020-09-18 20:41:31 +05:30
parent f936918278
commit 9efdfe0de4

View File

@@ -7,7 +7,9 @@ import os
import posixpath import posixpath
from contextlib import suppress from contextlib import suppress
from functools import lru_cache from functools import lru_cache
from typing import Generator, Iterable, List, NamedTuple, Optional, Tuple, cast from typing import (
Any, Generator, Iterable, List, NamedTuple, Optional, Tuple, cast
)
from urllib.parse import ParseResult, unquote, urlparse from urllib.parse import ParseResult, unquote, urlparse
from .conf.utils import to_bool, to_cmdline from .conf.utils import to_bool, to_cmdline
@@ -152,8 +154,10 @@ def actions_for_url_from_list(url: str, actions: Iterable[OpenAction]) -> Genera
'FRAGMENT': purl.fragment 'FRAGMENT': purl.fragment
} }
def expand(x: str) -> str: def expand(x: Any) -> Any:
return expandvars(x, env, fallback_to_os_env=False) if isinstance(x, str):
return expandvars(x, env, fallback_to_os_env=False)
return x
for action in actions: for action in actions:
if url_matches_criteria(purl, url, action.match_criteria): if url_matches_criteria(purl, url, action.match_criteria):