[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
python-mode patch
From: |
Slawomir Nowaczyk |
Subject: |
python-mode patch |
Date: |
Thu, 10 Aug 2006 12:43:54 +0200 |
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 <address@hidden>
+# Modified: Slawomir Nowaczyk <address@hidden>
# 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
( address@hidden )
Make it idiot-proof and someone will make a better idiot.
- python-mode patch,
Slawomir Nowaczyk <=
- Re: python-mode patch, Nick Roberts, 2006/08/10
- Re: python-mode patch, Slawomir Nowaczyk, 2006/08/10
- Re: python-mode patch, Richard Stallman, 2006/08/10
- Re: python-mode patch, Edward O'Connor, 2006/08/20
- Re: python-mode patch, Piet van Oostrum, 2006/08/21
- Re: python-mode patch, Slawomir Nowaczyk, 2006/08/21
- Re: python-mode patch, Peter Lee, 2006/08/21