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

Add pudb.b #110

Merged
merged 1 commit into from
Feb 28, 2014
Merged

Add pudb.b #110

merged 1 commit into from
Feb 28, 2014

Conversation

asmeurer
Copy link
Collaborator

This lets you just run

import pudb.b

to trigger a set_trace(). It works by monkey-patching
__builtins__.__import__. It does not yet work in Python 3.3, due to the new
import mechanism.

See #109.

This lets you just run

import pudb.b

to trigger a set_trace(). It works by monkey-patching
__builtins__.__import__. It does not yet work in Python 3.3, due to the new
import mechanism.

See inducer#109.
@asmeurer
Copy link
Collaborator Author

How do we feel about the name pudb.b? I could also create a module pu.db, though I think we would have to literally install pu/db.py.

@inducer
Copy link
Owner

inducer commented Feb 27, 2014

Will this work with PyPy?

@asmeurer
Copy link
Collaborator Author

Looks like it doesn't.

@asmeurer
Copy link
Collaborator Author

I changed it to use __builtin__.__dict__, but then I get

Traceback (most recent call last):
  File "app_main.py", line 72, in run_toplevel
  File "test.py", line 1, in <module>
    import pudb.b
  File "/Users/aaronmeurer/Documents/pudb/pudb/b.py", line 20, in <module>
    set_trace()
  File "/Users/aaronmeurer/Documents/pudb/pudb/b.py", line 16, in set_trace
    dbg = _get_debugger()
  File "/Users/aaronmeurer/Documents/pudb/pudb/__init__.py", line 34, in _get_debugger
    from pudb.debugger import Debugger
  File "/Users/aaronmeurer/Documents/pudb/pudb/b.py", line 8, in __myimport__
    return __origimport__(name, *args, **kwargs)
  File "/Users/aaronmeurer/Documents/pudb/pudb/debugger.py", line 5, in <module>
    import urwid
  File "/Users/aaronmeurer/Documents/pudb/pudb/b.py", line 8, in __myimport__
    return __origimport__(name, *args, **kwargs)
ImportError: No module named urwid

@inducer
Copy link
Owner

inducer commented Feb 28, 2014

I'm not sure I'm a huge fan of this, but I'll merge it for the time being. I reserve the right to yank it out if we determine it's a bad idea. (Which it may be because of how deeply it has to reach into Python's guts...import hooks?) On the upside, the change is self-contained, so there isn't much risk here.

inducer added a commit that referenced this pull request Feb 28, 2014
@inducer inducer merged commit 64627e4 into inducer:master Feb 28, 2014
@asmeurer
Copy link
Collaborator Author

I do intend to make this work with Python 3. It's pretty useless to me if it doesn't work there.

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

Successfully merging this pull request may close these issues.

2 participants