[Patches] [ python-Patches-590119 ] types.BoolType

noreply@sourceforge.net noreply@sourceforge.net
Thu, 12 Sep 2002 08:04:06 -0700


Patches item #590119, was opened at 2002-08-02 09:26
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=590119&group_id=5470

Category: Library (Lib)
Group: Python 2.3
>Status: Closed
>Resolution: Rejected
Priority: 4
Submitted By: Markus F.X.J. Oberhumer (mfx)
Assigned to: Guido van Rossum (gvanrossum)
Summary: types.BoolType

Initial Comment:
I know that types is getting deprecated, but for
orthogonality we really should have a BoolType. Also,
IMHO we should _not_ have a BooleanType (or
DictionaryType), but that might break code.

Index: types.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/types.py,v
retrieving revision 1.29
diff -u -r1.29 types.py
--- types.py    14 Jun 2002 20:41:13 -0000      1.29
+++ types.py    2 Aug 2002 13:22:22 -0000
@@ -16,7 +16,7 @@
 IntType = int
 LongType = long
 FloatType = float
-BooleanType = bool
+BoolType = BooleanType = bool
 try:
     ComplexType = complex
 except NameError:


----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-09-12 11:04

Message:
Logged In: YES 
user_id=6380

I see no bug here.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2002-09-12 11:02

Message:
Logged In: YES 
user_id=21627

The requirement that 

getattr(types, X).__name__.title()+"Type" == X for all X in
dir(types) 
if endswith("Type")

is reasonable; the following types currently break that:

BooleanType (bool)
BuiltinFunctionType (builtin_function_or_method)
BuiltinMethodType (builtin_function_or_method)
ClassType (classobj)
DictProxyType (dictproxy)
DictionaryType (dict)
LambdaType (function)
MethodType (instancemethod)
NoneType (NoneType)
StringType (str)
UnboundMethodType (instancemethod)
XRangeType (xrange)

If it is desirable tha the predicate above holds, then I'd
encourage the following fix:
- produce a test case that tests the predicate
- provide a patch that makes the test pass.

It certainly needs to be taken into account that some names
are synonyms of others, so they can be removed, so the test
should deal with that (by accepting cases where the
canonical type name is in types); cases that only show case
problems (xrange, dictproxy) probably can also pass as-is.

If that property is not desirable, I again ask what the
problem is.

If BoolType is added (for whatever reason), I agree with
Raymond that removing BooleanType is sensible.




----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2002-09-12 10:43

Message:
Logged In: YES 
user_id=80475

I think the OP doesn't have a bugfix in mind,
he is trying to keep a parallel to the line:

DictType = DictionaryType = dict

DictionaryType had already been in out in Py2.1.
Tim added DictType to maintain the naming rule:
    type(obj).__name__ .title() + "Type"

Since we are not already locked into BooleanType,
a better solution would be:

-BooleanType = bool 
+BoolType = bool 

Guido, do you care if I make this change or is there a 
reason for keeping BooleanType?

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2002-08-04 04:59

Message:
Logged In: YES 
user_id=21627

What bug does this fix?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=590119&group_id=5470