GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Make expressions in pdb work as people would expect · Issue #108463 · python/cpython

Make expressions in pdb work as people would expect #108463

New issue
Copy link
New issue
Copy link
Closed
Closed
Make expressions in pdb work as people would expect#108463
Copy link
Labels
type-featureA feature request or enhancementA feature request or enhancement

Description

@gaogaotiantian
gaogaotiantian
opened on Aug 25, 2023
Issue body actions

Feature or enhancement

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Proposal:

When people are using pdb, they often input an expression to check the evaluation of the expression.

(Pdb) data = 1
(Pdb) data
1
(Pdb)

This would normally work, but it could get complicated when the variable happens to be a command as well. If the variable is a command, there's nothing we can do, but we can deal with it in the following situation:

(Pdb) c.a

Before #103464, this would simply do a continue, which is a horrible experience for users - it's so confusing. After the argument check, it can realize the command "c(ontinue)" comes with an argument ".a" which is weird, and refuse to execute it with a warning to the user. However, the more intuitive result for the input is to print c.a - that's what the user expects.

The problem behind it is how cmd.Cmd parses commands - by default the identchars are the ones that can be used for a variable name, which makes sense, but would parse c.a as command c and argument .a.

For pdb, we'd rather parse this as command c.a - search for it's corresponding do_ method - fail and fallback to default which is run it in Python.

Therefore, we should expand the identchars for Pdb, so we can read this full expression/statement as a command to trigger the default behavior, rather than to use the part that can be a variable name as the command - in no case that works as expected.

This would make inputs like

c.a
c['a']
n()
j=1
r"a"

work.

Linked PRs

  • gh-108463: Make expressions/statements work as expected in pdb #108464

Activity

  1. gaogaotiantian
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Aug 25, 2023
  2. iritkatriel
    added a commit that references this issue on Sep 4, 2023

    gh-108463: Make expressions/statements work as expected in pdb (#108464)

    6304d98
  3. gaogaotiantian commented on Sep 4, 2023

    @gaogaotiantian
    gaogaotiantian
    on Sep 4, 2023
    MemberAuthor
    More actions

    Done in #108464

  4. gaogaotiantian
    closed this as completedon Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancementA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.