# HG changeset patch # User Franz Glasner # Date 1746443089 -7200 # Node ID 54a6d4534ef400bfe0be75fb8ef2ac9816b5254a # Parent 7044c2900890bfefab8fdf8d74baa5719f366da2 Convert some further value checks from plain Python assertions into real checks diff -r 7044c2900890 -r 54a6d4534ef4 cutils/util/__init__.py --- a/cutils/util/__init__.py Mon May 05 09:21:55 2025 +0200 +++ b/cutils/util/__init__.py Mon May 05 13:04:49 2025 +0200 @@ -393,12 +393,17 @@ tformatstr = formatstr.decode("latin1") tvalues = [] for v in values: + # Do not automatically convert text (unicode) string values into bytes. if PY2: if isinstance(v, unicode): # noqa: F821 undefined name 'unicode' - assert False + raise TypeError( + "unicode values not supported when interpolating" + " into bytes") else: if isinstance(v, str): - assert False + raise TypeError( + "unicode (native string) values not supported when" + " interpolating into bytes") if isinstance(v, bytes): tvalues.append(v.decode("latin1")) else: diff -r 7044c2900890 -r 54a6d4534ef4 cutils/util/fnmatch.py --- a/cutils/util/fnmatch.py Mon May 05 09:21:55 2025 +0200 +++ b/cutils/util/fnmatch.py Mon May 05 13:04:49 2025 +0200 @@ -213,7 +213,10 @@ matchers = [] if filter_definitions: for action, kpattern in filter_definitions: - assert action in ("include", "exclude", "accept-treesum") + if action not in ("include", "exclude", "accept-treesum"): + raise ValueError( + "unknown action in filter definitions: {}" + .format(action)) kind, sep, pattern = kpattern.partition(':') if not sep: # use the default