From: Simon Marchi <simon.marchi@polymtl.ca>
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 [thread overview]
Message-ID: <20220107152921.2858909-3-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20220107152921.2858909-1-simon.marchi@polymtl.ca>
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
next prev parent reply other threads:[~2022-01-07 15:29 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-07 15:29 [PATCH 1/3] gdb/python: remove Python 2 support Simon Marchi
2022-01-07 15:29 ` [PATCH 2/3] gdb/python: remove Python 2/3 compatibility macros Simon Marchi
2022-01-07 15:29 ` Simon Marchi [this message]
2022-01-07 16:33 ` [PATCH 3/3] gdb/python: drop support for Python < 3.4 Eli Zaretskii
2022-01-07 17:14 ` Simon Marchi
2022-01-07 15:33 ` [PATCH 1/3] gdb/python: remove Python 2 support Paul Koning
2022-01-07 15:41 ` Simon Marchi
2022-01-07 17:44 ` Andrew Burgess
2022-01-08 8:18 ` Joel Brobecker
2022-01-10 2:28 ` Simon Marchi
2022-01-10 2:59 ` Joel Brobecker
2022-01-10 16:39 ` Simon Marchi
2022-01-11 3:26 ` Joel Brobecker
2022-01-10 16:26 ` Tom Tromey
2022-03-03 16:31 ` Andrew Burgess
2022-03-03 17:40 ` Simon Marchi
2022-03-21 14:46 ` [PATCH v2 0/2] Remove " Simon Marchi
2022-03-21 14:46 ` [PATCH v2 1/2] gdb/python: remove " Simon Marchi
2022-03-21 14:50 ` Simon Marchi
2022-03-21 14:58 ` Eli Zaretskii
2022-03-21 15:04 ` Simon Marchi
2022-03-21 15:33 ` Pedro Alves
2022-03-21 16:31 ` Simon Marchi
2022-03-21 16:55 ` Pedro Alves
2022-03-21 17:04 ` Simon Marchi
2022-03-21 14:46 ` [PATCH v2 2/2] gdb/python: remove Python 2/3 compatibility macros Simon Marchi
2022-03-23 11:46 ` [PATCH v2 0/2] Remove Python 2 support Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220107152921.2858909-3-simon.marchi@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).