[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#15975: 24.3.50; Arithmetic error upon calling `python-indent-line` i

From: James De Ricco
Subject: bug#15975: 24.3.50; Arithmetic error upon calling `python-indent-line` in a buffer of a single non-empty line.
Date: Mon, 25 Nov 2013 15:49:58 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0

An Arithmetic error is raised when the `python-indent-line` function is
called on a buffer consisting of one non-empty line.

cd src/emacs-bzr/install-prefix/bin/
./emacs -Q
C-x b pybuf <RET> def main(): M-x python-mode <RET> C-j

*Messages* buffer:
  For information about GNU Emacs and the GNU system, type C-h C-a.
  python-indent-line: Arithmetic error

*Backtrace* buffer:
  Debugger entered--Lisp error: (arith-error)
    call-interactively(newline-and-indent nil nil)

The patch below resolves the problem by ensuring that the function
`python-indent-guess-indent-offset` does not set `python-indent-offset`
to zero, thereby violating the precondition of the function
`python-indent-calculate-levels` which expects `python-indent-offset` to
not equal zero (otherwise attempts to modulus a number and zero). It
makes sense that `python-indent-offset` would never equal zero since the
python language requires non-zero level indentation of blocks.

*** python.el.original  2013-11-25 14:48:53.118763386 -0500
--- python.el   2013-11-25 14:49:32.601625243 -0500
*** 676,682 ****
                   (goto-char block-end)
!           (if indentation
                (set (make-local-variable 'python-indent-offset)
              (message "Can't guess python-indent-offset, using
defaults: %s"
--- 676,682 ----
                   (goto-char block-end)
!           (if (> indentation 0)
                (set (make-local-variable 'python-indent-offset)
              (message "Can't guess python-indent-offset, using
defaults: %s"

In GNU Emacs (x86_64-unknown-linux-gnu, X toolkit, Xaw scroll
 of 2013-11-25 on jcdericco-MacBookPro-GNU
Bzr revision: 115235 address@hidden
Windowing system distributor `The X.Org Foundation', version 11.0.11103000
System Description:    Trisquel 6.0

Configured using:
 `configure --prefix=/home/jcdericco/src/emacs-bzr/install-prefix/'

Load-path shadows:
None found.

(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils time-date tooltip ediff-hook vc-hooks
lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt
fringe tabulated-list newcomment lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process inotify
dynamic-setting x-toolkit x multi-tty emacs)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]