From ee957c99c2aa8346c87392aa7547295ce1192a0d Mon Sep 17 00:00:00 2001 From: "biao716.wang" Date: Wed, 30 Nov 2022 19:28:25 +0900 Subject: [PATCH] fix next error in linkedlist.py Change-Id: I76f6ad919b415e4bff845ce1fef4182ba6fa9ab5 Signed-off-by: biao716.wang --- gbp/rpm/linkedlist.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/gbp/rpm/linkedlist.py b/gbp/rpm/linkedlist.py index c622f603..ac121316 100644 --- a/gbp/rpm/linkedlist.py +++ b/gbp/rpm/linkedlist.py @@ -12,8 +12,8 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# along with this program; if not, please see +# """Simple implementation of a doubly linked list""" import collections @@ -59,12 +59,11 @@ class LinkedListNode(object): data = "" self._data = data - def delete(self): """Delete node""" if self.prev: - self.prev.next = self.__next__ - if self.__next__: + self.prev.next = self.next + if self.next: self.next.prev = self.prev self._data = None @@ -78,11 +77,14 @@ class LinkedListIterator(collections.abc.Iterator): def __next__(self): ret = self._next if ret: - self._next = ret.__next__ + self._next = ret.next else: raise StopIteration return ret + def next(self): + return self.__next__() + class LinkedList(collections.abc.Iterable): """Doubly linked list""" @@ -171,8 +173,8 @@ class LinkedList(collections.abc.Iterable): >>> [str(data) for data in list] ['foo', 'baz', 'bar'] """ - new = LinkedListNode(data, prev_node=node, next_node=node.__next__) - if node.__next__: + new = LinkedListNode(data, prev_node=node, next_node=node.next) + if node.next: node.next.prev = new else: self._last = new @@ -205,10 +207,11 @@ class LinkedList(collections.abc.Iterable): """ ret = node.prev if node is self._first: - ret = self._first = self._first.__next__ + ret = self._first = self._first.next if node is self._last: self._last = self._last.prev node.delete() return ret # vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: + -- 2.34.1