-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 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: >> >> The optparse one could easily be fixed for 2.6, if we agree it >> should be >> fixed. This untested patch should do it I think: >> >> Index: Lib/optparse.py >> =================================================================== >> - --- Lib/optparse.py (revision 68465) >> +++ Lib/optparse.py (working copy) >> @@ -994,7 +994,7 @@ >> """add_option(Option) >> add_option(opt_str, ..., kwarg=val, ...) >> """ >> - - if type(args[0]) is types.StringType: >> + if type(args[0]) in types.StringTypes: >> option = self.option_class(*args, **kwargs) >> elif len(args) == 1 and not kwargs: >> option = args[0] > > 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. >> 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: > > --- Python/ceval.c (revision 68625) > +++ Python/ceval.c (working copy) > @@ -2932,7 +2932,8 @@ > PyObject *keyword = kws[2*i]; > PyObject *value = kws[2*i + 1]; > int j; > - if (keyword == NULL || ! > PyString_Check(keyword)) { > + if (keyword == NULL || ! > (PyString_Check(keyword) || > + > PyUnicode_Check(keyword))) { > PyErr_Format(PyExc_TypeError, > "%.200s() keywords must be > strings", > PyString_AsString(co->co_name)); That seems reasonable. > But I agree with Guido when he says this should be a 2.7 feature. As does that. - -Barry -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Darwin) iQCVAwUBSXJis3EjvBPtnXfVAQLnsAP+I7ZIa8vKwSJV+cGqlFyKYNdyYysxYW5w QL36DMXMwfg+Gddb5GN16IGXZt54yTneFAp6fxNgq55Seql/LFmhSrYoq0dk0uXz +sb92PRtYD7QjV6BkOUFlIGphmuOS7Vxv6+M2Xi1YoSyU6DHhno0AyYUFa3ysJiC lfNP6TLgGL0= =mp9M -----END PGP SIGNATURE-----
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4