diff options
Diffstat (limited to 'Lib/test/test_opcache.py')
-rw-r--r-- | Lib/test/test_opcache.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_opcache.py b/Lib/test/test_opcache.py index ac13246..21d7e62 100644 --- a/Lib/test/test_opcache.py +++ b/Lib/test/test_opcache.py @@ -16,6 +16,16 @@ if check_impl_detail(cpython=False): _testinternalcapi = import_module("_testinternalcapi") +def have_dict_key_versions(): + # max version value that can be stored in the load global cache. This is + # determined by the type of module_keys_version and builtin_keys_version + # in _PyLoadGlobalCache, uint16_t. + max_version = 1<<16 + # use a wide safety margin (use only half of what's available) + limit = max_version // 2 + return _testinternalcapi.get_next_dict_keys_version() < limit + + class TestBase(unittest.TestCase): def assert_specialized(self, f, opname): instructions = dis.get_instructions(f, adaptive=True) @@ -1029,6 +1039,8 @@ class TestRacesDoNotCrash(TestBase): @requires_specialization_ft def test_load_global_module(self): + if not have_dict_key_versions(): + raise unittest.SkipTest("Low on dict key versions") def get_items(): items = [] for _ in range(self.ITEMS): |