pg.ddx.io  psycopg/psycopg GitHub issues and pull requests  
help / color / mirror / Atom feed
From: anish-yen (@anish-yen) <noreply+anish-yen@github.com>
To: psycopg/psycopg <noreply+psycopg-psycopg@github.com>
Subject: Re: [psycopg/psycopg] PR #1505: Decode JSON data using the connection encoding
Date: Fri, 20 Nov 2026 00:11:18 +0000
Message-ID: <gh-psycopg-psycopg-1505-c7025942798@github.com> (raw)
In-Reply-To: <gh-psycopg-psycopg-1505@github.com>
References: <gh-psycopg-psycopg-1505@github.com>

Thanks for the review! All addressed in the two follow-up commits:

- Dumping: `_JsonDumper` now encodes `str` results in the connection encoding, and recodes utf8 bytes returned by the dumps function when the database encoding is not utf8/SQL_ASCII (left as-is in those two cases, as you suggested).
- Tests: added `test_dump_non_utf8_encoding` on the grid you proposed: encoding (utf8, sql_ascii, latin9) x dumps returning str with `ensure_ascii=False` or utf8 bytes x json/jsonb, in both text and binary formats.
- Style: `_decode()` renamed to `_maybe_decode()`, it now uses `str(data, self._encoding)` so memoryview works without the `bytes()` conversion, and the comment moved onto the function.
- Updated the changelog entry to mention dumping too.

I left the SQL_ASCII-with-non-utf8-database corner case alone, per your comment.

view thread (10+ messages)

Message-ID: <gh-psycopg-psycopg-1505-c7025942798@github.com>
Permalink:  ../gh-psycopg-psycopg-1505-c7025942798@github.com/

 · 


This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox