From 10cf7d6d00ad90867634114a894eb7e9f35df867 Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Mon, 29 Jul 2024 10:25:02 -0600 Subject: [PATCH] [3.13] gh-117482: Fix the Slot Wrapper Inheritance Tests (gh-122249) The tests were only checking cases where the slot wrapper was present in the initial case. They were missing when the slot wrapper was added in the additional initializations. This fixes that. (cherry-picked from commit 490e0ad83ac72c5688dfbbab4eac61ccfd7be5fd, AKA gh-122248) --- Lib/test/support/__init__.py | 55 ++++++++++++++++++++++++++++++++++++ Lib/test/test_embed.py | 52 +++++++++++++++++++++++----------- Lib/test/test_types.py | 38 ++++++++----------------- Objects/typeobject.c | 23 ++++++++++++--- Programs/_testembed.c | 14 +++++++-- 5 files changed, 131 insertions(+), 51 deletions(-) diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 03950bf63bf..a6fe8f5f2b2 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -2589,6 +2589,61 @@ def copy_python_src_ignore(path, names): return ignored +def iter_builtin_types(): + for obj in __builtins__.values(): + if not isinstance(obj, type): + continue + cls = obj + if cls.__module__ != 'builtins': + continue + yield cls + + +def iter_slot_wrappers(cls): + assert cls.__module__ == 'builtins', cls + + def is_slot_wrapper(name, value): + if not isinstance(value, types.WrapperDescriptorType): + assert not repr(value).startswith(' 3 + ? main_argc - 2 + : INIT_LOOPS; - for (int i=1; i <= INIT_LOOPS; i++) { - fprintf(stderr, "--- Loop #%d ---\n", i); + for (int i=0; i < loops; i++) { + fprintf(stderr, "--- Loop #%d ---\n", i+1); fflush(stderr); + if (main_argc > 3) { + code = main_argv[i+2]; + } + _testembed_Py_InitializeFromConfig(); int err = PyRun_SimpleString(code); Py_Finalize();