This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author kimiguel
Recipients brett.cannon, eric.snow, kimiguel, pablogsal, rhettinger
Date 2020-03-02.15:36:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1583163376.54.0.165592229385.issue39829@roundup.psfhosted.org>
In-reply-to
Content
(See #33234)

Recently we added Python 3.8 to our CI test matrix, and we noticed a possible backward incompatibility with the list() constructor.

We found that __len__ is getting called twice, while before 3.8 it was only called once.

Here's an example:

class Foo:
 def __iter__(self):
  print("iter")
  return iter([3, 5, 42, 69])

 def __len__(self):
  print("len")
  return 4

Calling list(Foo()) using Python 3.7 prints:

iter
len

But calling list(Foo()) using Python 3.8 prints:

len
iter
len

It looks like this behaviour was introduced for #33234 with PR GH-9846. 

We realize that this was merged a while back, but at least we wanted to make the team aware of this change in behaviour.
History
Date User Action Args
2020-03-02 15:36:16kimiguelsetrecipients: + kimiguel, brett.cannon, rhettinger, eric.snow, pablogsal
2020-03-02 15:36:16kimiguelsetmessageid: <1583163376.54.0.165592229385.issue39829@roundup.psfhosted.org>
2020-03-02 15:36:16kimiguellinkissue39829 messages
2020-03-02 15:36:16kimiguelcreate