This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Use builtin boolean if present
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: skip.montanaro Nosy List: loewis, skip.montanaro
Priority: normal Keywords: patch

Created on 2002-05-22 17:34 by skip.montanaro, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
xmlrpclib.diff skip.montanaro, 2003-01-22 17:10
Messages (9)
msg40089 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2002-05-22 17:34
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
msg40090 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2002-05-22 17:46
Logged In: YES 
user_id=44345

new patch - don't know why running the test suite didn't catch
the NameError...
msg40091 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2002-08-02 17:03
Logged In: YES 
user_id=44345

updated patch which avoids using types.BooleanType since there was so 
much pushback on the idea.
msg40092 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-10-07 21:44
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
msg40093 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2003-01-22 15:29
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.
msg40094 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2003-01-22 16:09
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.
msg40095 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2003-01-22 17:10
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.
msg40096 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2003-01-22 17:28
Logged In: YES 
user_id=21627

The patch is fine. Please apply it.
msg40097 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2003-01-22 18:21
Logged In: YES 
user_id=44345

checked in as xmlrpclib.py 1.23 (no new test case needed)
History
Date User Action Args
2022-04-10 16:05:20adminsetgithub: 36636
2002-05-22 17:34:57skip.montanarocreate