You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two DataError messages in the pure-Python implementation are plain string literals that contain {...} placeholders but are missing the f prefix, so the literal placeholder text is shown to the user instead of the offending value.
returnDataError("timestamp too small (before year 1): {s!r}")
The two sibling branches immediately below it are correctly f-strings (f"timestamp too large (after year 10K): {s!r}", f"can't parse timestamp {s!r}: ..."), which is what makes the missing prefix stand out.
frompsycopg.types.datetimeimport_get_timestamp_load_errorfrompsycopg.types.jsonimportJsonbBinaryLoaderfrompsycopgimport_oidsprint(_get_timestamp_load_error(None, b"0001-01-01 00:00:00 BC"))
# -> timestamp too small (before year 1): {s!r}try:
JsonbBinaryLoader(_oids.JSONB_OID, None).load(b"\x02{}")
exceptExceptionase:
print(e)
# -> unknown jsonb binary format: {data[0]}
Expected
timestamp too small (before year 1): '0001-01-01 00:00:00 BC'
unknown jsonb binary format: 2
A repo-wide grep confirms these are the only two occurrences of the pattern (every other {...}-in-a-plain-string case is an intentional sql.SQL(...).format(...) template). I'll open a PR adding the missing f prefix to both.
Activity
Fix missing f-string prefix in two DataError messages