From: Boris Staletic Date: Thu, 1 Apr 2021 18:09:27 +0000 (-0600) Subject: Use importlib instead of imp module on python 3.4+ X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bfb9f5dcfe575b9baee771612e6c197c7544e945;p=binutils-gdb.git Use importlib instead of imp module on python 3.4+ Python 3.4 has deprecated the imp module in favour of importlib. This patch avoids the DeprecationWarning. This warning is visible to users whose libpython.so has been compiled with --with-pydebug. Considering that even python 3.5 has reached end of life, would it be better to just use importlib and drop support for python 3.0 to 3.3? 2021-02-28 Boris Staletic * gdb/python/lib/gdb/__init__.py: Use importlib on python 3.4+ to avoid deprecation warnings. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9684f290401..ac40f8ebb6c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2021-02-28 Boris Staletic + + * gdb/python/lib/gdb/__init__.py: Use importlib on python 3.4+ + to avoid deprecation warnings. + 2021-04-01 Martin Liska * cp-name-parser.y: Use startswith instead of strncmp. diff --git a/gdb/python/lib/gdb/__init__.py b/gdb/python/lib/gdb/__init__.py index 84ec728ea21..9a0e9891cc5 100644 --- a/gdb/python/lib/gdb/__init__.py +++ b/gdb/python/lib/gdb/__init__.py @@ -18,8 +18,10 @@ import os import sys import _gdb -if sys.version_info[0] > 2: - # Python 3 moved "reload" +# Python 3 moved "reload" +if sys.version_info >= (3, 4): + from importlib import reload +elif sys.version_info[0] > 2: from imp import reload from _gdb import *