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

Pdb cannot access source code in zipped packages. #48451

Closed
abalkin opened this issue Oct 24, 2008 · 8 comments
Closed

Pdb cannot access source code in zipped packages. #48451

abalkin opened this issue Oct 24, 2008 · 8 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@abalkin
Copy link
Member

abalkin commented Oct 24, 2008

BPO 4201
Nosy @loewis, @ncoghlan, @abalkin
Files
  • test.zip: Zip file with a module containing a call to pdb
  • pdb.patch
  • 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 = 'https://github.com/ncoghlan'
    closed_at = <Date 2008-12-14.12:11:38.110>
    created_at = <Date 2008-10-24.22:52:22.047>
    labels = ['type-bug', 'library']
    title = 'Pdb cannot access source code in zipped packages.'
    updated_at = <Date 2008-12-14.12:11:38.109>
    user = 'https://github.com/abalkin'

    bugs.python.org fields:

    activity = <Date 2008-12-14.12:11:38.109>
    actor = 'ncoghlan'
    assignee = 'ncoghlan'
    closed = True
    closed_date = <Date 2008-12-14.12:11:38.110>
    closer = 'ncoghlan'
    components = ['Library (Lib)']
    creation = <Date 2008-10-24.22:52:22.047>
    creator = 'belopolsky'
    dependencies = []
    files = ['11882', '11883']
    hgrepos = []
    issue_num = 4201
    keywords = ['patch']
    message_count = 8.0
    messages = ['75197', '76838', '76854', '76858', '76878', '77512', '77784', '77792']
    nosy_count = 3.0
    nosy_names = ['loewis', 'ncoghlan', 'belopolsky']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue4201'
    versions = ['Python 2.7']

    @abalkin
    Copy link
    Member Author

    abalkin commented Oct 24, 2008

    With attached test.zip and svn revision 67006,

    $ ./python.exe test.zip 
    > /Users/sasha/Work/python-svn/trunk/test.zip/__main__.py(2)f()
    (Pdb) l
    [EOF]

    With pdb.patch:

    $ ./python.exe test.zip 
    > /Users/sasha/Work/python-svn/trunk/test.zip/__main__.py(2)f()
    -> pass
    (Pdb) l
      1  	def f():
      2  ->	    pass
      3  	
      4  	import pdb
      5  	pdb.runcall(f)
      6  	
      7  	                                
    [EOF]

    @abalkin abalkin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Oct 25, 2008
    @ncoghlan ncoghlan self-assigned this Dec 3, 2008
    @ncoghlan
    Copy link
    Contributor

    ncoghlan commented Dec 3, 2008

    Just to confirm - this is specific to __main__.py right?

    The problem is actually with runpy not being able to set __file__
    correctly, rather than being pdb specific.

    @abalkin
    Copy link
    Member Author

    abalkin commented Dec 3, 2008

    No, I only used __main__.py to make it easy to reproduce the problem.
    Pdb will not be able to access code in any module with a custom
    __loader__. For example, if you move f() to foo.py inside test.zip
    and import it from __main__, you will see the same issue. My patch
    gives linecache.getlines() called by Pdb access to module's globs and
    thus to its __loader__ . It has nothing to do with runpy.

    The problem is actually with runpy not being able to set __file__
    correctly, rather than being pdb specific.

    You must be thinking bpo-4197 where two distinct problems are
    adressed: first, the crash due to __file__ set to None by runpy and
    second, missing globs parameter to linecache.getlines() in doctest
    module.

    My patch, doctest-1.patch works around the first issue and fixes the second.

    @abalkin
    Copy link
    Member Author

    abalkin commented Dec 4, 2008

    Off-topic: How to report a bug tracker bug?

    The e-mail I sent in response to Nick's post started with:

    """
    On Wed, Dec 3, 2008 at 3:51 PM, Nick Coghlan <report@bugs.python.org>
    wrote:

    Just to confirm - this is specific to __main__.py right?

    No, I only used __main__.py to make it easy to reproduce the problem.
    ...
    """

    But the first two lines got eaten by the tracker. Should I open an
    issue here and if so, what do I set as a component?

    @ncoghlan
    Copy link
    Contributor

    ncoghlan commented Dec 4, 2008

    Issues with the tracker itself go in the meta tracker (see the "Report
    Tracker Problem" link at the bottom of the left hand navigation menu).
    It's a separate tracker in order to handle cases where the main tracker
    is actually down in addition to problems with the functionality.

    And you're right that the get_filename() limitation is only part of the
    story rather than all of it (for both this and other issues). I'll still
    try to look at them all in one go this weekend though.

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Dec 10, 2008

    The patch hasn't been accepted for the trunk, yet, so it is out of scope
    for 2.5.3. Retargetting.

    @ncoghlan
    Copy link
    Contributor

    Fixed for 2.7 in r67750.

    Will be ported to 2.6, 3.0 and 3.1.

    @ncoghlan
    Copy link
    Contributor

    Final revisions for fix:
    2.7 = r67751 (there was a new test file missing from the initial checkin)
    2.6 = r67752
    3.1 = r67753
    3.0 = r67754

    @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
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants