Title: Improve error message for unterminated strings with escapes · Issue #100445 · python/cpython · GitHub
Open Graph Title: Improve error message for unterminated strings with escapes · Issue #100445 · python/cpython
X Title: Improve error message for unterminated strings with escapes · Issue #100445 · python/cpython
Description: Inspired by #55688 and #94768. Currently, this code raises the following error: >>> "asdf\" File "
Open Graph Description: Inspired by #55688 and #94768. Currently, this code raises the following error: >>> "asdf\" File "
X Description: Inspired by #55688 and #94768. Currently, this code raises the following error: >>> "asdf\" File "<stdin>", line 1 "asdf\" ^ SyntaxError: unterminated s...
Opengraph URL: https://github.com/python/cpython/issues/100445
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Improve error message for unterminated strings with escapes","articleBody":"Inspired by #55688 and #94768.\r\n\r\nCurrently, this code raises the following error:\r\n```\r\n\u003e\u003e\u003e \"asdf\\\"\r\n File \"\u003cstdin\u003e\", line 1\r\n \"asdf\\\"\r\n ^\r\nSyntaxError: unterminated string literal (detected at line 1)\r\n```\r\n\r\nMaybe there's room to make this error message more helpful, to make the source of the error more obvious for users unfamiliar with escapes. Could the following be better?\r\n```\r\n\u003e\u003e\u003e \"asdf\\\"\r\n File \"\u003cstdin\u003e\", line 1\r\n \"asdf\\\"\r\n ^\r\nSyntaxError: unterminated string literal (detected at line 1); perhaps you escaped the end quote?\r\n```\r\n\r\n(The raw string situation in the linked issues that inspired this is a little extra tricky, since the workaround is still not clear. But hopefully the message still makes it clearer to users what is going on)\r\n\r\n\u003c!-- gh-linked-prs --\u003e\r\n### Linked PRs\r\n* gh-100446\r\n\u003c!-- /gh-linked-prs --\u003e\r\n","author":{"url":"https://github.com/hauntsaninja","@type":"Person","name":"hauntsaninja"},"datePublished":"2022-12-23T00:50:06.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/100445/cpython/issues/100445"}
| 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:106fcc14-cbf9-7ea6-113f-1c7908d18f6e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CC90:3A486F:83BA4D:B08A7A:6A5308AB |
| html-safe-nonce | 2a8ef58058b4e01da92a9448b38a73b88a6e16124f48bd03df312a0661dccc37 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQzkwOjNBNDg2Rjo4M0JBNEQ6QjA4QTdBOjZBNTMwOEFCIiwidmlzaXRvcl9pZCI6Ijc3NzYxNDcxMzg1NDgwMDkxMzEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d444e94542282bc6b4ff67749a6e43e21d6fd3f2480f2346b1b63752814e5db4 |
| hovercard-subject-tag | issue:1508723916 |
| 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/100445/issue_layout |
| twitter:image | https://opengraph.githubassets.com/05da222e2c677ccdbc5a4e10194bc5d6496c5f1646334671456d4a9e4867b16d/python/cpython/issues/100445 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/05da222e2c677ccdbc5a4e10194bc5d6496c5f1646334671456d4a9e4867b16d/python/cpython/issues/100445 |
| og:image:alt | Inspired by #55688 and #94768. Currently, this code raises the following error: >>> "asdf\" File " |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | hauntsaninja |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| 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 | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width