Title: dis._try_compile: traceback printed on error in source argument is too wordy · Issue #102114 · python/cpython · GitHub
Open Graph Title: dis._try_compile: traceback printed on error in source argument is too wordy · Issue #102114 · python/cpython
X Title: dis._try_compile: traceback printed on error in source argument is too wordy · Issue #102114 · python/cpython
Description: _try_compile function from dis module firstly tries to compile given source string with 'eval' mode and, if exception is occured, catches it and tries again with 'exec' mode. These actions lead to a long chained traceback if given string...
Open Graph Description: _try_compile function from dis module firstly tries to compile given source string with 'eval' mode and, if exception is occured, catches it and tries again with 'exec' mode. These actions lead to ...
X Description: _try_compile function from dis module firstly tries to compile given source string with 'eval' mode and, if exception is occured, catches it and tries again with 'exec' mode. These ...
Opengraph URL: https://github.com/python/cpython/issues/102114
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"dis._try_compile: traceback printed on error in source argument is too wordy","articleBody":"`_try_compile` function from `dis` module firstly tries to compile given source string with `'eval'` mode and, if exception is occured, catches it and tries again with `'exec'` mode. These actions lead to a long chained traceback if given string contains syntax/indentation error, because this string gets refused by `compile` in both `'eval'` and `'exec'` modes.\r\nAll functions/constructors from `dis` module that use `_try_compile` and accept source string as an argument (`dis`, `get_instructions`, `code_info`, `show_code`, `Bytecode`) are showing this behavior:\r\n```python\r\n\u003e\u003e\u003e dis.dis(')')\r\nTraceback (most recent call last):\r\n File \"/home/.../cpython/Lib/dis.py\", line 67, in _try_compile\r\n c = compile(source, name, 'eval')\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"\u003cdis\u003e\", line 1\r\n )\r\n ^\r\nSyntaxError: unmatched ')'\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\r\n File \"/home/.../cpython/Lib/dis.py\", line 112, in dis\r\n _disassemble_str(x, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive)\r\n File \"/home/.../cpython/Lib/dis.py\", line 593, in _disassemble_str\r\n _disassemble_recursive(_try_compile(source, '\u003cdis\u003e'), **kwargs)\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"/home/.../cpython/Lib/dis.py\", line 69, in _try_compile\r\n c = compile(source, name, 'exec')\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"\u003cdis\u003e\", line 1\r\n )\r\n ^\r\nSyntaxError: unmatched ')'\r\n```\r\nPython versions affected: 3.10.8, 3.11.0, current main.\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-102115\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/chgnrdv","@type":"Person","name":"chgnrdv"},"datePublished":"2023-02-21T14:26:09.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/102114/cpython/issues/102114"}
| 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:9952ea19-e802-85a6-532a-a6d1a2ea399b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E90A:2EFAA1:A57B16:DE3CD2:6969C1C2 |
| html-safe-nonce | 0dd14520d18ed1e0177df516f7173e75e683ff110a642de5169e6471bb1f47b4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOTBBOjJFRkFBMTpBNTdCMTY6REUzQ0QyOjY5NjlDMUMyIiwidmlzaXRvcl9pZCI6IjQ2NzEwODY3NjY1MTkzMzc0MTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 5acfb0f4ea3e4b71d5884d22be974105158483919884924ba6e028405476ef64 |
| hovercard-subject-tag | issue:1593578525 |
| 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/102114/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b5e06de1d2245c5af32ebd271f1bc5da492b4b656a85889d814727cb54cd5ad8/python/cpython/issues/102114 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b5e06de1d2245c5af32ebd271f1bc5da492b4b656a85889d814727cb54cd5ad8/python/cpython/issues/102114 |
| og:image:alt | _try_compile function from dis module firstly tries to compile given source string with 'eval' mode and, if exception is occured, catches it and tries again with 'exec' mode. These actions lead to ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | chgnrdv |
| hostname | github.com |
| expected-hostname | github.com |
| None | acedec8b5f975d9e3d494ddd8f949b0b8a0de59d393901e26f73df9dcba80056 |
| 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 | 83c08c21cdda978090dc44364b71aa5bc6dcea79 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width