Author njs
Recipients gvanrossum, njs
Date 2018-01-28.03:38:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1517110738.44.0.467229070634.issue32690@psf.upfronthosting.co.za>
In-reply-to
Content
What should happen for:

def f():
    if random.random() < 0.5:
        a = 1
        b = 2
    else:
        b = 1
        a = 2
    return locals()

? Right now co_varnames preserves the order that names were encountered when compiling, so it'd be easy to make 'a' come before 'b' in locals(), so the above function returns either {'a': 1, 'b': 2} or {'a': 2, 'b': 1}.

If we want to preserve the illusion that local variables are entries in the locals() dict, though, then the dict ought to be either {'a': 1, 'b': 2}, {'b': 1, 'a': 2}. Making this happen would require extra machinery for an extreme edge case so I'm guessing it's not worth it though.
History
Date User Action Args
2018-01-28 03:38:58njssetrecipients: + njs, gvanrossum
2018-01-28 03:38:58njssetmessageid: <1517110738.44.0.467229070634.issue32690@psf.upfronthosting.co.za>
2018-01-28 03:38:58njslinkissue32690 messages
2018-01-28 03:38:57njscreate