[3.7] bpo-20844: open script file with "rb" mode (GH-12616) by methane · Pull Request #12647 · python/cpython
Expand Up
@@ -387,6 +387,23 @@ def test_issue8202_dash_m_file_ignored(self):
script_name, script_name, script_dir, '',
importlib.machinery.SourceFileLoader)
def test_issue20884(self): # On Windows, script with encoding cookie and LF line ending # will be failed. with support.temp_dir() as script_dir: script_name = os.path.join(script_dir, "issue20884.py") with open(script_name, "w", newline='\n') as f: f.write("#coding: iso-8859-1\n") f.write('"""\n') for _ in range(30): f.write('x'*80 + '\n') f.write('"""\n')
with support.change_cwd(path=script_dir): rc, out, err = assert_python_ok(script_name) self.assertEqual(b"", out) self.assertEqual(b"", err)
@contextlib.contextmanager def setup_test_pkg(self, *args): with support.temp_dir() as script_dir, \ Expand Down
def test_issue20884(self): # On Windows, script with encoding cookie and LF line ending # will be failed. with support.temp_dir() as script_dir: script_name = os.path.join(script_dir, "issue20884.py") with open(script_name, "w", newline='\n') as f: f.write("#coding: iso-8859-1\n") f.write('"""\n') for _ in range(30): f.write('x'*80 + '\n') f.write('"""\n')
with support.change_cwd(path=script_dir): rc, out, err = assert_python_ok(script_name) self.assertEqual(b"", out) self.assertEqual(b"", err)
@contextlib.contextmanager def setup_test_pkg(self, *args): with support.temp_dir() as script_dir, \ Expand Down