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

has trouble tracing importlib._bootstrap in python3.3 #115

Open
bukzor opened this issue Apr 21, 2014 · 9 comments
Open

has trouble tracing importlib._bootstrap in python3.3 #115

bukzor opened this issue Apr 21, 2014 · 9 comments

Comments

@bukzor
Copy link
Contributor

bukzor commented Apr 21, 2014

I'm doing an experiment with sys.path_hooks, and pudb is having trouble tracing through it.

pudb seems to fail to find the source for /usr/lib/python3.3/importlib/_bootstrap.py, which results in the variables windowlet being smashed to the left.

To reproduce:

$ PYTHONPATH=dummypath python3.3 foo.py

foo.py:

from __future__ import print_function


class NoPathHook(object):
    def __init__(self, syspath):
        if syspath.endswith('/dummypath'):
            pass
        else:
            raise ImportError

    @staticmethod
    def find_module(module):
        if module == 'example_thingy_doesnt_exist':
            import pudb.b


def register():
    import sys
    sys.path_hooks.insert(0, NoPathHook)
    sys.path_importer_cache.clear()


def main():
    register()
    try:
        import example_thingy_doesnt_exist
    except ImportError as error:
        if error.name == 'example_thingy_doesnt_exist':
            pass
        else:
            raise

    print('DONE')

if __name__ == '__main__':
    exit(main())
@asmeurer
Copy link
Collaborator

This sounds like the same error I reported at #109

@asmeurer
Copy link
Collaborator

The issue is that importlib in Python 3.3 is implemented in Python (previously it was all implemented in C), but it is still doing some wacky things deleting stack frames (so that you don't get a ton of importlib calls in an ImportError traceback), which confuses PuDB.

@asmeurer
Copy link
Collaborator

The workaround is to use an earlier version of Python, like 3.2 or 2.7, which doesn't have importlib implemented in Python.

@bukzor
Copy link
Contributor Author

bukzor commented Apr 22, 2014

That's not a usable workaround for me, since I'm trying to trace a bug that only happens in 3.4.

1 similar comment
@bukzor
Copy link
Contributor Author

bukzor commented Apr 22, 2014

That's not a usable workaround for me, since I'm trying to trace a bug that only happens in 3.4.

@bukzor bukzor closed this as completed Apr 22, 2014
@bukzor bukzor reopened this Apr 22, 2014
@asmeurer
Copy link
Collaborator

Oh, you're using pudb.b. That basically doesn't work in Python 3.3 or 3.4, for the reasons noted in that other issue (I never was able to figure out how to get it to work). You'll have to use set_trace.

@bukzor
Copy link
Contributor Author

bukzor commented Apr 22, 2014

In my experience it works fine with python3. I'll try set trace though.

@asmeurer
Copy link
Collaborator

OK, I think it works, but it takes you to the wrong place in the stack.

@wronglink
Copy link
Contributor

Seems to be fixed at #240

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants