Repository navigation
Conversation
Connection.escape() handles a bytearray passed as a single parameter, but escape_item() has no encoder for it, so a bytearray inside a list or tuple fell back to escape_str and was sent as the text "bytearray(b'ab')".
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Encoder mapping and output test pymysql/converters.py, pymysql/tests/test_converters.py |
The encoder map assigns bytearray to escape_bytes. The test checks that sequences containing bytes or bytearray produce (_binary X'6162'). |
Estimated code review effort: 1 (Trivial) | ~5 minutes
Change: Bug fix
Suggested reviewers: methane
Merge Risk: 
Minimal · up to 81901
-
No actionable merge-blocking risk remains for this narrowly scoped encoder change.
Pre-merge checks: 
5
-
Full details: Docstring Coverage
-
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 2 files.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
|
fixed in 60eae5c |
Requested by Taltal
A
bytearraypassed as a single parameter is encoded as binary, but one inside a list or tuple is not:Connection.escape()checks forbytesandbytearrayitself, but sequences go throughconverters.escape_item(), whoseencoderstable only hasbytes. Abytearrayfalls back toescape_str, so the query silently compares against the text of its repr.This adds
bytearray: escape_bytestoencoders, so it gets the same_binary X'...'output asbytes.The new test in
test_converters.pyfails onmainand passes with the fix, andruff checkandruff format --checkare clean. I did not run the suites that need a MySQL server.Summary by CodeRabbit