Subject: Re: bug#74894: 29.4; Emacs not responding when calling python-fix-imports

From: Keglo Stephane <[email-masked]>
Date: Sat, 01 Mar 2025 17:40:29 +0000

Hello Sir,

This is the output of the backtrace

Debugger entered--Lisp error: (quit)
  call-process("python" nil (#<buffer  *temp*> nil) nil "-c" "from 
isort import find_imports_in_stream, find_imp..." "" "/home/stephanek/")
  apply(call-process "python" nil (#<buffer  *temp*> nil) nil "-c" 
"from isort import find_imports_in_stream, find_imp..." "" 
"/home/stephanek/")
  (save-current-buffer (set-buffer buffer) (apply #'call-process 
python-interpreter nil (list temp nil) nil "-c" python--list-imports 
(or name "") (mapcar #'file-local-name source)))
  (if (bufferp source) (save-current-buffer (set-buffer source) 
(call-process-region (point-min) (point-max) python-interpreter nil 
(list temp nil) nil "-c" python--list-imports (or name ""))) 
(save-current-buffer (set-buffer buffer) (apply #'call-process 
python-interpreter nil (list temp nil) nil "-c" python--list-imports 
(or name "") (mapcar #'file-local-name source))))
  (let* ((temp (current-buffer)) (status (if (bufferp source) 
(save-current-buffer (set-buffer source) (call-process-region 
(point-min) (point-max) python-interpreter nil (list temp nil) nil "-c" 
python--list-imports (or name ""))) (save-current-buffer (set-buffer 
buffer) (apply #'call-process python-interpreter nil (list temp nil) 
nil "-c" python--list-imports (or name "") (mapcar #'file-local-name 
source))))) lines) (if (eq 0 status) nil (error "%s exited with status 
%s (maybe isort is missing?)" python-interpreter status)) (goto-char 
(point-min)) (while (not (eobp)) (setq lines (cons 
(buffer-substring-no-properties (point) (pos-eol)) lines)) 
(forward-line 1)) (nreverse lines))
  (progn (let* ((temp (current-buffer)) (status (if (bufferp source) 
(save-current-buffer (set-buffer source) (call-process-region 
(point-min) (point-max) python-interpreter nil (list temp nil) nil "-c" 
python--list-imports (or name ""))) (save-current-buffer (set-buffer 
buffer) (apply #'call-process python-interpreter nil (list temp nil) 
nil "-c" python--list-imports (or name "") (mapcar ... source))))) 
lines) (if (eq 0 status) nil (error "%s exited with status %s (maybe 
isort is missing?)" python-interpreter status)) (goto-char (point-min)) 
(while (not (eobp)) (setq lines (cons (buffer-substring-no-properties 
(point) (pos-eol)) lines)) (forward-line 1)) (nreverse lines)))
  (unwind-protect (progn (let* ((temp (current-buffer)) (status (if 
(bufferp source) (save-current-buffer (set-buffer source) 
(call-process-region ... ... python-interpreter nil ... nil "-c" 
python--list-imports ...)) (save-current-buffer (set-buffer buffer) 
(apply ... python-interpreter nil ... nil "-c" python--list-imports ... 
...)))) lines) (if (eq 0 status) nil (error "%s exited with status %s 
(maybe isort is missing?)" python-interpreter status)) (goto-char 
(point-min)) (while (not (eobp)) (setq lines (cons 
(buffer-substring-no-properties (point) (pos-eol)) lines)) 
(forward-line 1)) (nreverse lines))) (and (buffer-name temp-buffer) 
(kill-buffer temp-buffer)))
  (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn 
(let* ((temp (current-buffer)) (status (if (bufferp source) 
(save-current-buffer ... ...) (save-current-buffer ... ...))) lines) 
(if (eq 0 status) nil (error "%s exited with status %s (maybe isort is 
missing?)" python-interpreter status)) (goto-char (point-min)) (while 
(not (eobp)) (setq lines (cons (buffer-substring-no-properties ... ...) 
lines)) (forward-line 1)) (nreverse lines))) (and (buffer-name 
temp-buffer) (kill-buffer temp-buffer))))
  (let ((temp-buffer (generate-new-buffer " *temp*" t))) 
(save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn 
(let* ((temp (current-buffer)) (status (if ... ... ...)) lines) (if (eq 
0 status) nil (error "%s exited with status %s (maybe isort is 
missing?)" python-interpreter status)) (goto-char (point-min)) (while 
(not (eobp)) (setq lines (cons ... lines)) (forward-line 1)) (nreverse 
lines))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))))
  (let ((buffer (current-buffer))) (let ((temp-buffer 
(generate-new-buffer " *temp*" t))) (save-current-buffer (set-buffer 
temp-buffer) (unwind-protect (progn (let* ((temp ...) (status ...) 
lines) (if (eq 0 status) nil (error "%s exited with status %s (maybe 
isort is missing?)" python-interpreter status)) (goto-char (point-min)) 
(while (not ...) (setq lines ...) (forward-line 1)) (nreverse lines))) 
(and (buffer-name temp-buffer) (kill-buffer temp-buffer))))))
  python--list-imports(nil ("/home/stephanek/"))
  (let* ((cands (python--list-imports name source)) 
(minibuffer-default-add-function #'(lambda nil (setq minibuffer-default 
(let (...) (if window ...))))) (statement (cond ((and name (length= 
cands 1)) (car cands)) (prompt (completing-read prompt (or cands 
python-import-history) nil nil nil 'python-import-history))))) (if 
(string-empty-p statement) nil statement))
  python--query-import(nil ("/home/stephanek/") "Add import: ")
  (and t (python--query-import name (python--import-sources) "Add 
import: "))
  (let* ((statement (and t (python--query-import name 
(python--import-sources) "Add import: ")))) (if statement (if 
(python--do-isort "--add" statement) (message "Added `%s'" statement) 
(message "(No changes in Python imports needed)")) nil))
  python-add-import(nil)
  funcall-interactively(python-add-import nil)
  command-execute(python-add-import)

On Sat, Mar 1 2025 at 02:10:09 PM +02:00:00, Eli Zaretskii 
<[email-masked]> wrote:
> Ping!  Keglo, could you please answer the question below?
> 
>>  Date: Sat, 15 Feb 2025 22:47:06 +0900
>>  From: kobarity <[email-masked] <mailto:[email-masked]>>
>>  Cc: Eli Zaretskii <[email-masked] <mailto:[email-masked]>>,
>>  	[email-masked] <mailto:[email-masked]>
>> 
>>  Keglo Stephane wrote:
>>  > Sorry Sir for not responding. I'm not working on a file inside a 
>> project. I'm just editing a file. I try to reproduce,
>>  > it still the same. when calling python-add-imports or 
>> python-fix-imports, i am seeing a circle loading for a long time. i
>>  > have to press control-g to stop it.
>> 
>>  Could you try the following steps I mentioned in my previous email?
>> 
>>  > 1. emacs -Q
>>  > 2. M-x load-fie
>>  >    Specify the location of python.el (or python.el.gz, not
>>  >    python.elc).  You can use M-x locate-library and enter 
>> "python" to
>>  >    locate the file.
>>  > 3. M-x toggle-debug-on-quit
>>  > 4. Reproduce the issue.
>>  > 5. Abort with Ctrl-G or SIGUSR2.
>>