From f5357692e8e22093d7b2b2ac8efd0200eca12c0e Mon Sep 17 00:00:00 2001 From: Shahar Naveh <50263213+ShaharNaveh@users.noreply.github.com> Date: Tue, 12 May 2026 14:52:52 +0300 Subject: [PATCH] Update `test_type_comments.py` to 3.14.5 (#7858) --- Lib/test/test_type_comments.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Lib/test/test_type_comments.py b/Lib/test/test_type_comments.py index 4f41171b2..0deb25f16 100644 --- a/Lib/test/test_type_comments.py +++ b/Lib/test/test_type_comments.py @@ -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", "", 256, flags) + with self.assertRaises(UnicodeDecodeError): + _testcapi.Py_CompileStringExFlags( + b"def a(f=8, #type: \x80\n\x80", "", 256, flags) + @unittest.expectedFailure # TODO: RUSTPYTHON; ValueError: mode must be "exec", "eval", "ipython", or "single" def test_func_type_input(self):