Locate error source of ExceptionGroup in Python shell
authorshynur <one.last.kiss@outlook.com>
Fri, 3 May 2024 11:40:23 +0000 (19:40 +0800)
committerEli Zaretskii <eliz@gnu.org>
Sat, 4 May 2024 11:48:38 +0000 (14:48 +0300)
The Python shell recognizes the line containing a file path and
a line number when an exception is raised up to the top-level,
in order to locate the source of error.  It's supposed to
recognize the built-in ExceptionGroup as well.  (Bug#70653)
* lisp/progmodes/python.el (python-shell-compilation-regexp-alist):
Take the single leading vertical line into account.
* etc/NEWS: Announce this change.

etc/NEWS
lisp/progmodes/python.el

index 518477fbb72a3e41d7e0dcbf8317c1e1bdf68085..9b264a23d5c36e9023e2074ef8666631189f5292 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1351,6 +1351,14 @@ interactive Python interpreter specified by 'python-interpreter'.
 It sends the python block delimited by 'python-nav-beginning-of-block'
 and 'python-nav-end-of-block' to the inferior Python process.
 
+** Inferior Python mode
+
+---
+*** Default value of 'python-shell-compilation-regexp-alist' is changed.
+Support for Python's ExceptionGroup has been added, so in the Python
+shell, the line indicating the source of error in the error messages
+from ExceptionGroup will be recognized as well.
+
 ** Scheme mode
 Scheme mode now handles regular expression literal '#/regexp/' that is
 available in some Scheme implementations.
index 5ba185bc60c9c861c6d6cb9a74939507ec178386..e332bd8f61ec4d069d197521de1c0543509f6140 100644 (file)
@@ -2860,7 +2860,7 @@ virtualenv."
   :type '(repeat symbol))
 
 (defcustom python-shell-compilation-regexp-alist
-  `((,(rx line-start (1+ (any " \t")) "File \""
+  `((,(rx line-start (1+ (any " \t")) (? ?| (1+ (any " \t"))) "File \""
           (group (1+ (not (any "\"<")))) ; avoid `<stdin>' &c
           "\", line " (group (1+ digit)))
      1 2)