GNU bug report logs - #15975
24.3.50; Arithmetic error upon calling `python-indent-line` in a buffer of a single non-empty line.

Previous Next

Package: emacs;

Reported by: James De Ricco <jcdericco <at> optonline.net>

Date: Mon, 25 Nov 2013 21:00:04 UTC

Severity: normal

Tags: patch

Merged with 23898

Found in versions 24.3, 24.3.50

Fixed in version 24.4

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 15975 in the body.
You can then email your comments to 15975 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#15975; Package emacs. (Mon, 25 Nov 2013 21:00:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to James De Ricco <jcdericco <at> optonline.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 25 Nov 2013 21:00:05 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: James De Ricco <jcdericco <at> optonline.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 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
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)
    python-indent-calculate-levels()
    python-indent-line()
    python-indent-line-function()
    indent-according-to-mode()
    newline-and-indent()
    call-interactively(newline-and-indent nil nil)
    command-execute(newline-and-indent)

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)
                   (python-util-forward-comment)
                   (current-indentation))))
!           (if indentation
                (set (make-local-variable 'python-indent-offset)
indentation)
              (message "Can't guess python-indent-offset, using
defaults: %s"
                       python-indent-offset)))))))
--- 676,682 ----
                   (goto-char block-end)
                   (python-util-forward-comment)
                   (current-indentation))))
!           (if (> indentation 0)
                (set (make-local-variable 'python-indent-offset)
indentation)
              (message "Can't guess python-indent-offset, using
defaults: %s"
                       python-indent-offset)))))))


In GNU Emacs 24.3.50.3 (x86_64-unknown-linux-gnu, X toolkit, Xaw scroll
bars)
 of 2013-11-25 on jcdericco-MacBookPro-GNU
Bzr revision: 115235 bozhidar <at> batsov.com-20131125190450-w5yaffnkd8ti4o5z
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.

Features:
(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 sent to Glenn Morris <rgm <at> gnu.org>:
You have taken responsibility. (Tue, 26 Nov 2013 03:17:01 GMT) Full text and rfc822 format available.

Notification sent to James De Ricco <jcdericco <at> optonline.net>:
bug acknowledged by developer. (Tue, 26 Nov 2013 03:17:02 GMT) Full text and rfc822 format available.

Message #10 received at 15975-done <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: 15975-done <at> debbugs.gnu.org
Subject: Re: 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 22:16:21 -0500
Version: 24.4

Thanks; fixed.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 24 Dec 2013 12:24:05 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 07 Dec 2016 22:13:02 GMT) Full text and rfc822 format available.

Forcibly Merged 15975 23898. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 07 Dec 2016 22:13:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 05 Jan 2017 12:24:14 GMT) Full text and rfc822 format available.

This bug report was last modified 7 years and 114 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.