Issue2645

classification
Title: pop method returns wrong result with Java LinkedList
Type: behaviour Severity: normal
Components: Core Versions: Jython 2.7
Milestone:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: jamesmudd
Priority: Keywords:

Created on 2017-11-22.18:58:50 by jamesmudd, last changed 2017-11-22.18:58:50 by jamesmudd.

Messages
msg11674 (view) Author: James Mudd (jamesmudd) Date: 2017-11-22.18:58:50
pop should return the last item in the list (https://docs.python.org/2/tutorial/datastructures.html#more-on-lists) which works correctly with ArrayList but fails with LinkedList e.g.
    >>> stack = [1,2,3]
    >>> stack.pop()
    3  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Correct
    >>> from java.util import ArrayList
    >>> jl = ArrayList([1,2,3])
    >>> jl.pop()
    3  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Correct
    >>> from java.util import LinkedList
    >>> jll = LinkedList([1,2,3])
    >>> jll.pop()
    1  <<<<<<<<<<<<<<<< First entry not last?

I think this is because LinkedList implements Deque with defines the pop method to return the first item not the last. This might not be fixable as both results are "correct" depending on what you define pop to do.
History
Date User Action Args
2017-11-22 18:58:50jamesmuddcreate