From unknown Fri Aug 15 02:02:09 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#5756 <5756@debbugs.gnu.org> To: bug#5756 <5756@debbugs.gnu.org> Subject: Status: 24.0.50; reloading files in python3 Reply-To: bug#5756 <5756@debbugs.gnu.org> Date: Fri, 15 Aug 2025 09:02:09 +0000 retitle 5756 24.0.50; reloading files in python3 reassign 5756 emacs submitter 5756 Alex Harsanyi severity 5756 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 23 08:15:00 2010 Received: (at submit) by debbugs.gnu.org; 23 Mar 2010 12:15:00 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nu30d-0005de-M7 for submit@debbugs.gnu.org; Tue, 23 Mar 2010 08:15:00 -0400 Received: from mx10.gnu.org ([199.232.76.166]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nu2kY-0005Xq-3z for submit@debbugs.gnu.org; Tue, 23 Mar 2010 07:58:24 -0400 Received: from lists.gnu.org ([199.232.76.165]:55302) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Nu2kS-00014c-Gv for submit@debbugs.gnu.org; Tue, 23 Mar 2010 07:58:16 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nu2kS-0003kl-Ao for bug-gnu-emacs@gnu.org; Tue, 23 Mar 2010 07:58:16 -0400 Received: from [140.186.70.92] (port=33453 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nu2kP-0003ka-Qb for bug-gnu-emacs@gnu.org; Tue, 23 Mar 2010 07:58:14 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.0 (2010-01-18) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.0 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Nu2kM-0000ya-Ss for bug-gnu-emacs@gnu.org; Tue, 23 Mar 2010 07:58:13 -0400 Received: from outbound-mail01.westnet.com.au ([203.10.1.242]:23266) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nu2kM-0000yH-8B for bug-gnu-emacs@gnu.org; Tue, 23 Mar 2010 07:58:10 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlgWADtJqEs6B2wzPGdsb2JhbAAHmy8BAQEBN7szhH0Egxw X-IronPort-AV: E=Sophos;i="4.51,294,1267372800"; d="scan'208";a="66547428" Received: from dsl-58-7-108-51.wa.westnet.com.au (HELO [10.0.1.2]) ([58.7.108.51]) by outbound-mail01.westnet.com.au with ESMTP/TLS/AES128-SHA; 23 Mar 2010 19:58:05 +0800 From: Alex Harsanyi Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: 24.0.50; reloading files in python3 Date: Tue, 23 Mar 2010 19:58:03 +0800 Message-Id: <64CCAC7D-54C4-45F7-BB72-7B9862EE5FC9@mac.com> To: bug-gnu-emacs@gnu.org Mime-Version: 1.0 (Apple Message framework v1077) X-Mailer: Apple Mail (2.1077) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -3.4 (---) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Tue, 23 Mar 2010 08:14:58 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.7 (----) Reloading a python file into the current interpreter using C-c C-l fails for python3. To test it, create a file hello.py with the contents: def Hello(): print ("Hello World"); and load it into the python interpreter using C-c C-l. Modify the file, than try to load it again. The python interpreter will fail with an exception about reload() not being defined. The problem is that the reload() function is no longer a built-in in Python3, instead it lives in the "imp" module. The following patch fixes the problem, but I'm not sure if it is correct if emacs3.py is re-generated from emacs2.py as the comment in the header states. === modified file 'etc/emacs3.py' --- etc/emacs3.py 2010-01-13 08:35:10 +0000 +++ etc/emacs3.py 2010-03-23 10:39:17 +0000 @@ -23,7 +23,7 @@ Warning: This file is automatically gene # You should have received a copy of the GNU General Public License # along with GNU Emacs. If not, see . -import os, sys, traceback, inspect, __main__ +import os, sys, traceback, inspect, imp, __main__ try: set @@ -216,7 +216,7 @@ def eimport (mod, dir): try: try: if mod in __dict__ and inspect.ismodule (__dict__[mod]): - reload (__dict__[mod]) + imp.reload (__dict__[mod]) else: __dict__[mod] = __import__ (mod) except: In GNU Emacs 24.0.50.1 (x86_64-apple-darwin10.2.0, NS apple-appkit-1038.25) of 2010-03-23 on karinji-2.local Windowing system distributor `Apple', version 10.3.1038 configured using `configure '--with-ns'' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: en_AU.UTF-8 value of $XMODIFIERS: nil locale-coding-system: utf-8-unix default enable-multibyte-characters: t Major mode: Python Minor modes in effect: diff-auto-refine-mode: t show-paren-mode: t global-cwarn-mode: t display-time-mode: t mouse-wheel-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t auto-encryption-mode: t auto-compression-mode: t size-indication-mode: t line-number-mode: t Recent input: C-x C-f O t h h e M-> C-e C-e C-x C-s C-c C-z i m p o r t SPC s y s s y s . v e r s i o n _ i n f o C-x o C-c C-l C-x o h e l l o . H e l l o ( ) ; C-x C-o C-x o , SPC 2 1 2 3 C-x C-s C-c C-l C-x o M-p C-x o C-x C-f k p k e m / q e t e m 3 C-x 1 C-x v = M-x r e o [ p p o r t Recent messages: Fontifying *Python*... (regexps...........) /Users/haral/Other/hello.py loaded Saving file /Users/haral/Other/hello.py... Wrote /Users/haral/Other/hello.py /Users/haral/Other/hello.py loaded History item: 1 Loading vc-bzr...done Finding changes in /Users/haral/pkg/emacs/quickfixes/etc/emacs3.py...done byte-code: Beginning of buffer Making completion list... Load-path shadows: None found. Features: (shadow sort gnus-util mail-extr message rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mailabbrev mail-utils gmm-utils mailheader emacsbug help-mode view diff-mode easy-mmode vc vc-dispatcher vc-bzr sha1 hex-util compile python-21 python comint ring uniquify paren avoid cwarn cus-start cus-load appt diary-lib diary-loaddefs cal-menu calendar cal-loaddefs time tex-site folding-isearch folding advice help-fns advice-preload protbuf server midnight time-stamp whitespace iswitchb cc-mode cc-menus cc-cmds ah-bufsel ah-cc-mode-extra cc-styles cc-align cc-fonts cc-engine cc-vars cc-defs regexp-opt ah-util autoinsert cl cl-19 tooltip ediff-hook vc-hooks lisp-float-type mwheel ns-win easymenu tool-bar dnd fontset image fringe lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar mldrag 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 loaddefs button minibuffer faces cus-face files text-properties overlay md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process ns multi-tty emacs) From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 22 19:50:40 2010 Received: (at 5756) by debbugs.gnu.org; 22 Aug 2010 23:50:40 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OnKJD-0008Af-JJ for submit@debbugs.gnu.org; Sun, 22 Aug 2010 19:50:39 -0400 Received: from pantheon-po45.its.yale.edu ([130.132.50.79]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OnKJB-0008Aa-Bv for 5756@debbugs.gnu.org; Sun, 22 Aug 2010 19:50:37 -0400 Received: from furry (173-9-75-145-NewEngland.hfc.comcastbusiness.net [173.9.75.145]) (authenticated bits=0) by pantheon-po45.its.yale.edu (8.12.11.20060308/8.12.11) with ESMTP id o7MNproC006823 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sun, 22 Aug 2010 19:51:53 -0400 Received: by furry (Postfix, from userid 1000) id 094F416D402; Sun, 22 Aug 2010 19:51:53 -0400 (EDT) From: Chong Yidong To: Alex Harsanyi Subject: Re: 24.0.50; reloading files in python3 Date: Sun, 22 Aug 2010 19:51:52 -0400 Message-ID: <87mxsekxyf.fsf@stupidchicken.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-YaleITSMailFilter: Version 1.2c (attachment(s) not renamed) X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: 5756 Cc: 5756@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.7 (--) > Reloading a python file into the current interpreter using C-c C-l fails > for python3. To test it, create a file hello.py with the contents: > > def Hello(): > print ("Hello World"); > > and load it into the python interpreter using C-c C-l. Modify the file, > than try to load it again. The python interpreter will fail with an > exception about reload() not being defined. Thanks. I've checked in the fix you suggested into the emacs-23 branch. > I'm not sure if it is correct if emacs3.py is re-generated from > emacs2.py as the comment in the header states. I don't see any better solution, so I've removed the comment. From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 22 19:50:52 2010 Received: (at control) by debbugs.gnu.org; 22 Aug 2010 23:50:52 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OnKJQ-0008Av-Bh for submit@debbugs.gnu.org; Sun, 22 Aug 2010 19:50:52 -0400 Received: from pantheon-po44.its.yale.edu ([130.132.50.78]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OnKJO-0008Ao-Im for control@debbugs.gnu.org; Sun, 22 Aug 2010 19:50:50 -0400 Received: from furry (173-9-75-145-NewEngland.hfc.comcastbusiness.net [173.9.75.145]) (authenticated bits=0) by pantheon-po44.its.yale.edu (8.12.11.20060308/8.12.11) with ESMTP id o7MNq64L004320 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Sun, 22 Aug 2010 19:52:06 -0400 Received: by furry (Postfix, from userid 1000) id 65DDF16D402; Sun, 22 Aug 2010 19:52:06 -0400 (EDT) From: Chong Yidong To: control@debbugs.gnu.org Subject: close 5756 Date: Sun, 22 Aug 2010 19:52:06 -0400 Message-ID: <87k4nikxy1.fsf@stupidchicken.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-YaleITSMailFilter: Version 1.2c (attachment(s) not renamed) X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.7 (--) close 5756 thanks From unknown Fri Aug 15 02:02:09 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 20 Sep 2010 11:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator