unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* python-mode patch
@ 2006-08-10 10:43 Slawomir Nowaczyk
  2006-08-10 11:22 ` Nick Roberts
  0 siblings, 1 reply; 40+ messages in thread
From: Slawomir Nowaczyk @ 2006-08-10 10:43 UTC (permalink / raw)


Hello,

I would like to suggest the following patch for python-mode.

The intend is to make commands like python-send-buffer execute files
in the global namespace of the "main" script, not within namespace of
the "emacs" module.

An example: currently, if you run python-send-buffer in a buffer
containing "x=1", a python interpreter will open and execute the
assignment, but trying "print x" will fail. One needs to type,
instead, "print emacs.x". All functions, classes, variables etc.
defined in the buffer will end up in a namespace of "emacs" module.

After my patch, "print x" does work (note that I only have python
2.4.3 so I only tested there, but I think older versions should work
similarly).

For me, personally, this is a serious bug which makes python-mode
almost unusable. Did anybody actually liked the way it used to work?
It would be sufficiently easy to provide an option here, but I do not
think it makes sense.

**********************************************************************

--- etc/emacs.py        2006-02-06 00:44:47.000000000 +0100
+++ /c/Emacs/etc/emacs.py       2006-08-10 12:26:39.930859200 +0200
@@ -2,6 +2,7 @@

 # Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
 # Author: Dave Love <d.love@dl.ac.uk>
+# Modified: Slawomir Nowaczyk <slawek@cs.lth.se>

 # This file is part of GNU Emacs.

@@ -26,10 +27,12 @@

 def eexecfile (file):
     """Execute FILE and then remove it.
+    Make sure we execute the file within a namespace of __main__ script.
     If we get an exception, print a traceback with the top frame
-    (oursleves) excluded."""
+    (ourselves) excluded."""
     try:
-       try: execfile (file, globals (), globals ())
+       try:
+            execfile (file, __main__.__dict__)
        except:
            (type, value, tb) = sys.exc_info ()
            # Lose the stack frame for this location.
@@ -96,8 +99,8 @@
     sys.path[0] = dir
     try:
        try:
-           if globals().has_key(mod) and inspect.ismodule (eval (mod)):
-               reload(eval (mod))
+           if mod in sys.modules:
+               reload(sys.modules[mod])
            else:
                globals ()[mod] = __import__ (mod)
        except:

**********************************************************************

-- 
 Best wishes,
   Slawomir Nowaczyk
     ( slawomir.nowaczyk.847@student.lu.se )

Make it idiot-proof and someone will make a better idiot.

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

end of thread, other threads:[~2006-09-28  2:13 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-10 10:43 python-mode patch Slawomir Nowaczyk
2006-08-10 11:22 ` Nick Roberts
2006-08-10 16:12   ` Slawomir Nowaczyk
2006-08-10 20:19   ` Richard Stallman
2006-08-20 19:53     ` Slawomir Nowaczyk
2006-08-20 20:31       ` Steven Huwig
2006-08-21  9:39         ` Slawomir Nowaczyk
2006-08-20 21:08       ` Edward O'Connor
2006-08-21  9:03         ` Piet van Oostrum
2006-08-21  9:39           ` Slawomir Nowaczyk
2006-08-21 17:57         ` Peter Lee
2006-08-22  1:31           ` Stefan Monnier
2006-08-22 19:40             ` Peter Lee
2006-08-22 20:07               ` Slawomir Nowaczyk
2006-08-22 20:31                 ` Peter Lee
2006-08-23 20:10                   ` Slawomir Nowaczyk
2006-09-09 19:48                     ` Stefan Monnier
2006-08-20 21:41       ` Nick Roberts
2006-08-21  9:39         ` Slawomir Nowaczyk
2006-08-20 22:33       ` Stefan Monnier
2006-08-21  9:39         ` Slawomir Nowaczyk
2006-08-21 15:58           ` Stefan Monnier
2006-08-21 11:13       ` Richard Stallman
2006-08-23 20:10         ` Slawomir Nowaczyk
2006-08-25  7:43           ` Richard Stallman
2006-08-25  8:11             ` David Kastrup
2006-08-25  8:26             ` Nick Roberts
2006-08-26 10:08               ` Richard Stallman
2006-09-26 21:56                 ` Nick Roberts
2006-09-27  3:41                   ` Stefan Monnier
2006-09-27  5:30                     ` Nick Roberts
2006-09-27  3:59                   ` Ken Manheimer
2006-09-28  2:13                     ` Richard Stallman
2006-08-25  7:43           ` Richard Stallman
2006-08-25 15:44             ` Slawomir Nowaczyk
2006-08-21 18:27       ` Ken Manheimer
2006-08-23  8:12         ` Nick Roberts
2006-08-23 15:03           ` Ken Manheimer
2006-08-24 19:08         ` Slawomir Nowaczyk
2006-08-24 22:06           ` Nick Roberts

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).