From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: James De Ricco Newsgroups: gmane.emacs.bugs 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 Message-ID: <5293B7F6.4000604@optonline.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7BIT X-Trace: ger.gmane.org 1385413220 24794 80.91.229.3 (25 Nov 2013 21:00:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 25 Nov 2013 21:00:20 +0000 (UTC) To: 15975@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Nov 25 22:00:25 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Vl3Gb-00038g-78 for geb-bug-gnu-emacs@m.gmane.org; Mon, 25 Nov 2013 22:00:25 +0100 Original-Received: from localhost ([::1]:55016 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vl3Ga-0002AO-SG for geb-bug-gnu-emacs@m.gmane.org; Mon, 25 Nov 2013 16:00:24 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60142) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vl3GP-0001v6-9Y for bug-gnu-emacs@gnu.org; Mon, 25 Nov 2013 16:00:20 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vl3GI-0007Yk-1L for bug-gnu-emacs@gnu.org; Mon, 25 Nov 2013 16:00:13 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:59183) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vl3GH-0007Xs-Ur for bug-gnu-emacs@gnu.org; Mon, 25 Nov 2013 16:00:05 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Vl3GH-00012I-7E for bug-gnu-emacs@gnu.org; Mon, 25 Nov 2013 16:00:05 -0500 X-Loop: help-debbugs@gnu.org Resent-From: James De Ricco Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 25 Nov 2013 21:00:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 15975 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.13854131993937 (code B ref -1); Mon, 25 Nov 2013 21:00:04 +0000 Original-Received: (at submit) by debbugs.gnu.org; 25 Nov 2013 20:59:59 +0000 Original-Received: from localhost ([127.0.0.1]:44969 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vl3GA-00011Q-AF for submit@debbugs.gnu.org; Mon, 25 Nov 2013 15:59:59 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:54850) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vl36v-0000nS-Nt for submit@debbugs.gnu.org; Mon, 25 Nov 2013 15:50:26 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vl36j-0004DS-CG for submit@debbugs.gnu.org; Mon, 25 Nov 2013 15:50:20 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:59391) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vl36j-0004DO-90 for submit@debbugs.gnu.org; Mon, 25 Nov 2013 15:50:13 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56364) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vl36c-00048t-Qh for bug-gnu-emacs@gnu.org; Mon, 25 Nov 2013 15:50:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vl36W-0003rh-JX for bug-gnu-emacs@gnu.org; Mon, 25 Nov 2013 15:50:06 -0500 Original-Received: from mta3.srv.hcvlny.cv.net ([167.206.4.198]:49725) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vl36W-0003ra-FN for bug-gnu-emacs@gnu.org; Mon, 25 Nov 2013 15:50:00 -0500 Original-Received: from [129.21.130.19] (res55557472689.rh.rit.edu [129.21.130.19]) by mta3.srv.hcvlny.cv.net (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) with ESMTPA id <0MWU00JH777ADKA0@mta3.srv.hcvlny.cv.net> for bug-gnu-emacs@gnu.org; Mon, 25 Nov 2013 15:49:59 -0500 (EST) X-Enigmail-Version: 1.5.2 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Mailman-Approved-At: Mon, 25 Nov 2013 15:59:56 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:80960 Archived-At: 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 def main(): M-x python-mode 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@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)