From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id wHmaIfKfOGg6kDkAWB0awg (envelope-from ) for ; Thu, 29 May 2025 13:57:06 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=VhiYsY7E; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 748FE1E11C; Thu, 29 May 2025 13:57:06 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-9.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 5CDD41E100 for ; Thu, 29 May 2025 13:57:05 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D7A653857B94 for ; Thu, 29 May 2025 17:57:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D7A653857B94 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=VhiYsY7E Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by sourceware.org (Postfix) with ESMTPS id 9DB983858C54 for ; Thu, 29 May 2025 17:56:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9DB983858C54 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9DB983858C54 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::136 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1748541374; cv=none; b=PMd6fpbENFNrXtVvEkO6nLN8SAGu8H6seqyPrzl3CauG3tVuCRkFmjHzZNynJ9ZArS+gaclVzDM7bAswlw6v0HRfMUpEOLzRzGq0qRPPCXFU0LnsH+cpZOGio5RYFshAXF170CeQGmy5SK7Ab/l7itqPolEAujz8C/nmyqCk0JA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1748541374; c=relaxed/simple; bh=p97q0EFQXPzDTAtbC2jsnmpaVPcy+4CuHuwsXCj2WbQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=GE9PXzCh0N+1R/e72Qrrf/xgF5pUE0QGdZdFom5cGSB9M5dLN4h2xaJJs4ce6QTArG/Tfis8ed0zBjL8M9fH92DeqyKTDVAgBK3QcGWN15PMK42RnBA3sMd98P9IAH0krXCrvbpx+igG56bcQabWNlLBAxMfuWdqOAc6xW/LBWU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9DB983858C54 Received: by mail-il1-x136.google.com with SMTP id e9e14a558f8ab-3d817bc6eb0so5895475ab.1 for ; Thu, 29 May 2025 10:56:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1748541374; x=1749146174; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=J8MnfNPHC9F3fExk8Mcy2EUMJCMpY7K31VBkQsomIWE=; b=VhiYsY7EeDOBDwe/f3G+nFVJ4Jber56sSau4PmLnU5H8AxdA4WwRv8wa7TzezH/+8v GfADH6cDanWf9mVbMtE0h1lrEbUvMHM1qzdBRbd7QOvO3ngpoDhvKsdOsnV0pTebSioY U0lnenrP5O2aDuGGWLZGOOiHbTLTdlh4LpTDF60cyGkQUfAPiQmRwpYzQbNjAI4lgmie iITFuwHSYDpwMwft5g0Ll6Ep8tPTGS4QWz3jNhfRLVotZoeMS/vvTg3Sz7o/qzzLmcFO +V6rdz/FNvpyky/bxeu9p6sDPU69+d91YP5EL3da0a5XSerZO5FCK+3EDDbzm0DZMCGl egEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748541374; x=1749146174; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=J8MnfNPHC9F3fExk8Mcy2EUMJCMpY7K31VBkQsomIWE=; b=wMIlun8GzMWsR1alzNDuoYW4PbTPw9O5J8Xuc+mY9oCG/wBlHbTfjR+QB7efHZGSY+ knYm/8Lfe0pTvhMaTGs94jan90bi1VFe+QG051LsUsNVqGFx3Gl4CxCx7lsV5o1d86VW cYgxnF9RAOcds/5QZWVmoGIvp2tVpUXo8XI4aTq+FRLOywFRZEZNAnlG3O9KdYapQmRo K22m4y3xJEtHP3DwUdXL6fmbopy/u9jDHM7opzADvYPzuJ0zINtRERIKFms4yMragEur 5FPJcRI4uWdeY3wVUaefF0HpW85kTklYTnOxlchE1LNH9/Qd311SGNbeAK2v9wKGz2dh e5Og== X-Gm-Message-State: AOJu0YxuExeCOvSo9i+SIBeswQO4zj2Jao6RIvuxuDO7VlD7ojO/EmtL CYuaYxBeItmFjAMKzyLBCbTtIxW0WHtwQSN96fIDPHwPSLavVw7YxJPLGqDEeLrxFMVAu6tpMTR vwKQ= X-Gm-Gg: ASbGnctRyPtAVaMmG8v9s7kbhO23Osjc6iJ0hZanP5nSCfIGSaYcTUP0TEVLkNxbUnz lDxePC5dCxwhKv6J3zj1l2hFNqTT4Pi3S9RhY0xz3EmrXx9T/0AfOxmvXw0T35hP81WJJcSpG4N R7PW8iq0CrProaJcIlFkf85LR8M6K9PLQEaUT6B4kYOrs49l3mVfMZAafUUFLiUTLmlUhllAewZ yfzQuTG6f/AKBfPDCDklck42+yygSWUcQqE48p98IMFA9XdLPja49qs+zY45ZxYdMnyTfAbicCv PVO67Tz8XyjwW5o/gcJ5rV6oqO+Oy44rJxMuls0YaiZZzkVxLgGzE6S2VLws69G7VZoO2oLkTW6 iDy0dsjyve6leY04= X-Google-Smtp-Source: AGHT+IF9b1D2kXpayKwZLXsoUk1iJOzTigh8Gr37hNKUaeG7vdEJHP/RYmbXsMYRIz81f3zblqpllg== X-Received: by 2002:a05:6e02:1b01:b0:3dc:7c5d:6372 with SMTP id e9e14a558f8ab-3dd99be4ea5mr9457635ab.7.1748541373636; Thu, 29 May 2025 10:56:13 -0700 (PDT) Received: from localhost.localdomain (97-118-46-156.hlrn.qwest.net. [97.118.46.156]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3dd9359dca8sm4142945ab.48.2025.05.29.10.56.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 May 2025 10:56:13 -0700 (PDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey , Eli Zaretskii , Kevin Buettner , Tom de Vries Subject: [PATCH v2] Require Python 3.4 Date: Thu, 29 May 2025 11:55:52 -0600 Message-ID: <20250529175552.1312658-1-tromey@adacore.com> X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org I believe we previously agreed that the minimum supported Python version should be 3.4. This patch makes this change, harmonizing the documentation (which was inconsistent about the minimum version) and the code. New in v2: rebased, and removed a pre-3.4 workaround from __init__.py. Reviewed-By: Eli Zaretskii Approved-by: Kevin Buettner Acked-By: Tom de Vries Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31870 --- gdb/NEWS | 2 ++ gdb/README | 2 +- gdb/configure | 4 ++-- gdb/configure.ac | 4 ++-- gdb/doc/gdb.texinfo | 2 +- gdb/python/lib/gdb/__init__.py | 7 +------ gdb/python/py-gdb-readline.c | 4 ---- gdb/python/python-internal.h | 13 ++----------- 8 files changed, 11 insertions(+), 27 deletions(-) diff --git a/gdb/NEWS b/gdb/NEWS index 2e48a00df5a..970a527a64c 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -124,6 +124,8 @@ info threads [-gid] [-stopped] [-running] [ID]... * Python API + ** GDB no longer supports Python versions less than 3.4. + ** New class gdb.Color for dealing with colors. ** New constant gdb.PARAM_COLOR represents color type of a diff --git a/gdb/README b/gdb/README index 5a0030511d6..3c42936b679 100644 --- a/gdb/README +++ b/gdb/README @@ -533,7 +533,7 @@ more obscure GDB `configure' options are not listed here. GDB scripting much more powerful than the restricted CLI scripting language. If your host does not have Python installed, you can find it on `http://www.python.org/download/'. The oldest - version of Python supported by GDB is 3.2. The optional argument + version of Python supported by GDB is 3.4. The optional argument PYTHON is used to find the Python headers and libraries. It can be either the name of a Python executable, or the name of the directory in which Python is installed. diff --git a/gdb/configure b/gdb/configure index 683fcaef9fe..b34f66679e8 100755 --- a/gdb/configure +++ b/gdb/configure @@ -28167,8 +28167,8 @@ int main () { - #if PY_MAJOR_VERSION != 3 - # error "We only support Python 3" + #if PY_VERSION_HEX < 0x03040000 + # error "Minimum supported Python version is 3.4" #endif Py_Initialize (); diff --git a/gdb/configure.ac b/gdb/configure.ac index 052d0319a04..9529e850154 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -740,8 +740,8 @@ AC_DEFUN([AC_TRY_LIBPYTHON], found_usable_python=no AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include "Python.h"]], [[ - #if PY_MAJOR_VERSION != 3 - # error "We only support Python 3" + #if PY_VERSION_HEX < 0x03040000 + # error "Minimum supported Python version is 3.4" #endif Py_Initialize (); ]])], diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 05f550233fe..267647108dd 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -41466,7 +41466,7 @@ libpython is present and found at configure time.) Python makes @value{GDBN} scripting much more powerful than the restricted CLI scripting language. If your host does not have Python installed, you can find it on @url{http://www.python.org/download/}. The oldest version -of Python supported by GDB is 3.0.1. The optional argument @var{python} +of Python supported by GDB is 3.4. The optional argument @var{python} is used to find the Python headers and libraries. It can be either the name of a Python executable, or the name of the directory in which Python is installed. diff --git a/gdb/python/lib/gdb/__init__.py b/gdb/python/lib/gdb/__init__.py index 69c15b16d87..03eb426b662 100644 --- a/gdb/python/lib/gdb/__init__.py +++ b/gdb/python/lib/gdb/__init__.py @@ -19,12 +19,7 @@ import sys import threading import traceback from contextlib import contextmanager - -# Python 3 moved "reload" -if sys.version_info >= (3, 4): - from importlib import reload -else: - from imp import reload +from importlib import reload import _gdb diff --git a/gdb/python/py-gdb-readline.c b/gdb/python/py-gdb-readline.c index ea3a3850312..70ceebb36a1 100644 --- a/gdb/python/py-gdb-readline.c +++ b/gdb/python/py-gdb-readline.c @@ -29,11 +29,7 @@ static char * gdbpy_readline_wrapper (FILE *sys_stdin, FILE *sys_stdout, -#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 4 const char *prompt) -#else - char *prompt) -#endif { int n; const char *p = NULL; diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index 5262d767529..bdccb265441 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -88,6 +88,8 @@ #include #include "py-ref.h" +static_assert (PY_VERSION_HEX >= 0x03040000); + #define Py_TPFLAGS_CHECKTYPES 0 /* If Python.h does not define WITH_THREAD, then the various @@ -135,17 +137,6 @@ typedef unsigned long gdb_py_ulongest; #endif /* HAVE_LONG_LONG */ -#if PY_VERSION_HEX < 0x03020000 -typedef long Py_hash_t; -#endif - -/* PyMem_RawMalloc appeared in Python 3.4. For earlier versions, we can just - fall back to PyMem_Malloc. */ - -#if PY_VERSION_HEX < 0x03040000 -#define PyMem_RawMalloc PyMem_Malloc -#endif - /* A template variable holding the format character (as for Py_BuildValue) for a given type. */ template base-commit: 2490dbf4e484616e6aecf3c57efcd17a819fae5b -- 2.49.0