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
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -7,7 +7,9 @@ import os
import posixpath
from contextlib import suppress
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 .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
}
def expand(x: str) -> str:
return expandvars(x, env, fallback_to_os_env=False)
def expand(x: Any) -> Any:
if isinstance(x, str):
return expandvars(x, env, fallback_to_os_env=False)
return x
for action in actions:
if url_matches_criteria(purl, url, action.match_criteria):