[Python-Dev] Problems with unicode_literals

Benjamin Peterson benjamin at python.org
Sun Jan 18 00:10:30 CET 2009


On Sat, Jan 17, 2009 at 4:58 PM, Barry Warsaw <barry at python.org> wrote:
> On Jan 16, 2009, at 10:52 PM, Benjamin Peterson wrote:
>> On Fri, Jan 16, 2009 at 9:45 PM, Barry Warsaw <barry at python.org> wrote:
>>> - -        if type(args[0]) is types.StringType:
>>> +        if type(args[0]) in types.StringTypes:
>>
>> It'd probably be better to replace that whole line with
>> isinstance(args[0], basestring).
>
> I thought about that, but clearly the style of that module is to use the
> 'is' test.  I'm assuming that's because of some required backward
> compatibility reason, but honestly I didn't check, I just copied the style
> of the file.

optparse is now no longer externally maintained, so it could probably
use a little TLC and modernization.

>
>>> The fact that 'a' and 'b' are unicodes and not accepted as keyword
>>> arguments
>>> is probably the tougher problem.  I haven't yet looked at what it might
>>> take
>>> to fix.  Is it worth fixing in 2.6 or is this a wait-for-2.7 thing?
>>
>> Actually, this looks like a one line fix, too:
 ....
> That seems reasonable.

I've posted this to the tracker with a test: http://bugs.python.org/issue4978



-- 
Regards,
Benjamin


More information about the Python-Dev mailing list