Benjamin-Loison / pyzo

Python to the people
https://pyzo.org
Other
0 stars 0 forks source link

Master debugging #39

Open Benjamin-Loison opened 4 months ago

Benjamin-Loison commented 4 months ago

To avoid writing temporary instructions in code just for debugging.

Notably debug with just pausing and resuming execution which would not be resumable easily by just executing part of the script.

Related to #33.

+8

Benjamin-Loison commented 3 months ago

Notably to know what line we are currently executing which may be unclear when execute whole script and there is no clear debugging prints.

Benjamin-Loison commented 3 months ago
Example Python script taking time: ```python import time SECONDS_TO_SLEEP = 3 iteration = 0 def printIteration(toPrint): print(f'Iteration {iteration}: {toPrint}') while True: printIteration(f'Sleeping {SECONDS_TO_SLEEP} seconds...') time.sleep(SECONDS_TO_SLEEP) printIteration(f'Finished sleeping {SECONDS_TO_SLEEP} seconds!') print() iteration += 1 ```
Benjamin-Loison commented 3 months ago

Related to #51, Getting started with Pyzo does not seem to help.

Benjamin-Loison commented 3 months ago

image

Both Shell and Shells have some buttons but unclear to make them available and use.

Maybe have to use Interrupt the current running code (does not work for extension code):

Output: ``` >>> (executing cell "" (line 1 of "")) Iteration 0: Sleeping 3 seconds... Iteration 0: Finished sleeping 3 seconds! Iteration 1: Sleeping 3 seconds... Iteration 1: Finished sleeping 3 seconds! Iteration 2: Sleeping 3 seconds... Traceback (most recent call last): File "", line 12, in time.sleep(SECONDS_TO_SLEEP) KeyboardInterrupt ```

the goal is then to resume.

image

Another time got:

image

image

Stop debugging results in:

image

Even with setting a yellow circle I still face the same behaviors.

Benjamin-Loison commented 3 months ago

Shell > Postmortem: debug from last traceback does not seem to do anything when the script is running.

Benjamin-Loison commented 3 months ago

Debugging next/step/continue. Post-mortem debugging.

Source: https://pyzo.org/features.html

Interactivity (ways to run code) does not help.

Tools does not have a specific tab but Workspace is interesting by listing all variables etc. Alternatively whos, source: https://pyzo.org/screenshots.html.

https://pyzo.org/interactive_vs_script.html does not help.

Benjamin-Loison commented 3 months ago

image

However, in my case I do not know where to put a breakpoint.

Benjamin-Loison commented 3 months ago

It does seem however that step-into doesn't (yet?) work well (i.e. stopping in one line and then stepping into another function) unless you set up another break-point.

Source: the Stack Overflow answer 38943360 (Aug 14, 2016 at 14:49)

Benjamin-Loison commented 3 months ago

https://pyzo.narkive.com/VbtSv80m/how-to-use-the-new-debug-mode-in is about setting breakpoints, so not interesting in our case.

Benjamin-Loison commented 3 months ago

Pyzo debugger on DuckDuckGo and Google first page of results do not seem very interesting.

Should watch YouTube: tM9YUWVQ26A.

Maybe can just set a breakpoint at the start and then run but I do not see how to resume from interruption: ![image](https://github.com/user-attachments/assets/8a7e7928-bfa9-4c90-a437-4cda20b96941)

Is it even possible without Pyzo?

Benjamin-Loison commented 3 months ago

Related to Benjamin_Loison/codeblocks/issues/10.

Benjamin-Loison commented 2 months ago

Highlighting line being executed would be nice and would maybe avoid Benjamin-Loison/cpython/issues/40.

Benjamin-Loison commented 3 weeks ago

Related to Benjamin-Loison/cpython/issues/22.

Benjamin-Loison commented 2 weeks ago

image

Note environ PYZO_PROCESS_EVENTS_WHILE_DEBUGGING=1.