#๐Ÿ”’ Debugging Issues

12 messages ยท Page 1 of 1 (latest)

tribal sand
#

I am having a hell of a time trying to debug my code.

A while back my usual import pdb; pdb.set_trace() break points stopped working and my python code exited without printing any errors or hitting any break points. Before you ask, there is no early exit path, or any way it would be doing that unexpectedly.

I am admittedly using several try: catch: blocks and asssertion statements.

After a bit of googling I decided to try ipdb instead. I wrapped the high level call in a try: except: block:

try:
            my_main(arg1)

except Exception as e:
            ipdb.set_trace()
            print(e)
            print(traceback.print_stack())

That worked, I am now hitting the break point however I can't get any information out of it.

As the attached image shows, print(e) prints nothing and the traceback shows a bunch of calls in bdb.py and pdb.py and doesn't show anything from my code.

However just e in the console shows an AssertionError. Which seems to suggest the code is failing on an assertion.

Any idea what is causing this and how I might be able to narrow down which Assert is causing this issue?

Appreciate any help.

twilit warrenBOT
#

@tribal sand

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

median prawn
#

you have no return on mymain where the error comes from.

tribal sand
#

Is that a question?

#

It has a return, just exits/excepts before it reaches it

#

I replaced the print_stack() call with

traceback.format_exc()

After some googling and FINALLY got a line number and longer error printout to work with

#

I am a bit worried, not sure why the tools I've relied on up till now suddenly aren't working

median prawn
#

sifferent python versions?

tribal sand
#

I am a bit reticent to start messing with that, but it has crossed my mind... I am developing on 3.9.2 so a bit behind.

I guess now that I am able to debug again I will call this good.

#

!close

twilit warrenBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.