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.
This commit is contained in:
Boris Staletic 2021-04-01 12:09:27 -06:00 committed by Tom Tromey
parent 74edb473c9
commit bfb9f5dcfe
2 changed files with 9 additions and 2 deletions

View File

@ -1,3 +1,8 @@
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.
2021-04-01 Martin Liska <mliska@suse.cz>
* cp-name-parser.y: Use startswith instead of strncmp.

View File

@ -18,8 +18,10 @@ import os
import sys
import _gdb
if sys.version_info[0] > 2:
# 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 *