Mercurial > hgrepos > Python > apps > py-cutils
diff cutils/util/__init__.py @ 376:54a6d4534ef4
Convert some further value checks from plain Python assertions into real checks
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 05 May 2025 13:04:49 +0200 |
| parents | bfe1160fbfd3 |
| children | 6d7659a709f2 |
line wrap: on
line diff
--- 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:
