return d
raise e.ProgrammingError(
- f"cannot adapt type {cls.__name__}"
- f" to format {PyFormat(format).name}"
+ f"cannot adapt type {cls.__name__!r} using placeholder '%{format}'"
+ f" (format: {PyFormat(format).name})"
)
def get_dumper_by_oid(self, oid: int, format: pq.Format) -> Type["Dumper"]:
)
elif ph[-1:] not in b"sbt":
raise e.ProgrammingError(
- f"only '%s', '%b', '%t' placeholders allowed, got"
- f" {m.group(0).decode(encoding)}"
+ f"only '%s', '%b', '%t' are allowed as placeholders, got"
+ f" '{m.group(0).decode(encoding)}'"
)
# Index or name
def test_no_adapter(conn):
point = Point(1.2, 3.4)
with pytest.raises(
- psycopg.ProgrammingError, match="cannot adapt type Point"
+ psycopg.ProgrammingError, match="cannot adapt type 'Point'"
):
conn.execute("SELECT pg_typeof(%s)", [point]).fetchone()[0]