From f4dba7ae78b3af21fc01f245ac983f280802c0c1 Mon Sep 17 00:00:00 2001 From: neonene <53406459+neonene@users.noreply.github.com> Date: Sat, 3 Aug 2024 02:58:56 +0900 Subject: [PATCH 1/3] Update test_embed.py --- Lib/test/test_embed.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py index ab112d6be85b46..f2f7ef265d1d5d 100644 --- a/Lib/test/test_embed.py +++ b/Lib/test/test_embed.py @@ -465,8 +465,11 @@ def test_getargs_reset_static_parser(self): # Test _PyArg_Parser initializations via _PyArg_UnpackKeywords() # https://github.com/python/cpython/issues/122334 code = textwrap.dedent(""" - import _ssl - _ssl.txt2obj(txt='1.3') + try: + import _ssl + _ssl.txt2obj(txt='1.3') + except ModuleNotFoundError: + pass print('1') import _queue From c4ea58a76bbb6588a78c6b8a2443b2bd87d65e7a Mon Sep 17 00:00:00 2001 From: neonene <53406459+neonene@users.noreply.github.com> Date: Sat, 3 Aug 2024 19:07:37 +0900 Subject: [PATCH 2/3] apply suggested change Co-authored-by: Wulian233 <1055917385@qq.com> --- Lib/test/test_embed.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py index f2f7ef265d1d5d..f025d16e757e93 100644 --- a/Lib/test/test_embed.py +++ b/Lib/test/test_embed.py @@ -467,9 +467,9 @@ def test_getargs_reset_static_parser(self): code = textwrap.dedent(""" try: import _ssl - _ssl.txt2obj(txt='1.3') except ModuleNotFoundError: - pass + _ssl = None + _ssl.txt2obj(txt='1.3') print('1') import _queue From 54073278b6229f856a2d5135c851dd8c0825e0bc Mon Sep 17 00:00:00 2001 From: neonene <53406459+neonene@users.noreply.github.com> Date: Sat, 3 Aug 2024 19:08:21 +0900 Subject: [PATCH 3/3] Add None check --- Lib/test/test_embed.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py index f025d16e757e93..916a9a79887dfc 100644 --- a/Lib/test/test_embed.py +++ b/Lib/test/test_embed.py @@ -469,7 +469,8 @@ def test_getargs_reset_static_parser(self): import _ssl except ModuleNotFoundError: _ssl = None - _ssl.txt2obj(txt='1.3') + if _ssl is not None: + _ssl.txt2obj(txt='1.3') print('1') import _queue