comparison etc/emacs.py @ 72456:044730770048

(eexecfile): Use the __main__ rather than `emacs' namespace.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sun, 20 Aug 2006 15:52:50 +0000
parents e8a3fb527b77
children 18443633d75d
comparison
equal deleted inserted replaced
72455:94094ff11364 72456:044730770048
24 24
25 __all__ = ["eexecfile", "args", "complete", "ehelp", "eimport"] 25 __all__ = ["eexecfile", "args", "complete", "ehelp", "eimport"]
26 26
27 def eexecfile (file): 27 def eexecfile (file):
28 """Execute FILE and then remove it. 28 """Execute FILE and then remove it.
29 Execute the file within the __main__ namespace.
29 If we get an exception, print a traceback with the top frame 30 If we get an exception, print a traceback with the top frame
30 (oursleves) excluded.""" 31 (ourselves) excluded."""
31 try: 32 try:
32 try: execfile (file, globals (), globals ()) 33 try: execfile (file, __main__.__dict__)
33 except: 34 except:
34 (type, value, tb) = sys.exc_info () 35 (type, value, tb) = sys.exc_info ()
35 # Lose the stack frame for this location. 36 # Lose the stack frame for this location.
36 tb = tb.tb_next 37 tb = tb.tb_next
37 if tb is None: # print_exception won't do it 38 if tb is None: # print_exception won't do it
38 print "Traceback (most recent call last):" 39 print "Traceback (most recent call last):"
39 traceback.print_exception (type, value, tb) 40 traceback.print_exception (type, value, tb)
40 finally: 41 finally: