Is the issue that in foo(**{'a': 1, 'b': 1}) the 'a' and 'b' are unicode and not acceptable as keyword arguments? I agree that should be fixed, though I'm not sure it'll be easy.
I'm not sure you're saying that the optparse case shouldn't be fixed in 2.6. or the foo(**{...}) shouldn't be fixed in 2.6, though I think the latter. On Fri, Jan 16, 2009 at 6:42 PM, Barry Warsaw <ba...@python.org> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > I've been playing with 'from __future__ import unicode_literals' just to see > how unicode unclean some of my code was. Almost everything was fairly easy > to fix but I found two interesting situations. One seems fairly shallow and > might arguably be fixable in Python 2.6 (but probably not :). The other > clearly can't be addressed in Python 2.6, but the question is whether it > should be changed for Python 2.7. > > Here's some sample code: > > - -----snip snip----- > from __future__ import unicode_literals > > def foo(a=None, b=None): > print a, b > > # This is a TypeError > foo(**{'a': 1, 'b': 2}) > > foo(**dict(a=1, b=2)) > > from optparse import OptionParser > > parser = OptionParser() > > # This also raises a TypeError > parser.add_option('-f', '--foo') > - -----snip snip----- > > The add_option() failure is a one-line fix. > > - -Barry > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (Darwin) > > iQCVAwUBSXFFmnEjvBPtnXfVAQKx0QP/Un7RG++ugtgywBHXd+pWTD2V7QC1JDqP > rpIkwqocicMZiNBbg0NS5/TSGHa0CyaQphDmBBeNFr7jFb4rxdUESyLmBNNIz7dV > /PEBZxJp5ZjTGCIylEJoXHMSN102wqe/n6QAAGqV5ce7e3Fhr8b7kU2m7cMT6yDQ > /1b4riH/H0Y= > =dp0u > -----END PGP SIGNATURE----- > _______________________________________________ > Python-Dev mailing list > Python-Dev@python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: > http://mail.python.org/mailman/options/python-dev/guido%40python.org > -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com