[Python-checkins] CVS: python/dist/src/Include Python.h,2.44,2.45 intobject.h,2.24,2.25 object.h,2.99,2.100
Guido van Rossum
gvanrossum@users.sourceforge.net
Wed, 03 Apr 2002 14:41:52 -0800
Update of /cvsroot/python/python/dist/src/Include
In directory usw-pr-cvs1:/tmp/cvs-serv31419/Include
Modified Files:
Python.h intobject.h object.h
Log Message:
Add the 'bool' type and its values 'False' and 'True', as described in
PEP 285. Everything described in the PEP is here, and there is even
some documentation. I had to fix 12 unit tests; all but one of these
were printing Boolean outcomes that changed from 0/1 to False/True.
(The exception is test_unicode.py, which did a type(x) == type(y)
style comparison. I could've fixed that with a single line using
issubtype(x, type(y)), but instead chose to be explicit about those
places where a bool is expected.
Still to do: perhaps more documentation; change standard library
modules to return False/True from predicates.
Index: Python.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/Python.h,v
retrieving revision 2.44
retrieving revision 2.45
diff -C2 -d -r2.44 -r2.45
*** Python.h 25 Mar 2002 22:21:58 -0000 2.44
--- Python.h 3 Apr 2002 22:41:50 -0000 2.45
***************
*** 80,83 ****
--- 80,84 ----
#include "unicodeobject.h"
#include "intobject.h"
+ #include "boolobject.h"
#include "longobject.h"
#include "floatobject.h"
Index: intobject.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/intobject.h,v
retrieving revision 2.24
retrieving revision 2.25
diff -C2 -d -r2.24 -r2.25
*** intobject.h 10 Sep 2001 20:52:47 -0000 2.24
--- intobject.h 3 Apr 2002 22:41:50 -0000 2.25
***************
*** 39,57 ****
extern DL_IMPORT(long) PyInt_GetMax(void);
-
- /*
- False and True are special intobjects used by Boolean expressions.
- All values of type Boolean must point to either of these; but in
- contexts where integers are required they are integers (valued 0 and 1).
- Hope these macros don't conflict with other people's.
-
- Don't forget to apply Py_INCREF() when returning True or False!!!
- */
-
- extern DL_IMPORT(PyIntObject) _Py_ZeroStruct, _Py_TrueStruct; /* Don't use these directly */
-
- #define Py_False ((PyObject *) &_Py_ZeroStruct)
- #define Py_True ((PyObject *) &_Py_TrueStruct)
-
/* Macro, trading safety for speed */
#define PyInt_AS_LONG(op) (((PyIntObject *)(op))->ob_ival)
--- 39,42 ----
Index: object.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/object.h,v
retrieving revision 2.99
retrieving revision 2.100
diff -C2 -d -r2.99 -r2.100
*** object.h 8 Dec 2001 18:02:50 -0000 2.99
--- object.h 3 Apr 2002 22:41:50 -0000 2.100
***************
*** 532,537 ****
if (--_Py_RefTotal, 0 < (--((op)->ob_refcnt))) ; \
else if (0 == (op)->ob_refcnt) _Py_Dealloc( (PyObject*)(op)); \
! else (void)fprintf( stderr, "%s:%i negative ref count %i\n", \
! __FILE__, __LINE__, (op)->ob_refcnt)
#else /* !Py_REF_DEBUG */
--- 532,537 ----
if (--_Py_RefTotal, 0 < (--((op)->ob_refcnt))) ; \
else if (0 == (op)->ob_refcnt) _Py_Dealloc( (PyObject*)(op)); \
! else ((void)fprintf( stderr, "%s:%i negative ref count %i\n", \
! __FILE__, __LINE__, (op)->ob_refcnt), abort())
#else /* !Py_REF_DEBUG */