[Python-checkins] CVS: python/dist/src/Include Python.h,2.27,2.28 object.h,2.65,2.66 pyport.h,2.18,2.19

Tim Peters python-dev@python.org
Sat, 9 Sep 2000 18:02:45 -0700


Update of /cvsroot/python/python/dist/src/Include
In directory slayer.i.sourceforge.net:/tmp/cvs-serv415/python/dist/src/include

Modified Files:
	Python.h object.h pyport.h 
Log Message:
Close SF bug 110826:  a complaint about the way Python #define'd NULL.
It's hard to sort out what the bug was, exactly.  So, Big Hammer:

1. Python shouldn't be in the business of #define'ing NULL, period.
2. Users of the Python C API shouldn't be in the business of not including
   Python.h, period.

Hence:

1. Removed all #define's of NULL in Python source code (pyport.h and
   object.h).
2. Since we're *relying* on stdio.h defining NULL, put an #error in
   Python.h after its #include of stdio.h if NULL isn't defined then.


Index: Python.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/Python.h,v
retrieving revision 2.27
retrieving revision 2.28
diff -C2 -r2.27 -r2.28
*** Python.h	2000/09/01 23:29:26	2.27
--- Python.h	2000/09/10 01:02:41	2.28
***************
*** 37,40 ****
--- 37,44 ----
  
  #include <stdio.h>
+ #ifndef NULL
+ #   error "Python.h requires that stdio.h define NULL."
+ #endif
+ 
  #include <string.h>
  #include <errno.h>

Index: object.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/object.h,v
retrieving revision 2.65
retrieving revision 2.66
diff -C2 -r2.65 -r2.66
*** object.h	2000/09/01 23:29:26	2.65
--- object.h	2000/09/10 01:02:41	2.66
***************
*** 424,434 ****
  #define Py_XDECREF(op) if ((op) == NULL) ; else Py_DECREF(op)
  
- /* Definition of NULL, so you don't have to include <stdio.h> */
- 
- #ifndef NULL
- #define NULL 0
- #endif
- 
- 
  /*
  _Py_NoneStruct is an object of undefined type which can be used in contexts
--- 424,427 ----

Index: pyport.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/pyport.h,v
retrieving revision 2.18
retrieving revision 2.19
diff -C2 -r2.18 -r2.19
*** pyport.h	2000/09/08 15:45:34	2.18
--- pyport.h	2000/09/10 01:02:41	2.19
***************
*** 314,321 ****
  #endif
  
- #ifndef NULL
- #define NULL ((void *)0)
- #endif
- 
  #ifdef MALLOC_ZERO_RETURNS_NULL
  /* XXX Always allocate one extra byte, since some malloc's return NULL
--- 314,317 ----