Ask Your Question
1

django shell and wingdbstub

asked 2022-01-26 10:10:36 -0500

Chris Curvey's avatar

updated 2022-01-26 11:26:57 -0500

my current client runs scripts against their Django site using this pattern

 $ python manage.py shell < path-to-script-file.py

If I put this in my script file

import wingdbstub
print("Hello World!")

and set a breakpoint at "print", I see that Wing switches into debug mode, but it does not stop at the breakpoint.

Any known issues with trying to use this pattern?

UPDATE: strange...if I have more advanced code in there, and it raises an exception, Wing stops at the exception...but still does not respect the breakpoint.

UPDATE 2: I think I see what's happening. Because the script itself is just "stdin" (due to the redirect), the "import wingdbstub" gets run, but then there no knowledge of what's in the script itself.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-01-26 11:26:46 -0500

Yes, with that command line manage.py has no idea where the code is coming from and thus the code object it creates does not have the co_filename attribute set correctly. When that is the case, we cannot know that this code has anything to do with the breakpoints you set in path-to-script-file.py. When an exception occurs, Wing still knows that and stops but won't be able to show the code.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2022-01-26 10:10:36 -0500

Seen: 57 times

Last updated: Jan 27