public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Use importlib instead of imp module on python 3.4+
@ 2021-02-28 10:11 Boris Staletic
  2021-04-01 18:12 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Boris Staletic @ 2021-02-28 10:11 UTC (permalink / raw)
  To: gdb-patches; +Cc: Boris Staletic

Hello,

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?

gdb/ChangeLog:

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.

---
 gdb/python/lib/gdb/__init__.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

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 *
-- 
2.30.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Use importlib instead of imp module on python 3.4+
  2021-02-28 10:11 [PATCH] Use importlib instead of imp module on python 3.4+ Boris Staletic
@ 2021-04-01 18:12 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2021-04-01 18:12 UTC (permalink / raw)
  To: Boris Staletic via Gdb-patches; +Cc: Boris Staletic

>>>>> "Boris" == Boris Staletic via Gdb-patches <gdb-patches@sourceware.org> writes:

Boris> Python 3.4 has deprecated the imp module in favour of importlib. This
Boris> patch avoids the DeprecationWarning. This warning is visible to users
Boris> whose libpython.so has been compiled with --with-pydebug.

Boris> Considering that even python 3.5 has reached end of life, would it be
Boris> better to just use importlib and drop support for python 3.0 to 3.3?

I am not sure.  I don't know if there is a minimum Python version we
support.

Boris> 2021-02-28  Boris Staletic  <boris.staletic@gmail.com>

Boris> 	* gdb/python/lib/gdb/__init__.py: Use importlib on python 3.4+
Boris> 	to avoid deprecation warnings.

I'm checking this in.  Thank you for the patch.
If it turns out that we don't in fact care about earlier versions of
Python, it's easy enough to update this.

Tom

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-01 18:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-28 10:11 [PATCH] Use importlib instead of imp module on python 3.4+ Boris Staletic
2021-04-01 18:12 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).