Skip to content

gh-162525: Fix json C encoder for str subclass separators - #162526

Open
thejesh23 wants to merge 5 commits into
python:mainfrom
thejesh23:fix-json-str-subclass-separators
Open

thejesh23 wants to merge 5 commits into
python:mainfrom
thejesh23:fix-json-str-subclass-separators

Conversation

@thejesh23

@thejesh23 thejesh23 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Write the separators with _PyUnicodeWriter_WriteStr(), like gh-148241 did for keys and values.

The new tests fail for C without the fix. test_json passes, also with -R 3:3.

Comment thread Lib/test/test_json/test_separators.py Outdated
return "StrSubclass"

h = {'a': [1, 2], 'b': 3}
seps = (StrSubclass(','), StrSubclass(':'))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use separators different than default seperators, to check that they are used?

For example, use (',_', ':_') or (', ', ': ') (1 and 2 spaces).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, switched to (',_', ':_').

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants