Update test_type_comments.py to 3.14.5 (#7858)

This commit is contained in:
Shahar Naveh authored and GitHub committed 2026-05-12 20:52:52 +09:00
1 parent e0689bad7c
commit f5357692e8
1 file changed
+11
+11
View File
@@ -1,6 +1,7 @@
import ast
import sys
import unittest
from test.support import import_helper
funcdef = """\
@@ -405,6 +406,16 @@ class TypeCommentTests(unittest.TestCase):
check_both_ways("pass # type: ignorewhatever\n")
check_both_ways("pass # type: ignoreé\n")
def test_non_utf8_type_comment_with_ignore_cookie(self):
_testcapi = import_helper.import_module('_testcapi')
flags = 0x0800 | 0x1000 # PyCF_IGNORE_COOKIE | PyCF_TYPE_COMMENTS
with self.assertRaises(UnicodeDecodeError):
_testcapi.Py_CompileStringExFlags(
b"a=1 # type: \x80", "<test>", 256, flags)
with self.assertRaises(UnicodeDecodeError):
_testcapi.Py_CompileStringExFlags(
b"def a(f=8, #type: \x80\n\x80", "<test>", 256, flags)
@unittest.expectedFailure # TODO: RUSTPYTHON; ValueError: mode must be "exec", "eval", "ipython", or "single"
def test_func_type_input(self):