[Python-Dev] PyString_GET_SIZE() (was: CVS: python/dist/src/Objects classobject.c,2.89,2.90 object.c,2.72,2.73)

Greg Stein gstein@lyra.org
Wed, 28 Jun 2000 15:17:58 -0700


On Wed, Jun 28, 2000 at 02:57:20PM -0700, Guido van Rossum wrote:
> Update of /cvsroot/python/python/dist/src/Objects
> In directory slayer.i.sourceforge.net:/tmp/cvs-serv5838
> 
> Modified Files:
> 	classobject.c object.c 
> Log Message:
> Trent Mick: change a few casts for Win64 compatibility.
> 
> 
> Index: classobject.c
> ===================================================================
> RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v
> retrieving revision 2.89
> retrieving revision 2.90
> diff -C2 -r2.89 -r2.90
> *** classobject.c	2000/06/23 19:37:01	2.89
> --- classobject.c	2000/06/28 21:57:18	2.90
> ***************
> *** 284,288 ****
>   	if (v == NULL || !PyString_Check(v))
>   		return "__name__ must be a string object";
> ! 	if ((long)strlen(PyString_AS_STRING(v)) != PyString_GET_SIZE(v))
>   		return "__name__ must not contain null bytes";
>   	set_slot(&c->cl_name, v);
> --- 284,288 ----
>   	if (v == NULL || !PyString_Check(v))
>   		return "__name__ must be a string object";
> ! 	if (strlen(PyString_AS_STRING(v)) != (size_t)PyString_GET_SIZE(v))
>   		return "__name__ must not contain null bytes";
>   	set_slot(&c->cl_name, v);

Actually, it would seem to make more sense to place the cast *inside* the
PyString_GET_SIZE() macro. That is the "true" semantic for GET_SIZE.

May as well start some ANSI-fication while we can...

Guido: any problem with my changing the macro?

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/