[issue36118] Cannot correctly concatenate nested list that contains more than ~45 entries with other nested lists.

Steven D'Aprano report at bugs.python.org
Tue Feb 26 04:21:25 EST 2019


Steven D'Aprano <steve+python at pearwood.info> added the comment:

I cannot reproduce the behaviour you show.

First problem: ``...`` is a legal Python object, Ellipsis, so your example code literally means:

# x = [["a", "b", ... , "BZ"]]

x is a list containing one sublist, which contains exactly four objects.

So when I run your code as you write it, I get:

py> x = [["a", "b", ... , "BZ"]]
py> y = [[], [1,2,3,4,5, ... , 99]]
py> y[0] = x[0]
py> print(y[0])
['a', 'b', Ellipsis, 'BZ']


which is exactly what I expect.

If we use more than 45 entries, as you suggest, I still cannot reproduce your bug report:


py> x = [ list(range(0, 100)) ]
py> y = [ [], list(range(1000, 1200)) ]
py> assert len(x[0]) > 45
py> assert len(y[1]) > 45
py> y[0] = x[0]
py> print(y[0])
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]

which is exactly the behaviour I expect.


The above is using Python 3.5.


I suggest you start from a fresh interpreter session and show precisely what steps needed to reproduce the behaviour you are seeing, and show the behaviour you expect. It might help to read this:

http://www.sscce.org/

----------
nosy: +steven.daprano

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36118>
_______________________________________


More information about the Python-bugs-list mailing list