Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run modules with pdb #76387

Closed
mariocj89 mannequin opened this issue Dec 3, 2017 · 10 comments
Closed

Run modules with pdb #76387

mariocj89 mannequin opened this issue Dec 3, 2017 · 10 comments
Labels
3.7 stdlib type-feature

Comments

@mariocj89
Copy link
Mannequin

@mariocj89 mariocj89 mannequin commented Dec 3, 2017

BPO 32206
Nosy @jaraco, @ncoghlan, @ericvw, @mariocj89
PRs
  • #4752
  • #5111
  • #5474
  • #5474
  • 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 = <Date 2018-01-28.05:07:16.667>
    created_at = <Date 2017-12-03.13:36:40.972>
    labels = ['3.7', 'type-feature', 'library']
    title = 'Run modules with pdb'
    updated_at = <Date 2018-02-02.05:16:57.186>
    user = 'https://github.com/mariocj89'

    bugs.python.org fields:

    activity = <Date 2018-02-02.05:16:57.186>
    actor = 'mariocj89'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-01-28.05:07:16.667>
    closer = 'ncoghlan'
    components = ['Library (Lib)']
    creation = <Date 2017-12-03.13:36:40.972>
    creator = 'mariocj89'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 32206
    keywords = ['patch']
    message_count = 10.0
    messages = ['307513', '309493', '309540', '309541', '309548', '310780', '310882', '310883', '310916', '310918']
    nosy_count = 4.0
    nosy_names = ['jaraco', 'ncoghlan', 'ericvw', 'mariocj89']
    pr_nums = ['4752', '5111', '5474', '5474']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue32206'
    versions = ['Python 3.7']

    @mariocj89
    Copy link
    Mannequin Author

    @mariocj89 mariocj89 mannequin commented Dec 3, 2017

    Since PEP-338 we can run python modules as a script via python -m module_name but there is no way to run pdb on those (AFAIK).

    The proposal is to add a new argument "-m" to the pdb module to allow users to run python -m pdb -m my_module_name

    This is especially useful when working on cli tools that use entrypoints in setup.py, as there is no other way to run them.

    I have a WIP here: mariocj89@f47d1b7

    Haven't sent the PR as I am still polishing some issues. If it sounds like a good idea I'll clean it up and open the PR.

    @mariocj89 mariocj89 mannequin added 3.7 stdlib labels Dec 3, 2017
    @ncoghlan
    Copy link
    Contributor

    @ncoghlan ncoghlan commented Jan 5, 2018

    Linking back to the overall RFE for improved executable module support for standard library modules that run other scripts: https://bugs.python.org/issue9325

    @ncoghlan
    Copy link
    Contributor

    @ncoghlan ncoghlan commented Jan 6, 2018

    New changeset 9f1e5f1 by Nick Coghlan (Mario Corchero) in branch 'master':
    bpo-32206: Pdb can now run modules (GH-4752)
    9f1e5f1

    @ncoghlan
    Copy link
    Contributor

    @ncoghlan ncoghlan commented Jan 6, 2018

    Thanks for the patch!

    @ncoghlan ncoghlan closed this as completed Jan 6, 2018
    @ncoghlan ncoghlan added the type-feature label Jan 6, 2018
    @ncoghlan
    Copy link
    Contributor

    @ncoghlan ncoghlan commented Jan 6, 2018

    Re-opening for the CLI help updates.

    @ncoghlan ncoghlan reopened this Jan 6, 2018
    @jaraco
    Copy link
    Member

    @jaraco jaraco commented Jan 26, 2018

    Thanks for creating this functionality. I'm so excited to use it that I've published a backport [https://pypi.org/project/backports.pdb], which seems to work for at least the basic use cases on Python 2.7+.

    @jaraco
    Copy link
    Member

    @jaraco jaraco commented Jan 27, 2018

    Adopting the backport, I believe I've found a defect. I filed the defect with the backport as backports.pdb 1.

    Essentially, the issue is that __package__ gets set to the module name instead of the package name, causing issues with from .mod imports.

    Feel free to take the relevant parts of the fix in the backport to adjust the implementation here, and definitely let me know if you think the adjustment I've made is somehow incorrect.

    Full disclosure, I have not tested the canonical implementation in Python 3.7, only the backport in Python 3.6 and 2.7.

    Please let me know if you would like me to file a separate issue.

    @mariocj89
    Copy link
    Mannequin Author

    @mariocj89 mariocj89 mannequin commented Jan 27, 2018

    Hi Jason, thanks a lot!

    I’ll have a look to the bug you reported on Monday. Out for holidays atm ^^

    @ncoghlan
    Copy link
    Contributor

    @ncoghlan ncoghlan commented Jan 28, 2018

    New changeset fcf8b4c by Nick Coghlan (Mario Corchero) in branch 'master':
    bpo-32206: Update pdb usage to include new module option (GH-5111)
    fcf8b4c

    @ncoghlan
    Copy link
    Contributor

    @ncoghlan ncoghlan commented Jan 28, 2018

    I checked the original PR, and I'm pretty sure the reference implementation is going to have the same bug.

    To keep the NEWS entries clear (since the buggy implementation already shipped in the alpha releases), I've created a new issue here: https://bugs.python.org/issue32691

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 stdlib type-feature
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants