From 02a0eb05081dedb56cacac33769309940b568372 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sun, 11 Dec 2022 23:26:46 +0200 Subject: [PATCH 1/2] Use PY_VERSION_HEX for version comparison `PY_VERSION_HEX` should be used when comparing version numbers, for example `PY_VERSION_HEX >= 0x03080000`. Avoid `PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 8` because that is true for 3.8-3.12, but also for 4.8-4.12 and so on. Hoist the comment from `PY_VERSION_HEX`'s definition in `patchlevel.h` to docs in `apiabiversion.rst`. --- Doc/c-api/apiabiversion.rst | 2 ++ Doc/whatsnew/3.11.rst | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Doc/c-api/apiabiversion.rst b/Doc/c-api/apiabiversion.rst index 85b6e2f373877f..8e77aee6f4e59c 100644 --- a/Doc/c-api/apiabiversion.rst +++ b/Doc/c-api/apiabiversion.rst @@ -58,6 +58,8 @@ See :ref:`stable` for a discussion of API and ABI stability across versions. Thus ``3.4.1a2`` is hexversion ``0x030401a2`` and ``3.10.0`` is hexversion ``0x030a00f0``. + Use this for numeric comparisons, e.g. ``#if PY_VERSION_HEX >= ...`` + This version is also available via the symbol :data:`Py_Version`. .. c:var:: const unsigned long Py_Version diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index 7931988ed0b04d..6f283f1d800202 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -2319,7 +2319,7 @@ Porting to Python 3.11 can define the following macros and use them throughout the code (credit: these were copied from the ``mypy`` codebase):: - #if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 8 + #if PY_VERSION_HEX >= 0x03080000 # define CPy_TRASHCAN_BEGIN(op, dealloc) Py_TRASHCAN_BEGIN(op, dealloc) # define CPy_TRASHCAN_END(op) Py_TRASHCAN_END #else From 52763bb7d14aa978cc2c9df4cf00b3c759066c18 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Mon, 12 Dec 2022 07:16:19 +0200 Subject: [PATCH 2/2] Add full stop Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com> --- Doc/c-api/apiabiversion.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/c-api/apiabiversion.rst b/Doc/c-api/apiabiversion.rst index 8e77aee6f4e59c..62d542966622ce 100644 --- a/Doc/c-api/apiabiversion.rst +++ b/Doc/c-api/apiabiversion.rst @@ -58,7 +58,7 @@ See :ref:`stable` for a discussion of API and ABI stability across versions. Thus ``3.4.1a2`` is hexversion ``0x030401a2`` and ``3.10.0`` is hexversion ``0x030a00f0``. - Use this for numeric comparisons, e.g. ``#if PY_VERSION_HEX >= ...`` + Use this for numeric comparisons, e.g. ``#if PY_VERSION_HEX >= ...``. This version is also available via the symbol :data:`Py_Version`. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy