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 belopolsky
Recipients belopolsky
Date 2016-07-19.21:01:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1468962090.7.0.636707577928.issue27576@psf.upfronthosting.co.za>
In-reply-to
Content
Consider the following code:

$ cat x.py
from collections import OrderedDict
class X:
    def items(self):
        print('items')
        return []
    def keys(self):
        print('keys')
        return []

print(dict(X()))
print(OrderedDict(X()))

When I run it under python 3.4, I get

$ python3.4 x.py
keys
{}
keys
OrderedDict()

but under python 3.5, I get

$ python3.5 x.py
keys
{}
items
OrderedDict()


Under 3.4 both dict and OrderedDict constructors call the keys() method of the underlying object (and then call __getitem__ repeatedly if keys() returns a non-empty list), but in 3.5 OrderedDict behavior changed and it calls the values() method instead.
History
Date User Action Args
2016-07-19 21:01:30belopolskysetrecipients: + belopolsky
2016-07-19 21:01:30belopolskysetmessageid: <1468962090.7.0.636707577928.issue27576@psf.upfronthosting.co.za>
2016-07-19 21:01:30belopolskylinkissue27576 messages
2016-07-19 21:01:30belopolskycreate