public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Remove some Python 2 code
@ 2023-06-13 18:53 Tom Tromey
  2023-06-28 13:43 ` Bruno Larsen
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2023-06-13 18:53 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

I found some Python 2 compatibility code in gdb's Python library.
There's no need for this any more, so this removes it.  There is still
a bit more of this remaining in __init__.py, but I haven't tried
removing that yet.
---
 gdb/python/lib/gdb/FrameIterator.py | 8 +-------
 gdb/python/lib/gdb/frames.py        | 8 ++------
 2 files changed, 3 insertions(+), 13 deletions(-)

diff --git a/gdb/python/lib/gdb/FrameIterator.py b/gdb/python/lib/gdb/FrameIterator.py
index 190ec942814..2cae7b59a0f 100644
--- a/gdb/python/lib/gdb/FrameIterator.py
+++ b/gdb/python/lib/gdb/FrameIterator.py
@@ -30,7 +30,7 @@ class FrameIterator(object):
     def __iter__(self):
         return self
 
-    def next(self):
+    def __next__(self):
         """next implementation.
 
         Returns:
@@ -41,9 +41,3 @@ class FrameIterator(object):
             raise StopIteration
         self.frame = result.older()
         return result
-
-    # Python 3.x requires __next__(self) while Python 2.x requires
-    # next(self).  Define next(self), and for Python 3.x create this
-    # wrapper.
-    def __next__(self):
-        return self.next()
diff --git a/gdb/python/lib/gdb/frames.py b/gdb/python/lib/gdb/frames.py
index 5f8119c22a0..0287a9bf3d3 100644
--- a/gdb/python/lib/gdb/frames.py
+++ b/gdb/python/lib/gdb/frames.py
@@ -190,12 +190,8 @@ def execute_frame_filters(frame, frame_low, frame_high):
     frame_iterator = FrameIterator(frame)
 
     # Apply a basic frame decorator to all gdb.Frames.  This unifies
-    # the interface.  Python 3.x moved the itertools.imap
-    # functionality to map(), so check if it is available.
-    if hasattr(itertools, "imap"):
-        frame_iterator = itertools.imap(FrameDecorator, frame_iterator)
-    else:
-        frame_iterator = map(FrameDecorator, frame_iterator)
+    # the interface.
+    frame_iterator = map(FrameDecorator, frame_iterator)
 
     for ff in sorted_list:
         frame_iterator = ff.filter(frame_iterator)
-- 
2.40.1


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

* Re: [PATCH] Remove some Python 2 code
  2023-06-13 18:53 [PATCH] Remove some Python 2 code Tom Tromey
@ 2023-06-28 13:43 ` Bruno Larsen
  0 siblings, 0 replies; 2+ messages in thread
From: Bruno Larsen @ 2023-06-28 13:43 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 13/06/2023 20:53, Tom Tromey via Gdb-patches wrote:
> I found some Python 2 compatibility code in gdb's Python library.
> There's no need for this any more, so this removes it.  There is still
> a bit more of this remaining in __init__.py, but I haven't tried
> removing that yet.
> ---
Nice cleanup, and a long time coming IMO. Reviewed-By: Bruno Larsen 
<blarsen@redhat.com>

-- 
Cheers,
Bruno

>   gdb/python/lib/gdb/FrameIterator.py | 8 +-------
>   gdb/python/lib/gdb/frames.py        | 8 ++------
>   2 files changed, 3 insertions(+), 13 deletions(-)
>
> diff --git a/gdb/python/lib/gdb/FrameIterator.py b/gdb/python/lib/gdb/FrameIterator.py
> index 190ec942814..2cae7b59a0f 100644
> --- a/gdb/python/lib/gdb/FrameIterator.py
> +++ b/gdb/python/lib/gdb/FrameIterator.py
> @@ -30,7 +30,7 @@ class FrameIterator(object):
>       def __iter__(self):
>           return self
>   
> -    def next(self):
> +    def __next__(self):
>           """next implementation.
>   
>           Returns:
> @@ -41,9 +41,3 @@ class FrameIterator(object):
>               raise StopIteration
>           self.frame = result.older()
>           return result
> -
> -    # Python 3.x requires __next__(self) while Python 2.x requires
> -    # next(self).  Define next(self), and for Python 3.x create this
> -    # wrapper.
> -    def __next__(self):
> -        return self.next()
> diff --git a/gdb/python/lib/gdb/frames.py b/gdb/python/lib/gdb/frames.py
> index 5f8119c22a0..0287a9bf3d3 100644
> --- a/gdb/python/lib/gdb/frames.py
> +++ b/gdb/python/lib/gdb/frames.py
> @@ -190,12 +190,8 @@ def execute_frame_filters(frame, frame_low, frame_high):
>       frame_iterator = FrameIterator(frame)
>   
>       # Apply a basic frame decorator to all gdb.Frames.  This unifies
> -    # the interface.  Python 3.x moved the itertools.imap
> -    # functionality to map(), so check if it is available.
> -    if hasattr(itertools, "imap"):
> -        frame_iterator = itertools.imap(FrameDecorator, frame_iterator)
> -    else:
> -        frame_iterator = map(FrameDecorator, frame_iterator)
> +    # the interface.
> +    frame_iterator = map(FrameDecorator, frame_iterator)
>   
>       for ff in sorted_list:
>           frame_iterator = ff.filter(frame_iterator)


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

end of thread, other threads:[~2023-06-28 13:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-13 18:53 [PATCH] Remove some Python 2 code Tom Tromey
2023-06-28 13:43 ` Bruno Larsen

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).