Skip to content

utils.escape() raises TypeError for ASCII bytes - #39

Open
SAY-5 wants to merge 1 commit into
TurboGears:masterfrom
SAY-5:fix-escape-ascii-bytes
Open

SAY-5 wants to merge 1 commit into
TurboGears:masterfrom
SAY-5:fix-escape-ascii-bytes

Conversation

@SAY-5

@SAY-5 SAY-5 commented Aug 25, 2026

Copy link
Copy Markdown

Fixes #35.

escape() decoded bytes with 'ascii' just to check, then discarded the result, so ASCII bytes stayed bytes and crashed on the str.replace() calls below. Decoding unconditionally with utf-8/replace fixes both the ASCII and non-ASCII paths.

Added an ASCII bytes case to test_utils.py, confirmed it fails on master (TypeError) and passes with the fix. Full suite (80 tests) still green.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

utils.escape() raises TypeError for ASCII bytes

1 participant