[Python-bugs-list] SWIG's embed.i and Python 1.5.2 on WinNT (PR#25)

fp@contact.de fp@contact.de
Wed, 14 Jul 1999 11:35:05 -0400 (EDT)


Full_Name: Frank Patz
Version: 1.5.2
OS: WinNT 4.0
Submission from: b82.bitz.uni-bremen.de (134.102.49.82)


PYTHON15.DLL does not export "initimp", "initsha", "PyMarshal_Init" 
and "PyImport_Inittab". Those are needed to use Swig's embed.i on
Windows. I had to patch PC/config.c, Python/import.c, Python/marshal.c
and Modules/shamodule.c to get everything working. I also had to 
apply a small change to SWIG's embed.i.

*** PC\config.c	Wed Jul 14 17:10:04 1999
***************
*** 73,79 ****
  extern void PyMarshal_Init();
  extern void initimp();
  
! struct _inittab _PyImport_Inittab[] = {
  
          {"array", initarray},
  #ifdef MS_WINDOWS
--- 73,79 ----
  extern void PyMarshal_Init();
  extern void initimp();
  
! DL_EXPORT(struct _inittab) _PyImport_Inittab[] = {
  
          {"array", initarray},
  #ifdef MS_WINDOWS

*** Python/import.c	Wed Jul 14 17:08:24 1999
***************
*** 92,98 ****
  /* This table is defined in config.c: */
  extern struct _inittab _PyImport_Inittab[];
  
! struct _inittab *PyImport_Inittab = _PyImport_Inittab;
  
  /* Initialize things */
  
--- 92,98 ----
  /* This table is defined in config.c: */
  extern struct _inittab _PyImport_Inittab[];
  
! DL_EXPORT(struct _inittab *) PyImport_Inittab = _PyImport_Inittab;
  
  /* Initialize things */
  
***************
*** 2326,2332 ****
  	return err;
  }
  
! void
  initimp()
  {
  	PyObject *m, *d;
--- 2326,2332 ----
  	return err;
  }
  
! DL_EXPORT(void)
  initimp()
  {
  	PyObject *m, *d;

*** Python/marshal.c	Wed Jul 14 17:11:10 1999
***************
*** 766,772 ****
  	{NULL,		NULL}		/* sentinel */
  };
  
! void
  PyMarshal_Init()
  {
  	(void) Py_InitModule("marshal", marshal_methods);
--- 766,772 ----
  	{NULL,		NULL}		/* sentinel */
  };
  
! DL_EXPORT(void)
  PyMarshal_Init()
  {
  	(void) Py_InitModule("marshal", marshal_methods);

*** Modules/shamodule.c	Wed Jul 14 17:12:32 1999
***************
*** 582,588 ****
  	if (o!=NULL) PyDict_SetItemString(d,n,o); \
  	Py_XDECREF(o); }
  
! void
  initsha()
  {
  	PyObject *d, *m;
--- 582,588 ----
  	if (o!=NULL) PyDict_SetItemString(d,n,o); \
  	Py_XDECREF(o); }
  
! DL_EXPORT(void)
  initsha()
  {
  	PyObject *d, *m;



This is the patch for SWIG's embed.i

*** swig_lib/python/embed.i	Wed Jul 14 17:14:20 1999
***************
*** 99,105 ****
  }
  #endif
  
! /* extern struct _inittab *PyImport_Inittab; */
  
  int
  main(int argc, char **argv) {
--- 99,105 ----
  }
  #endif
  
! extern struct _inittab *PyImport_Inittab;
  
  int
  main(int argc, char **argv) {