Title: Misleading documentation of `!` prefix in `pdb` · Issue #104301 · python/cpython · GitHub
Open Graph Title: Misleading documentation of `!` prefix in `pdb` · Issue #104301 · python/cpython
X Title: Misleading documentation of `!` prefix in `pdb` · Issue #104301 · python/cpython
Description: The documentation for pdb says: .. pdbcommand:: ! statement Execute the (one-line) *statement* in the context of the current stack frame. The exclamation point can be omitted unless the first word of the statement resembles a debugger co...
Open Graph Description: The documentation for pdb says: .. pdbcommand:: ! statement Execute the (one-line) *statement* in the context of the current stack frame. The exclamation point can be omitted unless the first word ...
X Description: The documentation for pdb says: .. pdbcommand:: ! statement Execute the (one-line) *statement* in the context of the current stack frame. The exclamation point can be omitted unless the first word ...
Opengraph URL: https://github.com/python/cpython/issues/104301
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Misleading documentation of `!` prefix in `pdb`","articleBody":"The documentation for `pdb` says:\r\n\r\n```\r\n.. pdbcommand:: ! statement \r\n \r\n Execute the (one-line) *statement* in the context of the current stack frame. \r\n The exclamation point can be omitted unless the first word of the statement \r\n resembles a debugger command. To set a global variable, you can prefix the \r\n assignment command with a :keyword:`global` statement on the same line, \r\n e.g.:: \r\n \r\n (Pdb) global list_options; list_options = ['-l'] \r\n (Pdb)\r\n```\r\n\r\nWhich suggests that the prefix is used with a space between the `!` prefix and the statement to be executed. However, [the implementation](https://github.com/python/cpython/blob/9af485436b83003b5705a6e54bdeb900c70e0c69/Lib/pdb.py#L443) consumes _only the prefix_, which means that the natural reading of the docs leads to an `IndentationError`:\r\n\r\n```\r\n$ python3 test.py \r\n--Return--\r\n\u003e /home/snoopjedi/repos/cpython/test.py(3)\u003cmodule\u003e()-\u003eNone\r\n-\u003e breakpoint()\r\n(Pdb) l\r\n 1 lst = [1, 2, 3]\r\n 2 it = iter(lst)\r\n 3 -\u003e breakpoint()\r\n[EOF]\r\n(Pdb) ! next(it)\r\n*** IndentationError: unexpected indent\r\n```\r\n\r\nwhile omitting the space gives the intended result:\r\n\r\n```\r\n(Pdb) !next(it)\r\n1\r\n```\r\n\r\nIt would also be helpful to have an example in the documentation that actually uses the prefix for first-word disambiguation as described in the text.\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-104302\n* gh-104342\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/SnoopJ","@type":"Person","name":"SnoopJ"},"datePublished":"2023-05-08T19:08:36.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/104301/cpython/issues/104301"}
| 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:4d2a9a02-7fdf-1640-0ec9-b10d971d327d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9482:3AAB0D:9177CD:C2217D:6969BEB2 |
| html-safe-nonce | 9ed04a9bedfa3894a526096e77428c99266a1b93536b9eac32e0d44bd4f27692 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NDgyOjNBQUIwRDo5MTc3Q0Q6QzIyMTdEOjY5NjlCRUIyIiwidmlzaXRvcl9pZCI6IjY0MDYxODk3NTIzNjQxNTQ1NDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 577b611ea455e2cb46ea3bbdc4e12b4c2b9dcc8d32f15717727180d6d930f3e6 |
| hovercard-subject-tag | issue:1700777722 |
| 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/104301/issue_layout |
| twitter:image | https://opengraph.githubassets.com/11f51a7d3ca909e25f77e22b3a86255e6497b171971cfddac9d0543664391e5e/python/cpython/issues/104301 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/11f51a7d3ca909e25f77e22b3a86255e6497b171971cfddac9d0543664391e5e/python/cpython/issues/104301 |
| og:image:alt | The documentation for pdb says: .. pdbcommand:: ! statement Execute the (one-line) *statement* in the context of the current stack frame. The exclamation point can be omitted unless the first word ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | SnoopJ |
| 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