]> granicus.if.org Git - python/commitdiff
Patch #661760: Cygwin auto-import module patch
authorJason Tishler <jason@tishler.net>
Mon, 6 Jan 2003 12:41:26 +0000 (12:41 +0000)
committerJason Tishler <jason@tishler.net>
Mon, 6 Jan 2003 12:41:26 +0000 (12:41 +0000)
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.

Include/pyport.h
Modules/_hotshot.c
Modules/_randommodule.c
Modules/_tkinter.c
Modules/arraymodule.c
Modules/bz2module.c
Modules/cPickle.c
Modules/socketmodule.c

index 6a9b7e6fd4b7a293f733a4f43f919021867f390a..09fc693655a004f2f19a2ccc49f4a80a22514763 100644 (file)
@@ -429,7 +429,11 @@ and both these use __declspec()
 #              else /* Py_BUILD_CORE */
                        /* Building an extension module, or an embedded situation */
                        /* 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
                        /* module init functions outside the core must be exported */
 #                      if defined(__cplusplus)
index 53130d65a5bb4c769c7fd688c0aaf90a58be0036..83222ce3ca0d56750ff2c04141f804bf3b3305e8 100644 (file)
@@ -1258,7 +1258,7 @@ static PyTypeObject ProfilerType = {
     0,                                 /* tp_hash              */
     0,                                 /* tp_call              */
     0,                                 /* tp_str               */
-    0,                                 /* tp_getattro          */
+    PyObject_GenericGetAttr,           /* tp_getattro          */
     0,                                 /* tp_setattro          */
     0,                                 /* tp_as_buffer         */
     Py_TPFLAGS_DEFAULT,                        /* tp_flags             */
@@ -1343,7 +1343,7 @@ static PyTypeObject LogReaderType = {
     0,                                 /* tp_hash              */
     0,                                 /* tp_call              */
     0,                                 /* tp_str               */
-    0,                                 /* tp_getattro          */
+    PyObject_GenericGetAttr,           /* tp_getattro          */
     0,                                 /* tp_setattro          */
     0,                                 /* tp_as_buffer         */
     Py_TPFLAGS_DEFAULT,                        /* tp_flags             */
@@ -1634,9 +1634,7 @@ init_hotshot(void)
     PyObject *module;
 
     LogReaderType.ob_type = &PyType_Type;
-    LogReaderType.tp_getattro = PyObject_GenericGetAttr;
     ProfilerType.ob_type = &PyType_Type;
-    ProfilerType.tp_getattro = PyObject_GenericGetAttr;
     module = Py_InitModule("_hotshot", functions);
     if (module != NULL) {
         char *s = get_version_string();
index 1b96dc8c35453450b47ab64059d70907458ae559..35f10a5d36662b4992613083c82d1aa7ced6cfce 100644 (file)
@@ -486,7 +486,7 @@ static PyTypeObject Random_Type = {
        0,                              /*tp_hash*/
        0,                              /*tp_call*/
        0,                              /*tp_str*/
-       0,                              /*tp_getattro*/
+       PyObject_GenericGetAttr,        /*tp_getattro*/
        0,                              /*tp_setattro*/
        0,                              /*tp_as_buffer*/
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,       /*tp_flags*/
@@ -506,9 +506,9 @@ static PyTypeObject Random_Type = {
        0,                              /*tp_descr_set*/
        0,                              /*tp_dictoffset*/
        0,                              /*tp_init*/
-       0,                              /*tp_alloc*/
+       PyType_GenericAlloc,            /*tp_alloc*/
        random_new,                     /*tp_new*/
-       0,                              /*tp_free*/
+       _PyObject_Del,                  /*tp_free*/
        0,                              /*tp_is_gc*/
 };
 
@@ -520,9 +520,6 @@ init_random(void)
 {
        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)
                return;
        m = Py_InitModule3("_random", NULL, module_doc);
index 21d62b1dfa6e6b069ec394b51c070d0421e210fb..1bb2d82a7cebd32e34e9bc9dc8296f63ef74bf1c 100644 (file)
@@ -834,7 +834,7 @@ statichere PyTypeObject PyTclObject_Type = {
        0,                      /*tp_hash*/
         0,                      /*tp_call*/
         (reprfunc)PyTclObject_str,        /*tp_str*/
-        0,                      /*tp_getattro*/
+        PyObject_GenericGetAttr,/*tp_getattro*/
         0,                      /*tp_setattro*/
         0,                      /*tp_as_buffer*/
         Py_TPFLAGS_DEFAULT,     /*tp_flags*/
@@ -2931,7 +2931,6 @@ init_tkinter(void)
        PyDict_SetItemString(d, "TkttType", (PyObject *)&Tktt_Type);
 
        PyTclObject_Type.ob_type = &PyType_Type;
-       PyTclObject_Type.tp_getattro = &PyObject_GenericGetAttr;
        PyDict_SetItemString(d, "Tcl_Obj", (PyObject *)&PyTclObject_Type);
 
 #ifdef TK_AQUA
index 933eae01bd0568d606682d4a68b851f7f412e835..03447cb9e382b4d4914e5f761baf7d90fae49518 100644 (file)
@@ -13,8 +13,6 @@
 #endif /* DONT_HAVE_SYS_TYPES_H */
 #endif /* !STDC_HEADERS */
 
-#define DELAYED(X)     0
-
 struct arrayobject; /* Forward */
 
 /* All possible arraydescr values are defined in the vector "descriptors"
@@ -1842,7 +1840,7 @@ static PyTypeObject Arraytype = {
        0,                                      /* tp_hash */
        0,                                      /* tp_call */
        0,                                      /* tp_str */
-       DELAYED(PyObject_GenericGetAttr),       /* tp_getattro */
+       PyObject_GenericGetAttr,                /* tp_getattro */
        0,                                      /* tp_setattro */
        &array_as_buffer,                       /* tp_as_buffer*/
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,  /* tp_flags */
@@ -1862,9 +1860,9 @@ static PyTypeObject Arraytype = {
        0,                                      /* tp_descr_set */
        0,                                      /* tp_dictoffset */
        0,                                      /* tp_init */
-       DELAYED(PyType_GenericAlloc),           /* tp_alloc */
+       PyType_GenericAlloc,                    /* tp_alloc */
        array_new,                              /* tp_new */
-       DELAYED(PyObject_Del),                  /* tp_free */
+       PyObject_Del,                           /* tp_free */
 };
 
 /* No functions in array module. */
@@ -1879,9 +1877,6 @@ initarray(void)
        PyObject *m;
 
        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);
 
         Py_INCREF((PyObject *)&Arraytype);
index d0383ac7ee48455747cc6d9970763f8258c7cf25..f358de7e91956e4b11be450344ec414aca9b7040 100644 (file)
@@ -1387,8 +1387,8 @@ static PyTypeObject BZ2File_Type = {
        0,                      /*tp_hash*/
         0,                      /*tp_call*/
         0,                      /*tp_str*/
-        0,                      /*tp_getattro*/
-        0,                      /*tp_setattro*/
+        PyObject_GenericGetAttr,/*tp_getattro*/
+        PyObject_GenericSetAttr,/*tp_setattro*/
         0,                      /*tp_as_buffer*/
         Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/
         BZ2File__doc__,         /*tp_doc*/
@@ -1407,9 +1407,9 @@ static PyTypeObject BZ2File_Type = {
         0,                      /*tp_descr_set*/
         0,                      /*tp_dictoffset*/
         (initproc)BZ2File_init, /*tp_init*/
-        0,                      /*tp_alloc*/
+        PyType_GenericAlloc,    /*tp_alloc*/
         0,                      /*tp_new*/
-       0,                      /*tp_free*/
+       _PyObject_Del,          /*tp_free*/
         0,                      /*tp_is_gc*/
 };
 
@@ -1652,8 +1652,8 @@ static PyTypeObject BZ2Comp_Type = {
        0,                      /*tp_hash*/
         0,                      /*tp_call*/
         0,                      /*tp_str*/
-        0,                      /*tp_getattro*/
-        0,                      /*tp_setattro*/
+        PyObject_GenericGetAttr,/*tp_getattro*/
+        PyObject_GenericSetAttr,/*tp_setattro*/
         0,                      /*tp_as_buffer*/
         Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/
         BZ2Comp__doc__,         /*tp_doc*/
@@ -1672,9 +1672,9 @@ static PyTypeObject BZ2Comp_Type = {
         0,                      /*tp_descr_set*/
         0,                      /*tp_dictoffset*/
         (initproc)BZ2Comp_init, /*tp_init*/
-        0,                      /*tp_alloc*/
-        0,                      /*tp_new*/
-       0,                      /*tp_free*/
+        PyType_GenericAlloc,    /*tp_alloc*/
+        PyType_GenericNew,      /*tp_new*/
+       _PyObject_Del,          /*tp_free*/
         0,                      /*tp_is_gc*/
 };
 
@@ -1869,8 +1869,8 @@ static PyTypeObject BZ2Decomp_Type = {
        0,                      /*tp_hash*/
         0,                      /*tp_call*/
         0,                      /*tp_str*/
-        0,                      /*tp_getattro*/
-        0,                      /*tp_setattro*/
+        PyObject_GenericGetAttr,/*tp_getattro*/
+        PyObject_GenericSetAttr,/*tp_setattro*/
         0,                      /*tp_as_buffer*/
         Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /*tp_flags*/
         BZ2Decomp__doc__,       /*tp_doc*/
@@ -1889,9 +1889,9 @@ static PyTypeObject BZ2Decomp_Type = {
         0,                      /*tp_descr_set*/
         0,                      /*tp_dictoffset*/
         (initproc)BZ2Decomp_init, /*tp_init*/
-        0,                      /*tp_alloc*/
-        0,                      /*tp_new*/
-       0,                      /*tp_free*/
+        PyType_GenericAlloc,    /*tp_alloc*/
+        PyType_GenericNew,      /*tp_new*/
+       _PyObject_Del,          /*tp_free*/
         0,                      /*tp_is_gc*/
 };
 
@@ -2089,24 +2089,9 @@ initbz2(void)
        BZ2File_Type.ob_type = &PyType_Type;
        BZ2File_Type.tp_base = &PyFile_Type;
        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.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.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__);
 
index 9412ad9718ca7e46229c4de1d6f4c46b89c80b03..24a9f131e7de26b6cfbd58e618b2e2866991f255 100644 (file)
@@ -2543,8 +2543,8 @@ static PyTypeObject Picklertype = {
     0,                                 /* tp_hash */
     0,                                 /* tp_call */
     0,                                 /* tp_str */
-    0, /* set below */                 /* tp_getattro */
-    0, /* set below */                 /* tp_setattro */
+    PyObject_GenericGetAttr,           /* tp_getattro */
+    PyObject_GenericSetAttr,           /* tp_setattro */
     0,                                 /* tp_as_buffer */
     Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
     Picklertype__doc__,                        /* tp_doc */
@@ -4808,8 +4808,6 @@ initcPickle(void)
        PyObject *compatible_formats;
 
        Picklertype.ob_type = &PyType_Type;
-       Picklertype.tp_getattro = PyObject_GenericGetAttr;
-       Picklertype.tp_setattro = PyObject_GenericSetAttr;
        Unpicklertype.ob_type = &PyType_Type;
        PdataType.ob_type = &PyType_Type;
 
index 1bbd9411a9669480aa132afb7da9ec6ef5e16a78..2b0b79607909fc360ba5fac7ba276aefef4e5725 100644 (file)
@@ -2115,7 +2115,7 @@ static PyTypeObject sock_type = {
        0,                                      /* tp_hash */
        0,                                      /* tp_call */
        0,                                      /* tp_str */
-       0,      /* set below */                 /* tp_getattro */
+       PyObject_GenericGetAttr,                /* tp_getattro */
        0,                                      /* tp_setattro */
        0,                                      /* tp_as_buffer */
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
@@ -2135,9 +2135,9 @@ static PyTypeObject sock_type = {
        0,                                      /* tp_descr_set */
        0,                                      /* tp_dictoffset */
        sock_initobj,                           /* tp_init */
-       0,      /* set below */                 /* tp_alloc */
+       PyType_GenericAlloc,                    /* tp_alloc */
        sock_new,                               /* tp_new */
-       0,      /* set below */                 /* tp_free */
+       PyObject_Del,                           /* tp_free */
 };
 
 
@@ -3147,9 +3147,6 @@ init_socket(void)
                return;
 
        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,
                           socket_methods,
                           socket_doc);