From abc32e47bfed782750edbb617ec543a33c8ecf42 Mon Sep 17 00:00:00 2001 From: Jens Vagelpohl Date: Thu, 3 Oct 2024 12:15:01 +0200 Subject: [PATCH 1/2] - fix segmentation fault and FrameLocalsProxy check --- CHANGES.rst | 3 +++ src/zope/interface/common/tests/test_collections.py | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index e2554aaa..578e796e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,9 @@ 7.0.4 (unreleased) ================== +- Fix segmentation faults on Python 3.13. + (`#323 `_) + 7.0.3 (2024-08-27) ================== diff --git a/src/zope/interface/common/tests/test_collections.py b/src/zope/interface/common/tests/test_collections.py index 6d23f6f9..beb94334 100644 --- a/src/zope/interface/common/tests/test_collections.py +++ b/src/zope/interface/common/tests/test_collections.py @@ -12,6 +12,7 @@ import array +import sys import unittest from collections import OrderedDict from collections import abc @@ -127,6 +128,14 @@ class TestVerifyObject(VerifyObjectMixin, 'async_generator': unittest.SkipTest, type(iter(tuple())): lambda: iter(tuple()), } + if sys.version_info >= (3, 13): + def FrameLocalsProxy_constructor(): + FrameLocalsProxy = type([sys._getframe().f_locals for x in + range(1)][0]) + return FrameLocalsProxy(sys._getframe()) + FrameLocalsProxy = type([sys._getframe().f_locals for x in + range(1)][0]) + CONSTRUCTORS[FrameLocalsProxy] = FrameLocalsProxy_constructor UNVERIFIABLE_RO = { # ``array.array`` fails the ``test_auto_ro_*`` tests with and From 185e0fa91ec377998a8df80e55164b4a05175b33 Mon Sep 17 00:00:00 2001 From: Jens Vagelpohl Date: Fri, 4 Oct 2024 10:08:34 +0200 Subject: [PATCH 2/2] - apply simplification suggestion --- src/zope/interface/common/tests/test_collections.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/zope/interface/common/tests/test_collections.py b/src/zope/interface/common/tests/test_collections.py index beb94334..df7dec99 100644 --- a/src/zope/interface/common/tests/test_collections.py +++ b/src/zope/interface/common/tests/test_collections.py @@ -101,6 +101,10 @@ def test_UserString(self): add_abc_interface_tests(TestVerifyClass, collections.ISet.__module__) +def _get_FrameLocalsProxy(): + return type(sys._getframe().f_locals) + + class TestVerifyObject(VerifyObjectMixin, TestVerifyClass): CONSTRUCTORS = { @@ -130,11 +134,8 @@ class TestVerifyObject(VerifyObjectMixin, } if sys.version_info >= (3, 13): def FrameLocalsProxy_constructor(): - FrameLocalsProxy = type([sys._getframe().f_locals for x in - range(1)][0]) - return FrameLocalsProxy(sys._getframe()) - FrameLocalsProxy = type([sys._getframe().f_locals for x in - range(1)][0]) + return _get_FrameLocalsProxy()(sys._getframe()) + FrameLocalsProxy = _get_FrameLocalsProxy() CONSTRUCTORS[FrameLocalsProxy] = FrameLocalsProxy_constructor UNVERIFIABLE_RO = {