From b4b4fcd72cf3a9b2f71f08d2a015b87222807e0e Mon Sep 17 00:00:00 2001 From: Michael Howitz Date: Thu, 28 Nov 2024 08:54:31 +0100 Subject: [PATCH] Rework version dependent code + add change log. --- CHANGES.rst | 6 +++++- src/zope/interface/_compat.py | 2 +- src/zope/interface/common/builtins.py | 4 ++-- src/zope/interface/common/collections.py | 4 ++-- src/zope/interface/common/tests/test_builtins.py | 4 ++-- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 5a680c26..46595a81 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,7 +5,11 @@ 7.1.2 (unreleased) ================== -- Add preliminary support for Python 3.14a2. +- Add preliminary support for Python 3.14a2, this means that + ``.common.builtins.IByteString`` and ``.common.collections.IByteString`` are + no longer available from this version onwards as Python 3.14 dropped + ``collections.abc.ByteString``. + 7.1.1 (2024-10-23) ================== diff --git a/src/zope/interface/_compat.py b/src/zope/interface/_compat.py index fb147e15..38032953 100644 --- a/src/zope/interface/_compat.py +++ b/src/zope/interface/_compat.py @@ -22,7 +22,7 @@ import sys -PY314_OR_GREATER = sys.version_info >= (3, 14) +PY313_OR_OLDER = sys.version_info < (3, 14) def _normalize_name(name): diff --git a/src/zope/interface/common/builtins.py b/src/zope/interface/common/builtins.py index bb473de2..9e543c83 100644 --- a/src/zope/interface/common/builtins.py +++ b/src/zope/interface/common/builtins.py @@ -19,7 +19,7 @@ """ from zope.interface import classImplements -from zope.interface._compat import PY314_OR_GREATER +from zope.interface._compat import PY313_OR_OLDER from zope.interface.common import collections from zope.interface.common import io from zope.interface.common import numbers @@ -68,7 +68,7 @@ class ITextString(collections.ISequence): extra_classes = (str,) -if not PY314_OR_GREATER: +if PY313_OR_OLDER: class IByteString(collections.IByteString): """ Interface for immutable byte strings. diff --git a/src/zope/interface/common/collections.py b/src/zope/interface/common/collections.py index 25ab31d1..defa8a15 100644 --- a/src/zope/interface/common/collections.py +++ b/src/zope/interface/common/collections.py @@ -38,7 +38,7 @@ from collections import UserString from collections import abc -from zope.interface._compat import PY314_OR_GREATER +from zope.interface._compat import PY313_OR_OLDER from zope.interface.common import ABCInterface from zope.interface.common import optional @@ -191,7 +191,7 @@ class IMutableSequence(ISequence): extra_classes = (UserList,) -if not PY314_OR_GREATER: +if PY313_OR_OLDER: class IByteString(ISequence): """ This unifies `bytes` and `bytearray`. diff --git a/src/zope/interface/common/tests/test_builtins.py b/src/zope/interface/common/tests/test_builtins.py index 3397839b..3c764392 100644 --- a/src/zope/interface/common/tests/test_builtins.py +++ b/src/zope/interface/common/tests/test_builtins.py @@ -12,7 +12,7 @@ import unittest -from zope.interface._compat import PY314_OR_GREATER +from zope.interface._compat import PY313_OR_OLDER from zope.interface.common import builtins from . import VerifyClassMixin @@ -35,7 +35,7 @@ class TestVerifyClass(VerifyClassMixin, (builtins.IFile, ()), ] -if not PY314_OR_GREATER: +if PY313_OR_OLDER: VERIFY_TESTS.append( (builtins.IByteString, (bytes,)) )