-
Notifications
You must be signed in to change notification settings - Fork 147
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 should ask iPython 5 which debugger class to use #105
ipdb should ask iPython 5 which debugger class to use #105
Comments
This was created to reference this issue I previously opened on ipython: ipython/ipython#9740 |
This patched it for me on version 5, would not be backwards compatible, but works seemigly for nose: def _init_pdb(context=3):
term = import_module(['IPython.terminal.interactiveshell'], "TerminalInteractiveShell")
debugger_cls = term.TerminalInteractiveShell().debugger_cls
if 'context' in getargspec(Pdb.__init__)[0]:
p = debugger_cls(def_colors, context=context)
else:
p = debugger_cls(def_colors)
p.rcLines += def_exec_lines
return p edit: I'm happy to contribute a PR but I'm not sure how you guys would want the conditional import_module and check. |
@gotcha any opinions? |
I had the same issue with ipython5 and ipdb |
I was seeing the same exception, but I don't think this is actually a bug. Try this:
nosetests has a similar option.
|
@GuyHoozdis that is a bug, the fix would detect the option and use the appropriate debugger class. i.e. the same one it uses now if you didn't use capture. Not all applications have an arg like that, to work around ipdb. |
I could be wrong, but my understanding of the issue is that packages like nose or pytest take over stdout in a way that causes problems for any debugger. That is why they offer an argument like I suspect that when you added the line
Are you referring to honcho? If honcho is fiddling with stdout and doesn't offer an argument to disable that behavior, then bug should be filed against their application - not ipdb. https://github.com/gotcha/ipdb#issues-with-stdout |
That is the issue but the breakage was that previously that call did this check, based on earlier versions of ipython and its API. It essentially did the same thing, but using a different path. When they released version 5, they expect you to ask for the debugger class rather than use the specific class referenced by that line. It's not a new feature, the upgrade to version 5 accidentally missed that change. It simply lost some behaviour when it bumped ipython. It's not that it overwrites or changes stdout. It's just that the code as of version 5 is calling the wrong debugger class because of an API change in version 5. There are simply limitations of what you can do when they override stdout and you cannot use the other debugger in those cases. |
Also, I'm using |
I got the same issue using kivy framework:
|
Downgrading to ipython 4 solved the issue for me. |
fyi, this is the code I'm currently using in my app to monkey patch ipdb while #108 is unmerged/worked on. # ==============================================================================
# Ipython 5 with ipdb monkey patch (https://github.com/gotcha/ipdb/pull/108/)
# ==============================================================================
from inspect import getargspec # noqa
import ipdb # noqa
from ipdb.__main__ import def_colors, def_exec_lines # noqa
from IPython import version_info as ipython_version # noqa
from IPython.terminal.interactiveshell import TerminalInteractiveShell # noqa
def _get_debugger_cls():
if ipython_version < (5, 0, 0):
from IPython.core.debugger import Pdb
return Pdb
return TerminalInteractiveShell().debugger_cls
def _init_pdb(context=3):
debugger_cls = _get_debugger_cls()
if 'context' in getargspec(debugger_cls.__init__)[0]:
p = debugger_cls(def_colors, context=context)
else:
p = debugger_cls(def_colors)
p.rcLines += def_exec_lines
return p
ipdb.__main__._init_pdb = _init_pdb For use with nose/honcho for a month, have yet to have any specific issues with hitting exceptions at debuggers. |
I hit a similar issue (I think -- I got the same error anyway) from trying to debug flake8 to track down an incorrect line number report. Trying the fix proposed by JBKahn removed the exception for me. |
Update? I'm running into this now. Ps. @JBKahn code snippet works, just wondering if its going to be integrated anytime soon. |
I was experiencing the same error on an ubuntu box. I was sending a file via stdin as follows: |
Yup, this is related to what happens when stdout is redirected. |
Irregardless of why is happening, shouldn't it be addressed? |
When @gotcha works on ipdb again, hopefully it will be! |
@gotcha just bumping this in case you're active again. |
hitting the same rock for a couple of months here too, any specific reason for not merging the fix / addressing the issue? |
PR merged. Thx, @JBKahn ! |
I've got this in two ways:
import ipdb; ipdb.sset_trace()
in my Django appAlthough a breakpoint in the running app did happen, we had some weird behaviour with the autocompletion that used to be there in 4.2 but didn't seem to be present once we bumped ipython to 5, maybe that was known.
Here's the traceback for my test
The text was updated successfully, but these errors were encountered: