Skip to content

Commit 3218c31

Browse files
author
Victor Stinner
committed
test_httpservers: Fix skip test check, the python executable path have to be
encodable to utf-8, not to the file1 encoding.
1 parent 23d05c1 commit 3218c31

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

Lib/test/test_httpservers.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -310,15 +310,18 @@ def setUp(self):
310310
else:
311311
self.pythonexe = sys.executable
312312

313+
try:
314+
# The python executable path is written as the first line of the
315+
# CGI Python script. The encoding cookie cannot be used, and so the
316+
# path should be encodable to the default script encoding (utf-8)
317+
self.pythonexe.encode('utf-8')
318+
except UnicodeEncodeError:
319+
self.tearDown()
320+
raise self.skipTest(
321+
"Python executable path is not encodable to utf-8")
322+
313323
self.file1_path = os.path.join(self.cgi_dir, 'file1.py')
314324
with open(self.file1_path, 'w') as file1:
315-
try:
316-
self.pythonexe.encode(file1.encoding)
317-
except UnicodeEncodeError:
318-
self.tearDown()
319-
raise self.skipTest(
320-
"Python executable path is not encodable to %s"
321-
% file1.encoding)
322325
file1.write(cgi_file1 % self.pythonexe)
323326
os.chmod(self.file1_path, 0o777)
324327

0 commit comments

Comments
 (0)