all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#5756: 24.0.50; reloading files in python3
@ 2010-03-23 11:58 Alex Harsanyi
  2010-08-22 23:51 ` Chong Yidong
  0 siblings, 1 reply; 2+ messages in thread
From: Alex Harsanyi @ 2010-03-23 11:58 UTC (permalink / raw)
  To: 5756

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 <http://www.gnu.org/licenses/>.

-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:
<help-echo> <help-echo> C-x C-f O t h <tab> h e <tab> 
<return> M-> <up> <up> C-e <left> <left> <left> <backspace> 
<backspace> <backspace> <backspace> C-e C-x C-s C-c 
C-z i m p o r t SPC s y s <return> s y s . v e r s 
i o n _ i n f o <return> C-x o C-c C-l <return> C-x 
o h e l l o . H e l l o ( ) ; <return> C-x C-o C-x 
o <left> <left> <left> , SPC 2 <backspace> 1 2 3 C-x 
C-s C-c C-l <return> C-x o M-p <return> C-x o C-x C-f 
<C-backspace> k <tab> <backspace> p k <tab> e m <tab> 
/ q <tab> e t <tab> e m <tab> 3 <tab> <return> C-x 
1 C-x v = <wheel-down> <wheel-up> <double-wheel-up> 
<help-echo> <down-mouse-1> <mouse-1> M-x r e o <tab> 
<backspace> [ p <tab> <backspace> <backspace> p o <tab> 
r t <tab> <return>

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)







^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#5756: 24.0.50; reloading files in python3
  2010-03-23 11:58 bug#5756: 24.0.50; reloading files in python3 Alex Harsanyi
@ 2010-08-22 23:51 ` Chong Yidong
  0 siblings, 0 replies; 2+ messages in thread
From: Chong Yidong @ 2010-08-22 23:51 UTC (permalink / raw)
  To: Alex Harsanyi; +Cc: 5756

> 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.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-08-22 23:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-23 11:58 bug#5756: 24.0.50; reloading files in python3 Alex Harsanyi
2010-08-22 23:51 ` Chong Yidong

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.