Skip to content

Commit d61186d

Browse files
committed
Require Python 3.4
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 <[email protected]> Approved-by: Kevin Buettner <[email protected]> Acked-By: Tom de Vries <[email protected]> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31870
1 parent 429fb15 commit d61186d

File tree

8 files changed

+11
-27
lines changed

8 files changed

+11
-27
lines changed

gdb/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ info threads [-gid] [-stopped] [-running] [ID]...
124124

125125
* Python API
126126

127+
** GDB no longer supports Python versions less than 3.4.
128+
127129
** New class gdb.Color for dealing with colors.
128130

129131
** New constant gdb.PARAM_COLOR represents color type of a

gdb/README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ more obscure GDB `configure' options are not listed here.
533533
GDB scripting much more powerful than the restricted CLI
534534
scripting language. If your host does not have Python installed,
535535
you can find it on `http://www.python.org/download/'. The oldest
536-
version of Python supported by GDB is 3.2. The optional argument
536+
version of Python supported by GDB is 3.4. The optional argument
537537
PYTHON is used to find the Python headers and libraries. It can
538538
be either the name of a Python executable, or the name of the
539539
directory in which Python is installed.

gdb/configure

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28167,8 +28167,8 @@ int
2816728167
main ()
2816828168
{
2816928169

28170-
#if PY_MAJOR_VERSION != 3
28171-
# error "We only support Python 3"
28170+
#if PY_VERSION_HEX < 0x03040000
28171+
# error "Minimum supported Python version is 3.4"
2817228172
#endif
2817328173
Py_Initialize ();
2817428174

gdb/configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,8 +740,8 @@ AC_DEFUN([AC_TRY_LIBPYTHON],
740740
found_usable_python=no
741741
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include "Python.h"]],
742742
[[
743-
#if PY_MAJOR_VERSION != 3
744-
# error "We only support Python 3"
743+
#if PY_VERSION_HEX < 0x03040000
744+
# error "Minimum supported Python version is 3.4"
745745
#endif
746746
Py_Initialize ();
747747
]])],

gdb/doc/gdb.texinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41466,7 +41466,7 @@ libpython is present and found at configure time.) Python makes
4146641466
@value{GDBN} scripting much more powerful than the restricted CLI
4146741467
scripting language. If your host does not have Python installed, you
4146841468
can find it on @url{http://www.python.org/download/}. The oldest version
41469-
of Python supported by GDB is 3.0.1. The optional argument @var{python}
41469+
of Python supported by GDB is 3.4. The optional argument @var{python}
4147041470
is used to find the Python headers and libraries. It can be either
4147141471
the name of a Python executable, or the name of the directory in which
4147241472
Python is installed.

gdb/python/lib/gdb/__init__.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,7 @@
1919
import threading
2020
import traceback
2121
from contextlib import contextmanager
22-
23-
# Python 3 moved "reload"
24-
if sys.version_info >= (3, 4):
25-
from importlib import reload
26-
else:
27-
from imp import reload
22+
from importlib import reload
2823

2924
import _gdb
3025

gdb/python/py-gdb-readline.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@
2929

3030
static char *
3131
gdbpy_readline_wrapper (FILE *sys_stdin, FILE *sys_stdout,
32-
#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 4
3332
const char *prompt)
34-
#else
35-
char *prompt)
36-
#endif
3733
{
3834
int n;
3935
const char *p = NULL;

gdb/python/python-internal.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@
8888
#include <frameobject.h>
8989
#include "py-ref.h"
9090

91+
static_assert (PY_VERSION_HEX >= 0x03040000);
92+
9193
#define Py_TPFLAGS_CHECKTYPES 0
9294

9395
/* If Python.h does not define WITH_THREAD, then the various
@@ -135,17 +137,6 @@ typedef unsigned long gdb_py_ulongest;
135137

136138
#endif /* HAVE_LONG_LONG */
137139

138-
#if PY_VERSION_HEX < 0x03020000
139-
typedef long Py_hash_t;
140-
#endif
141-
142-
/* PyMem_RawMalloc appeared in Python 3.4. For earlier versions, we can just
143-
fall back to PyMem_Malloc. */
144-
145-
#if PY_VERSION_HEX < 0x03040000
146-
#define PyMem_RawMalloc PyMem_Malloc
147-
#endif
148-
149140
/* A template variable holding the format character (as for
150141
Py_BuildValue) for a given type. */
151142
template<typename T>

0 commit comments

Comments
 (0)