[Zope3-dev] Zope3 vs CVS Python

Guido van Rossum guido@python.org
Tue, 06 Aug 2002 10:51:49 -0400


> >>That brings me to a slightly different topic that still fits the subject 
> >>line.  If anyone can help, I'd like to understand why gcc 2.95.3 under 
> >>Wine doesn't think PyType_GenericNew, PyType_GenericAlloc, 
> >>_PyObject_GC_Del are constants.  Compiling the Zope3 modules that use 
> >>these constants in the PyTypeObject struct results in errors like this:
> >>
> >>wrapper.c:228: initializer element is not constant
> >>wrapper.c:228: (near initialization for `WrapperType.tp_alloc')
> >>wrapper.c:230: initializer element is not constant
> >>wrapper.c:230: (near initialization for `WrapperType.tp_free')
> >>error: command 'gcc' failed with exit status 1
> > 
> > Hm.  This works with GCC on Unix, and also works with MSVC on Windows.
> > But if you feel that GCC on Windows is an important target, can you
> > please check in a fix?
> 
> Ok, I'll check it in soon.  GCC on Windows lets us give an answer to all 
> the folks on the mailing lists who want to use Zope source releases and 
> Zope CVS without buying and learning MSVC.
> 
>  > It's a fine line, initializing structures with
> > addresses defined in different files often doesn't seem to work on
> > Windows.  MSVC has this problem only for the address of external
> > data, I believe -- over the years we've grown a whole set of ways to
> > deal with the fact that you can't initialize the ob_type field of a
> > type struct with &PyType_Type on Windows...
> 
> Ok.  I didn't want to slightly muck up the code unless there's no better 
> way.

I don't think there is.  The socket module does the same thing; at the
top of init_socket(), there are these lines:

	PySocketSock_Type.ob_type = &PyType_Type;
	PySocketSock_Type.tp_getattro = PyObject_GenericGetAttr;
	PySocketSock_Type.tp_alloc = PyType_GenericAlloc;
	PySocketSock_Type.tp_free = _PyObject_Del;

--Guido van Rossum (home page: http://www.python.org/~guido/)