From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 036673857C62 for ; Fri, 7 Jan 2022 15:29:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 036673857C62 X-ASG-Debug-ID: 1641569363-0c856e06ab13fd0001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id mZYnHTUC3KPM8i6L (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 07 Jan 2022 10:29:24 -0500 (EST) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.localdomain (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) by smtp.ebox.ca (Postfix) with ESMTP id DED2C441D64; Fri, 7 Jan 2022 10:29:23 -0500 (EST) From: Simon Marchi X-Barracuda-RBL-IP: 192.222.157.6 X-Barracuda-Effective-Source-IP: 192-222-157-6.qc.cable.ebox.net[192.222.157.6] X-Barracuda-Apparent-Source-IP: 192.222.157.6 To: gdb-patches@sourceware.org Subject: [PATCH 3/3] gdb/python: drop support for Python < 3.4 Date: Fri, 7 Jan 2022 10:29:21 -0500 X-ASG-Orig-Subj: [PATCH 3/3] gdb/python: drop support for Python < 3.4 Message-Id: <20220107152921.2858909-3-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220107152921.2858909-1-simon.marchi@polymtl.ca> References: <20220107152921.2858909-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1641569364 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 4090 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.50 X-Barracuda-Spam-Status: No, SCORE=0.50 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests=BSF_RULE_7582B X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.95167 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.50 BSF_RULE_7582B Custom Rule 7582B X-Spam-Status: No, score=-15.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_QUARANTINE, KAM_DMARC_STATUS, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Jan 2022 15:29:37 -0000 Python 3 versions <= 3.3 are quite old and not likely to be used nowadays. Dropping support for them allows us to remove some hacks and compatibility macros that depend on the Python version being < 3.4. Change the documentation to state the Python 3 versions we support. We could go even further and document that we only support versions 3.5 or 3.6 and up, for example, but that wouldn't change the code. So we might as well document the older Python 3 version we can support without special hacks. [1] https://www.python.org/dev/peps/pep-0478/ [2] https://www.python.org/dev/peps/pep-0494/ Change-Id: I608610dced678c93e2bd338a91662d1c706df511 --- gdb/doc/python.texi | 2 +- gdb/python/lib/gdb/__init__.py | 8 +------- gdb/python/py-gdb-readline.c | 7 +------ gdb/python/python-internal.h | 11 ----------- gdb/testsuite/gdb.perf/lib/perftest/measure.py | 6 ------ 5 files changed, 3 insertions(+), 31 deletions(-) diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi index 6e89aae02bd3..889888c4a459 100644 --- a/gdb/doc/python.texi +++ b/gdb/doc/python.texi @@ -18,7 +18,7 @@ You can extend @value{GDBN} using the @uref{http://www.python.org/, Python programming language}. This feature is available only if @value{GDBN} was configured using @option{--with-python}. -@value{GDBN} can be built against Python 3. +@value{GDBN} can be built against Python 3, versions 3.4 and above. @cindex python directory Python scripts used by @value{GDBN} should be installed in diff --git a/gdb/python/lib/gdb/__init__.py b/gdb/python/lib/gdb/__init__.py index 0c04a72f7819..4c939da6d400 100644 --- a/gdb/python/lib/gdb/__init__.py +++ b/gdb/python/lib/gdb/__init__.py @@ -17,13 +17,7 @@ import traceback import os import sys import _gdb - -# Python 3 moved "reload" -if sys.version_info >= (3, 4): - from importlib import reload -else: - from imp import reload - +from importlib import reload from _gdb import * diff --git a/gdb/python/py-gdb-readline.c b/gdb/python/py-gdb-readline.c index af388d5ed72e..ee243d15412a 100644 --- a/gdb/python/py-gdb-readline.c +++ b/gdb/python/py-gdb-readline.c @@ -29,12 +29,7 @@ command_line_input is used instead. */ 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 +gdbpy_readline_wrapper (FILE *sys_stdin, FILE *sys_stdout, const char *prompt) { int n; const char *p = NULL; diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index b38d69258add..1137b1da56fe 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -121,17 +121,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 - /* PyObject_CallMethod's 'method' and 'format' parameters were missing the 'const' qualifier before Python 3.4. Hence, we wrap the function in our own version to avoid errors with string literals. diff --git a/gdb/testsuite/gdb.perf/lib/perftest/measure.py b/gdb/testsuite/gdb.perf/lib/perftest/measure.py index 88fd6c87e52f..514687d0ec69 100644 --- a/gdb/testsuite/gdb.perf/lib/perftest/measure.py +++ b/gdb/testsuite/gdb.perf/lib/perftest/measure.py @@ -18,12 +18,6 @@ import os import gc import sys -# time.perf_counter() and time.process_time() were added in Python -# 3.3, time.clock() was removed in Python 3.8. -if sys.version_info < (3, 3, 0): - time.perf_counter = time.clock - time.process_time = time.clock - class Measure(object): """A class that measure and collect the interesting data for a given testcase. -- 2.34.1