From unknown Sat Jun 21 12:28:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15975: 24.3.50; Arithmetic error upon calling `python-indent-line` in a buffer of a single non-empty line. 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: To: 15975@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.13854131993937 (code B ref -1); Mon, 25 Nov 2013 21:00:04 +0000 Received: (at submit) by debbugs.gnu.org; 25 Nov 2013 20:59:59 +0000 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 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 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 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_MANY_HDRS_LCASE autolearn=disabled version=3.3.2 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 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 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 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 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) Date: Mon, 25 Nov 2013 15:49:58 -0500 From: James De Ricco Message-id: <5293B7F6.4000604@optonline.net> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: 7BIT 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-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) 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 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.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 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) From unknown Sat Jun 21 12:28:30 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.503 (Entity 5.503) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: James De Ricco Subject: bug#15975: closed (Re: bug#15975: 24.3.50; Arithmetic error upon calling `python-indent-line` in a buffer of a single non-empty line.) Message-ID: References: <5293B7F6.4000604@optonline.net> X-Gnu-PR-Message: they-closed 15975 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 15975@debbugs.gnu.org Date: Tue, 26 Nov 2013 03:17:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1385435822-17559-1" This is a multi-part message in MIME format... ------------=_1385435822-17559-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #15975: 24.3.50; Arithmetic error upon calling `python-indent-line` in a bu= ffer of a single non-empty line. which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 15975@debbugs.gnu.org. --=20 15975: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D15975 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1385435822-17559-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 15975-done) by debbugs.gnu.org; 26 Nov 2013 03:16:27 +0000 Received: from localhost ([127.0.0.1]:45244 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vl98U-0004YD-7a for submit@debbugs.gnu.org; Mon, 25 Nov 2013 22:16:26 -0500 Received: from fencepost.gnu.org ([208.118.235.10]:55919 ident=Debian-exim) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vl98Q-0004Y4-Dg for 15975-done@debbugs.gnu.org; Mon, 25 Nov 2013 22:16:23 -0500 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1Vl98P-0001jM-Fq; Mon, 25 Nov 2013 22:16:21 -0500 From: Glenn Morris To: 15975-done@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. References: <5293B7F6.4000604@optonline.net> X-Spook: S Key George W. Bush Exon Shell SAFE DRM Maple halcon X-Ran: 5QB\1WR1I_v7[h{2}(F?K?)C`k(k8?gE4'00>X~w~9ejX2Z(#HUm(:CgtJ&Y?!Bg7Vg_jv X-Hue: yellow X-Debbugs-No-Ack: yes X-Attribution: GM Date: Mon, 25 Nov 2013 22:16:21 -0500 In-Reply-To: <5293B7F6.4000604@optonline.net> (James De Ricco's message of "Mon, 25 Nov 2013 15:49:58 -0500") Message-ID: User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 15975-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) Version: 24.4 Thanks; fixed. ------------=_1385435822-17559-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 25 Nov 2013 20:59:59 +0000 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 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 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 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_MANY_HDRS_LCASE autolearn=disabled version=3.3.2 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 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 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 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 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) Date: Mon, 25 Nov 2013 15:49:58 -0500 From: James De Ricco Subject: 24.3.50; Arithmetic error upon calling `python-indent-line` in a buffer of a single non-empty line. To: bug-gnu-emacs@gnu.org Message-id: <5293B7F6.4000604@optonline.net> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: 7BIT 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-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit 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 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.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 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) ------------=_1385435822-17559-1-- From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 07 17:12:32 2016 Received: (at control) by debbugs.gnu.org; 7 Dec 2016 22:12:33 +0000 Received: from localhost ([127.0.0.1]:60415 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cEkS0-0003TI-R2 for submit@debbugs.gnu.org; Wed, 07 Dec 2016 17:12:32 -0500 Received: from eggs.gnu.org ([208.118.235.92]:45257) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cEkRz-0003T7-Kg for control@debbugs.gnu.org; Wed, 07 Dec 2016 17:12:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cEkRt-0006ts-Sn for control@debbugs.gnu.org; Wed, 07 Dec 2016 17:12:26 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:57999) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cEkRt-0006to-Pf for control@debbugs.gnu.org; Wed, 07 Dec 2016 17:12:25 -0500 Received: from rgm by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1cEkRt-0001pS-Fc for control@debbugs.gnu.org; Wed, 07 Dec 2016 17:12:25 -0500 Subject: control message for bug 23898 To: X-Mailer: mail (GNU Mailutils 2.99.98) Message-Id: From: Glenn Morris Date: Wed, 07 Dec 2016 17:12:25 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -8.0 (--------) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -8.0 (--------) unarchive 15975 forcemerge 15975 23898