Patch #661760: Cygwin auto-import module patch

The attached patch enables shared extension
modules to build cleanly under Cygwin without
moving the static initialization of certain function
pointers (i.e., ones exported from the Python
DLL core) to a module initialization function.

Additionally, this patch fixes the modules that
have been changed in the past to accommodate
Cygwin.
This commit is contained in:
Jason Tishler 2003-01-06 12:41:26 +00:00
parent f2128b004c
commit fb8595df4f
8 changed files with 33 additions and 60 deletions

View file

@ -429,7 +429,11 @@ and both these use __declspec()
# else /* Py_BUILD_CORE */ # else /* Py_BUILD_CORE */
/* Building an extension module, or an embedded situation */ /* Building an extension module, or an embedded situation */
/* public Python functions and data are imported */ /* public Python functions and data are imported */
# define PyAPI_FUNC(RTYPE) __declspec(dllimport) RTYPE /* Under Cygwin, auto-import functions to prevent compilation */
/* failures similar to http://python.org/doc/FAQ.html#3.24 */
# if !defined(__CYGWIN__)
# define PyAPI_FUNC(RTYPE) __declspec(dllimport) RTYPE
# endif /* !__CYGWIN__ */
# define PyAPI_DATA(RTYPE) extern __declspec(dllimport) RTYPE # define PyAPI_DATA(RTYPE) extern __declspec(dllimport) RTYPE
/* module init functions outside the core must be exported */ /* module init functions outside the core must be exported */
# if defined(__cplusplus) # if defined(__cplusplus)

View file

@ -1258,7 +1258,7 @@ static PyTypeObject ProfilerType = {
0, /* tp_hash */ 0, /* tp_hash */
0, /* tp_call */ 0, /* tp_call */
0, /* tp_str */ 0, /* tp_str */
0, /* tp_getattro */ PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */ 0, /* tp_setattro */
0, /* tp_as_buffer */ 0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */ Py_TPFLAGS_DEFAULT, /* tp_flags */
@ -1343,7 +1343,7 @@ static PyTypeObject LogReaderType = {
0, /* tp_hash */ 0, /* tp_hash */
0, /* tp_call */ 0, /* tp_call */
0, /* tp_str */ 0, /* tp_str */
0, /* tp_getattro */ PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */ 0, /* tp_setattro */
0, /* tp_as_buffer */ 0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */ Py_TPFLAGS_DEFAULT, /* tp_flags */
@ -1634,9 +1634,7 @@ init_hotshot(void)
PyObject *module; PyObject *module;
LogReaderType.ob_type = &PyType_Type; LogReaderType.ob_type = &PyType_Type;
LogReaderType.tp_getattro = PyObject_GenericGetAttr;
ProfilerType.ob_type = &PyType_Type; ProfilerType.ob_type = &PyType_Type;
ProfilerType.tp_getattro = PyObject_GenericGetAttr;
module = Py_InitModule("_hotshot", functions); module = Py_InitModule("_hotshot", functions);
if (module != NULL) { if (module != NULL) {
char *s = get_version_string(); char *s = get_version_string();

View file

@ -486,7 +486,7 @@ static PyTypeObject Random_Type = {
0, /*tp_hash*/ 0, /*tp_hash*/
0, /*tp_call*/ 0, /*tp_call*/
0, /*tp_str*/ 0, /*tp_str*/
0, /*tp_getattro*/ PyObject_GenericGetAttr, /*tp_getattro*/
0, /*tp_setattro*/ 0, /*tp_setattro*/
0, /*tp_as_buffer*/ 0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
@ -506,9 +506,9 @@ static PyTypeObject Random_Type = {
0, /*tp_descr_set*/ 0, /*tp_descr_set*/
0, /*tp_dictoffset*/ 0, /*tp_dictoffset*/
0, /*tp_init*/ 0, /*tp_init*/
0, /*tp_alloc*/ PyType_GenericAlloc, /*tp_alloc*/
random_new, /*tp_new*/ random_new, /*tp_new*/
0, /*tp_free*/ _PyObject_Del, /*tp_free*/
0, /*tp_is_gc*/ 0, /*tp_is_gc*/
}; };
@ -520,9 +520,6 @@ init_random(void)
{ {
PyObject *m; PyObject *m;
Random_Type.tp_getattro = PyObject_GenericGetAttr;
Random_Type.tp_alloc = PyType_GenericAlloc;
Random_Type.tp_free = _PyObject_Del;
if (PyType_Ready(&Random_Type) < 0) if (PyType_Ready(&Random_Type) < 0)
return; return;
m = Py_InitModule3("_random", NULL, module_doc); m = Py_InitModule3("_random", NULL, module_doc);

View file

@ -834,7 +834,7 @@ statichere PyTypeObject PyTclObject_Type = {
0, /*tp_hash*/ 0, /*tp_hash*/
0, /*tp_call*/ 0, /*tp_call*/
(reprfunc)PyTclObject_str, /*tp_str*/ (reprfunc)PyTclObject_str, /*tp_str*/
0, /*tp_getattro*/ PyObject_GenericGetAttr,/*tp_getattro*/
0, /*tp_setattro*/ 0, /*tp_setattro*/
0, /*tp_as_buffer*/ 0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT, /*tp_flags*/ Py_TPFLAGS_DEFAULT, /*tp_flags*/
@ -2931,7 +2931,6 @@ init_tkinter(void)
PyDict_SetItemString(d, "TkttType", (PyObject *)&Tktt_Type); PyDict_SetItemString(d, "TkttType", (PyObject *)&Tktt_Type);
PyTclObject_Type.ob_type = &PyType_Type; PyTclObject_Type.ob_type = &PyType_Type;
PyTclObject_Type.tp_getattro = &PyObject_GenericGetAttr;
PyDict_SetItemString(d, "Tcl_Obj", (PyObject *)&PyTclObject_Type); PyDict_SetItemString(d, "Tcl_Obj", (PyObject *)&PyTclObject_Type);
#ifdef TK_AQUA #ifdef TK_AQUA

View file

@ -13,8 +13,6 @@
#endif /* DONT_HAVE_SYS_TYPES_H */ #endif /* DONT_HAVE_SYS_TYPES_H */
#endif /* !STDC_HEADERS */ #endif /* !STDC_HEADERS */
#define DELAYED(X) 0
struct arrayobject; /* Forward */ struct arrayobject; /* Forward */
/* All possible arraydescr values are defined in the vector "descriptors" /* All possible arraydescr values are defined in the vector "descriptors"
@ -1842,7 +1840,7 @@ static PyTypeObject Arraytype = {
0, /* tp_hash */ 0, /* tp_hash */
0, /* tp_call */ 0, /* tp_call */
0, /* tp_str */ 0, /* tp_str */
DELAYED(PyObject_GenericGetAttr), /* tp_getattro */ PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */ 0, /* tp_setattro */
&array_as_buffer, /* tp_as_buffer*/ &array_as_buffer, /* tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
@ -1862,9 +1860,9 @@ static PyTypeObject Arraytype = {
0, /* tp_descr_set */ 0, /* tp_descr_set */
0, /* tp_dictoffset */ 0, /* tp_dictoffset */
0, /* tp_init */ 0, /* tp_init */
DELAYED(PyType_GenericAlloc), /* tp_alloc */ PyType_GenericAlloc, /* tp_alloc */
array_new, /* tp_new */ array_new, /* tp_new */
DELAYED(PyObject_Del), /* tp_free */ PyObject_Del, /* tp_free */
}; };
/* No functions in array module. */ /* No functions in array module. */
@ -1879,9 +1877,6 @@ initarray(void)
PyObject *m; PyObject *m;
Arraytype.ob_type = &PyType_Type; Arraytype.ob_type = &PyType_Type;
Arraytype.tp_getattro = PyObject_GenericGetAttr;
Arraytype.tp_alloc = PyType_GenericAlloc;
Arraytype.tp_free = PyObject_Del;
m = Py_InitModule3("array", a_methods, module_doc); m = Py_InitModule3("array", a_methods, module_doc);
Py_INCREF((PyObject *)&Arraytype); Py_INCREF((PyObject *)&Arraytype);

View file

@ -1387,8 +1387,8 @@ static PyTypeObject BZ2File_Type = {
0, /*tp_hash*/ 0, /*tp_hash*/
0, /*tp_call*/ 0, /*tp_call*/
0, /*tp_str*/ 0, /*tp_str*/
0, /*tp_getattro*/ PyObject_GenericGetAttr,/*tp_getattro*/
0, /*tp_setattro*/ PyObject_GenericSetAttr,/*tp_setattro*/
0, /*tp_as_buffer*/ 0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/
BZ2File__doc__, /*tp_doc*/ BZ2File__doc__, /*tp_doc*/
@ -1407,9 +1407,9 @@ static PyTypeObject BZ2File_Type = {
0, /*tp_descr_set*/ 0, /*tp_descr_set*/
0, /*tp_dictoffset*/ 0, /*tp_dictoffset*/
(initproc)BZ2File_init, /*tp_init*/ (initproc)BZ2File_init, /*tp_init*/
0, /*tp_alloc*/ PyType_GenericAlloc, /*tp_alloc*/
0, /*tp_new*/ 0, /*tp_new*/
0, /*tp_free*/ _PyObject_Del, /*tp_free*/
0, /*tp_is_gc*/ 0, /*tp_is_gc*/
}; };
@ -1652,8 +1652,8 @@ static PyTypeObject BZ2Comp_Type = {
0, /*tp_hash*/ 0, /*tp_hash*/
0, /*tp_call*/ 0, /*tp_call*/
0, /*tp_str*/ 0, /*tp_str*/
0, /*tp_getattro*/ PyObject_GenericGetAttr,/*tp_getattro*/
0, /*tp_setattro*/ PyObject_GenericSetAttr,/*tp_setattro*/
0, /*tp_as_buffer*/ 0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/
BZ2Comp__doc__, /*tp_doc*/ BZ2Comp__doc__, /*tp_doc*/
@ -1672,9 +1672,9 @@ static PyTypeObject BZ2Comp_Type = {
0, /*tp_descr_set*/ 0, /*tp_descr_set*/
0, /*tp_dictoffset*/ 0, /*tp_dictoffset*/
(initproc)BZ2Comp_init, /*tp_init*/ (initproc)BZ2Comp_init, /*tp_init*/
0, /*tp_alloc*/ PyType_GenericAlloc, /*tp_alloc*/
0, /*tp_new*/ PyType_GenericNew, /*tp_new*/
0, /*tp_free*/ _PyObject_Del, /*tp_free*/
0, /*tp_is_gc*/ 0, /*tp_is_gc*/
}; };
@ -1869,8 +1869,8 @@ static PyTypeObject BZ2Decomp_Type = {
0, /*tp_hash*/ 0, /*tp_hash*/
0, /*tp_call*/ 0, /*tp_call*/
0, /*tp_str*/ 0, /*tp_str*/
0, /*tp_getattro*/ PyObject_GenericGetAttr,/*tp_getattro*/
0, /*tp_setattro*/ PyObject_GenericSetAttr,/*tp_setattro*/
0, /*tp_as_buffer*/ 0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/
BZ2Decomp__doc__, /*tp_doc*/ BZ2Decomp__doc__, /*tp_doc*/
@ -1889,9 +1889,9 @@ static PyTypeObject BZ2Decomp_Type = {
0, /*tp_descr_set*/ 0, /*tp_descr_set*/
0, /*tp_dictoffset*/ 0, /*tp_dictoffset*/
(initproc)BZ2Decomp_init, /*tp_init*/ (initproc)BZ2Decomp_init, /*tp_init*/
0, /*tp_alloc*/ PyType_GenericAlloc, /*tp_alloc*/
0, /*tp_new*/ PyType_GenericNew, /*tp_new*/
0, /*tp_free*/ _PyObject_Del, /*tp_free*/
0, /*tp_is_gc*/ 0, /*tp_is_gc*/
}; };
@ -2089,24 +2089,9 @@ initbz2(void)
BZ2File_Type.ob_type = &PyType_Type; BZ2File_Type.ob_type = &PyType_Type;
BZ2File_Type.tp_base = &PyFile_Type; BZ2File_Type.tp_base = &PyFile_Type;
BZ2File_Type.tp_new = PyFile_Type.tp_new; BZ2File_Type.tp_new = PyFile_Type.tp_new;
BZ2File_Type.tp_getattro = PyObject_GenericGetAttr;
BZ2File_Type.tp_setattro = PyObject_GenericSetAttr;
BZ2File_Type.tp_alloc = PyType_GenericAlloc;
BZ2File_Type.tp_free = _PyObject_Del;
BZ2Comp_Type.ob_type = &PyType_Type; BZ2Comp_Type.ob_type = &PyType_Type;
BZ2Comp_Type.tp_getattro = PyObject_GenericGetAttr;
BZ2Comp_Type.tp_setattro = PyObject_GenericSetAttr;
BZ2Comp_Type.tp_alloc = PyType_GenericAlloc;
BZ2Comp_Type.tp_new = PyType_GenericNew;
BZ2Comp_Type.tp_free = _PyObject_Del;
BZ2Decomp_Type.ob_type = &PyType_Type; BZ2Decomp_Type.ob_type = &PyType_Type;
BZ2Decomp_Type.tp_getattro = PyObject_GenericGetAttr;
BZ2Decomp_Type.tp_setattro = PyObject_GenericSetAttr;
BZ2Decomp_Type.tp_alloc = PyType_GenericAlloc;
BZ2Decomp_Type.tp_new = PyType_GenericNew;
BZ2Decomp_Type.tp_free = _PyObject_Del;
m = Py_InitModule3("bz2", bz2_methods, bz2__doc__); m = Py_InitModule3("bz2", bz2_methods, bz2__doc__);

View file

@ -2543,8 +2543,8 @@ static PyTypeObject Picklertype = {
0, /* tp_hash */ 0, /* tp_hash */
0, /* tp_call */ 0, /* tp_call */
0, /* tp_str */ 0, /* tp_str */
0, /* set below */ /* tp_getattro */ PyObject_GenericGetAttr, /* tp_getattro */
0, /* set below */ /* tp_setattro */ PyObject_GenericSetAttr, /* tp_setattro */
0, /* tp_as_buffer */ 0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
Picklertype__doc__, /* tp_doc */ Picklertype__doc__, /* tp_doc */
@ -4808,8 +4808,6 @@ initcPickle(void)
PyObject *compatible_formats; PyObject *compatible_formats;
Picklertype.ob_type = &PyType_Type; Picklertype.ob_type = &PyType_Type;
Picklertype.tp_getattro = PyObject_GenericGetAttr;
Picklertype.tp_setattro = PyObject_GenericSetAttr;
Unpicklertype.ob_type = &PyType_Type; Unpicklertype.ob_type = &PyType_Type;
PdataType.ob_type = &PyType_Type; PdataType.ob_type = &PyType_Type;

View file

@ -2115,7 +2115,7 @@ static PyTypeObject sock_type = {
0, /* tp_hash */ 0, /* tp_hash */
0, /* tp_call */ 0, /* tp_call */
0, /* tp_str */ 0, /* tp_str */
0, /* set below */ /* tp_getattro */ PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */ 0, /* tp_setattro */
0, /* tp_as_buffer */ 0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
@ -2135,9 +2135,9 @@ static PyTypeObject sock_type = {
0, /* tp_descr_set */ 0, /* tp_descr_set */
0, /* tp_dictoffset */ 0, /* tp_dictoffset */
sock_initobj, /* tp_init */ sock_initobj, /* tp_init */
0, /* set below */ /* tp_alloc */ PyType_GenericAlloc, /* tp_alloc */
sock_new, /* tp_new */ sock_new, /* tp_new */
0, /* set below */ /* tp_free */ PyObject_Del, /* tp_free */
}; };
@ -3147,9 +3147,6 @@ init_socket(void)
return; return;
sock_type.ob_type = &PyType_Type; sock_type.ob_type = &PyType_Type;
sock_type.tp_getattro = PyObject_GenericGetAttr;
sock_type.tp_alloc = PyType_GenericAlloc;
sock_type.tp_free = PyObject_Del;
m = Py_InitModule3(PySocket_MODULE_NAME, m = Py_InitModule3(PySocket_MODULE_NAME,
socket_methods, socket_methods,
socket_doc); socket_doc);