Hello,

please consider the attached patch for the matplotlib-py3 fork on github. It corrects some build and test failures and removes unnecessary 'extern "C"' statements from PyMODINIT_FUNC functions.

From <http://docs.python.org/release/2.6.6/extending/extending.html>:
Note that PyMODINIT_FUNC declares the function as void return type, declares any special linkage declarations required by the platform, and for C++ declares the function as extern "C".

Christoph
diff --git a/examples/animation/simple_3danim.py 
b/examples/animation/simple_3danim.py
index 4a59a35..74e918f 100644
--- a/examples/animation/simple_3danim.py
+++ b/examples/animation/simple_3danim.py
@@ -15,7 +15,7 @@ def Gen_RandLine(length, dims=2) :
     """
     lineData = np.empty((dims, length))
     lineData[:, 0] = np.random.rand(dims)
-    for index in xrange(1, length) :
+    for index in range(1, length) :
         # scaling the random numbers by 0.1 so
         # movement is small compared to position.
         # subtraction by 0.5 is to change the range to [-0.5, 0.5]
diff --git a/examples/event_handling/viewlims.py 
b/examples/event_handling/viewlims.py
index 5bb7bf6..fe5838c 100644
--- a/examples/event_handling/viewlims.py
+++ b/examples/event_handling/viewlims.py
@@ -30,7 +30,7 @@ class MandlebrotDisplay(object):
         threshold_time = np.zeros((self.height, self.width))
         z = np.zeros(threshold_time.shape, dtype=np.complex)
         mask = np.ones(threshold_time.shape, dtype=np.bool)
-        for i in xrange(self.niter):
+        for i in range(self.niter):
             z[mask] = z[mask]**self.power + c[mask]
             mask = (np.abs(z) < self.radius)
             threshold_time += mask
diff --git a/examples/misc/multiprocess.py b/examples/misc/multiprocess.py
index e15c5a8..09aa4ed 100644
--- a/examples/misc/multiprocess.py
+++ b/examples/misc/multiprocess.py
@@ -81,7 +81,7 @@ class NBPlot(object):
 
 def main():
     pl = NBPlot()
-    for ii in xrange(10):
+    for ii in range(10):
         pl.plot()
         time.sleep(0.5)
     raw_input('press Enter...')
diff --git a/examples/pylab_examples/scatter_star_poly.py 
b/examples/pylab_examples/scatter_star_poly.py
index ae0d207..a3b5831 100644
--- a/examples/pylab_examples/scatter_star_poly.py
+++ b/examples/pylab_examples/scatter_star_poly.py
@@ -13,8 +13,8 @@ plt.subplot(322)
 plt.scatter(x,y,s=80, c=z, marker=(5,0))
 
 verts = list(zip([-1.,1.,1.,-1.],[-1.,-1.,1.,-1.]))
-pylab.subplot(323)
-pylab.scatter(x,y,s=80, c=z, marker=(verts,0))
+plt.subplot(323)
+plt.scatter(x,y,s=80, c=z, marker=(verts,0))
 # equivalent:
 #plt.scatter(x,y,s=80, c=z, marker=None, verts=verts)
 
diff --git a/examples/pylab_examples/simple_plot_fps.py 
b/examples/pylab_examples/simple_plot_fps.py
index 11dba15..5459479 100755
--- a/examples/pylab_examples/simple_plot_fps.py
+++ b/examples/pylab_examples/simple_plot_fps.py
@@ -24,7 +24,7 @@ import time
 frames = 100.0
 t = time.time()
 c = time.clock()
-for i in xrange(int(frames)):
+for i in range(int(frames)):
     part = i / frames
     axis([0.0, 1.0 - part, -1.0 + part, 1.0 - part])
 wallclock = time.time() - t
diff --git a/examples/user_interfaces/embedding_in_qt.py 
b/examples/user_interfaces/embedding_in_qt.py
index c5e0e35..311fd9e 100755
--- a/examples/user_interfaces/embedding_in_qt.py
+++ b/examples/user_interfaces/embedding_in_qt.py
@@ -76,7 +76,7 @@ class MyDynamicMplCanvas(MyMplCanvas):
 
     def update_figure(self):
         # Build a list of 4 random integers between 0 and 10 (both inclusive)
-        l = [ random.randint(0, 10) for i in xrange(4) ]
+        l = [ random.randint(0, 10) for i in range(4) ]
 
         self.axes.plot([0, 1, 2, 3], l, 'r')
         self.draw()
diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py
index d067d0c..8176071 100644
--- a/lib/matplotlib/figure.py
+++ b/lib/matplotlib/figure.py
@@ -316,6 +316,7 @@ class Figure(Artist):
         """
         allsubplots = np.alltrue([hasattr(ax, 'is_last_row') for ax in 
self.axes])
         if len(self.axes)==1:
+            ax = self.get_axes()[0]
             for label in ax.get_xticklabels():
                 label.set_ha(ha)
                 label.set_rotation(rotation)
diff --git a/src/_backend_agg.cpp b/src/_backend_agg.cpp
index 200dd18..ecc464d 100644
--- a/src/_backend_agg.cpp
+++ b/src/_backend_agg.cpp
@@ -2441,7 +2441,6 @@ void RendererAgg::init_type()
                        "restore_region(region, x1, y1, x2, y2, x3, y3)");
 }
 
-extern "C"
 #if PY3K
 PyMODINIT_FUNC
 PyInit__backend_agg(void)
diff --git a/src/_backend_gdk.c b/src/_backend_gdk.c
index 4c50aa2..152554c 100644
--- a/src/_backend_gdk.c
+++ b/src/_backend_gdk.c
@@ -52,7 +52,7 @@ static PyMethodDef _backend_gdk_functions[] = {
     { NULL, NULL, 0 }
 };
 
-DL_EXPORT(void)
+PyMODINIT_FUNC
 init_backend_gdk(void)
 {
     PyObject *mod;
diff --git a/src/_gtkagg.cpp b/src/_gtkagg.cpp
index 5a0b461..60c704a 100644
--- a/src/_gtkagg.cpp
+++ b/src/_gtkagg.cpp
@@ -131,9 +131,7 @@ private:
     }
 };
 
-
-extern "C"
-DL_EXPORT(void)
+PyMODINIT_FUNC
 init_gtkagg(void)
 {
     init_pygobject();
diff --git a/src/_path.cpp b/src/_path.cpp
index 02f2e6c..d26d708 100644
--- a/src/_path.cpp
+++ b/src/_path.cpp
@@ -1482,11 +1482,9 @@ _path_module::cleanup_path(const Py::Tuple& args)
 }
 
 #if PY3K
-extern "C"
 PyMODINIT_FUNC
 PyInit__path(void)
 #else
-extern "C"
 PyMODINIT_FUNC
 init_path(void)
 #endif
diff --git a/src/_png.cpp b/src/_png.cpp
index f835922..f5cc721 100644
--- a/src/_png.cpp
+++ b/src/_png.cpp
@@ -569,7 +569,6 @@ _png_module::read_png_uint8(const Py::Tuple& args)
     return Py::asObject(_read_png(args[0], false));
 }
 
-extern "C"
 #if PY3K
 PyMODINIT_FUNC
 PyInit__png(void)
diff --git a/src/_subprocess.c b/src/_subprocess.c
index 78dfc94..4320008 100644
--- a/src/_subprocess.c
+++ b/src/_subprocess.c
@@ -547,11 +547,7 @@ defint(PyObject* d, const char* name, int value)
         }
 }
 
-#if PY_VERSION_HEX >= 0x02030000
 PyMODINIT_FUNC
-#else
-DL_EXPORT(void)
-#endif
 init_subprocess()
 {
         PyObject *d;
diff --git a/src/_tkagg.cpp b/src/_tkagg.cpp
index 464abc1..1af9f9f 100644
--- a/src/_tkagg.cpp
+++ b/src/_tkagg.cpp
@@ -265,8 +265,6 @@ static PyMethodDef functions[] =
     {NULL, NULL} /* sentinel */
 };
 
-extern "C"
-{
 #if PY3K
 static PyModuleDef _tkagg_module = {
     PyModuleDef_HEAD_INIT,
@@ -296,4 +294,4 @@ PyMODINIT_FUNC init_tkagg(void)
     Py_InitModule("_tkagg", functions);
 }
 #endif
-}
+
diff --git a/src/ft2font.cpp b/src/ft2font.cpp
index e4a98ee..b5d6efb 100644
--- a/src/ft2font.cpp
+++ b/src/ft2font.cpp
@@ -2056,14 +2056,6 @@ ft2font_module::~ft2font_module()
     FT_Done_FreeType(_ft2Library);
 }
 
-#if defined(_MSC_VER)
-DL_EXPORT(void)
-#elif defined(__cplusplus)
-extern "C"
-#else
-void
-#endif
-
 #if PY3K
 PyMODINIT_FUNC
 PyInit_ft2font(void)
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to