Two error messages were built from plain string literals containing
{...} placeholders but missing the f prefix, so the literal placeholder
text was shown to the user instead of the offending value:
- types/datetime.py: "timestamp too small (before year 1): {s!r}"
- types/json.py: "unknown jsonb binary format: {data[0]}"
The sibling branches next to the datetime message are already f-strings,
which is what makes the omission stand out. Add the missing prefix to
both so the value is interpolated.
Fixes #1372
no `!NoneType` dumper registered in python implementation (:ticket:`#1325`).
- Fix `!wait_selector` wait function to not raise `!KeyError`
(:ticket:`#1327`).
+- Fix `!DataError` messages leaking the literal ``{...}`` placeholder instead
+ of the offending value when loading a pre-year-1 :sql:`timestamp` or a
+ malformed binary :sql:`jsonb` value (:ticket:`#1372`).
Current release
return len(s.split()[-1]) > 4 # year is last token
if s == "-infinity" or s.endswith("BC"):
- return DataError("timestamp too small (before year 1): {s!r}")
+ return DataError(f"timestamp too small (before year 1): {s!r}")
elif s == "infinity" or is_overflow(s):
return DataError(f"timestamp too large (after year 10K): {s!r}")
else:
def load(self, data: Buffer) -> Any:
if data and data[0] != 1:
- raise DataError("unknown jsonb binary format: {data[0]}")
+ raise DataError(f"unknown jsonb binary format: {data[0]}")
if not isinstance((data := data[1:]), bytes):
data = bytes(data)
return self.loads(data)