[Python-bugs-list] [ python-Bugs-508730 ] CGIHTTPServer execfile should save cwd
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 25 Jan 2002 15:41:54 -0800
Bugs item #508730, was opened at 2002-01-25 15:41
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=508730&group_id=5470
Category: Python Library
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Dan Grassi (dgrassi)
Assigned to: Nobody/Anonymous (nobody)
Summary: CGIHTTPServer execfile should save cwd
Initial Comment:
In CGIHTTPServer when running a script via execfile the
cwd is not saved and restored. If the executed script
changes the cwd subsequent requests will fail because
self.translate_path in SimpleHTTPServer relies on the
cwd.
One fix is to suround the execfile call with
save_cwd = os.getcwd()
and
os.chdir(save_cwd)
Here is the proposed fix starting at line 254:
+ save_cwd = os.getcwd()
try:
try:
sys.argv = [scriptfile]
if '=' not in decoded_query:
sys.argv.append(decoded_query)
sys.stdout = self.wfile
sys.stdin = self.rfile
execfile(scriptfile, {"__name__":
"__main__"})
finally:
+ os.chdir(save_cwd)
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=508730&group_id=5470