[Patches] [ python-Patches-559288 ] Use builtin boolean if present
SourceForge.net
noreply@sourceforge.net
Wed, 22 Jan 2003 10:21:40 -0800
Patches item #559288, was opened at 2002-05-22 12:34
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=559288&group_id=5470
Category: Library (Lib)
Group: Python 2.3
>Status: Closed
Resolution: Accepted
Priority: 5
Submitted By: Skip Montanaro (montanaro)
Assigned to: Skip Montanaro (montanaro)
Summary: Use builtin boolean if present
Initial Comment:
Now that Python has a boolean type, perhaps xmlrpclib
should use it if available. Here's a patch that (I think)
does what's necessary. The existing test case (which
does manipulate a boolean) passes. Haven't tested it
with a pre-bool version of Python though.
Skip
----------------------------------------------------------------------
>Comment By: Skip Montanaro (montanaro)
Date: 2003-01-22 12:21
Message:
Logged In: YES
user_id=44345
checked in as xmlrpclib.py 1.23 (no new test case needed)
----------------------------------------------------------------------
Comment By: Martin v. Löwis (loewis)
Date: 2003-01-22 11:28
Message:
Logged In: YES
user_id=21627
The patch is fine. Please apply it.
----------------------------------------------------------------------
Comment By: Skip Montanaro (montanaro)
Date: 2003-01-22 11:10
Message:
Logged In: YES
user_id=44345
Thanks for the suggestion. That eases the pain. All tests pass w/
CVS, 2.2 and 2.1. I don't have 2.0 or 1.5.2 installed, but since no boolean
stuff is in 2.1 I don't think these changes will break those older versions
either.
----------------------------------------------------------------------
Comment By: Martin v. Löwis (loewis)
Date: 2003-01-22 10:09
Message:
Logged In: YES
user_id=21627
I suggest you introduce a _bool_is_builtin flag early on,
e.g. with
try:
bla bla bla
_bool_is_builtin = False.__class__.__name__ == 'bool'
except NameError:
_bool_is_builtin = 0
You are right: for 2.2, xmlrpclib.False must be different
from False, since otherwise it would never marshal <boolean>
elements.
I also think you need to conditionally modify WRAPPERS.
----------------------------------------------------------------------
Comment By: Skip Montanaro (montanaro)
Date: 2003-01-22 09:29
Message:
Logged In: YES
user_id=44345
Here's a new version. I think there may still be problems related to 2.2
(see the dump_bool method), but it should be better w.r.t. 2.1 and earlier
versions. I'd really like to see this get into 2.3.
----------------------------------------------------------------------
Comment By: Martin v. Löwis (loewis)
Date: 2002-10-07 16:44
Message:
Logged In: YES
user_id=21627
I think xmlrpclib.{True,False} must stay, even though they
could become aliases for the builtin True and False (notice
that you can access True with bool(1))
The module must stay 1.5.2 compatible, I think this is
currently not the case: dispatching is based on the type, but
type(True) will be ClassType in 1.5.2.
The test looks for True to determine presence of the boolean
type; this is incorrect: Python 2.2 has True without having
bool. The test also binds x without reason. I'd suggest
try:
boolean = bool
except:
...
instead
----------------------------------------------------------------------
Comment By: Skip Montanaro (montanaro)
Date: 2002-08-02 12:03
Message:
Logged In: YES
user_id=44345
updated patch which avoids using types.BooleanType since there was so
much pushback on the idea.
----------------------------------------------------------------------
Comment By: Skip Montanaro (montanaro)
Date: 2002-05-22 12:46
Message:
Logged In: YES
user_id=44345
new patch - don't know why running the test suite didn't catch
the NameError...
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=559288&group_id=5470