Commit 648c67d
committed
Coerce user/database/server_settings to plain str before the wire
WriteBuffer.write_str() (in the vendored pgproto submodule) is typed
to accept exactly str and does not accept str subclasses -- e.g.
enum.StrEnum members, or third-party string-like values such as
tomlkit's -- even though isinstance(x, str) is True for them. When one
of these reaches the startup packet via user/database/server_settings,
building it raises a TypeError deep inside the compiled protocol
layer, which in turn triggers a secondary AttributeError ('Protocol'
object has no attribute '_on_error') while trying to report the
original failure, masking the real cause entirely.
Coerce user, database, and server_settings keys/values to plain str
right after they're resolved/validated in
_parse_connect_dsn_and_args(), before they ever reach the protocol
layer.
Verified against a real PostgreSQL server (Docker) with an
enum.StrEnum user and server_settings entry: TypeError/AttributeError
before the fix, successful connection after.
Fixes #1340.1 parent db8ecc2 commit 648c67d
2 files changed
Lines changed: 53 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
613 | 613 | | |
614 | 614 | | |
615 | 615 | | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
616 | 624 | | |
617 | 625 | | |
618 | 626 | | |
| |||
821 | 829 | | |
822 | 830 | | |
823 | 831 | | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
824 | 837 | | |
825 | 838 | | |
826 | 839 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1256 | 1256 | | |
1257 | 1257 | | |
1258 | 1258 | | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
1259 | 1299 | | |
1260 | 1300 | | |
1261 | 1301 | | |
| |||
0 commit comments