Finalize "Debugging Python programs in Emacs" section

This commit is contained in:
Gerard Vermeulen 2024-06-12 15:27:10 +02:00
parent 0b5374374b
commit e604ab21a3
2 changed files with 13 additions and 19 deletions

1
.gitignore vendored
View File

@ -11,7 +11,6 @@
/var /var
# File names: # File names:
buggy.py
column-view-demonstration.org column-view-demonstration.org
custom.el custom.el
dir-locals.el dir-locals.el

View File

@ -284,7 +284,7 @@ of [[info:emacs#Saving Customizations][saving customizations (info)]].
(vertico . "gnu") (vertico . "gnu")
(with-editor . "nongnu") (with-editor . "nongnu")
(yasnippet . "gnu")) (yasnippet . "gnu"))
package-selected-packages '(no-littering realgud)) package-selected-packages '(no-littering))
#+end_src #+end_src
#+caption[Set the third set of Emacs options: final tweaks]: #+caption[Set the third set of Emacs options: final tweaks]:
@ -5570,10 +5570,10 @@ configures =code-cells=.
:CUSTOM_ID: sec:debug-python :CUSTOM_ID: sec:debug-python
:END: :END:
Listing [[lst:pdb-example]] and [[lst:pdb-numpy]] show how to start debugging by means [[https://github.com/realgud/realgud][RealGUD]] is the best option and in case of defaulting to {{{kbd(M-x pdb)}}}
of =pdb= or =realgud:pdb=. [[https://github.com/realgud/realgud][RealGUD]] is the best option and in case of {{{kbd(M-x debugging may work better with =tool-bar-mode= enabled. Listing
pdb)}}} debugging may work better with =tool-bar-mode= enabled. Links of [[lst:ensure-realgud]] ensures the installation of =realgud=. Listing [[lst:pdb-numpy]]
interest are: is a debugging start by means of =pdb= or =realgud:pdb=. Links of interest are:
- [[https://github.com/realgud/realgud][RealGUD]] provides a nice interface to PDB by means of {{{kbd(M-x - [[https://github.com/realgud/realgud][RealGUD]] provides a nice interface to PDB by means of {{{kbd(M-x
realgud:pdb)}}} that also works well with =tool-bar-mode= disabled. realgud:pdb)}}} that also works well with =tool-bar-mode= disabled.
- [[https://realpython.com/python-debugging-pdb/][Python Debugging with PDB]] - [[https://realpython.com/python-debugging-pdb/][Python Debugging with PDB]]
@ -5588,18 +5588,13 @@ interest are:
with =pyenv= is an unresolved issue: see [[https://github.com/pyenv/pyenv/issues/1190][Install python-gdb.py]]. with =pyenv= is an unresolved issue: see [[https://github.com/pyenv/pyenv/issues/1190][Install python-gdb.py]].
Python info links of interest are: Python info links of interest are:
- [[info:python#Debugging C API extensions and CPython Internals with GDB][Debugging C API extensions and CPython Internals with GDB (info)]]. - [[info:python#Debugging C API extensions and CPython Internals with GDB][Debugging C API extensions and CPython Internals with GDB (info)]].
- [[info:python#Debugging and Profiling][Debugging and Profiling (info)]] - [[info:python#Debugging and Profiling][Debugging and Profiling (info)]].
#+caption[PDB example: =python -m pdb .emacs.d/buggy.py=]: #+caption[Ensure =realgud= installation]:
#+caption: PDB example: =python -m pdb .emacs.d/buggy.py=. #+caption: Ensure =realgud= installation.
#+name: lst:pdb-example #+name: lst:ensure-realgud
#+begin_src python -i -n :results silent :tangle buggy.py #+begin_src emacs-lisp -n :results silent
def unsafe(x, y): (ensure-package-installation 'realgud)
"""Raises an exception if the second argument equals zero."""
return x / y
if __name__ == "__main__":
unsafe(1.0, 0.0)
#+end_src #+end_src
#+caption[PDB NumPy example: =python -m pdb .emacs.d/nuggy.py=]: #+caption[PDB NumPy example: =python -m pdb .emacs.d/nuggy.py=]:
@ -5612,13 +5607,13 @@ def buggy():
a = matrix(array([[1.0, 1.0], [1.0, 1.0]])) a = matrix(array([[1.0, 1.0], [1.0, 1.0]]))
# Use "display", "p", or "pp" to inspect "a". # Use "display", "p", or "pp" to inspect "a".
# A series of "s" does not raise the exception here, contrary to "c". # PDB: A series of "s" does not raise the exception here, contrary to "c".
b = inv(a) b = inv(a)
return b return b
if __name__ == "__main__": if __name__ == "__main__":
b = buggy() b = buggy()
# The series of "s" says only here "Uncaught exception". # PDB: The series of "s" says only here "Uncaught exception".
#+end_src #+end_src
* [[https://github.com/emacs-tw/awesome-emacs#library][Libraries]] * [[https://github.com/emacs-tw/awesome-emacs#library][Libraries]]