traceback and script output mixed up in debugger console

Hello,

When debugging a Python program I often end up with traceback messages being mixed up with actual script output

Example of code:

print "1"
print doc['html']['body']['div']['div'][2]['div'][1]['div'][1]['div'][1]['div'][1]['div']
print "2"
print doc['html']['body']['div']['div'][2]['div'][1]['div'][1]['div'][1]['div'][0]['div']
print "3"
print doc['html']['body']['div']['div'][2]['div'][1]['div'][1]['div'][0]['div'][1]['div']
print "4"
print doc['html']['body']['div']['div'][2]['div'][1]['div'][1]['div'][0]['div'][0]['div']


This code crashes after the third print. The message I have in the debugger console:

C:\Python27\python.exe C:/infoscreen/uesmartradio.py
1
Traceback (most recent call last):
[OrderedDict([(u'@class', ... (long line)
  File "C:/infoscreen/uesmartradio.py", line 74, in <module>
2
    print doc['html']['body']['div']['div'][2]['div'][1]['div'][1]['div'][0]['div'][1]['div']
[OrderedDict([(u'@id', u'alarms_43733_btn')]), ... (long line)
KeyError: 'div'
3

Process finished with exit code 1


The same output (correct this time) when run from a command prompt:

C:\infoscreen>python uesmartradio.py
1
[OrderedDict([(u'@class', u'ue-alarm-status'), ... (long line)
2
[OrderedDict([(u'@id', u'alarms_43733_btn')]), ... (long line)
3
Traceback (most recent call last):
  File "uesmartradio.py", line 74, in <module>
    print doc['html']['body']['div']['div'][2]['div'][1]['div'][1]['div'][0]['di
v'][1]['div']
KeyError: 'div'


Is this something I can configure or rather a bug?

Please sign in to leave a comment.