Mpaa added a comment.
In T335720#8825687 <https://phabricator.wikimedia.org/T335720#8825687>, @Xqt wrote: > The problem is that the pop default is evaluated even if it is not needed: > > x = {'foo': 'bar'} > def baz(): print('quez') > > x.pop('foo', baz()) > quez > 'bar' > > Here some other samples: > https://codesearch.wmcloud.org/pywikibot/?q=%28get%7Cpop%29%5C%28%5B%5E+%2C%5C%29%5D%2B%2C+%5B%5E%5C%28%5C%29%5D%2B%5C%28&files=&excludeFiles=&repos= > > dict should have been implemented like that instead: > > class lazy_dict(dict): > sentinel = object() > def pop(value, default=sentinel): > try: > r = super.pop(value) > except KeyError: > if default is sentinel: > raise > r = default > return r > > but it is a C function See https://bugs.python.org/issue39083 TASK DETAIL https://phabricator.wikimedia.org/T335720 EMAIL PREFERENCES https://phabricator.wikimedia.org/settings/panel/emailpreferences/ To: Xqt, Mpaa Cc: Mpaa, Aklapper, pywikibot-bugs-list, Xqt, JJMC89, Themindcoder, Adamm71, Jersione, Hellket777, LisafBia6531, 786, Biggs657, PotsdamLamb, Jyoo1011, JohnsonLee01, Juan90264, SHEKH, Dijkstra, Alter-paule, Beast1978, Un1tY, Khutuck, Zkhalido, Hook696, Kent7301, joker88john, Viztor, CucyNoiD, Wenyi, Gaboe420, Giuliamocci, Cpaulf30, Af420, Bsandipan, Tbscho, MayS, Framawiki, Lewizho99, Mdupont, Maathavan, Dvorapa, Altostratus, Neuronton, Avicennasis, mys_721tx, jayvdb, Masti, Alchimista
_______________________________________________ pywikibot-bugs mailing list -- [email protected] To unsubscribe send an email to [email protected]
