diff options
author | Boris Staletic <boris.staletic@gmail.com> | 2021-04-01 12:09:27 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2021-04-01 12:26:52 -0600 |
commit | bfb9f5dcfe575b9baee771612e6c197c7544e945 (patch) | |
tree | 1f67e0773e1bae8d18d684f7ca70c230a8c8322b /gdb/python | |
parent | 74edb473c9ecf5e2053ecf8e429ee608feafb9e1 (diff) | |
download | binutils-bfb9f5dcfe575b9baee771612e6c197c7544e945.zip binutils-bfb9f5dcfe575b9baee771612e6c197c7544e945.tar.gz binutils-bfb9f5dcfe575b9baee771612e6c197c7544e945.tar.bz2 |
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 <boris.staletic@gmail.com>
* gdb/python/lib/gdb/__init__.py: Use importlib on python 3.4+
to avoid deprecation warnings.
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/lib/gdb/__init__.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/gdb/python/lib/gdb/__init__.py b/gdb/python/lib/gdb/__init__.py index 84ec728..9a0e989 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 * |