2

I'm using Netbeans for coding Django. When I insert:

import ipdb; ipdb.set_trace()

Flow execution gets stopped but it shows gibberish, such as:

[1;32m/path/to/file/models.py[0m(344)[0;36macceptBid[1;34m()[0m
[1;32m    343 [1;33m        [1;32mimport[0m [1;37mipdb[0m[1;33m;[0m [1;37mipdb[0m[1;33m.[0m[1;37mset_trace[0m[1;33m([0m[1;33m)[0m[1;33m[0m[0m
[0m[1;32m--> 344 [1;33m        [1;32mreturn[0m [1;37mself[0m[1;33m.[0m[1;37msenderId[0m[1;33m([0m[1;33m)[0m [1;33m==[0m [1;37muser_obj[0m[1;33m.[0m[1;37mid[0m[1;33m[0m[0m
[0m[1;32m    345 [1;33m[1;33m[0m[0m
[0m

I can use next, skip and everything from pdb. But I can not see where I'm in the code, which forces me to use pdb instead of ipdb.

maraujop
  • 4,472
  • 2
  • 36
  • 40

4 Answers4

2

for me worked fine with just commenting the line and add a pass sentence in ipdb/__main__.py

    from IPython.utils import io

    def update_stdout():
        # setup stdout to ensure output is available with nose

        #THIS IS THE LINE TO COMMENT #########################
        #io.stdout = sys.stdout = sys.__stdout__ 

        #REMEMBER TO ADD pass
        pass                                     
else:
    from IPython.Debugger import Pdb, BdbQuit_excepthook
    from IPython.Shell import IPShell
    from IPython import ipapi
1

This is the problem: https://github.com/gotcha/ipdb/issues/31

and you can solve it by commenting out a line in ipdb/_ _ main _ _.py

fastmultiplication
  • 2,951
  • 1
  • 31
  • 39
1

These are ANSI escape codes, which are used for the text colours in ipdb's output. For some reason, the terminal you're debugging in is not accepting the codes and is printing them as text. You may be able to find a setting in NetBeans to either change what the terminal is reporting itself as, or what it actually accepts.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
  • Thanks again Daniel. It looks like Netbeans terminal does not have ANSI support yet although it is in the TODO list. – maraujop Oct 08 '10 at 09:32
  • 1
    For ANSI color support in the cmd.exe see [this solution](http://adoxa.110mb.com/ansicon/) by Jason Hood. – Amit Kotlovski Oct 04 '11 at 09:44
0

What I have done to be able to use ipdb with Django Netbeans, is disable coloring output in ipdb. There are several ways to do this. If you have installed ipdb through easy_install you can edit the code in __init__.py leaving it like:

import sys
from IPython.Debugger import Pdb
from IPython.Shell import IPShell
from IPython import ipapi

shell = IPShell(argv=[''])

def set_trace():
    Pdb("NoColor").set_trace(sys._getframe().f_back)

Also you can create yourself a hook to import ipdb without colors. I hope this helps :)

maraujop
  • 4,472
  • 2
  • 36
  • 40