[Idle-dev] CVS: idle ScriptBinding.py,1.23,1.24

Kurt B. Kaiser kbk@users.sourceforge.net
Sat, 31 May 2003 16:44:21 -0700


Update of /cvsroot/idlefork/idle
In directory sc8-pr-cvs1:/tmp/cvs-serv21028

Modified Files:
	ScriptBinding.py 
Log Message:

SF 745525

Excecution environment and residual shell has cwd set to the directory of
the module being run.

M ScriptBinding.py


Index: ScriptBinding.py
===================================================================
RCS file: /cvsroot/idlefork/idle/ScriptBinding.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -r1.23 -r1.24
*** ScriptBinding.py	26 May 2003 22:20:34 -0000	1.23
--- ScriptBinding.py	31 May 2003 23:44:18 -0000	1.24
***************
*** 18,21 ****
--- 18,22 ----
  """
  
+ import os
  import re
  import string
***************
*** 116,120 ****
  
      def run_module_event(self, event):
!         "Check syntax, if ok run the module in the shell top level"
          filename = self.getfilename()
          if not filename:
--- 117,128 ----
  
      def run_module_event(self, event):
!         """Run the module after setting up the environment.
! 
!         First check the syntax.  If OK, make sure the shell is active and
!         then transfer the arguments, set the run environment's working
!         directory to the directory of the module being executed and also
!         add that directory to its sys.path if not already included.
! 
!         """
          filename = self.getfilename()
          if not filename:
***************
*** 128,131 ****
--- 136,140 ----
          if PyShell.use_subprocess:
              shell.restart_shell()
+         dirname = os.path.dirname(filename)
          # XXX Too often this discards arguments the user just set...
          interp.runcommand("""if 1:
***************
*** 136,141 ****
                  _basename(_sys.argv[0]) != _basename(_filename)):
                  _sys.argv = [_filename]
!             del _filename, _sys, _basename
!             \n""" % `filename`)
          interp.prepend_syspath(filename)
          interp.runcode(code)
--- 145,152 ----
                  _basename(_sys.argv[0]) != _basename(_filename)):
                  _sys.argv = [_filename]
!             import os as _os
!             _os.chdir(%s)
!             del _filename, _sys, _basename, _os
!             \n""" % (`filename`, `dirname`))
          interp.prepend_syspath(filename)
          interp.runcode(code)