Skip to content

Fix for issue 528 - quoting string literals in list/dict/set - #529

Merged
rocky merged 1 commit into
rocky:masterfrom
charlesgwaldman:issue-528
Oct 5, 2026
Merged

rocky merged 1 commit into
rocky:masterfrom
charlesgwaldman:issue-528

Conversation

@charlesgwaldman

Copy link
Copy Markdown
Contributor

Fix string quoting of constant collection elements in n_const_list

Fixes #528.

Elements of folded constant collections (BUILD_CONST_LIST/SET/KEY_MAP, 5+ elements) were misquoted. Add a new format_const() helper: emits pattr on 3.x, repr's the raw value on 2.x.

Fixes two cases:

2.7 list/set string elements printed unquoted
3.6+ const dict values printed double-repr'd (the old "%r" % pattr re-repr'd an already-repr'd string).

3.x list/set output is unchanged.

Note that there's a mix of single and double quotes in the 3.x disassembly but I think this is purely cosmetic.

D = {239: 240, 168: 169, 54: 55, 128: 129, 'fred': "wilma"}

Test: test/simple_source/bug27+/05_const_collection.py (self-checking), with 2.7 and 3.6 fixtures covering the list/set and dict paths respectively.

@rocky

rocky commented Oct 5, 2026

Copy link
Copy Markdown
Owner

Looks good - thanks!

@rocky
rocky merged commit 91298ba into rocky:master Oct 5, 2026
3 checks passed
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.

Incorrect quoting of string constants in lists (2.7) and dicts (3.x)

2 participants