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 — [doc] pdb access to return value · Issue #86690 · python/cpython

[doc] pdb access to return value #86690

New issue
Copy link
New issue
Copy link
Closed
Closed
[doc] pdb access to return value#86690
Copy link
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.9 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

Description

romuald
mannequin
opened on Dec 1, 2020
Issue body actions
BPO 42524
Nosy @romuald, @iritkatriel
PRs
  • gh-86690: Add retval [variable] option to pdb #23601
  • gh-86690: pdb: additional documentation on retval #27612
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2020-12-01.15:13:18.533>
    labels = ['type-feature', 'library', '3.9', '3.10', '3.11']
    title = '[doc] pdb access to return value'
    updated_at = <Date 2021-08-05.08:10:47.486>
    user = 'https://github.com/romuald'

    bugs.python.org fields:

    activity = <Date 2021-08-05.08:10:47.486>
    actor = 'Romuald'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2020-12-01.15:13:18.533>
    creator = 'Romuald'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 42524
    keywords = ['patch']
    message_count = 5.0
    messages = ['382259', '398853', '398855', '398894', '398896']
    nosy_count = 2.0
    nosy_names = ['Romuald', 'iritkatriel']
    pr_nums = ['23601', '27612']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue42524'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    Activity

    1. romuald commented on Dec 1, 2020

      @romuald
      romualdmannequin
      on Dec 1, 2020
      MannequinAuthor
      More actions

      When using the pdb module, there is currently no way to easy access the current return value of the stack

      This return value is accessed by the 'retval command'

      I propose using the currently unused argument to allow storing the return value in the local variables, accessible via the debugger

      For example:

          def foo():
              debugger()
              return ComplexObject()
      
          def bar():
              return foo()

      (pdb) retval
      <ComplexObject instance at 0x1234>
      (pdb) retval zz
      (pdb) zz.attribute
      'some value'

    2. romuald
      added
      3.10 (EOL)end of lifeend of life
      stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
      type-featureA feature request or enhancementA feature request or enhancement
      on Dec 1, 2020
    3. iritkatriel commented on Aug 3, 2021

      @iritkatriel
      iritkatriel
      on Aug 3, 2021
      Member
      More actions

      It actually is in the locals, and it's called __return__. So you can access it with

      locals()['__return__']

      I'll try to see where that can be documented.

    4. iritkatriel
      added
      3.9 (EOL)end of lifeend of life
      3.11only security fixesonly security fixes
      on Aug 3, 2021
    5. iritkatriel
      changed the title [-]pdb access to return value[/-] [+][doc] pdb access to return value[/+] on Aug 3, 2021
    6. iritkatriel
      added
      3.9 (EOL)end of lifeend of life
      3.11only security fixesonly security fixes
      on Aug 3, 2021
    7. iritkatriel
      changed the title [-]pdb access to return value[/-] [+][doc] pdb access to return value[/+] on Aug 3, 2021
    8. iritkatriel commented on Aug 3, 2021

      @iritkatriel
      iritkatriel
      on Aug 3, 2021
      Member
      More actions

      I just noticed your PR. Would you like to continue working on this?

      I think we should update the documentation of retval (in the doc and in the function's doctring) to say:

      """
      retval
      Print the return value for the last return of a function. Alternatively, the return value can be accessed with locals()['__return__'].
      """

      Then add unit tests and examples as you did.

    9. romuald commented on Aug 4, 2021

      @romuald
      romualdmannequin
      on Aug 4, 2021
      MannequinAuthor
      More actions

      I'm not sure I follow.

      You wish to "simply" update the doc? (and not update the retval to allow storing it into a varible. I'm OK with that)

      But if we choose this, I'm not sure what needs changing in the doctests :-?

      Another interrogation: is the use locals() really necessary? I can see that I can simply use __return__ to access the return object.
      Is there a reason to access it via locals() inside pdb?

    10. iritkatriel commented on Aug 4, 2021

      @iritkatriel
      iritkatriel
      on Aug 4, 2021
      Member
      More actions

      Yes, exactly - to update the doc so that the next person who needs it will easily find a way to do it (which was not available to you when you created this issue).

      The test should assert that what the doc says, so that if someone breaks documented functionality we will immediately know.

      Your point about accessing __return__ directly from the prompt is interesting - sure, if that works just document that and make sure the test fails if we make a change that breaks it.

    11. ezio-melotti
      transferred this issue fromon Apr 10, 2022
    12. gaogaotiantian commented on Oct 7, 2023

      @gaogaotiantian
      gaogaotiantian
      on Oct 7, 2023
      Member
      More actions

      The return value can be accessed with $_retval now.

    13. gaogaotiantian
      closed this as completedon Oct 7, 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

      3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.9 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-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.