-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
ipdb.set_trace() breaks inspect #8671
Comments
I can't work out what would be replacing the |
Sorry, hit the wrong button. I can't work out what would be replacing the main module in that case. The |
Step through the code in the example and you'll find it. I also found a work around that fixes the issue for me. It's pretty hacky and not exhaustive. I copy some of the attributes that inspect is looking for from the original sys.modules['main'] module into the one ipython overrides it with. The true fix is probably to restore sys.modules['main'] every time ipdb.set_trace() completes. Here's the diff.
|
Thanks, I see it. I'll try to work out a good fix for that. |
Any updates on this? It's been two weeks. Thanks! |
Sorry, fell off the radar. I've just dug into it, and I think the easiest sensible fix would be in ipdb. I fixed it in my local copy by making the def set_trace(frame=None):
update_stdout()
wrap_sys_excepthook()
if frame is None:
frame = sys._getframe().f_back
p = Pdb(def_colors)
p.set_trace(frame)
p.shell.restore_sys_module_state() The last line is the key bit - that will put Perhaps we shouldn't be replacing the |
When's the next ipython release? |
There isn't a schedule. When we do a major release, which we just did, we typically do a bugfix release as we accumulate new issues about a month later, which would be early September. |
What's the status of this? Been waiting for a while. |
@sthompson0 sorry, the repo explosion made IPython 4.1 take (much) longer than usual. We shipped 4.1 yesterday. |
Did this fix make it in, or did it get deferred? |
I don't think we have made any change in IPython for this. As mentioned above, I think the easiest fix is in ipdb, which is a separate project which we don't control. |
Oh, okay I didn't realize this was two different projects or I would have filed the bug over there. Thanks. |
No worries. It's a bit confusing, because most of the actual debugger machinery ipdb uses is inside IPython, but ipdb exists as a separate project to provide an API to use it outside IPython. So it's not obvious where to file bugs. |
For future reference please point this out earlier. 👍 |
If a script attempts to use inspect.getfile() on a class that was defined in a script file after set_trace() is called an exception is raised. Here's the traceback and the demo script.
I discovered that ipython is replacing sys.modules['main'] at some point (didn't get as far as pinpointing an exact line). This object ipython puts in there doesn't have attributes inspect is looking for which leads to the exception. It seems ipython could clean up after itself when set_trace() exits or copy those attributes to the replaced item.
I'd really like to get a work around so I can make a local modification until this fix goes out.
Version info
Python 2.7.10
Trackback
Script for reproduction
The text was updated successfully, but these errors were encountered: