From e604ab21a33358179fd8da7448d28520a2d691c0 Mon Sep 17 00:00:00 2001 From: Gerard Vermeulen Date: Wed, 12 Jun 2024 15:27:10 +0200 Subject: [PATCH] Finalize "Debugging Python programs in Emacs" section --- .gitignore | 1 - README.org | 31 +++++++++++++------------------ 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 0e05c44..dee48a9 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,6 @@ /var # File names: -buggy.py column-view-demonstration.org custom.el dir-locals.el diff --git a/README.org b/README.org index d2010f5..77c16c2 100644 --- a/README.org +++ b/README.org @@ -284,7 +284,7 @@ of [[info:emacs#Saving Customizations][saving customizations (info)]]. (vertico . "gnu") (with-editor . "nongnu") (yasnippet . "gnu")) - package-selected-packages '(no-littering realgud)) + package-selected-packages '(no-littering)) #+end_src #+caption[Set the third set of Emacs options: final tweaks]: @@ -5570,10 +5570,10 @@ configures =code-cells=. :CUSTOM_ID: sec:debug-python :END: -Listing [[lst:pdb-example]] and [[lst:pdb-numpy]] show how to start debugging by means -of =pdb= or =realgud:pdb=. [[https://github.com/realgud/realgud][RealGUD]] is the best option and in case of {{{kbd(M-x -pdb)}}} debugging may work better with =tool-bar-mode= enabled. Links of -interest are: +[[https://github.com/realgud/realgud][RealGUD]] is the best option and in case of defaulting to {{{kbd(M-x pdb)}}} +debugging may work better with =tool-bar-mode= enabled. Listing +[[lst:ensure-realgud]] ensures the installation of =realgud=. Listing [[lst:pdb-numpy]] +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 realgud:pdb)}}} that also works well with =tool-bar-mode= disabled. - [[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]]. 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 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: PDB example: =python -m pdb .emacs.d/buggy.py=. -#+name: lst:pdb-example -#+begin_src python -i -n :results silent :tangle buggy.py -def unsafe(x, y): - """Raises an exception if the second argument equals zero.""" - return x / y - -if __name__ == "__main__": - unsafe(1.0, 0.0) +#+caption[Ensure =realgud= installation]: +#+caption: Ensure =realgud= installation. +#+name: lst:ensure-realgud +#+begin_src emacs-lisp -n :results silent +(ensure-package-installation 'realgud) #+end_src #+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]])) # 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) return b if __name__ == "__main__": b = buggy() - # The series of "s" says only here "Uncaught exception". + # PDB: The series of "s" says only here "Uncaught exception". #+end_src * [[https://github.com/emacs-tw/awesome-emacs#library][Libraries]]