dmg <d...@turingmachine.org> writes:

>> Could you please provide the details of the failure?
>>
>
> it seems to be related to python (I am running MacOS):
>
> ...
>    passed   358/1318  test-ob-python/assign-underscore (0.064578 sec)
> Can’t guess python-indent-offset, using defaults: 4
> Sent: print 
> ('ob_comint_async_python_start_958ce85c-48e1-483d-af42-cb807c90181d')...
> Can’t guess python-indent-offset, using defaults: 4
> Sent: print 
> ('ob_comint_async_python_start_ae9f77ca-4aca-41fc-94ef-af28fa5b0250')...
> error in process filter: Search failed: 
> "ob_comint_async_python_\\(start\\|end\\|file\\)_\\(.+\\)"
> Failed to remove temporary Org-babel directory 
> /var/folders/_f/2r7vwdj90j12k0g51xkh80g40000gn/T//tmp-orgtest/
> make: *** [test] Error 255

Try the attached patch, but this kind of situation must never happen in
the tests. Something is very wrong is happening with
python+ob-python+Mac OS.

>From 291616698e76de1c08787376fd7903f34eb5152a Mon Sep 17 00:00:00 2001
Message-ID: <291616698e76de1c08787376fd7903f34eb5152a.1752426961.git.yanta...@posteo.net>
From: Ihor Radchenko <yanta...@posteo.net>
Date: Sun, 13 Jul 2025 19:15:29 +0200
Subject: [PATCH] lisp/ob-comint.el (org-babel-comint-async-filter): Avoid
 throwing an error

* lisp/ob-comint.el (org-babel-comint-async-filter): Consider the case
when we have <...>_end async indicator but miss <...>_begin before.
Assume empty result then.
---
 lisp/ob-comint.el | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/lisp/ob-comint.el b/lisp/ob-comint.el
index fb3808b30..ec68aa047 100644
--- a/lisp/ob-comint.el
+++ b/lisp/ob-comint.el
@@ -343,15 +343,19 @@ (defun org-babel-comint-async-filter (string)
 	  (when (equal (match-string 1) "end")
 	    (let* ((uuid (match-string-no-properties 2))
 		   (res-str-raw
-		    (buffer-substring
-		     ;; move point to beginning of indicator
-                     (match-beginning 0)
-		     ;; find the matching start indicator
-		     (cl-loop
-                      do (re-search-backward indicator)
-		      until (and (equal (match-string 1) "start")
-				 (equal (match-string 2) uuid))
-		      finally return (+ 1 (match-end 0)))))
+                    (condition-case _
+		        (buffer-substring
+		         ;; move point to beginning of indicator
+                         (match-beginning 0)
+		         ;; find the matching start indicator
+		         (cl-loop
+                          do (re-search-backward indicator)
+		          until (and (equal (match-string 1) "start")
+				     (equal (match-string 2) uuid))
+		          finally return (+ 1 (match-end 0))))
+                      (error
+                       (warn "org-babel-comint-async-filter failed to find matching begin indicator.")
+                       "")))
 		   ;; Apply user callback
 		   (res-str (funcall org-babel-comint-async-chunk-callback
                                      (if org-babel-comint-async-remove-prompts-p
-- 
2.50.1

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

Reply via email to