Title: Parts of strings that look like comments being stripped out of nested strings with debug specifier · Issue #135148 · python/cpython · GitHub
Open Graph Title: Parts of strings that look like comments being stripped out of nested strings with debug specifier · Issue #135148 · python/cpython
X Title: Parts of strings that look like comments being stripped out of nested strings with debug specifier · Issue #135148 · python/cpython
Description: Bug report Bug description: Is this desired behavior? $ ./python -m ast f'{""" # this is part of the string, it shouldn't be stripped out """=}' Module( body=[ Expr( value=JoinedStr( values=[ Constant(value='""" \n"""='), FormattedValue(...
Open Graph Description: Bug report Bug description: Is this desired behavior? $ ./python -m ast f'{""" # this is part of the string, it shouldn't be stripped out """=}' Module( body=[ Expr( value=JoinedStr( values=[ Const...
X Description: Bug report Bug description: Is this desired behavior? $ ./python -m ast f'{""" # this is part of the string, it shouldn't be stripped out """=}' Module( bo...
Opengraph URL: https://github.com/python/cpython/issues/135148
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Parts of strings that look like comments being stripped out of nested strings with debug specifier","articleBody":"# Bug report\n\n### Bug description:\n\nIs this desired behavior?\n```\n$ ./python -m ast\nf'{\"\"\" # this is part of the string, it shouldn't be stripped out\n\"\"\"=}'\nModule(\n body=[\n Expr(\n value=JoinedStr(\n values=[\n Constant(value='\"\"\" \\n\"\"\"='),\n FormattedValue(\n value=Constant(value=\" # this is part of the string, it shouldn't be stripped out\\n\"),\n conversion=114)]))])\n\n$ ./python -m ast\nt'{\"\"\" # this is part of the string, it shouldn't be stripped out\n\"\"\"=}'\nModule(\n body=[\n Expr(\n value=TemplateStr(\n values=[\n Constant(value='\"\"\" \\n\"\"\"='),\n Interpolation(\n value=Constant(value=\" # this is part of the string, it shouldn't be stripped out\\n\"),\n str='\"\"\" \\n\"\"\"',\n conversion=114)]))])\n```\nEven if they are not actually multiline:\n```\n$ python -m ast\nt'{\" # nooo \"=}'\nModule(\n body=[\n Expr(\n value=TemplateStr(\n values=[\n Constant(value='\" '),\n Interpolation(\n value=Constant(value=' # nooo '),\n str='\"',\n conversion=114)]))])\n\n```\nSeems to go back to 3.12\n\n### CPython versions tested on:\n\n3.14, CPython main branch\n\n### Operating systems tested on:\n\n_No response_\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-135198\n* gh-136720\n* gh-136899\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/tom-pytel","@type":"Person","name":"tom-pytel"},"datePublished":"2025-06-04T18:55:30.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/135148/cpython/issues/135148"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:cf0221ee-02f0-5c81-fa8f-bd63b4d41514 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D9EC:385F9F:21EA983:2E292D4:696ACD06 |
| html-safe-nonce | 02f5673645fb0fe34e77b009c7479cbfe31230ee4abbae8eb541e0b84ac86db5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOUVDOjM4NUY5RjoyMUVBOTgzOjJFMjkyRDQ6Njk2QUNEMDYiLCJ2aXNpdG9yX2lkIjoiMjI5MzQyNzM2MDA0MTE5MjcxMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 51642c24e588e801ccded84b927648d7b5547e55384ac8531ec786af497fffde |
| hovercard-subject-tag | issue:3118797188 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/135148/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a6dc58da1afb4af379b1cdb73c4f48a3cd49da8203d1a634d97f7e162471c977/python/cpython/issues/135148 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a6dc58da1afb4af379b1cdb73c4f48a3cd49da8203d1a634d97f7e162471c977/python/cpython/issues/135148 |
| og:image:alt | Bug report Bug description: Is this desired behavior? $ ./python -m ast f'{""" # this is part of the string, it shouldn't be stripped out """=}' Module( body=[ Expr( value=JoinedStr( values=[ Const... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tom-pytel |
| hostname | github.com |
| expected-hostname | github.com |
| None | c785f4ce187e9e7331257791b36ddee01625bb8e292a9b4fe2c16d4c006abf5d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | c718a376fcf780eb22089171adb84a543f660bf7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width