Emacs 23 hangs on python mode when typing string block """

Question:

My Emacs hangs (Ubuntu 9 + Emacs 23 + Pyflakes) when I type """ quotes for string blocks.

Anybody experienced the same problem? I think, it may not be an Emacs problem but some Python mode or Pyflakes which I use it for error checking.

Anybody got around the issue? It is a really frustrating experience.

Asked By: user90150

||

Answers:

are you using the external python-mode (from package python-mode) or the internal python mode ? I use pyflakes with the internal emacs python mode without any problems and this is my configuration :

(when (load "flymake" t)
(defun flymake-pyflakes-init ()
  (let* ((temp-file (flymake-init-create-temp-buffer-copy
                     'flymake-create-temp-inplace))
         (local-file (file-relative-name
                      temp-file
                      (file-name-directory buffer-file-name))))
    (list "pyflakes" (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
             '("\.py\'" flymake-pyflakes-init)))
Answered By: Chmouel Boudjnah

latest pyflakes in development mode fixed this problem for me. Thanks all

sudo easy_install -U pyflakes

Answered By: user90150

This is the specific pyflakes bug that causes emacs to go nonlinear: http://divmod.org/trac/ticket/2821

Answered By: adonymous nonor

This is backtraces when this problem happens:

enter image description here

By using gdb to debug the problem but cannot get helpful information since it’s using compiled binary files of Emacs packages.

(gdb) step
Single stepping until exit from function F707974686f6e2d6e61762d656e642d6f662d73746174656d656e74_python_nav_end_of_statement_0,
which has no line number information.

Finally, I gave up and used workarounds to add or fix docstring:

  1. py-pyment-region command from the package py-pyment
  2. replace non-standard docstring by command anzu-query-replace from the package anzu

Besides, in Emacs 28.1 + gcc/9.5.0_jit, typing single quote or typing double quotes before single quote will cause this problem.
Typing double quotes in blank line or not before single quote won’t have this problem.

More info from gdb:

(gdb) backtrace
#0  0x0000000000676a6c in syntax_property_with_flags ()
#1  0x000000000067e33a in scan_sexps_forward ()
#2  0x000000000067eae9 in Fparse_partial_sexp ()
#3  0x0000000000635396 in funcall_subr ()
#4  0x0000000000634e7a in Ffuncall ()
#5  0x00007f366cb8de6f in F73796e7461782d70707373_syntax_ppss_0 () at /xxx/emacs/28.1/x86_64-pc-linux-gnu/../../../../bin/../lib/emacs/28.1/native-lisp/28.1-7901736e/preloaded/syntax-bf4e4bc4-19987706.eln
...
#68 0x000000000046df78 in redisplay_window_1 ()
#69 0x0000000000631365 in internal_condition_case_1 ()
#70 0x000000000046d2ae in redisplay_internal ()
#71 0x000000000046b129 in redisplay ()
#72 0x000000000057e312 in read_char ()
#73 0x000000000058d619 in read_key_sequence ()
#74 0x000000000057b509 in command_loop_1 ()
#75 0x00000000006312be in internal_condition_case ()
#76 0x000000000057ad96 in command_loop_2 ()
#77 0x00000000006309fa in internal_catch ()
#78 0x000000000057ad3e in command_loop ()
#79 0x000000000057a2f2 in recursive_edit_1 ()
#80 0x000000000057a490 in Frecursive_edit ()
#81 0x0000000000576fc2 in sort_args ()
(gdb)

So, it looks like that the emacs code has some issue causing this problem.

However, this problem CANNOT be reproduced when start Emacs without init.el file. So, it should be triggered by installed packages.

Finally, when I comment out the below line in custom-set-variables, the problem disappeared. So, it’s NOT caused by any packages, at least for Emacs 28.1 + gcc/9.5.0_jit.

;; '(debug-on-error t) 

It’s reproduced by adding only blow content in init.el file:

(custom-set-variables
'(debug-on-error t)
)

'(debug-on-error t) could be also '(debug-on-error '(nil))

By using '(debug-on-error nil), it doesn’t have problem.

Therefore, as long as debug-on-error is enabled as always - t or when - '(nil), then it will cause the problem.

Answered By: Bruce Wen
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.