File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -1511,6 +1511,20 @@ def test_nonascii_coding(self):
15111511 with self .assertRaises (SyntaxError ):
15121512 tokenize .detect_encoding (readline )
15131513
1514+ def test_nonascii (self ):
1515+ # gh-63161: test non-ASCII header with no coding marker
1516+ lines = ["# nonascii line 1 €" .encode ('utf8' ),
1517+ '# nonascii line 2 €' .encode ('utf8' )]
1518+ readline = self .get_readline (lines )
1519+ found , consumed_lines = tokenize .detect_encoding (readline )
1520+ self .assertEqual (found , "utf-8" )
1521+
1522+ lines = ["# nonascii line 1 €" .encode ('iso8859-15' ),
1523+ '# nonascii line 2 €' .encode ('iso8859-15' )]
1524+ readline = self .get_readline (lines )
1525+ with self .assertRaises (SyntaxError ):
1526+ tokenize .detect_encoding (readline )
1527+
15141528 def test_utf8_normalization (self ):
15151529 # See get_normal_name() in Parser/tokenizer/helpers.c.
15161530 encodings = ("utf-8" , "utf-8-mac" , "utf-8-unix" )
You can’t perform that action at this time.
0 commit comments