From: Daniele Varrazzo Date: Wed, 20 Oct 2021 11:16:42 +0000 (+0200) Subject: Fix wrong error message on unknown PostgreSQL encoding X-Git-Tag: 3.0.2~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c0d13eb05bf9acc71afec43a95cbce6e20b844e;p=thirdparty%2Fpsycopg.git Fix wrong error message on unknown PostgreSQL encoding Reported in #122. --- diff --git a/psycopg/psycopg/_encodings.py b/psycopg/psycopg/_encodings.py index 705e1cadf..0d917466a 100644 --- a/psycopg/psycopg/_encodings.py +++ b/psycopg/psycopg/_encodings.py @@ -88,4 +88,6 @@ def pg2pyenc(name: Union[bytes, str]) -> str: try: return py_codecs[name] except KeyError: - raise NotSupportedError("codec not available in Python: {name!r}") + if isinstance(name, bytes): + name = name.decode("utf8", "replace") + raise NotSupportedError(f"codec not available in Python: {name!r}")