mirror of
https://github.com/python/cpython.git
synced 2025-07-30 06:34:15 +00:00
#7668: Fix test_httpservers failure when sys.executable contains non-ASCII bytes.
This commit is contained in:
parent
eba2aca4bd
commit
0805e6eed9
1 changed files with 12 additions and 2 deletions
|
@ -297,14 +297,22 @@ class CGIHTTPServerTestCase(BaseTestCase):
|
||||||
self.cgi_dir = os.path.join(self.parent_dir, 'cgi-bin')
|
self.cgi_dir = os.path.join(self.parent_dir, 'cgi-bin')
|
||||||
os.mkdir(self.cgi_dir)
|
os.mkdir(self.cgi_dir)
|
||||||
|
|
||||||
|
# The shebang line should be pure ASCII: use symlink if possible.
|
||||||
|
# See issue #7668.
|
||||||
|
if hasattr(os, 'symlink'):
|
||||||
|
self.pythonexe = os.path.join(self.parent_dir, 'python')
|
||||||
|
os.symlink(sys.executable, self.pythonexe)
|
||||||
|
else:
|
||||||
|
self.pythonexe = sys.executable
|
||||||
|
|
||||||
self.file1_path = os.path.join(self.cgi_dir, 'file1.py')
|
self.file1_path = os.path.join(self.cgi_dir, 'file1.py')
|
||||||
with open(self.file1_path, 'w') as file1:
|
with open(self.file1_path, 'w') as file1:
|
||||||
file1.write(cgi_file1 % sys.executable)
|
file1.write(cgi_file1 % self.pythonexe)
|
||||||
os.chmod(self.file1_path, 0777)
|
os.chmod(self.file1_path, 0777)
|
||||||
|
|
||||||
self.file2_path = os.path.join(self.cgi_dir, 'file2.py')
|
self.file2_path = os.path.join(self.cgi_dir, 'file2.py')
|
||||||
with open(self.file2_path, 'w') as file2:
|
with open(self.file2_path, 'w') as file2:
|
||||||
file2.write(cgi_file2 % sys.executable)
|
file2.write(cgi_file2 % self.pythonexe)
|
||||||
os.chmod(self.file2_path, 0777)
|
os.chmod(self.file2_path, 0777)
|
||||||
|
|
||||||
self.cwd = os.getcwd()
|
self.cwd = os.getcwd()
|
||||||
|
@ -313,6 +321,8 @@ class CGIHTTPServerTestCase(BaseTestCase):
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
try:
|
try:
|
||||||
os.chdir(self.cwd)
|
os.chdir(self.cwd)
|
||||||
|
if self.pythonexe != sys.executable:
|
||||||
|
os.remove(self.pythonexe)
|
||||||
os.remove(self.file1_path)
|
os.remove(self.file1_path)
|
||||||
os.remove(self.file2_path)
|
os.remove(self.file2_path)
|
||||||
os.rmdir(self.cgi_dir)
|
os.rmdir(self.cgi_dir)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue