diff options
author | Inada Naoki <songofacandy@gmail.com> | 2019-04-01 09:35:20 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-01 09:35:20 (GMT) |
commit | 10654c19b5e6efdf3c529ff9bf7bcab89bdca1c1 (patch) | |
tree | ca75a763dce4e28e32ea396acb12665f6cf2cfe5 /Lib/test/test_cmd_line_script.py | |
parent | 62f9588663ebfea1735e9d142ef527395a6c2b95 (diff) | |
download | cpython-10654c19b5e6efdf3c529ff9bf7bcab89bdca1c1.zip cpython-10654c19b5e6efdf3c529ff9bf7bcab89bdca1c1.tar.gz cpython-10654c19b5e6efdf3c529ff9bf7bcab89bdca1c1.tar.bz2 |
bpo-20844: open script file with "rb" mode (GH-12616)
Diffstat (limited to 'Lib/test/test_cmd_line_script.py')
-rw-r--r-- | Lib/test/test_cmd_line_script.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py index 85d2a4b..d138ca0 100644 --- a/Lib/test/test_cmd_line_script.py +++ b/Lib/test/test_cmd_line_script.py @@ -409,6 +409,23 @@ class CmdLineTest(unittest.TestCase): 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, \ |