diff mbox

Remove Python 2.4 and 2.5 support

Message ID 20190226195345.8775-1-tromey@adacore.com
State New
Headers show

Commit Message

Tom Tromey Feb. 26, 2019, 7:53 p.m. UTC
This removes all the remainings spots I could find that work around
issues in Python 2.4 and 2.5.

I don't have a good way to test that Python 2.6 still works.

Tested by the buildbot.

gdb/ChangeLog
2019-02-26  Tom Tromey  <tromey@adacore.com>

	* configure.ac (HAVE_LIBPYTHON2_4, HAVE_LIBPYTHON2_5): Never
	define.
	* python/py-value.c: Remove Python 2.4 workaround.
	* python/py-utils.c (gdb_pymodule_addobject): Remove Python 2.4
	workaround.
	* python/py-type.c (convert_field, gdbpy_initialize_types): Remove
	Python 2.4 workaround.
	* python/python-internal.h: Remove Python 2.4 comment.
	(Py_ssize_t): Don't define.
	(PyVarObject_HEAD_INIT, Py_TYPE): Don't define.
	(gdb_Py_DECREF): Remove Python 2.4 workaround.
	(gdb_PyObject_GetAttrString, PyObject_GetAttrString): Remove.
	(gdb_PyObject_HasAttrString, PyObject_HasAttrString): Remove.
	* python/python.c (do_start_initialization): Remove Python 2.4
	workaround.
	* python/py-prettyprint.c (class dummy_python_frame): Remove.
	(print_children): Remove Python 2.4 workaround.
	* python/py-inferior.c (buffer_procs): Remove Python 2.4
	workaround.
	(CHARBUFFERPROC_NAME): Remove.
	* python/py-breakpoint.c (gdbpy_initialize_breakpoints): Remove
	Python 2.4 workaround.

gdb/testsuite/ChangeLog
2019-02-26  Tom Tromey  <tromey@adacore.com>

	* lib/gdb.exp (skip_python_tests_prompt): Don't check for Python
	2.4.
	* gdb.python/py-finish-breakpoint.exp: Remove Python 2.4
	workaround.
---
 gdb/ChangeLog                                 | 25 +++++
 gdb/config.in                                 |  6 --
 gdb/configure                                 | 88 +----------------
 gdb/configure.ac                              | 16 +---
 gdb/python/py-breakpoint.c                    |  8 +-
 gdb/python/py-inferior.c                      | 11 +--
 gdb/python/py-prettyprint.c                   | 94 -------------------
 gdb/python/py-type.c                          |  8 +-
 gdb/python/py-utils.c                         |  3 +-
 gdb/python/py-value.c                         |  3 -
 gdb/python/python-internal.h                  | 53 +----------
 gdb/python/python.c                           |  8 +-
 gdb/testsuite/ChangeLog                       |  7 ++
 .../gdb.python/py-finish-breakpoint.exp       |  7 --
 gdb/testsuite/lib/gdb.exp                     | 12 ---
 15 files changed, 46 insertions(+), 303 deletions(-)

Comments

Kevin Buettner Feb. 26, 2019, 9:48 p.m. UTC | #1
On Tue, 26 Feb 2019 12:53:45 -0700
Tom Tromey <tromey@adacore.com> wrote:

> This removes all the remainings spots I could find that work around
> issues in Python 2.4 and 2.5.

LGTM.
 
> I don't have a good way to test that Python 2.6 still works.

I don't either.  Eli said that he regularly builds and tests using
2.6 though.

Kevin
Tom Tromey Feb. 26, 2019, 10:04 p.m. UTC | #2
>>>>> "Kevin" == Kevin Buettner <kevinb@redhat.com> writes:

Tom> I don't have a good way to test that Python 2.6 still works.

Kevin> I don't either.  Eli said that he regularly builds and tests using
Kevin> 2.6 though.

I won't be putting this in until after the 8.3 branch is made anyway --
it's hardly critical.  So, if there are problems, we'll have plenty of
time to correct them.

Tom
Eli Zaretskii Feb. 27, 2019, 3:33 a.m. UTC | #3
> Date: Tue, 26 Feb 2019 14:48:01 -0700
> From: Kevin Buettner <kevinb@redhat.com>
> 
> > I don't have a good way to test that Python 2.6 still works.
> 
> I don't either.  Eli said that he regularly builds and tests using
> 2.6 though.

Yes.  Once the pretest is out, I will build it, and will see any
problems then.
Tom Tromey Feb. 27, 2019, 6:41 p.m. UTC | #4
>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:

>>>>> "Kevin" == Kevin Buettner <kevinb@redhat.com> writes:
Tom> I don't have a good way to test that Python 2.6 still works.

Kevin> I don't either.  Eli said that he regularly builds and tests using
Kevin> 2.6 though.

Tom> I won't be putting this in until after the 8.3 branch is made anyway --
Tom> it's hardly critical.  So, if there are problems, we'll have plenty of
Tom> time to correct them.

I'm going to check this in now.

Tom
Pedro Alves Feb. 27, 2019, 7:08 p.m. UTC | #5
On 02/26/2019 07:53 PM, Tom Tromey wrote:
> This removes all the remainings spots I could find that work around
> issues in Python 2.4 and 2.5.
> 
> I don't have a good way to test that Python 2.6 still works.
> 
> Tested by the buildbot.

Great, thanks for doing this.

Pedro Alves
Eli Zaretskii Feb. 28, 2019, 6:14 p.m. UTC | #6
> From: Pedro Alves <palves@redhat.com>
> Date: Wed, 27 Feb 2019 19:08:52 +0000
> 
> On 02/26/2019 07:53 PM, Tom Tromey wrote:
> > This removes all the remainings spots I could find that work around
> > issues in Python 2.4 and 2.5.
> > 
> > I don't have a good way to test that Python 2.6 still works.
> > 
> > Tested by the buildbot.
> 
> Great, thanks for doing this.

FYI, I've built the pretest of GDB 8.3 with Python 2.6.  The build was
clean wrt Python-related sources, and the little testing I did
indicates that it works fine.
Tom Tromey Feb. 28, 2019, 7:35 p.m. UTC | #7
>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:

Eli> FYI, I've built the pretest of GDB 8.3 with Python 2.6.  The build was
Eli> clean wrt Python-related sources, and the little testing I did
Eli> indicates that it works fine.

Thanks for doing that.

Tom
diff mbox

Patch

diff --git a/gdb/config.in b/gdb/config.in
index ea907d2b56b..c0291fbd9c5 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -249,12 +249,6 @@ 
 /* Define if you have the mpfr library. */
 #undef HAVE_LIBMPFR
 
-/* Define if Python 2.4 is being used. */
-#undef HAVE_LIBPYTHON2_4
-
-/* Define if Python 2.5 is being used. */
-#undef HAVE_LIBPYTHON2_5
-
 /* Define if Python 2.6 is being used. */
 #undef HAVE_LIBPYTHON2_6
 
diff --git a/gdb/configure b/gdb/configure
index 9c99213a168..f2d271e23a2 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -10649,82 +10649,6 @@  if ac_fn_c_try_link "$LINENO"; then :
                   PYTHON_CPPFLAGS=$new_CPPFLAGS
                   PYTHON_LIBS=$new_LIBS
 fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  CPPFLAGS=$save_CPPFLAGS
-  LIBS=$save_LIBS
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${found_usable_python}" >&5
-$as_echo "${found_usable_python}" >&6; }
-
-    fi
-    if test ${have_libpython} = no; then
-
-  version=python2.5
-
-  new_CPPFLAGS=${python_includes}
-  new_LIBS="-lpython2.5 ${python_libs}"
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${version}" >&5
-$as_echo_n "checking for ${version}... " >&6; }
-  save_CPPFLAGS=$CPPFLAGS
-  save_LIBS=$LIBS
-  CPPFLAGS="$CPPFLAGS $new_CPPFLAGS"
-  LIBS="$new_LIBS $LIBS"
-  found_usable_python=no
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include "Python.h"
-int
-main ()
-{
-Py_Initialize ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  have_libpython=${version}
-                  found_usable_python=yes
-                  PYTHON_CPPFLAGS=$new_CPPFLAGS
-                  PYTHON_LIBS=$new_LIBS
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  CPPFLAGS=$save_CPPFLAGS
-  LIBS=$save_LIBS
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${found_usable_python}" >&5
-$as_echo "${found_usable_python}" >&6; }
-
-    fi
-    if test ${have_libpython} = no; then
-
-  version=python2.4
-
-  new_CPPFLAGS=${python_includes}
-  new_LIBS="-lpython2.4 ${python_libs}"
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${version}" >&5
-$as_echo_n "checking for ${version}... " >&6; }
-  save_CPPFLAGS=$CPPFLAGS
-  save_LIBS=$LIBS
-  CPPFLAGS="$CPPFLAGS $new_CPPFLAGS"
-  LIBS="$new_LIBS $LIBS"
-  found_usable_python=no
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include "Python.h"
-int
-main ()
-{
-Py_Initialize ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  have_libpython=${version}
-                  found_usable_python=yes
-                  PYTHON_CPPFLAGS=$new_CPPFLAGS
-                  PYTHON_LIBS=$new_LIBS
-fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
   CPPFLAGS=$save_CPPFLAGS
@@ -10742,14 +10666,6 @@  $as_echo "#define HAVE_LIBPYTHON2_7 1" >>confdefs.h
 
 $as_echo "#define HAVE_LIBPYTHON2_6 1" >>confdefs.h
 
-  elif test "${have_libpython}" = python2.5 -o "${have_libpython}" = python25; then
-
-$as_echo "#define HAVE_LIBPYTHON2_5 1" >>confdefs.h
-
-  elif test "${have_libpython}" = python2.4 -o "${have_libpython}" = python24; then
-
-$as_echo "#define HAVE_LIBPYTHON2_4 1" >>confdefs.h
-
   fi
 
   if test "${have_libpython}" = no; then
@@ -11477,8 +11393,8 @@  fi
 
 SRCHIGH_LIBS=
 SRCHIGH_CFLAGS=
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for source highlight" >&5
-$as_echo_n "checking for source highlight... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for the source-highlight library" >&5
+$as_echo_n "checking for the source-highlight library... " >&6; }
 if test "${pkg_config_prog_path}" = "missing"; then
    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - pkg-config not found" >&5
 $as_echo "no - pkg-config not found" >&6; }
diff --git a/gdb/configure.ac b/gdb/configure.ac
index f63507ff74e..8ddd0fda61c 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -734,7 +734,7 @@  dnl no -   Don't include python support.
 dnl yes -  Include python support, error if it's missing.
 dnl        If we find python in $PATH, use it to fetch configure options,
 dnl        otherwise assume the compiler can find it with no help from us.
-dnl        Python 2.7, 2.6, 2.5, and then 2.4 are tried in turn.
+dnl        Python 2.7 and 2.6 are tried in turn.
 dnl auto - Same as "yes", but if python is missing from the system,
 dnl        fall back to "no".
 dnl /path/to/python/exec-prefix -
@@ -743,7 +743,7 @@  dnl        If /path/to/python/exec-prefix/bin/python exists, use it to find
 dnl        the compilation parameters.  Otherwise use
 dnl        -I/path/to/python/exec-prefix/include,
 dnl        -L/path/to/python/exec-prefix/lib.
-dnl        Python 2.7, 2.6, 2.5, and then 2.4 are tried in turn.
+dnl        Python 2.7 and 2.6 are tried in turn.
 dnl        NOTE: This case is historical.  It is what was done for 7.0/7.1
 dnl        but is deprecated.
 dnl /path/to/python/executable -
@@ -911,23 +911,11 @@  else
       AC_TRY_LIBPYTHON(python2.6, have_libpython,
                        ${python_includes}, "-lpython2.6 ${python_libs}")
     fi
-    if test ${have_libpython} = no; then
-      AC_TRY_LIBPYTHON(python2.5, have_libpython,
-                       ${python_includes}, "-lpython2.5 ${python_libs}")
-    fi
-    if test ${have_libpython} = no; then
-      AC_TRY_LIBPYTHON(python2.4, have_libpython,
-                       ${python_includes}, "-lpython2.4 ${python_libs}")
-    fi
   fi
   if test "${have_libpython}" = python2.7 -o "${have_libpython}" = python27; then
     AC_DEFINE(HAVE_LIBPYTHON2_7, 1, [Define if Python 2.7 is being used.])
   elif test "${have_libpython}" = python2.6 -o "${have_libpython}" = python26; then
     AC_DEFINE(HAVE_LIBPYTHON2_6, 1, [Define if Python 2.6 is being used.])
-  elif test "${have_libpython}" = python2.5 -o "${have_libpython}" = python25; then
-    AC_DEFINE(HAVE_LIBPYTHON2_5, 1, [Define if Python 2.5 is being used.])
-  elif test "${have_libpython}" = python2.4 -o "${have_libpython}" = python24; then
-    AC_DEFINE(HAVE_LIBPYTHON2_4, 1, [Define if Python 2.4 is being used.])
   fi
 
   if test "${have_libpython}" = no; then
diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index f41d88dbf51..ba3b4f0fc38 100644
--- a/gdb/python/py-breakpoint.c
+++ b/gdb/python/py-breakpoint.c
@@ -1138,9 +1138,7 @@  gdbpy_initialize_breakpoints (void)
   /* Add breakpoint types constants.  */
   for (i = 0; pybp_codes[i].name; ++i)
     {
-      if (PyModule_AddIntConstant (gdb_module,
-				   /* Cast needed for Python 2.4.  */
-				   (char *) pybp_codes[i].name,
+      if (PyModule_AddIntConstant (gdb_module, pybp_codes[i].name,
 				   pybp_codes[i].code) < 0)
 	return -1;
     }
@@ -1148,9 +1146,7 @@  gdbpy_initialize_breakpoints (void)
   /* Add watchpoint types constants.  */
   for (i = 0; pybp_watch_types[i].name; ++i)
     {
-      if (PyModule_AddIntConstant (gdb_module,
-				   /* Cast needed for Python 2.4.  */
-				   (char *) pybp_watch_types[i].name,
+      if (PyModule_AddIntConstant (gdb_module, pybp_watch_types[i].name,
 				   pybp_watch_types[i].code) < 0)
 	return -1;
     }
diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index 24fc5e69fef..395f619b357 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -1050,20 +1050,11 @@  static PyBufferProcs buffer_procs =
 
 #else
 
-/* Python doesn't provide a decent way to get compatibility here.  */
-#if HAVE_LIBPYTHON2_4
-#define CHARBUFFERPROC_NAME getcharbufferproc
-#else
-#define CHARBUFFERPROC_NAME charbufferproc
-#endif
-
 static PyBufferProcs buffer_procs = {
   get_read_buffer,
   get_write_buffer,
   get_seg_count,
-  /* The cast here works around a difference between Python 2.4 and
-     Python 2.5.  */
-  (CHARBUFFERPROC_NAME) get_char_buffer
+  get_char_buffer
 };
 #endif	/* IS_PY3K */
 
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c
index 8effa81d5b0..b069ca3a9f9 100644
--- a/gdb/python/py-prettyprint.c
+++ b/gdb/python/py-prettyprint.c
@@ -350,88 +350,6 @@  print_string_repr (PyObject *printer, const char *hint,
   return result;
 }
 
-#ifndef IS_PY3K
-
-/* Create a dummy PyFrameObject, needed to work around
-   a Python-2.4 bug with generators.  */
-class dummy_python_frame
-{
- public:
-
-  dummy_python_frame ();
-
-  ~dummy_python_frame ()
-  {
-    if (m_valid)
-      m_tstate->frame = m_saved_frame;
-  }
-
-  bool failed () const
-  {
-    return !m_valid;
-  }
-
- private:
-
-  bool m_valid;
-  PyFrameObject *m_saved_frame;
-  gdbpy_ref<> m_frame;
-  PyThreadState *m_tstate;
-};
-
-dummy_python_frame::dummy_python_frame ()
-: m_valid (false),
-  m_saved_frame (NULL),
-  m_tstate (NULL)
-{
-  PyCodeObject *code;
-  PyFrameObject *frame;
-
-  gdbpy_ref<> empty_string (PyString_FromString (""));
-  if (empty_string == NULL)
-    return;
-
-  gdbpy_ref<> null_tuple (PyTuple_New (0));
-  if (null_tuple == NULL)
-    return;
-
-  code = PyCode_New (0,			  /* argcount */
-		     0,			  /* locals */
-		     0,			  /* stacksize */
-		     0,			  /* flags */
-		     empty_string.get (), /* code */
-		     null_tuple.get (),	  /* consts */
-		     null_tuple.get (),	  /* names */
-		     null_tuple.get (),	  /* varnames */
-#if PYTHON_API_VERSION >= 1010
-		     null_tuple.get (),	  /* freevars */
-		     null_tuple.get (),	  /* cellvars */
-#endif
-		     empty_string.get (), /* filename */
-		     empty_string.get (), /* name */
-		     1,			  /* firstlineno */
-		     empty_string.get ()  /* lnotab */
-		     );
-  if (code == NULL)
-    return;
-  gdbpy_ref<> code_holder ((PyObject *) code);
-
-  gdbpy_ref<> globals (PyDict_New ());
-  if (globals == NULL)
-    return;
-
-  m_tstate = PyThreadState_GET ();
-  frame = PyFrame_New (m_tstate, code, globals.get (), NULL);
-  if (frame == NULL)
-    return;
-
-  m_frame.reset ((PyObject *) frame);
-  m_tstate->frame = frame;
-  m_saved_frame = frame->f_back;
-  m_valid = true;
-}
-#endif
-
 /* Helper for gdbpy_apply_val_pretty_printer that formats children of the
    printer, if any exist.  If is_py_none is true, then nothing has
    been printed by to_string, and format output accordingly. */
@@ -480,18 +398,6 @@  print_children (PyObject *printer, const char *hint,
 	pretty = options->prettyformat_structs;
     }
 
-  /* Manufacture a dummy Python frame to work around Python 2.4 bug,
-     where it insists on having a non-NULL tstate->frame when
-     a generator is called.  */
-#ifndef IS_PY3K
-  dummy_python_frame frame;
-  if (frame.failed ())
-    {
-      gdbpy_print_stack ();
-      return;
-    }
-#endif
-
   done_flag = 0;
   for (i = 0; i < options->print_max; ++i)
     {
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index 7ad1a0c70e8..c908ec62de6 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -198,9 +198,7 @@  convert_field (struct type *type, int field)
       if (arg == NULL)
 	return NULL;
 
-      /* At least python-2.4 had the second parameter non-const.  */
-      if (PyObject_SetAttrString (result.get (), (char *) attrstring,
-				  arg.get ()) < 0)
+      if (PyObject_SetAttrString (result.get (), attrstring, arg.get ()) < 0)
 	return NULL;
     }
 
@@ -1408,9 +1406,7 @@  gdbpy_initialize_types (void)
 
   for (i = 0; pyty_codes[i].name; ++i)
     {
-      if (PyModule_AddIntConstant (gdb_module,
-				   /* Cast needed for Python 2.4.  */
-				   (char *) pyty_codes[i].name,
+      if (PyModule_AddIntConstant (gdb_module, pyty_codes[i].name,
 				   pyty_codes[i].code) < 0)
 	return -1;
     }
diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c
index 0f96aab718a..a380b34afe8 100644
--- a/gdb/python/py-utils.c
+++ b/gdb/python/py-utils.c
@@ -382,8 +382,7 @@  gdb_pymodule_addobject (PyObject *module, const char *name, PyObject *object)
   int result;
 
   Py_INCREF (object);
-  /* Python 2.4 did not have a 'const' here.  */
-  result = PyModule_AddObject (module, (char *) name, object);
+  result = PyModule_AddObject (module, name, object);
   if (result < 0)
     Py_DECREF (object);
   return result;
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index 445be729467..63a9952e513 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -2001,10 +2001,7 @@  static PyNumberMethods value_object_as_number = {
   valpy_divide,               /* nb_true_divide */
   NULL,			      /* nb_inplace_floor_divide */
   NULL,			      /* nb_inplace_true_divide */
-#ifndef HAVE_LIBPYTHON2_4
-  /* This was added in Python 2.5.  */
   valpy_long,		      /* nb_index */
-#endif /* HAVE_LIBPYTHON2_4 */
 };
 
 static PyMappingMethods value_object_as_mapping = {
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index d11af83c8e5..449926ca874 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -51,8 +51,6 @@ 
 #define CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
 #endif
 
-/* Python 2.4 doesn't include stdint.h soon enough to get {u,}intptr_t
-   needed by pyport.h.  */
 /* /usr/include/features.h on linux systems will define _POSIX_C_SOURCE
    if it sees _GNU_SOURCE (which config.h will define).
    pyconfig.h defines _POSIX_C_SOURCE to a different value than
@@ -109,26 +107,6 @@ 
 #define PyString_Check PyUnicode_Check
 #endif
 
-#if HAVE_LIBPYTHON2_4
-/* Py_ssize_t is not defined until 2.5.
-   Logical type for Py_ssize_t is Py_intptr_t, but that fails in 64-bit
-   compilation due to several apparent mistakes in python2.4 API, so we
-   use 'int' instead.  */
-typedef int Py_ssize_t;
-#endif
-
-#ifndef PyVarObject_HEAD_INIT
-/* Python 2.4 does not define PyVarObject_HEAD_INIT.  */
-#define PyVarObject_HEAD_INIT(type, size)       \
-    PyObject_HEAD_INIT(type) size,
-
-#endif
-
-#ifndef Py_TYPE
-/* Python 2.4 does not define Py_TYPE.  */
-#define Py_TYPE(ob)             (((PyObject*)(ob))->ob_type)
-#endif
-
 /* If Python.h does not define WITH_THREAD, then the various
    GIL-related functions will not be defined.  However,
    PyGILState_STATE will be.  */
@@ -183,41 +161,12 @@  typedef long Py_hash_t;
 static inline void
 gdb_Py_DECREF (void *op) /* ARI: editCase function */
 {
-  /* ... and Python 2.4 didn't cast OP to PyObject pointer on the
-     '(op)->ob_refcnt' references within the macro.  Cast it ourselves
-     too.  */
-  Py_DECREF ((PyObject *) op);
+  Py_DECREF (op);
 }
 
 #undef Py_DECREF
 #define Py_DECREF(op) gdb_Py_DECREF (op)
 
-/* The second argument to PyObject_GetAttrString was missing the 'const'
-   qualifier in Python-2.4.  Hence, we wrap it in a function to avoid errors
-   when compiled with -Werror.  */
-
-static inline PyObject *
-gdb_PyObject_GetAttrString (PyObject *obj,
-			    const char *attr) /* ARI: editCase function */
-{
-  return PyObject_GetAttrString (obj, (char *) attr);
-}
-
-#define PyObject_GetAttrString(obj, attr) gdb_PyObject_GetAttrString (obj, attr)
-
-/* The second argument to PyObject_HasAttrString was also missing the 'const'
-   qualifier in Python-2.4.  Hence, we wrap it also in a function to avoid
-   errors when compiled with -Werror.  */
-
-static inline int
-gdb_PyObject_HasAttrString (PyObject *obj,
-			    const char *attr)  /* ARI: editCase function */
-{
-  return PyObject_HasAttrString (obj, (char *) attr);
-}
-
-#define PyObject_HasAttrString(obj, attr) gdb_PyObject_HasAttrString (obj, attr)
-
 /* 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/python/python.c b/gdb/python/python.c
index c23db2c1261..0d9415ce807 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -1646,12 +1646,10 @@  do_start_initialization ()
   if (gdb_module == NULL)
     return false;
 
-  /* The casts to (char*) are for python 2.4.  */
-  if (PyModule_AddStringConstant (gdb_module, "VERSION", (char*) version) < 0
-      || PyModule_AddStringConstant (gdb_module, "HOST_CONFIG",
-				     (char*) host_name) < 0
+  if (PyModule_AddStringConstant (gdb_module, "VERSION", version) < 0
+      || PyModule_AddStringConstant (gdb_module, "HOST_CONFIG", host_name) < 0
       || PyModule_AddStringConstant (gdb_module, "TARGET_CONFIG",
-				     (char*) target_name) < 0)
+				     target_name) < 0)
     return false;
 
   /* Add stream constants.  */
diff --git a/gdb/testsuite/gdb.python/py-finish-breakpoint.exp b/gdb/testsuite/gdb.python/py-finish-breakpoint.exp
index 293c9138c84..6ffa17a3577 100644
--- a/gdb/testsuite/gdb.python/py-finish-breakpoint.exp
+++ b/gdb/testsuite/gdb.python/py-finish-breakpoint.exp
@@ -46,13 +46,6 @@  clean_restart ${testfile}
 
 if { [skip_python_tests] } { continue }
 
-if { $gdb_py_is_py24 == 1 } {
-    # Python 2.4, 2.5 do not support the "ValueError as e" syntax used in
-    # the py-finish-breakpoint.py script.
-	untested "missing support on Python 2.4 and 2.5"
-    return 0
-}
-
 #
 # Test FinishBreakpoint in normal conditions
 #
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index d05854329d8..8a83313c2d5 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1803,7 +1803,6 @@  proc skip_rust_tests {} {
 
 proc skip_python_tests_prompt { prompt_regexp } {
     global gdb_py_is_py3k
-    global gdb_py_is_py24
 
     gdb_test_multiple "python print ('test')" "verify python support" {
 	-re "not supported.*$prompt_regexp" {
@@ -1813,7 +1812,6 @@  proc skip_python_tests_prompt { prompt_regexp } {
 	-re "$prompt_regexp" {}
     }
 
-    set gdb_py_is_py24 0
     gdb_test_multiple "python print (sys.version_info\[0\])" "check if python 3" {
 	-re "3.*$prompt_regexp" {
             set gdb_py_is_py3k 1
@@ -1822,16 +1820,6 @@  proc skip_python_tests_prompt { prompt_regexp } {
             set gdb_py_is_py3k 0
         }
     }
-    if { $gdb_py_is_py3k == 0 } {
-        gdb_test_multiple "python print (sys.version_info\[1\])" "check if python 2.4" {
-	    -re "\[45\].*$prompt_regexp" {
-                set gdb_py_is_py24 1
-            }
-	    -re ".*$prompt_regexp" {
-                set gdb_py_is_py24 0
-            }
-        }
-    }
 
     return 0
 }