From 7a38d81ff9ff68279091d63fdfcdb15fe3d132eb Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 20 Dec 2021 12:00:46 -0800 Subject: [PATCH] mesonlib: allow check_dirent_issues to take an iterable There's no reason it needs a concrete list, any iterable is fine. This does mean that we need to explicitly check for `str | bytes` in the listify pass, as `str` and `bytes` are both iterable. --- mesonbuild/mesonlib/universal.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mesonbuild/mesonlib/universal.py b/mesonbuild/mesonlib/universal.py index e86fb9930..1bbc2c641 100644 --- a/mesonbuild/mesonlib/universal.py +++ b/mesonbuild/mesonlib/universal.py @@ -245,7 +245,7 @@ def is_ascii_string(astring: T.Union[str, bytes]) -> bool: return True -def check_direntry_issues(direntry_array: T.Union[T.List[T.Union[str, bytes]], str, bytes]) -> None: +def check_direntry_issues(direntry_array: T.Union[T.Iterable[T.Union[str, bytes]], str, bytes]) -> None: import locale # Warn if the locale is not UTF-8. This can cause various unfixable issues # such as os.stat not being able to decode filenames with unicode in them. @@ -253,7 +253,7 @@ def check_direntry_issues(direntry_array: T.Union[T.List[T.Union[str, bytes]], s # encoding, so we can just warn about it. e = locale.getpreferredencoding() if e.upper() != 'UTF-8' and not is_windows(): - if not isinstance(direntry_array, list): + if isinstance(direntry_array, (str, bytes)): direntry_array = [direntry_array] for de in direntry_array: if is_ascii_string(de):