From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Slawomir Nowaczyk Newsgroups: gmane.emacs.devel Subject: python-mode patch Date: Thu, 10 Aug 2006 12:43:54 +0200 Message-ID: <20060810122914.EF42.SLAWOMIR.NOWACZYK.847@student.lu.se> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1155206682 11094 80.91.229.2 (10 Aug 2006 10:44:42 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 10 Aug 2006 10:44:42 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Aug 10 12:44:41 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GB81g-0002Oq-SY for ged-emacs-devel@m.gmane.org; Thu, 10 Aug 2006 12:44:33 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GB81g-000472-6w for ged-emacs-devel@m.gmane.org; Thu, 10 Aug 2006 06:44:32 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GB81R-000454-90 for emacs-devel@gnu.org; Thu, 10 Aug 2006 06:44:17 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GB81O-00043w-7i for emacs-devel@gnu.org; Thu, 10 Aug 2006 06:44:16 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GB81O-00043t-3p for emacs-devel@gnu.org; Thu, 10 Aug 2006 06:44:14 -0400 Original-Received: from [130.235.16.11] (helo=himmelsborg.cs.lth.se) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GB86H-0003nD-3Q for emacs-devel@gnu.org; Thu, 10 Aug 2006 06:49:17 -0400 Original-Received: from [127.0.0.1] (slawek@dain [130.235.16.76]) by himmelsborg.cs.lth.se (8.13.6/8.13.6/perf-jw-tr) with ESMTP id k7AAhxHb002832 for ; Thu, 10 Aug 2006 12:44:03 +0200 (CEST) Original-To: emacs-devel@gnu.org X-Esmandil_Citation: done X-Mailer-Plugin: Popup Memopad for Becky!2 Ver.0.02 Rev.2 X-Mailer: Becky! ver. 2.25.02 [en] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:58258 Archived-At: 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 +# Modified: Slawomir Nowaczyk # 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.