diff --git a/.gitignore b/.gitignore
index 23cd2f707940..40671a929598 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,7 @@
*~
*$
*.bak
+*.kdev4
.project
.pydevproject
@@ -34,6 +35,7 @@ dist
# OS generated files #
######################
+.directory
.gdb_history
.DS_Store?
ehthumbs.db
@@ -51,3 +53,4 @@ doc/examples
doc/_templates/gallery.html
doc/users/installing.rst
doc/_static/matplotlibrc
+lib/dateutil
diff --git a/.travis.yml b/.travis.yml
index 27f3008405ae..2066611a045c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,12 +7,20 @@ python:
- 3.3
install:
- - pip -q install --use-mirrors nose numpy
+ - pip install -q --use-mirrors nose python-dateutil numpy pep8
+ # This is a workaround to install the latest versions of pyparsing,
+ # which are not yet available on PyPI
+ - 'if [ ${TRAVIS_PYTHON_VERSION:0:1} == "3" ]; then pip -q install http://sourceforge.net/projects/pyparsing/files/pyparsing/pyparsing-2.0.0/pyparsing-2.0.0.tar.gz; fi'
+ - 'if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then pip -q install http://sourceforge.net/projects/pyparsing/files/pyparsing/pyparsing-1.5.7/pyparsing-1.5.7.tar.gz; fi'
- if [[ $TRAVIS_PYTHON_VERSION == '2.'* ]]; then pip -q install --use-mirrors PIL; fi
- - sudo apt-get -qq update && sudo apt-get -qq install inkscape
+ - sudo apt-get update && sudo apt-get -qq install inkscape
- python setup.py install
script:
- mkdir ../tmp_test_dir
- cd ../tmp_test_dir
- - python ../matplotlib/tests.py -sv
+ # The number of processes is hardcoded, because using too many causes the
+ # Travis VM to run out of memory (since so many copies of inkscape and
+ # ghostscript are running at the same time).
+ - echo Testing using 8 processes
+ - python ../matplotlib/tests.py -sv --processes=8 --process-timeout=300
diff --git a/CHANGELOG b/CHANGELOG
index 8e17358c5407..8d2c91c224cb 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,55 @@
+2013-05-18 Added support for arbitrary rasterization resolutions to the
+ SVG backend. Previously the resolution was hard coded to 72
+ dpi. Now the backend class takes a image_dpi argument for
+ its constructor, adjusts the image bounding box accordingly
+ and forwards a magnification factor to the image renderer.
+ The code and results now resemble those of the PDF backend.
+ - MW
+
+2013-05-08 Changed behavior of hist when given stacked=True and normed=True.
+ Histograms are now stacked first, then the sum is normalized.
+ Previously, each histogram was normalized, then they were stacked.
+
+2013-04-25 Changed all instances of:
+
+ from matplotlib import MatplotlibDeprecationWarning as mplDeprecation
+ to:
+
+ from cbook import mplDeprecation
+
+ and removed the import into the matplotlib namespace in __init__.py
+ Thomas Caswell
+
+
+2013-04-15 Added 'axes.xmargin' and 'axes.ymargin' to rpParams to set default
+ margins on auto-scaleing. - TAC
+
+2013-04-16 Added patheffect support for Line2D objects. -JJL
+
+2013-03-19 Added support for passing `linestyle` kwarg to `step` so all `plot`
+ kwargs are passed to the underlying `plot` call. -TAC
+
+2013-02-25 Added classes CubicTriInterpolator, UniformTriRefiner, TriAnalyzer
+ to matplotlib.tri module. - GBy
+
+2013-01-23 Add 'savefig.directory' to rcParams to remember and fill in the last
+ directory saved to for figure save dialogs - Martin Spacek
+
+2013-01-13 Add eventplot method to axes and pyplot and EventCollection class
+ to collections.
+
+2013-01-08 Added two extra titles to axes which are flush with the left and
+ right edges of the plot respectively.
+ Andrew Dawson
+
+2013-01-07 Add framealpha keyword argument to legend - PO
+
+2013-01-16 Till Stensitzki added a baseline feature to stackplot
+
+2012-12-22 Added classes for interpolation within triangular grids
+ (LinearTriInterpolator) and to find the triangles in which points
+ lie (TrapezoidMapTriFinder) to matplotlib.tri module. - IMT
+
2012-12-05 Added MatplotlibDeprecationWarning class for signaling deprecation.
Matplotlib developers can use this class as follows:
@@ -8,6 +60,42 @@
for the signaling of deprecation, but via UserWarnings which are
not ignored by default. - PI
+2012-11-27 Added the *mtext* parameter for supplying matplotlib.text.Text
+ instances to RendererBase.draw_tex and RendererBase.draw_text.
+ This allows backends to utilize additional text attributes, like
+ the alignment of text elements. - pwuertz
+
+2012-11-26 deprecate matplotlib/mpl.py, which was used only in pylab.py and is
+ now replaced by the more suitable `import matplotlib as mpl`. - PI
+
+2012-11-25 Make rc_context available via pyplot interface - PI
+
+2012-11-16 plt.set_cmap no longer throws errors if there is not already
+ an active colorable artist, such as an image, and just sets
+ up the colormap to use from that point forward. - PI
+
+2012-11-16 Added the funcction _get_rbga_face, which is identical to
+ _get_rbg_face except it return a (r,g,b,a) tuble, to line2D.
+ Modified Line2D.draw to use _get_rbga_face to get the markerface
+ color so that any alpha set by markerfacecolor will respected.
+ - Thomas Caswell
+
+2012-11-13 Add a symmetric log normalization class to colors.py.
+ Also added some tests for the normalization class.
+ Till Stensitzki
+
+2012-11-12 Make axes.stem take at least one argument.
+ Uses a default range(n) when the first arg not provided.
+ Damon McDougall
+
+2012-11-09 Make plt.subplot() without arguments act as subplot(111) - PI
+
+2012-11-08 Replaced plt.figure and plt.subplot calls by the newer, more
+ convenient single call to plt.subplots() in the documentation
+ examples - PI
+
+2012-10-05 Add support for saving animations as animated GIFs. - JVDP
+
2012-08-11 Fix path-closing bug in patches.Polygon, so that regardless
of whether the path is the initial one or was subsequently
set by set_xy(), get_xy() will return a closed path if and
@@ -980,7 +1068,7 @@
2009-02-02 Change default resolution on polar plot to 1 - MGD
2009-02-02 Avoid malloc errors in ttconv for fonts that don't have
- e.g. PostName (a version of Tahoma triggered this) - JKS
+ e.g., PostName (a version of Tahoma triggered this) - JKS
2009-01-30 Remove support for pyExcelerator in exceltools -- use xlwt
instead - JDH
@@ -1054,7 +1142,7 @@
(slanting and extending). - JKS
2008-12-29 Fix a bug in pdf usetex support, which occurred if the same
- Type-1 font was used with different encodings, e.g. with
+ Type-1 font was used with different encodings, e.g., with
Minion Pro and MnSymbol. - JKS
2008-12-20 fix the dpi-dependent offset of Shadow. - JJL
@@ -1153,7 +1241,7 @@
2008-12-08 Some of the changes Michael made to improve the output of
the property tables in the rest docs broke of made
- difficult to use some of the interactive doc helpers, eg
+ difficult to use some of the interactive doc helpers, e.g.,
setp and getp. Having all the rest markup in the ipython
shell also confused the docstrings. I added a new rc param
docstring.harcopy, to format the docstrings differently for
@@ -1177,7 +1265,7 @@
2008-12-05 Fixed a bug that the handlelength of the new legend class
set too short when numpoints=1 -JJL
-2008-12-04 Added support for data with units (e.g. dates) to
+2008-12-04 Added support for data with units (e.g., dates) to
Axes.fill_between. -RM
2008-12-04 Added fancybox keyword to legend. Also applied some changes
@@ -1258,7 +1346,7 @@
Tollerud and Jae-Joon Lee. - MM
2008-10-11 Fixed bug in pdf backend: if you pass a file object for
- output instead of a filename, e.g. in a wep app, we now
+ output instead of a filename, e.g., in a wep app, we now
flush the object at the end. - JKS
2008-10-08 Add path simplification support to paths with gaps. - EF
@@ -1471,7 +1559,7 @@
2008-06-20 Added set/get_closed method to Polygon; fixes error
in hist - MM
-2008-06-19 Use relative font sizes (e.g. 'medium' and 'large') in
+2008-06-19 Use relative font sizes (e.g., 'medium' and 'large') in
rcsetup.py and matplotlibrc.template so that text will
be scaled by default when changing rcParams['font.size'] -
EF
@@ -2103,8 +2191,8 @@
2007-07-31 Refactoring of distutils scripts.
- Will not fail on the entire build if an optional Python
- package (e.g. Tkinter) is installed but its development
- headers are not (e.g. tk-devel). Instead, it will
+ package (e.g., Tkinter) is installed but its development
+ headers are not (e.g., tk-devel). Instead, it will
continue to build all other extensions.
- Provide an overview at the top of the output to display
what dependencies and their versions were found, and (by
@@ -2136,7 +2224,7 @@
should be changed to ${\cal R}$. Alternatively, you may
use the new LaTeX-style font commands (\mathcal, \mathrm,
\mathit, \mathtt) which do affect the following group,
- eg. $\mathcal{R}$.
+ e.g., $\mathcal{R}$.
Other new features include:
@@ -2146,10 +2234,10 @@
- Sub/superscripts are less likely to accidentally overlap.
- - Support for sub/superscripts in either order, eg. $x^i_j$
+ - Support for sub/superscripts in either order, e.g., $x^i_j$
and $x_j^i$ are equivalent.
- - Double sub/superscripts (eg. $x_i_j$) are considered
+ - Double sub/superscripts (e.g., $x_i_j$) are considered
ambiguous and raise an exception. Use braces to disambiguate.
- $\frac{x}{y}$ can be used for displaying fractions.
@@ -2412,7 +2500,7 @@
color-setting operations in the pdf backend. The idea is
that you include the resulting file in another program and
set the colors (both stroke and fill color) there, so you
- can use the same pdf file for e.g. a paper and a
+ can use the same pdf file for e.g., a paper and a
presentation and have them in the surrounding color. You
will probably not want to draw figure and axis frames in
that case, since they would be filled in the same color. - JKS
@@ -2501,7 +2589,7 @@
frameowrk. Artists will define their own pick method with
a configurable epsilon tolerance and return pick attrs.
All artists that meet the tolerance threshold will fire a
- PickEvent with artist dependent attrs; eg, a Line2D can set
+ PickEvent with artist dependent attrs; e.g., a Line2D can set
the indices attribute that shows the indices into the line
that are within epsilon of the pick point. See
examples/pick_event_demo.py. The implementation of pick
@@ -2611,7 +2699,7 @@
2006-11-19 Added semi-automatic docstring generation detailing all the
kwargs that functions take using the artist introspection
- tools; eg 'help text now details the scatter kwargs
+ tools; e.g., 'help text now details the scatter kwargs
that control the Text properties - JDH
2006-11-17 Removed obsolete scatter_classic, leaving a stub to
@@ -2901,7 +2989,7 @@
2006-06-16 Added a pointer to parent in figure canvas so you can
access the container with fig.canvas.manager. Useful if
- you want to set the window title, eg in gtk
+ you want to set the window title, e.g., in gtk
fig.canvas.manager.window.set_title, though a GUI neutral
method would be preferable JDH
@@ -3370,7 +3458,7 @@
2005-12-03 Modified scipy patch to support Numeric, scipy and numarray
Some work remains to be done because some of the scipy
- imports are broken if only the core is installed. Eg
+ imports are broken if only the core is installed. e.g.,
apparently we need from scipy.basic.fftpack import * rather
than from scipy.fftpack import *
@@ -3619,7 +3707,7 @@
2005-07-06 Made HOME/.matplotlib the new config dir where the
matplotlibrc file, the ttf.cache, and the tex.cache live.
The new default filenames in .matplotlib have no leading
- dot and are not hidden. Eg, the new names are matplotlibrc
+ dot and are not hidden. e.g., the new names are matplotlibrc
tex.cache ttffont.cache. This is how ipython does it so it
must be right. If old files are found, a warning is issued
and they are moved to the new location. Also fixed
@@ -3893,7 +3981,7 @@
2005-04-11 Applied a variant of rick's xlim/ylim/axis patch. These
functions now take kwargs to let you selectively alter only
- the min or max if desired. Eg xlim(xmin=2) or
+ the min or max if desired. e.g., xlim(xmin=2) or
axis(ymax=3). They always return the new lim. - JDH
@@ -4022,7 +4110,7 @@
2005-02-23 Added rc param ps.useafm so backend ps can use native afm
fonts or truetype. afme breaks mathtext but causes much
smaller font sizes and may result in images that display
- better in some contexts (eg pdfs incorporated into latex
+ better in some contexts (e.g., pdfs incorporated into latex
docs viewed in acrobat reader). I would like to extend
this approach to allow the user to use truetype only for
mathtext, which should be easy.
@@ -4150,9 +4238,9 @@
2005-01-18 Added accents to mathtext: \hat, \breve, \grave, \bar,
\acute, \tilde, \vec, \dot, \ddot. All of them have the
- same syntax, eg to make an overbar you do \bar{o} or to
+ same syntax, e.g., to make an overbar you do \bar{o} or to
make an o umlaut you do \ddot{o}. The shortcuts are also
- provided, eg: \"o \'e \`e \~n \.x \^y - JDH
+ provided, e.g., \"o \'e \`e \~n \.x \^y - JDH
2005-01-18 Plugged image resize memory leaks - JDH
@@ -4319,7 +4407,7 @@
2004-12-04 Fixed some legend bugs JDH
-2004-11-30 Added over command for oneoff over plots. Eg over(plot, x,
+2004-11-30 Added over command for oneoff over plots. e.g., over(plot, x,
y, lw=2). Works with any plot function.
2004-11-30 Added bbox property to text - JDH
@@ -4495,7 +4583,7 @@
2004-09-17 Added coords formatter attributes. These must be callable,
and return a string for the x or y data. These will be used
to format the x and y data for the coords box. Default is
- the axis major formatter. Eg
+ the axis major formatter. e.g.:
# format the coords message box
def price(x): return '$%1.2f'%x
diff --git a/CXX/IndirectPythonInterface.cxx b/CXX/IndirectPythonInterface.cxx
index 7286cdf65737..256bd7ebda80 100644
--- a/CXX/IndirectPythonInterface.cxx
+++ b/CXX/IndirectPythonInterface.cxx
@@ -34,10 +34,524 @@
// DAMAGE.
//
//-----------------------------------------------------------------------------
-#include "CXX/WrapPython.h"
+#include "CXX/IndirectPythonInterface.hxx"
+
+namespace Py
+{
+bool _CFunction_Check( PyObject *op ) { return op->ob_type == _CFunction_Type(); }
+bool _Complex_Check( PyObject *op ) { return op->ob_type == _Complex_Type(); }
+bool _Dict_Check( PyObject *op ) { return op->ob_type == _Dict_Type(); }
+bool _Float_Check( PyObject *op ) { return op->ob_type == _Float_Type(); }
+bool _Function_Check( PyObject *op ) { return op->ob_type == _Function_Type(); }
+bool _Boolean_Check( PyObject *op ) { return op->ob_type == _Bool_Type(); }
+bool _List_Check( PyObject *op ) { return op->ob_type == _List_Type(); }
+bool _Long_Check( PyObject *op ) { return op->ob_type == _Long_Type(); }
+bool _Method_Check( PyObject *op ) { return op->ob_type == _Method_Type(); }
+bool _Module_Check( PyObject *op ) { return op->ob_type == _Module_Type(); }
+bool _Range_Check( PyObject *op ) { return op->ob_type == _Range_Type(); }
+bool _Slice_Check( PyObject *op ) { return op->ob_type == _Slice_Type(); }
+bool _TraceBack_Check( PyObject *op ) { return op->ob_type == _TraceBack_Type(); }
+bool _Tuple_Check( PyObject *op ) { return op->ob_type == _Tuple_Type(); }
+bool _Type_Check( PyObject *op ) { return op->ob_type == _Type_Type(); }
+bool _Unicode_Check( PyObject *op ) { return op->ob_type == _Unicode_Type(); }
#if PY_MAJOR_VERSION == 2
-#include "Python2/IndirectPythonInterface.cxx"
+bool _String_Check( PyObject *op ) { return op->ob_type == _String_Type(); }
+bool _Int_Check( PyObject *op ) { return op->ob_type == _Int_Type(); }
+bool _CObject_Check( PyObject *op ) { return op->ob_type == _CObject_Type(); }
+#endif
+#if PY_MAJOR_VERSION >= 3
+bool _Bytes_Check( PyObject *op ) { return op->ob_type == _Bytes_Type(); }
+#endif
+
+#if defined(PY_WIN32_DELAYLOAD_PYTHON_DLL)
+
+#if defined(MS_WINDOWS)
+#include
+
+
+static HMODULE python_dll;
+
+static PyObject *ptr__Exc_ArithmeticError = NULL;
+static PyObject *ptr__Exc_AssertionError = NULL;
+static PyObject *ptr__Exc_AttributeError = NULL;
+static PyObject *ptr__Exc_EnvironmentError = NULL;
+static PyObject *ptr__Exc_EOFError = NULL;
+static PyObject *ptr__Exc_Exception = NULL;
+static PyObject *ptr__Exc_FloatingPointError = NULL;
+static PyObject *ptr__Exc_ImportError = NULL;
+static PyObject *ptr__Exc_IndexError = NULL;
+static PyObject *ptr__Exc_IOError = NULL;
+static PyObject *ptr__Exc_KeyboardInterrupt = NULL;
+static PyObject *ptr__Exc_KeyError = NULL;
+static PyObject *ptr__Exc_LookupError = NULL;
+static PyObject *ptr__Exc_MemoryError = NULL;
+static PyObject *ptr__Exc_NameError = NULL;
+static PyObject *ptr__Exc_NotImplementedError = NULL;
+static PyObject *ptr__Exc_OSError = NULL;
+static PyObject *ptr__Exc_OverflowError = NULL;
+static PyObject *ptr__Exc_RuntimeError = NULL;
+static PyObject *ptr__Exc_StandardError = NULL;
+static PyObject *ptr__Exc_SyntaxError = NULL;
+static PyObject *ptr__Exc_SystemError = NULL;
+static PyObject *ptr__Exc_SystemExit = NULL;
+static PyObject *ptr__Exc_TypeError = NULL;
+static PyObject *ptr__Exc_ValueError = NULL;
+static PyObject *ptr__Exc_ZeroDivisionError = NULL;
+
+#ifdef MS_WINDOWS
+static PyObject *ptr__Exc_WindowsError = NULL;
+#endif
+
+static PyObject *ptr__Exc_IndentationError = NULL;
+static PyObject *ptr__Exc_TabError = NULL;
+static PyObject *ptr__Exc_UnboundLocalError = NULL;
+static PyObject *ptr__Exc_UnicodeError = NULL;
+static PyObject *ptr__PyNone = NULL;
+static PyObject *ptr__PyFalse = NULL;
+static PyObject *ptr__PyTrue = NULL;
+static PyTypeObject *ptr__CFunction_Type = NULL;
+static PyTypeObject *ptr__Complex_Type = NULL;
+static PyTypeObject *ptr__Dict_Type = NULL;
+static PyTypeObject *ptr__Float_Type = NULL;
+static PyTypeObject *ptr__Function_Type = NULL;
+static PyTypeObject *ptr__Bool_Type = NULL;
+static PyTypeObject *ptr__List_Type = NULL;
+static PyTypeObject *ptr__Long_Type = NULL;
+static PyTypeObject *ptr__Method_Type = NULL;
+static PyTypeObject *ptr__Module_Type = NULL;
+static PyTypeObject *ptr__Range_Type = NULL;
+static PyTypeObject *ptr__Slice_Type = NULL;
+static PyTypeObject *ptr__TraceBack_Type = NULL;
+static PyTypeObject *ptr__Tuple_Type = NULL;
+static PyTypeObject *ptr__Type_Type = NULL;
+#if PY_MAJOR_VERSION == 2
+static PyTypeObject *ptr__Int_Type = NULL;
+static PyTypeObject *ptr__String_Type = NULL;
+static PyTypeObject *ptr__CObject_Type = NULL;
+#endif
+#if PY_MAJOR_VERSION >= 3
+static PyTypeObject *ptr__Bytes_Type = NULL;
+#endif
+
+
+static int *ptr_Py_DebugFlag = NULL;
+static int *ptr_Py_InteractiveFlag = NULL;
+static int *ptr_Py_OptimizeFlag = NULL;
+static int *ptr_Py_NoSiteFlag = NULL;
+static int *ptr_Py_VerboseFlag = NULL;
+
+static char **ptr__Py_PackageContext = NULL;
+
+#ifdef Py_REF_DEBUG
+int *ptr_Py_RefTotal;
+#endif
+
+
+//--------------------------------------------------------------------------------
+class GetAddressException
+{
+public:
+ GetAddressException( const char *_name )
+ : name( _name )
+ {}
+ virtual ~GetAddressException() {}
+ const char *name;
+};
+
+
+//--------------------------------------------------------------------------------
+static PyObject *GetPyObjectPointer_As_PyObjectPointer( const char *name )
+{
+ FARPROC addr = GetProcAddress( python_dll, name );
+ if( addr == NULL )
+ throw GetAddressException( name );
+
+ return *(PyObject **)addr;
+}
+
+static PyObject *GetPyObject_As_PyObjectPointer( const char *name )
+{
+ FARPROC addr = GetProcAddress( python_dll, name );
+ if( addr == NULL )
+ throw GetAddressException( name );
+
+ return (PyObject *)addr;
+}
+
+static PyTypeObject *GetPyTypeObjectPointer_As_PyTypeObjectPointer( const char *name )
+{
+ FARPROC addr = GetProcAddress( python_dll, name );
+ if( addr == NULL )
+ throw GetAddressException( name );
+
+ return *(PyTypeObject **)addr;
+}
+
+static PyTypeObject *GetPyTypeObject_As_PyTypeObjectPointer( const char *name )
+{
+ FARPROC addr = GetProcAddress( python_dll, name );
+ if( addr == NULL )
+ throw GetAddressException( name );
+
+ return (PyTypeObject *)addr;
+}
+
+static int *GetInt_as_IntPointer( const char *name )
+{
+ FARPROC addr = GetProcAddress( python_dll, name );
+ if( addr == NULL )
+ throw GetAddressException( name );
+
+ return (int *)addr;
+}
+
+static char **GetCharPointer_as_CharPointerPointer( const char *name )
+{
+ FARPROC addr = GetProcAddress( python_dll, name );
+ if( addr == NULL )
+ throw GetAddressException( name );
+
+ return (char **)addr;
+}
+
+
+#ifdef _DEBUG
+static const char python_dll_name_format[] = "PYTHON%1.1d%1.1d_D.DLL";
#else
-#include "Python3/IndirectPythonInterface.cxx"
+static const char python_dll_name_format[] = "PYTHON%1.1d%1.1d.DLL";
+#endif
+
+//--------------------------------------------------------------------------------
+bool InitialisePythonIndirectInterface()
+{
+ char python_dll_name[sizeof(python_dll_name_format)];
+
+ _snprintf( python_dll_name, sizeof(python_dll_name_format) / sizeof(char) - 1, python_dll_name_format, PY_MAJOR_VERSION, PY_MINOR_VERSION );
+
+ python_dll = LoadLibraryA( python_dll_name );
+ if( python_dll == NULL )
+ return false;
+
+ try
+ {
+#ifdef Py_REF_DEBUG
+ ptr_Py_RefTotal = GetInt_as_IntPointer( "_Py_RefTotal" );
+#endif
+ ptr_Py_DebugFlag = GetInt_as_IntPointer( "Py_DebugFlag" );
+ ptr_Py_InteractiveFlag = GetInt_as_IntPointer( "Py_InteractiveFlag" );
+ ptr_Py_OptimizeFlag = GetInt_as_IntPointer( "Py_OptimizeFlag" );
+ ptr_Py_NoSiteFlag = GetInt_as_IntPointer( "Py_NoSiteFlag" );
+ ptr_Py_VerboseFlag = GetInt_as_IntPointer( "Py_VerboseFlag" );
+ ptr__Py_PackageContext = GetCharPointer_as_CharPointerPointer( "_Py_PackageContext" );
+
+ ptr__Exc_ArithmeticError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_ArithmeticError" );
+ ptr__Exc_AssertionError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_AssertionError" );
+ ptr__Exc_AttributeError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_AttributeError" );
+ ptr__Exc_EnvironmentError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_EnvironmentError" );
+ ptr__Exc_EOFError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_EOFError" );
+ ptr__Exc_Exception = GetPyObjectPointer_As_PyObjectPointer( "PyExc_Exception" );
+ ptr__Exc_FloatingPointError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_FloatingPointError" );
+ ptr__Exc_ImportError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_ImportError" );
+ ptr__Exc_IndexError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_IndexError" );
+ ptr__Exc_IOError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_IOError" );
+ ptr__Exc_KeyboardInterrupt = GetPyObjectPointer_As_PyObjectPointer( "PyExc_KeyboardInterrupt" );
+ ptr__Exc_KeyError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_KeyError" );
+ ptr__Exc_LookupError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_LookupError" );
+ ptr__Exc_MemoryError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_MemoryError" );
+ ptr__Exc_NameError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_NameError" );
+ ptr__Exc_NotImplementedError= GetPyObjectPointer_As_PyObjectPointer( "PyExc_NotImplementedError" );
+ ptr__Exc_OSError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_OSError" );
+ ptr__Exc_OverflowError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_OverflowError" );
+ ptr__Exc_RuntimeError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_RuntimeError" );
+ ptr__Exc_StandardError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_StandardError" );
+ ptr__Exc_SyntaxError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_SyntaxError" );
+ ptr__Exc_SystemError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_SystemError" );
+ ptr__Exc_SystemExit = GetPyObjectPointer_As_PyObjectPointer( "PyExc_SystemExit" );
+ ptr__Exc_TypeError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_TypeError" );
+ ptr__Exc_ValueError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_ValueError" );
+#ifdef MS_WINDOWS
+ ptr__Exc_WindowsError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_WindowsError" );
+#endif
+ ptr__Exc_ZeroDivisionError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_ZeroDivisionError" );
+ ptr__Exc_IndentationError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_IndentationError" );
+ ptr__Exc_TabError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_TabError" );
+ ptr__Exc_UnboundLocalError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_UnboundLocalError" );
+ ptr__Exc_UnicodeError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_UnicodeError" );
+ ptr__PyNone = GetPyObject_As_PyObjectPointer( "_Py_NoneStruct" );
+
+ ptr__PyFalse = GetPyObject_As_PyObjectPointer( "_Py_ZeroStruct" );
+ ptr__PyTrue = GetPyObject_As_PyObjectPointer( "_Py_TrueStruct" );
+
+ ptr__CFunction_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyCFunction_Type" );
+ ptr__Complex_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyComplex_Type" );
+ ptr__Dict_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyDict_Type" );
+ ptr__Float_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyFloat_Type" );
+ ptr__Function_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyFunction_Type" );
+ ptr__Bool_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyBool_Type" );
+ ptr__List_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyList_Type" );
+ ptr__Long_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyLong_Type" );
+ ptr__Method_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyMethod_Type" );
+ ptr__Module_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyModule_Type" );
+ ptr__Range_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyRange_Type" );
+ ptr__Slice_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PySlice_Type" );
+ ptr__TraceBack_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyTraceBack_Type" );
+ ptr__Tuple_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyTuple_Type" );
+ ptr__Type_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyType_Type" );
+ ptr__Unicode_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyUnicode_Type" );
+#if PY_MAJOR_VERSION == 2
+ ptr__String_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyString_Type" );
+ ptr__Int_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyInt_Type" );
+ ptr__CObject_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyCObject_Type" );
+#endif
+#if PY_MAJOR_VERSION >= 3
+ ptr__Bytes_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyBytes_Type" );
+#endif
+ }
+ catch( GetAddressException &e )
+ {
+ OutputDebugStringA( python_dll_name );
+ OutputDebugStringA( " does not contain symbol " );
+ OutputDebugStringA( e.name );
+ OutputDebugStringA( "\n" );
+
+ return false;
+ }
+
+ return true;
+}
+
+//
+// Wrap variables as function calls
+//
+PyObject *_Exc_ArithmeticError() { return ptr__Exc_ArithmeticError; }
+PyObject *_Exc_AssertionError() { return ptr__Exc_AssertionError; }
+PyObject *_Exc_AttributeError() { return ptr__Exc_AttributeError; }
+PyObject *_Exc_EnvironmentError() { return ptr__Exc_EnvironmentError; }
+PyObject *_Exc_EOFError() { return ptr__Exc_EOFError; }
+PyObject *_Exc_Exception() { return ptr__Exc_Exception; }
+PyObject *_Exc_FloatingPointError() { return ptr__Exc_FloatingPointError; }
+PyObject *_Exc_ImportError() { return ptr__Exc_ImportError; }
+PyObject *_Exc_IndexError() { return ptr__Exc_IndexError; }
+PyObject *_Exc_IOError() { return ptr__Exc_IOError; }
+PyObject *_Exc_KeyboardInterrupt() { return ptr__Exc_KeyboardInterrupt; }
+PyObject *_Exc_KeyError() { return ptr__Exc_KeyError; }
+PyObject *_Exc_LookupError() { return ptr__Exc_LookupError; }
+PyObject *_Exc_MemoryError() { return ptr__Exc_MemoryError; }
+PyObject *_Exc_NameError() { return ptr__Exc_NameError; }
+PyObject *_Exc_NotImplementedError() { return ptr__Exc_NotImplementedError; }
+PyObject *_Exc_OSError() { return ptr__Exc_OSError; }
+PyObject *_Exc_OverflowError() { return ptr__Exc_OverflowError; }
+PyObject *_Exc_RuntimeError() { return ptr__Exc_RuntimeError; }
+PyObject *_Exc_StandardError() { return ptr__Exc_StandardError; }
+PyObject *_Exc_SyntaxError() { return ptr__Exc_SyntaxError; }
+PyObject *_Exc_SystemError() { return ptr__Exc_SystemError; }
+PyObject *_Exc_SystemExit() { return ptr__Exc_SystemExit; }
+PyObject *_Exc_TypeError() { return ptr__Exc_TypeError; }
+PyObject *_Exc_ValueError() { return ptr__Exc_ValueError; }
+#ifdef MS_WINDOWS
+PyObject *_Exc_WindowsError() { return ptr__Exc_WindowsError; }
+#endif
+PyObject *_Exc_ZeroDivisionError() { return ptr__Exc_ZeroDivisionError; }
+PyObject *_Exc_IndentationError() { return ptr__Exc_IndentationError; }
+PyObject *_Exc_TabError() { return ptr__Exc_TabError; }
+PyObject *_Exc_UnboundLocalError() { return ptr__Exc_UnboundLocalError; }
+PyObject *_Exc_UnicodeError() { return ptr__Exc_UnicodeError; }
+
+//
+// wrap items in Object.h
+//
+PyObject *_None() { return ptr__PyNone; }
+
+PyObject *_False() { return ptr__PyFalse; }
+PyObject *_True() { return ptr__PyTrue; }
+
+PyTypeObject *_CFunction_Type() { return ptr__CFunction_Type; }
+PyTypeObject *_Complex_Type() { return ptr__Complex_Type; }
+PyTypeObject *_Dict_Type() { return ptr__Dict_Type; }
+PyTypeObject *_Float_Type() { return ptr__Float_Type; }
+PyTypeObject *_Function_Type() { return ptr__Function_Type; }
+PyTypeObject *_Bool_Type() { return ptr__Bool_Type; }
+PyTypeObject *_List_Type() { return ptr__List_Type; }
+PyTypeObject *_Long_Type() { return ptr__Long_Type; }
+PyTypeObject *_Method_Type() { return ptr__Method_Type; }
+PyTypeObject *_Module_Type() { return ptr__Module_Type; }
+PyTypeObject *_Range_Type() { return ptr__Range_Type; }
+PyTypeObject *_Slice_Type() { return ptr__Slice_Type; }
+PyTypeObject *_TraceBack_Type() { return ptr__TraceBack_Type; }
+PyTypeObject *_Tuple_Type() { return ptr__Tuple_Type; }
+PyTypeObject *_Type_Type() { return ptr__Type_Type; }
+PyTypeObject *_Unicode_Type() { return ptr__Unicode_Type; }
+#if PY_MAJOR_VERSION == 2
+PyTypeObject *_String_Type() { return ptr__String_Type; }
+PyTypeObject *_Int_Type() { return ptr__Int_Type; }
+PyTypeObject *_CObject_Type() { return ptr__CObject_Type; }
+#endif
+#if PY_MAJOR_VERSION >= 3
+PyTypeObject *_Bytes_Type() { return ptr__Bytes_Type; }
+#endif
+
+char *__Py_PackageContext() { return *ptr__Py_PackageContext; }
+
+
+//
+// wrap the Python Flag variables
+//
+int &_Py_DebugFlag() { return *ptr_Py_DebugFlag; }
+int &_Py_InteractiveFlag() { return *ptr_Py_InteractiveFlag; }
+int &_Py_OptimizeFlag() { return *ptr_Py_OptimizeFlag; }
+int &_Py_NoSiteFlag() { return *ptr_Py_NoSiteFlag; }
+int &_Py_VerboseFlag() { return *ptr_Py_VerboseFlag; }
+
+#if 0
+#define Py_INCREF(op) ( \
+ _Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \
+ ((PyObject*)(op))->ob_refcnt++)
+
+#define Py_DECREF(op) \
+ if (_Py_DEC_REFTOTAL _Py_REF_DEBUG_COMMA \
+ --((PyObject*)(op))->ob_refcnt != 0) \
+ _Py_CHECK_REFCNT(op) \
+ else \
+ _Py_Dealloc((PyObject *)(op))
+#endif
+
+void _XINCREF( PyObject *op )
+{
+ // This function must match the contents of Py_XINCREF(op)
+ if( op == NULL )
+ return;
+
+#ifdef Py_REF_DEBUG
+ (*ptr_Py_RefTotal)++;
+#endif
+ (op)->ob_refcnt++;
+
+}
+
+void _XDECREF( PyObject *op )
+{
+ // This function must match the contents of Py_XDECREF(op);
+ if( op == NULL )
+ return;
+
+#ifdef Py_REF_DEBUG
+ (*ptr_Py_RefTotal)--;
+#endif
+
+ if (--(op)->ob_refcnt == 0)
+ _Py_Dealloc((PyObject *)(op));
+}
+
+
+#else
+#error "Can only delay load under Win32"
+#endif
+
+#else
+
+//================================================================================
+//
+// Map onto Macros
+//
+//================================================================================
+
+//
+// Wrap variables as function calls
+//
+
+PyObject *_Exc_ArithmeticError() { return ::PyExc_ArithmeticError; }
+PyObject *_Exc_AssertionError() { return ::PyExc_AssertionError; }
+PyObject *_Exc_AttributeError() { return ::PyExc_AttributeError; }
+PyObject *_Exc_EnvironmentError() { return ::PyExc_EnvironmentError; }
+PyObject *_Exc_EOFError() { return ::PyExc_EOFError; }
+PyObject *_Exc_Exception() { return ::PyExc_Exception; }
+PyObject *_Exc_FloatingPointError() { return ::PyExc_FloatingPointError; }
+PyObject *_Exc_ImportError() { return ::PyExc_ImportError; }
+PyObject *_Exc_IndexError() { return ::PyExc_IndexError; }
+PyObject *_Exc_IOError() { return ::PyExc_IOError; }
+PyObject *_Exc_KeyboardInterrupt() { return ::PyExc_KeyboardInterrupt; }
+PyObject *_Exc_KeyError() { return ::PyExc_KeyError; }
+PyObject *_Exc_LookupError() { return ::PyExc_LookupError; }
+PyObject *_Exc_MemoryError() { return ::PyExc_MemoryError; }
+PyObject *_Exc_NameError() { return ::PyExc_NameError; }
+PyObject *_Exc_NotImplementedError() { return ::PyExc_NotImplementedError; }
+PyObject *_Exc_OSError() { return ::PyExc_OSError; }
+PyObject *_Exc_OverflowError() { return ::PyExc_OverflowError; }
+PyObject *_Exc_RuntimeError() { return ::PyExc_RuntimeError; }
+PyObject *_Exc_SyntaxError() { return ::PyExc_SyntaxError; }
+PyObject *_Exc_SystemError() { return ::PyExc_SystemError; }
+PyObject *_Exc_SystemExit() { return ::PyExc_SystemExit; }
+PyObject *_Exc_TypeError() { return ::PyExc_TypeError; }
+PyObject *_Exc_ValueError() { return ::PyExc_ValueError; }
+PyObject *_Exc_ZeroDivisionError() { return ::PyExc_ZeroDivisionError; }
+PyObject *_Exc_IndentationError() { return ::PyExc_IndentationError; }
+PyObject *_Exc_TabError() { return ::PyExc_TabError; }
+PyObject *_Exc_UnboundLocalError() { return ::PyExc_UnboundLocalError; }
+PyObject *_Exc_UnicodeError() { return ::PyExc_UnicodeError; }
+
+#ifdef MS_WINDOWS
+PyObject *_Exc_WindowsError() { return ::PyExc_WindowsError; }
+#endif
+
+
+
+
+//
+// wrap items in Object.h
+//
+PyObject *_None() { return &::_Py_NoneStruct; }
+
+PyObject *_False() { return Py_False; }
+PyObject *_True() { return Py_True; }
+
+PyTypeObject *_CFunction_Type() { return &PyCFunction_Type; }
+PyTypeObject *_Complex_Type() { return &PyComplex_Type; }
+PyTypeObject *_Dict_Type() { return &PyDict_Type; }
+PyTypeObject *_Float_Type() { return &PyFloat_Type; }
+PyTypeObject *_Function_Type() { return &PyFunction_Type; }
+PyTypeObject *_Bool_Type() { return &PyBool_Type; }
+PyTypeObject *_List_Type() { return &PyList_Type; }
+PyTypeObject *_Long_Type() { return &PyLong_Type; }
+PyTypeObject *_Method_Type() { return &PyMethod_Type; }
+PyTypeObject *_Module_Type() { return &PyModule_Type; }
+PyTypeObject *_Range_Type() { return &PyRange_Type; }
+PyTypeObject *_Slice_Type() { return &PySlice_Type; }
+PyTypeObject *_TraceBack_Type() { return &PyTraceBack_Type; }
+PyTypeObject *_Tuple_Type() { return &PyTuple_Type; }
+PyTypeObject *_Type_Type() { return &PyType_Type; }
+PyTypeObject *_Unicode_Type() { return &PyUnicode_Type; }
+#if PY_MAJOR_VERSION == 2
+PyTypeObject *_String_Type() { return &PyString_Type; }
+PyTypeObject *_Int_Type() { return &PyInt_Type; }
+PyTypeObject *_CObject_Type() { return &PyCObject_Type; }
+#endif
+#if PY_MAJOR_VERSION >= 3
+PyTypeObject *_Bytes_Type() { return &PyBytes_Type; }
+#endif
+
+//
+// wrap flags
+//
+int &_Py_DebugFlag() { return Py_DebugFlag; }
+int &_Py_InteractiveFlag() { return Py_InteractiveFlag; }
+int &_Py_OptimizeFlag() { return Py_OptimizeFlag; }
+int &_Py_NoSiteFlag() { return Py_NoSiteFlag; }
+int &_Py_VerboseFlag() { return Py_VerboseFlag; }
+char *__Py_PackageContext() { return _Py_PackageContext; }
+
+//
+// Needed to keep the abstactions for delayload interface
+//
+void _XINCREF( PyObject *op )
+{
+ Py_XINCREF( op );
+}
+
+void _XDECREF( PyObject *op )
+{
+ Py_XDECREF( op );
+}
+
#endif
+}
diff --git a/CXX/Python2/ExtensionModule.hxx b/CXX/Python2/ExtensionModule.hxx
index dde3ec6f854b..3eb436d00048 100644
--- a/CXX/Python2/ExtensionModule.hxx
+++ b/CXX/Python2/ExtensionModule.hxx
@@ -66,9 +66,6 @@ namespace Py
const std::string m_module_name;
const std::string m_full_module_name;
MethodTable m_method_table;
-#if PY3
- PyModuleDef m_module_def;
-#endif
PyObject *m_module;
private:
@@ -136,19 +133,11 @@ namespace Py
{
MethodDefExt *method_def = (*i).second;
- #if PY_VERSION_HEX < 0x02070000
- static PyObject *self = PyCObject_FromVoidPtr( this, do_not_dealloc );
- #else
- static PyObject *self = PyCapsule_New( this, NULL, NULL );
- #endif
+ static PyObject *self = PyCObject_FromVoidPtr( this, do_not_dealloc );
Tuple args( 2 );
- args[0] = Object( self );
- #if PY_VERSION_HEX < 0x02070000
- args[1] = Object( PyCObject_FromVoidPtr( method_def, do_not_dealloc ) );
- #else
- args[1] = Object( PyCapsule_New( method_def, NULL, NULL ) );
- #endif
+ args[0] = Object( self, true );
+ args[1] = Object( PyCObject_FromVoidPtr( method_def, do_not_dealloc ), true );
PyObject *func = PyCFunction_New
(
diff --git a/CXX/Python2/ExtensionOldType.hxx b/CXX/Python2/ExtensionOldType.hxx
index 9702b00e7455..cfd2fbe6a578 100644
--- a/CXX/Python2/ExtensionOldType.hxx
+++ b/CXX/Python2/ExtensionOldType.hxx
@@ -178,11 +178,8 @@ namespace Py
Tuple self( 2 );
self[0] = Object( this );
- #if PY_VERSION_HEX < 0x02070000
- self[1] = Object( PyCObject_FromVoidPtr( method_def, do_not_dealloc ), true );
- #else
- self[1] = Object( PyCapsule_New( method_def, NULL, NULL ), true );
- #endif
+ self[1] = Object( PyCObject_FromVoidPtr( method_def, do_not_dealloc ), true );
+
PyObject *func = PyCFunction_New( &method_def->ext_meth_def, self.ptr() );
return Object(func, true);
@@ -238,12 +235,8 @@ namespace Py
PyObject *self_in_cobject = self_and_name_tuple[0].ptr();
T *self = static_cast( self_in_cobject );
- #if PY_VERSION_HEX < 0x02070000
- void *capsule = PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() );
- #else
- void *capsule = PyCapsule_GetPointer( self_and_name_tuple[1].ptr(), NULL );
- #endif
- MethodDefExt *meth_def = reinterpret_cast *>( capsule );
+ MethodDefExt *meth_def = reinterpret_cast *>(
+ PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() ) );
Object result;
// Adding try & catch in case of STL debug-mode exceptions.
@@ -278,12 +271,8 @@ namespace Py
PyObject *self_in_cobject = self_and_name_tuple[0].ptr();
T *self = static_cast( self_in_cobject );
- #if PY_VERSION_HEX < 0x02070000
- void *capsule = PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() );
- #else
- void *capsule = PyCapsule_GetPointer( self_and_name_tuple[1].ptr(), NULL );
- #endif
- MethodDefExt *meth_def = reinterpret_cast *>( capsule );
+ MethodDefExt *meth_def = reinterpret_cast *>(
+ PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() ) );
Tuple args( _args );
Object result;
@@ -319,12 +308,8 @@ namespace Py
PyObject *self_in_cobject = self_and_name_tuple[0].ptr();
T *self = static_cast( self_in_cobject );
- #if PY_VERSION_HEX < 0x02070000
- void *capsule = PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() );
- #else
- void *capsule = PyCapsule_GetPointer( self_and_name_tuple[1].ptr(), NULL );
- #endif
- MethodDefExt *meth_def = reinterpret_cast *>( capsule );
+ MethodDefExt *meth_def = reinterpret_cast *>(
+ PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() ) );
Tuple args( _args );
diff --git a/CXX/Python2/ExtensionTypeBase.hxx b/CXX/Python2/ExtensionTypeBase.hxx
index ad11029e71dc..1dfe4243619a 100644
--- a/CXX/Python2/ExtensionTypeBase.hxx
+++ b/CXX/Python2/ExtensionTypeBase.hxx
@@ -70,9 +70,7 @@ namespace Py
virtual void reinit( Tuple &args, Dict &kwds );
// object basics
-#if defined( PYCXX_PYTHON_2TO3 ) || !defined( PY3 )
virtual int print( FILE *, int );
-#endif
virtual Object getattr( const char * );
virtual int setattr( const char *, const Object & );
virtual Object getattro( const String & );
diff --git a/CXX/Python2/IndirectPythonInterface.cxx b/CXX/Python2/IndirectPythonInterface.cxx
deleted file mode 100644
index 203f3f9170ff..000000000000
--- a/CXX/Python2/IndirectPythonInterface.cxx
+++ /dev/null
@@ -1,607 +0,0 @@
-//-----------------------------------------------------------------------------
-//
-// Copyright (c) 1998 - 2007, The Regents of the University of California
-// Produced at the Lawrence Livermore National Laboratory
-// All rights reserved.
-//
-// This file is part of PyCXX. For details,see http://cxx.sourceforge.net/. The
-// full copyright notice is contained in the file COPYRIGHT located at the root
-// of the PyCXX distribution.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// - Redistributions of source code must retain the above copyright notice,
-// this list of conditions and the disclaimer below.
-// - Redistributions in binary form must reproduce the above copyright notice,
-// this list of conditions and the disclaimer (as noted below) in the
-// documentation and/or materials provided with the distribution.
-// - Neither the name of the UC/LLNL nor the names of its contributors may be
-// used to endorse or promote products derived from this software without
-// specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OF THE UNIVERSITY OF
-// CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR
-// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-// DAMAGE.
-//
-//-----------------------------------------------------------------------------
-
-#include "CXX/IndirectPythonInterface.hxx"
-
-namespace Py
-{
-bool _Buffer_Check( PyObject *op ) { return (op)->ob_type == _Buffer_Type(); }
-bool _CFunction_Check( PyObject *op ) { return (op)->ob_type == _CFunction_Type(); }
-bool _Class_Check( PyObject *op ) { return (op)->ob_type == _Class_Type(); }
-#if PY_VERSION_HEX < 0x02070000
-bool _CObject_Check( PyObject *op ) { return (op)->ob_type == _CObject_Type(); }
-#endif
-bool _Complex_Check( PyObject *op ) { return (op)->ob_type == _Complex_Type(); }
-bool _Dict_Check( PyObject *op ) { return (op)->ob_type == _Dict_Type(); }
-bool _File_Check( PyObject *op ) { return (op)->ob_type == _File_Type(); }
-bool _Float_Check( PyObject *op ) { return (op)->ob_type == _Float_Type(); }
-bool _Function_Check( PyObject *op ) { return (op)->ob_type == _Function_Type(); }
-bool _Instance_Check( PyObject *op ) { return (op)->ob_type == _Instance_Type(); }
-bool _Boolean_Check( PyObject *op ) { return (op)->ob_type == _Bool_Type(); }
-bool _Int_Check( PyObject *op ) { return (op)->ob_type == _Int_Type(); }
-bool _List_Check( PyObject *o ) { return o->ob_type == _List_Type(); }
-bool _Long_Check( PyObject *op ) { return (op)->ob_type == _Long_Type(); }
-bool _Method_Check( PyObject *op ) { return (op)->ob_type == _Method_Type(); }
-bool _Module_Check( PyObject *op ) { return (op)->ob_type == _Module_Type(); }
-bool _Range_Check( PyObject *op ) { return (op)->ob_type == _Range_Type(); }
-bool _Slice_Check( PyObject *op ) { return (op)->ob_type == _Slice_Type(); }
-bool _String_Check( PyObject *o ) { return o->ob_type == _String_Type(); }
-bool _TraceBack_Check( PyObject *v ) { return (v)->ob_type == _TraceBack_Type(); }
-bool _Tuple_Check( PyObject *op ) { return (op)->ob_type == _Tuple_Type(); }
-bool _Type_Check( PyObject *op ) { return (op)->ob_type == _Type_Type(); }
-
-#if PY_MAJOR_VERSION >= 2
-bool _Unicode_Check( PyObject *op ) { return (op)->ob_type == _Unicode_Type(); }
-#endif
-
-
-
-#if defined(PY_WIN32_DELAYLOAD_PYTHON_DLL)
-
-#if defined(MS_WINDOWS)
-#include
-
-
-static HMODULE python_dll;
-
-static PyObject *ptr__Exc_ArithmeticError = NULL;
-static PyObject *ptr__Exc_AssertionError = NULL;
-static PyObject *ptr__Exc_AttributeError = NULL;
-static PyObject *ptr__Exc_EnvironmentError = NULL;
-static PyObject *ptr__Exc_EOFError = NULL;
-static PyObject *ptr__Exc_Exception = NULL;
-static PyObject *ptr__Exc_FloatingPointError = NULL;
-static PyObject *ptr__Exc_ImportError = NULL;
-static PyObject *ptr__Exc_IndexError = NULL;
-static PyObject *ptr__Exc_IOError = NULL;
-static PyObject *ptr__Exc_KeyboardInterrupt = NULL;
-static PyObject *ptr__Exc_KeyError = NULL;
-static PyObject *ptr__Exc_LookupError = NULL;
-static PyObject *ptr__Exc_MemoryError = NULL;
-static PyObject *ptr__Exc_MemoryErrorInst = NULL;
-static PyObject *ptr__Exc_NameError = NULL;
-static PyObject *ptr__Exc_NotImplementedError = NULL;
-static PyObject *ptr__Exc_OSError = NULL;
-static PyObject *ptr__Exc_OverflowError = NULL;
-static PyObject *ptr__Exc_RuntimeError = NULL;
-static PyObject *ptr__Exc_StandardError = NULL;
-static PyObject *ptr__Exc_SyntaxError = NULL;
-static PyObject *ptr__Exc_SystemError = NULL;
-static PyObject *ptr__Exc_SystemExit = NULL;
-static PyObject *ptr__Exc_TypeError = NULL;
-static PyObject *ptr__Exc_ValueError = NULL;
-static PyObject *ptr__Exc_ZeroDivisionError = NULL;
-
-#ifdef MS_WINDOWS
-static PyObject *ptr__Exc_WindowsError = NULL;
-#endif
-
-#if PY_MAJOR_VERSION >= 2
-static PyObject *ptr__Exc_IndentationError = NULL;
-static PyObject *ptr__Exc_TabError = NULL;
-static PyObject *ptr__Exc_UnboundLocalError = NULL;
-static PyObject *ptr__Exc_UnicodeError = NULL;
-#endif
-
-static PyObject *ptr__PyNone = NULL;
-
-static PyObject *ptr__PyFalse = NULL;
-static PyObject *ptr__PyTrue = NULL;
-
-static PyTypeObject *ptr__Buffer_Type = NULL;
-static PyTypeObject *ptr__CFunction_Type = NULL;
-static PyTypeObject *ptr__Class_Type = NULL;
-#if PY_VERSION_HEX < 0x02070000
-static PyTypeObject *ptr__CObject_Type = NULL;
-#endif
-static PyTypeObject *ptr__Complex_Type = NULL;
-static PyTypeObject *ptr__Dict_Type = NULL;
-static PyTypeObject *ptr__File_Type = NULL;
-static PyTypeObject *ptr__Float_Type = NULL;
-static PyTypeObject *ptr__Function_Type = NULL;
-static PyTypeObject *ptr__Instance_Type = NULL;
-static PyTypeObject *ptr__Int_Type = NULL;
-static PyTypeObject *ptr__List_Type = NULL;
-static PyTypeObject *ptr__Long_Type = NULL;
-static PyTypeObject *ptr__Method_Type = NULL;
-static PyTypeObject *ptr__Module_Type = NULL;
-static PyTypeObject *ptr__Range_Type = NULL;
-static PyTypeObject *ptr__Slice_Type = NULL;
-static PyTypeObject *ptr__String_Type = NULL;
-static PyTypeObject *ptr__TraceBack_Type = NULL;
-static PyTypeObject *ptr__Tuple_Type = NULL;
-static PyTypeObject *ptr__Type_Type = NULL;
-
-#if PY_MAJOR_VERSION >= 2
-static PyTypeObject *ptr__Unicode_Type = NULL;
-#endif
-
-static int *ptr_Py_DebugFlag = NULL;
-static int *ptr_Py_InteractiveFlag = NULL;
-static int *ptr_Py_OptimizeFlag = NULL;
-static int *ptr_Py_NoSiteFlag = NULL;
-static int *ptr_Py_TabcheckFlag = NULL;
-static int *ptr_Py_VerboseFlag = NULL;
-
-#if PY_MAJOR_VERSION >= 2
-static int *ptr_Py_UnicodeFlag = NULL;
-#endif
-
-static char **ptr__Py_PackageContext = NULL;
-
-#ifdef Py_REF_DEBUG
-int *ptr_Py_RefTotal;
-#endif
-
-
-//--------------------------------------------------------------------------------
-class GetAddressException
-{
-public:
- GetAddressException( const char *_name )
- : name( _name )
- {}
- virtual ~GetAddressException() {}
- const char *name;
-};
-
-
-//--------------------------------------------------------------------------------
-static PyObject *GetPyObjectPointer_As_PyObjectPointer( const char *name )
-{
- FARPROC addr = GetProcAddress( python_dll, name );
- if( addr == NULL )
- throw GetAddressException( name );
-
- return *(PyObject **)addr;
-}
-
-static PyObject *GetPyObject_As_PyObjectPointer( const char *name )
-{
- FARPROC addr = GetProcAddress( python_dll, name );
- if( addr == NULL )
- throw GetAddressException( name );
-
- return (PyObject *)addr;
-}
-
-static PyTypeObject *GetPyTypeObjectPointer_As_PyTypeObjectPointer( const char *name )
-{
- FARPROC addr = GetProcAddress( python_dll, name );
- if( addr == NULL )
- throw GetAddressException( name );
-
- return *(PyTypeObject **)addr;
-}
-
-static PyTypeObject *GetPyTypeObject_As_PyTypeObjectPointer( const char *name )
-{
- FARPROC addr = GetProcAddress( python_dll, name );
- if( addr == NULL )
- throw GetAddressException( name );
-
- return (PyTypeObject *)addr;
-}
-
-static int *GetInt_as_IntPointer( const char *name )
-{
- FARPROC addr = GetProcAddress( python_dll, name );
- if( addr == NULL )
- throw GetAddressException( name );
-
- return (int *)addr;
-}
-
-static char **GetCharPointer_as_CharPointerPointer( const char *name )
-{
- FARPROC addr = GetProcAddress( python_dll, name );
- if( addr == NULL )
- throw GetAddressException( name );
-
- return (char **)addr;
-}
-
-
-#ifdef _DEBUG
-static const char python_dll_name_format[] = "PYTHON%1.1d%1.1d_D.DLL";
-#else
-static const char python_dll_name_format[] = "PYTHON%1.1d%1.1d.DLL";
-#endif
-
-//--------------------------------------------------------------------------------
-bool InitialisePythonIndirectInterface()
-{
- char python_dll_name[sizeof(python_dll_name_format)];
-
- sprintf( python_dll_name, python_dll_name_format, PY_MAJOR_VERSION, PY_MINOR_VERSION );
-
- python_dll = LoadLibrary( python_dll_name );
- if( python_dll == NULL )
- return false;
-
- try
-{
-#ifdef Py_REF_DEBUG
- ptr_Py_RefTotal = GetInt_as_IntPointer( "_Py_RefTotal" );
-#endif
- ptr_Py_DebugFlag = GetInt_as_IntPointer( "Py_DebugFlag" );
- ptr_Py_InteractiveFlag = GetInt_as_IntPointer( "Py_InteractiveFlag" );
- ptr_Py_OptimizeFlag = GetInt_as_IntPointer( "Py_OptimizeFlag" );
- ptr_Py_NoSiteFlag = GetInt_as_IntPointer( "Py_NoSiteFlag" );
- ptr_Py_TabcheckFlag = GetInt_as_IntPointer( "Py_TabcheckFlag" );
- ptr_Py_VerboseFlag = GetInt_as_IntPointer( "Py_VerboseFlag" );
-#if PY_MAJOR_VERSION >= 2
- ptr_Py_UnicodeFlag = GetInt_as_IntPointer( "Py_UnicodeFlag" );
-#endif
- ptr__Py_PackageContext = GetCharPointer_as_CharPointerPointer( "_Py_PackageContext" );
-
- ptr__Exc_ArithmeticError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_ArithmeticError" );
- ptr__Exc_AssertionError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_AssertionError" );
- ptr__Exc_AttributeError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_AttributeError" );
- ptr__Exc_EnvironmentError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_EnvironmentError" );
- ptr__Exc_EOFError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_EOFError" );
- ptr__Exc_Exception = GetPyObjectPointer_As_PyObjectPointer( "PyExc_Exception" );
- ptr__Exc_FloatingPointError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_FloatingPointError" );
- ptr__Exc_ImportError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_ImportError" );
- ptr__Exc_IndexError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_IndexError" );
- ptr__Exc_IOError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_IOError" );
- ptr__Exc_KeyboardInterrupt = GetPyObjectPointer_As_PyObjectPointer( "PyExc_KeyboardInterrupt" );
- ptr__Exc_KeyError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_KeyError" );
- ptr__Exc_LookupError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_LookupError" );
- ptr__Exc_MemoryError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_MemoryError" );
- ptr__Exc_MemoryErrorInst = GetPyObjectPointer_As_PyObjectPointer( "PyExc_MemoryErrorInst" );
- ptr__Exc_NameError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_NameError" );
- ptr__Exc_NotImplementedError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_NotImplementedError" );
- ptr__Exc_OSError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_OSError" );
- ptr__Exc_OverflowError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_OverflowError" );
- ptr__Exc_RuntimeError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_RuntimeError" );
- ptr__Exc_StandardError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_StandardError" );
- ptr__Exc_SyntaxError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_SyntaxError" );
- ptr__Exc_SystemError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_SystemError" );
- ptr__Exc_SystemExit = GetPyObjectPointer_As_PyObjectPointer( "PyExc_SystemExit" );
- ptr__Exc_TypeError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_TypeError" );
- ptr__Exc_ValueError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_ValueError" );
-#ifdef MS_WINDOWS
- ptr__Exc_WindowsError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_WindowsError" );
-#endif
- ptr__Exc_ZeroDivisionError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_ZeroDivisionError" );
-
-#if PY_MAJOR_VERSION >= 2
- ptr__Exc_IndentationError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_IndentationError" );
- ptr__Exc_TabError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_TabError" );
- ptr__Exc_UnboundLocalError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_UnboundLocalError" );
- ptr__Exc_UnicodeError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_UnicodeError" );
-#endif
- ptr__PyNone = GetPyObject_As_PyObjectPointer( "_Py_NoneStruct" );
-
- ptr__PyFalse = GetPyObject_As_PyObjectPointer( "_Py_ZeroStruct" );
- ptr__PyTrue = GetPyObject_As_PyObjectPointer( "_Py_TrueStruct" );
-
- ptr__Buffer_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyBuffer_Type" );
- ptr__CFunction_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyCFunction_Type" );
- ptr__Class_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyClass_Type" );
-#if PY_VERSION_HEX < 0x02070000
- ptr__CObject_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyCObject_Type" );
-#endif
- ptr__Complex_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyComplex_Type" );
- ptr__Dict_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyDict_Type" );
- ptr__File_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyFile_Type" );
- ptr__Float_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyFloat_Type" );
- ptr__Function_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyFunction_Type" );
- ptr__Instance_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyInstance_Type" );
- ptr__Int_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyInt_Type" );
- ptr__List_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyList_Type" );
- ptr__Long_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyLong_Type" );
- ptr__Method_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyMethod_Type" );
- ptr__Module_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyModule_Type" );
- ptr__Range_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyRange_Type" );
- ptr__Slice_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PySlice_Type" );
- ptr__String_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyString_Type" );
- ptr__TraceBack_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyTraceBack_Type" );
- ptr__Tuple_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyTuple_Type" );
- ptr__Type_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyType_Type" );
-
-#if PY_MAJOR_VERSION >= 2
- ptr__Unicode_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyUnicode_Type" );
-#endif
-}
- catch( GetAddressException &e )
- {
- OutputDebugString( python_dll_name );
- OutputDebugString( " does not contain symbol ");
- OutputDebugString( e.name );
- OutputDebugString( "\n" );
-
- return false;
- }
-
- return true;
-}
-
-//
-// Wrap variables as function calls
-//
-PyObject * _Exc_ArithmeticError(){ return ptr__Exc_ArithmeticError; }
-PyObject * _Exc_AssertionError(){ return ptr__Exc_AssertionError; }
-PyObject * _Exc_AttributeError(){ return ptr__Exc_AttributeError; }
-PyObject * _Exc_EnvironmentError(){ return ptr__Exc_EnvironmentError; }
-PyObject * _Exc_EOFError() { return ptr__Exc_EOFError; }
-PyObject * _Exc_Exception() { return ptr__Exc_Exception; }
-PyObject * _Exc_FloatingPointError(){ return ptr__Exc_FloatingPointError; }
-PyObject * _Exc_ImportError() { return ptr__Exc_ImportError; }
-PyObject * _Exc_IndexError() { return ptr__Exc_IndexError; }
-PyObject * _Exc_IOError() { return ptr__Exc_IOError; }
-PyObject * _Exc_KeyboardInterrupt(){ return ptr__Exc_KeyboardInterrupt; }
-PyObject * _Exc_KeyError() { return ptr__Exc_KeyError; }
-PyObject * _Exc_LookupError() { return ptr__Exc_LookupError; }
-PyObject * _Exc_MemoryError() { return ptr__Exc_MemoryError; }
-PyObject * _Exc_MemoryErrorInst(){ return ptr__Exc_MemoryErrorInst; }
-PyObject * _Exc_NameError() { return ptr__Exc_NameError; }
-PyObject * _Exc_NotImplementedError(){ return ptr__Exc_NotImplementedError; }
-PyObject * _Exc_OSError() { return ptr__Exc_OSError; }
-PyObject * _Exc_OverflowError() { return ptr__Exc_OverflowError; }
-PyObject * _Exc_RuntimeError() { return ptr__Exc_RuntimeError; }
-PyObject * _Exc_StandardError() { return ptr__Exc_StandardError; }
-PyObject * _Exc_SyntaxError() { return ptr__Exc_SyntaxError; }
-PyObject * _Exc_SystemError() { return ptr__Exc_SystemError; }
-PyObject * _Exc_SystemExit() { return ptr__Exc_SystemExit; }
-PyObject * _Exc_TypeError() { return ptr__Exc_TypeError; }
-PyObject * _Exc_ValueError() { return ptr__Exc_ValueError; }
-#ifdef MS_WINDOWS
-PyObject * _Exc_WindowsError() { return ptr__Exc_WindowsError; }
-#endif
-PyObject * _Exc_ZeroDivisionError(){ return ptr__Exc_ZeroDivisionError; }
-
-#if PY_MAJOR_VERSION >= 2
-PyObject * _Exc_IndentationError(){ return ptr__Exc_IndentationError; }
-PyObject * _Exc_TabError() { return ptr__Exc_TabError; }
-PyObject * _Exc_UnboundLocalError(){ return ptr__Exc_UnboundLocalError; }
-PyObject * _Exc_UnicodeError() { return ptr__Exc_UnicodeError; }
-#endif
-
-//
-// wrap items in Object.h
-//
-PyObject * _None() { return ptr__PyNone; }
-
-PyObject * _False() { return ptr__PyFalse; }
-PyObject * _True() { return ptr__PyTrue; }
-
-PyTypeObject * _Buffer_Type() { return ptr__Buffer_Type; }
-PyTypeObject * _CFunction_Type(){ return ptr__CFunction_Type; }
-PyTypeObject * _Class_Type() { return ptr__Class_Type; }
-#if PY_VERSION_HEX < 0x02070000
-PyTypeObject * _CObject_Type() { return ptr__CObject_Type; }
-#endif
-PyTypeObject * _Complex_Type() { return ptr__Complex_Type; }
-PyTypeObject * _Dict_Type() { return ptr__Dict_Type; }
-PyTypeObject * _File_Type() { return ptr__File_Type; }
-PyTypeObject * _Float_Type() { return ptr__Float_Type; }
-PyTypeObject * _Function_Type() { return ptr__Function_Type; }
-PyTypeObject * _Instance_Type() { return ptr__Instance_Type; }
-PyTypeObject * _Bool_Type() { return ptr__Bool_Type; }
-PyTypeObject * _Int_Type() { return ptr__Int_Type; }
-PyTypeObject * _List_Type() { return ptr__List_Type; }
-PyTypeObject * _Long_Type() { return ptr__Long_Type; }
-PyTypeObject * _Method_Type() { return ptr__Method_Type; }
-PyTypeObject * _Module_Type() { return ptr__Module_Type; }
-PyTypeObject * _Range_Type() { return ptr__Range_Type; }
-PyTypeObject * _Slice_Type() { return ptr__Slice_Type; }
-PyTypeObject * _String_Type() { return ptr__String_Type; }
-PyTypeObject * _TraceBack_Type(){ return ptr__TraceBack_Type; }
-PyTypeObject * _Tuple_Type() { return ptr__Tuple_Type; }
-PyTypeObject * _Type_Type() { return ptr__Type_Type; }
-
-#if PY_MAJOR_VERSION >= 2
-PyTypeObject * _Unicode_Type() { return ptr__Unicode_Type; }
-#endif
-
-char *__Py_PackageContext() { return *ptr__Py_PackageContext; }
-
-
-//
-// wrap the Python Flag variables
-//
-int &_Py_DebugFlag() { return *ptr_Py_DebugFlag; }
-int &_Py_InteractiveFlag() { return *ptr_Py_InteractiveFlag; }
-int &_Py_OptimizeFlag() { return *ptr_Py_OptimizeFlag; }
-int &_Py_NoSiteFlag() { return *ptr_Py_NoSiteFlag; }
-int &_Py_TabcheckFlag() { return *ptr_Py_TabcheckFlag; }
-int &_Py_VerboseFlag() { return *ptr_Py_VerboseFlag; }
-#if PY_MAJOR_VERSION >= 2
-int &_Py_UnicodeFlag() { return *ptr_Py_UnicodeFlag; }
-#endif
-
-void _XINCREF( PyObject *op )
-{
- // This function must match the contents of Py_XINCREF(op)
- if( op == NULL )
- return;
-
-#ifdef Py_REF_DEBUG
- (*ptr_Py_RefTotal)++;
-#endif
- (op)->ob_refcnt++;
-
-}
-
-void _XDECREF( PyObject *op )
-{
- // This function must match the contents of Py_XDECREF(op);
- if( op == NULL )
- return;
-
-#ifdef Py_REF_DEBUG
- (*ptr_Py_RefTotal)--;
-#endif
-
- if (--(op)->ob_refcnt == 0)
- _Py_Dealloc((PyObject *)(op));
-}
-
-
-#else
-#error "Can only delay load under Win32"
-#endif
-
-#else
-
-//
-// Duplicated these declarations from rangeobject.h which is missing the
-// extern "C". This has been reported as a bug upto and include 2.1
-//
-extern "C" DL_IMPORT(PyTypeObject) PyRange_Type;
-extern "C" DL_IMPORT(PyObject *) PyRange_New(long, long, long, int);
-
-
-//================================================================================
-//
-// Map onto Macros
-//
-//================================================================================
-
-//
-// Wrap variables as function calls
-//
-
-PyObject * _Exc_ArithmeticError() { return ::PyExc_ArithmeticError; }
-PyObject * _Exc_AssertionError() { return ::PyExc_AssertionError; }
-PyObject * _Exc_AttributeError() { return ::PyExc_AttributeError; }
-PyObject * _Exc_EnvironmentError() { return ::PyExc_EnvironmentError; }
-PyObject * _Exc_EOFError() { return ::PyExc_EOFError; }
-PyObject * _Exc_Exception() { return ::PyExc_Exception; }
-PyObject * _Exc_FloatingPointError() { return ::PyExc_FloatingPointError; }
-PyObject * _Exc_ImportError() { return ::PyExc_ImportError; }
-PyObject * _Exc_IndexError() { return ::PyExc_IndexError; }
-PyObject * _Exc_IOError() { return ::PyExc_IOError; }
-PyObject * _Exc_KeyboardInterrupt() { return ::PyExc_KeyboardInterrupt; }
-PyObject * _Exc_KeyError() { return ::PyExc_KeyError; }
-PyObject * _Exc_LookupError() { return ::PyExc_LookupError; }
-PyObject * _Exc_MemoryError() { return ::PyExc_MemoryError; }
-PyObject * _Exc_MemoryErrorInst() { return ::PyExc_MemoryErrorInst; }
-PyObject * _Exc_NameError() { return ::PyExc_NameError; }
-PyObject * _Exc_NotImplementedError() { return ::PyExc_NotImplementedError; }
-PyObject * _Exc_OSError() { return ::PyExc_OSError; }
-PyObject * _Exc_OverflowError() { return ::PyExc_OverflowError; }
-PyObject * _Exc_RuntimeError() { return ::PyExc_RuntimeError; }
-PyObject * _Exc_StandardError() { return ::PyExc_StandardError; }
-PyObject * _Exc_SyntaxError() { return ::PyExc_SyntaxError; }
-PyObject * _Exc_SystemError() { return ::PyExc_SystemError; }
-PyObject * _Exc_SystemExit() { return ::PyExc_SystemExit; }
-PyObject * _Exc_TypeError() { return ::PyExc_TypeError; }
-PyObject * _Exc_ValueError() { return ::PyExc_ValueError; }
-PyObject * _Exc_ZeroDivisionError() { return ::PyExc_ZeroDivisionError; }
-
-#ifdef MS_WINDOWS
-PyObject * _Exc_WindowsError() { return ::PyExc_WindowsError; }
-#endif
-
-
-#if PY_MAJOR_VERSION >= 2
-PyObject * _Exc_IndentationError() { return ::PyExc_IndentationError; }
-PyObject * _Exc_TabError() { return ::PyExc_TabError; }
-PyObject * _Exc_UnboundLocalError() { return ::PyExc_UnboundLocalError; }
-PyObject * _Exc_UnicodeError() { return ::PyExc_UnicodeError; }
-#endif
-
-
-//
-// wrap items in Object.h
-//
-PyObject * _None() { return &::_Py_NoneStruct; }
-
-PyObject * _False() { return Py_False; }
-PyObject * _True() { return Py_True; }
-
-PyTypeObject * _Buffer_Type() { return &PyBuffer_Type; }
-PyTypeObject * _CFunction_Type() { return &PyCFunction_Type; }
-PyTypeObject * _Class_Type() { return &PyClass_Type; }
-#if PY_VERSION_HEX < 0x02070000
-PyTypeObject * _CObject_Type() { return &PyCObject_Type; }
-#endif
-PyTypeObject * _Complex_Type() { return &PyComplex_Type; }
-PyTypeObject * _Dict_Type() { return &PyDict_Type; }
-PyTypeObject * _File_Type() { return &PyFile_Type; }
-PyTypeObject * _Float_Type() { return &PyFloat_Type; }
-PyTypeObject * _Function_Type() { return &PyFunction_Type; }
-PyTypeObject * _Instance_Type() { return &PyInstance_Type; }
-PyTypeObject * _Bool_Type() { return &PyBool_Type; }
-PyTypeObject * _Int_Type() { return &PyInt_Type; }
-PyTypeObject * _List_Type() { return &PyList_Type; }
-PyTypeObject * _Long_Type() { return &PyLong_Type; }
-PyTypeObject * _Method_Type() { return &PyMethod_Type; }
-PyTypeObject * _Module_Type() { return &PyModule_Type; }
-PyTypeObject * _Range_Type() { return &PyRange_Type; }
-PyTypeObject * _Slice_Type() { return &PySlice_Type; }
-PyTypeObject * _String_Type() { return &PyString_Type; }
-PyTypeObject * _TraceBack_Type() { return &PyTraceBack_Type; }
-PyTypeObject * _Tuple_Type() { return &PyTuple_Type; }
-PyTypeObject * _Type_Type() { return &PyType_Type; }
-
-#if PY_MAJOR_VERSION >= 2
-PyTypeObject * _Unicode_Type() { return &PyUnicode_Type; }
-#endif
-
-//
-// wrap flags
-//
-int &_Py_DebugFlag() { return Py_DebugFlag; }
-int &_Py_InteractiveFlag(){ return Py_InteractiveFlag; }
-int &_Py_OptimizeFlag() { return Py_OptimizeFlag; }
-int &_Py_NoSiteFlag() { return Py_NoSiteFlag; }
-int &_Py_TabcheckFlag() { return Py_TabcheckFlag; }
-int &_Py_VerboseFlag() { return Py_VerboseFlag; }
-#if PY_MAJOR_VERSION >= 2
-int &_Py_UnicodeFlag() { return Py_UnicodeFlag; }
-#endif
-char *__Py_PackageContext(){ return _Py_PackageContext; }
-
-//
-// Needed to keep the abstactions for delayload interface
-//
-void _XINCREF( PyObject *op )
-{
- Py_XINCREF(op);
-}
-
-void _XDECREF( PyObject *op )
-{
- Py_XDECREF(op);
-}
-
-#endif
-}
diff --git a/CXX/Python2/IndirectPythonInterface.hxx b/CXX/Python2/IndirectPythonInterface.hxx
index 33d4b83f34fc..a29a394c6c6a 100644
--- a/CXX/Python2/IndirectPythonInterface.hxx
+++ b/CXX/Python2/IndirectPythonInterface.hxx
@@ -113,10 +113,8 @@ bool _Instance_Check( PyObject *op );
PyTypeObject * _Method_Type();
bool _Method_Check( PyObject *op );
-#if PY_VERSION_HEX < 0x02070000
PyTypeObject * _CObject_Type();
bool _CObject_Check( PyObject *op );
-#endif
PyTypeObject * _Complex_Type();
bool _Complex_Check( PyObject *op );
diff --git a/CXX/Python2/PythonType.hxx b/CXX/Python2/PythonType.hxx
index a89a6c90481e..fc45a4bc6c5e 100644
--- a/CXX/Python2/PythonType.hxx
+++ b/CXX/Python2/PythonType.hxx
@@ -57,17 +57,15 @@ namespace Py
PythonType &doc( const char *d );
PythonType &supportClass( void );
-#if !defined( PY3 )
PythonType &dealloc( void (*f)( PyObject* ) );
-#endif
-#if defined( PYCXX_PYTHON_2TO3 ) || !defined( PY3 )
+#if defined( PYCXX_PYTHON_2TO3 )
PythonType &supportPrint( void );
#endif
PythonType &supportGetattr( void );
PythonType &supportSetattr( void );
PythonType &supportGetattro( void );
PythonType &supportSetattro( void );
-#if defined( PYCXX_PYTHON_2TO3 ) || !defined( PY3 )
+#if defined( PYCXX_PYTHON_2TO3 )
PythonType &supportCompare( void );
#endif
PythonType &supportRichCompare( void );
diff --git a/CXX/Python2/cxx_extensions.cxx b/CXX/Python2/cxx_extensions.cxx
index 6ae62c7cfb05..611a335d1164 100644
--- a/CXX/Python2/cxx_extensions.cxx
+++ b/CXX/Python2/cxx_extensions.cxx
@@ -254,12 +254,16 @@ extern "C"
// All the following functions redirect the call from Python
// onto the matching virtual function in PythonExtensionBase
//
+#if defined( PYCXX_PYTHON_2TO3 )
static int print_handler( PyObject *, FILE *, int );
+#endif
static PyObject *getattr_handler( PyObject *, char * );
static int setattr_handler( PyObject *, char *, PyObject * );
static PyObject *getattro_handler( PyObject *, PyObject * );
static int setattro_handler( PyObject *, PyObject *, PyObject * );
+#if defined( PYCXX_PYTHON_2TO3 )
static int compare_handler( PyObject *, PyObject * );
+#endif
static PyObject *rich_compare_handler( PyObject *, PyObject *, int );
static PyObject *repr_handler( PyObject * );
static PyObject *str_handler( PyObject * );
@@ -290,9 +294,7 @@ extern "C"
static PyObject *number_invert_handler( PyObject * );
static PyObject *number_int_handler( PyObject * );
static PyObject *number_float_handler( PyObject * );
-#if !defined( PY3 )
static PyObject *number_long_handler( PyObject * );
-#endif
static PyObject *number_oct_handler( PyObject * );
static PyObject *number_hex_handler( PyObject * );
static PyObject *number_add_handler( PyObject *, PyObject * );
@@ -335,13 +337,9 @@ PythonType &PythonType::supportSequenceType()
sequence_table->sq_concat = sequence_concat_handler;
sequence_table->sq_repeat = sequence_repeat_handler;
sequence_table->sq_item = sequence_item_handler;
-#if !defined( PY3 )
sequence_table->sq_slice = sequence_slice_handler;
-#endif
sequence_table->sq_ass_item = sequence_ass_item_handler; // BAS setup seperately?
-#if !defined( PY3 )
sequence_table->sq_ass_slice = sequence_ass_slice_handler; // BAS setup seperately?
-#endif
}
return *this;
}
@@ -370,36 +368,26 @@ PythonType &PythonType::supportNumberType()
number_table->nb_add = number_add_handler;
number_table->nb_subtract = number_subtract_handler;
number_table->nb_multiply = number_multiply_handler;
-#if !defined( PY3 )
number_table->nb_divide = number_divide_handler;
-#endif
number_table->nb_remainder = number_remainder_handler;
number_table->nb_divmod = number_divmod_handler;
number_table->nb_power = number_power_handler;
number_table->nb_negative = number_negative_handler;
number_table->nb_positive = number_positive_handler;
number_table->nb_absolute = number_absolute_handler;
-#if !defined( PY3 )
number_table->nb_nonzero = number_nonzero_handler;
-#endif
number_table->nb_invert = number_invert_handler;
number_table->nb_lshift = number_lshift_handler;
number_table->nb_rshift = number_rshift_handler;
number_table->nb_and = number_and_handler;
number_table->nb_xor = number_xor_handler;
number_table->nb_or = number_or_handler;
-#if !defined( PY3 )
number_table->nb_coerce = 0;
-#endif
number_table->nb_int = number_int_handler;
-#if !defined( PY3 )
number_table->nb_long = number_long_handler;
-#endif
number_table->nb_float = number_float_handler;
-#if !defined( PY3 )
number_table->nb_oct = number_oct_handler;
number_table->nb_hex = number_hex_handler;
-#endif
}
return *this;
}
@@ -411,11 +399,9 @@ PythonType &PythonType::supportBufferType()
buffer_table = new PyBufferProcs;
memset( buffer_table, 0, sizeof( PyBufferProcs ) ); // ensure new fields are 0
table->tp_as_buffer = buffer_table;
-#if !defined( PY3 )
buffer_table->bf_getreadbuffer = buffer_getreadbuffer_handler;
buffer_table->bf_getwritebuffer = buffer_getwritebuffer_handler;
buffer_table->bf_getsegcount = buffer_getsegcount_handler;
-#endif
}
return *this;
}
@@ -434,10 +420,9 @@ PythonType::PythonType( size_t basic_size, int itemsize, const char *default_nam
memset( table, 0, sizeof( PyTypeObject ) ); // ensure new fields are 0
*reinterpret_cast( table ) = py_object_initializer;
-#if !defined( PY3 )
table->ob_type = _Type_Type();
table->ob_size = 0;
-#endif
+
table->tp_name = const_cast( default_name );
table->tp_basicsize = basic_size;
table->tp_itemsize = itemsize;
@@ -575,11 +560,13 @@ PythonType &PythonType::dealloc( void( *f )( PyObject * ))
return *this;
}
+#if defined( PYCXX_PYTHON_2TO3 )
PythonType &PythonType::supportPrint()
{
table->tp_print = print_handler;
return *this;
}
+#endif
PythonType &PythonType::supportGetattr()
{
@@ -605,11 +592,13 @@ PythonType &PythonType::supportSetattro()
return *this;
}
+#if defined( PYCXX_PYTHON_2TO3 )
PythonType &PythonType::supportCompare()
{
table->tp_compare = compare_handler;
return *this;
}
+#endif
#if PY_MAJOR_VERSION > 2 || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION >= 1)
PythonType &PythonType::supportRichCompare()
@@ -669,6 +658,7 @@ PythonExtensionBase *getPythonExtensionBase( PyObject *self )
}
+#if defined( PYCXX_PYTHON_2TO3 )
extern "C" int print_handler( PyObject *self, FILE *fp, int flags )
{
try
@@ -681,6 +671,7 @@ extern "C" int print_handler( PyObject *self, FILE *fp, int flags )
return -1; // indicate error
}
}
+#endif
extern "C" PyObject *getattr_handler( PyObject *self, char *name )
{
@@ -734,6 +725,7 @@ extern "C" int setattro_handler( PyObject *self, PyObject *name, PyObject *value
}
}
+#if defined( PYCXX_PYTHON_2TO3 )
extern "C" int compare_handler( PyObject *self, PyObject *other )
{
try
@@ -746,6 +738,7 @@ extern "C" int compare_handler( PyObject *self, PyObject *other )
return -1; // indicate error
}
}
+#endif
#if PY_MAJOR_VERSION > 2 || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION >= 1)
extern "C" PyObject *rich_compare_handler( PyObject *self, PyObject *other, int op )
@@ -1719,11 +1712,7 @@ extern "C" PyObject *method_keyword_call_handler( PyObject *_self_and_name_tuple
Tuple self_and_name_tuple( _self_and_name_tuple );
PyObject *self_in_cobject = self_and_name_tuple[0].ptr();
- #if PY_VERSION_HEX < 0x02070000
- void *self_as_void = PyCObject_AsVoidPtr( self_in_cobject );
- #else
- void *self_as_void = PyCapsule_GetPointer( self_in_cobject, NULL );
- #endif
+ void *self_as_void = PyCObject_AsVoidPtr( self_in_cobject );
if( self_as_void == NULL )
return NULL;
@@ -1739,11 +1728,7 @@ extern "C" PyObject *method_keyword_call_handler( PyObject *_self_and_name_tuple
(
self->invoke_method_keyword
(
- #if PY_VERSION_HEX < 0x02070000
- PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() ),
- #else
- PyCapsule_GetPointer( self_and_name_tuple[1].ptr(), NULL ),
- #endif
+ PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() ),
args,
keywords
)
@@ -1759,11 +1744,7 @@ extern "C" PyObject *method_keyword_call_handler( PyObject *_self_and_name_tuple
(
self->invoke_method_keyword
(
- #if PY_VERSION_HEX < 0x02070000
- PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() ),
- #else
- PyCapsule_GetPointer( self_and_name_tuple[1].ptr(), NULL ),
- #endif
+ PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() ),
args,
keywords
)
@@ -1785,11 +1766,7 @@ extern "C" PyObject *method_varargs_call_handler( PyObject *_self_and_name_tuple
Tuple self_and_name_tuple( _self_and_name_tuple );
PyObject *self_in_cobject = self_and_name_tuple[0].ptr();
- #if PY_VERSION_HEX < 0x02070000
- void *self_as_void = PyCObject_AsVoidPtr( self_in_cobject );
- #else
- void *self_as_void = PyCapsule_GetPointer( self_in_cobject, NULL );
- #endif
+ void *self_as_void = PyCObject_AsVoidPtr( self_in_cobject );
if( self_as_void == NULL )
return NULL;
@@ -1800,11 +1777,7 @@ extern "C" PyObject *method_varargs_call_handler( PyObject *_self_and_name_tuple
(
self->invoke_method_varargs
(
- #if PY_VERSION_HEX < 0x02070000
- PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() ),
- #else
- PyCapsule_GetPointer( self_and_name_tuple[1].ptr(), NULL ),
- #endif
+ PyCObject_AsVoidPtr( self_and_name_tuple[1].ptr() ),
args
)
);
diff --git a/CXX/Python3/ExtensionModule.hxx b/CXX/Python3/ExtensionModule.hxx
index a892a6f8cde5..75eb77568ae4 100644
--- a/CXX/Python3/ExtensionModule.hxx
+++ b/CXX/Python3/ExtensionModule.hxx
@@ -135,8 +135,8 @@ namespace Py
static PyObject *self = PyCapsule_New( this, NULL, NULL );
Tuple args( 2 );
- args[0] = Object( self );
- args[1] = Object( PyCapsule_New( method_def, NULL, NULL ) );
+ args[0] = Object( self, true );
+ args[1] = Object( PyCapsule_New( method_def, NULL, NULL ), true );
PyObject *func = PyCFunction_New
(
diff --git a/CXX/Python3/IndirectPythonInterface.cxx b/CXX/Python3/IndirectPythonInterface.cxx
deleted file mode 100644
index 2b7ff41b75da..000000000000
--- a/CXX/Python3/IndirectPythonInterface.cxx
+++ /dev/null
@@ -1,518 +0,0 @@
-//-----------------------------------------------------------------------------
-//
-// Copyright (c) 1998 - 2007, The Regents of the University of California
-// Produced at the Lawrence Livermore National Laboratory
-// All rights reserved.
-//
-// This file is part of PyCXX. For details,see http://cxx.sourceforge.net/. The
-// full copyright notice is contained in the file COPYRIGHT located at the root
-// of the PyCXX distribution.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// - Redistributions of source code must retain the above copyright notice,
-// this list of conditions and the disclaimer below.
-// - Redistributions in binary form must reproduce the above copyright notice,
-// this list of conditions and the disclaimer (as noted below) in the
-// documentation and/or materials provided with the distribution.
-// - Neither the name of the UC/LLNL nor the names of its contributors may be
-// used to endorse or promote products derived from this software without
-// specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OF THE UNIVERSITY OF
-// CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR
-// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-// DAMAGE.
-//
-//-----------------------------------------------------------------------------
-
-#include "CXX/IndirectPythonInterface.hxx"
-
-namespace Py
-{
-bool _CFunction_Check( PyObject *op ) { return op->ob_type == _CFunction_Type(); }
-bool _Complex_Check( PyObject *op ) { return op->ob_type == _Complex_Type(); }
-bool _Dict_Check( PyObject *op ) { return op->ob_type == _Dict_Type(); }
-bool _Float_Check( PyObject *op ) { return op->ob_type == _Float_Type(); }
-bool _Function_Check( PyObject *op ) { return op->ob_type == _Function_Type(); }
-bool _Boolean_Check( PyObject *op ) { return op->ob_type == _Bool_Type(); }
-bool _List_Check( PyObject *op ) { return op->ob_type == _List_Type(); }
-bool _Long_Check( PyObject *op ) { return op->ob_type == _Long_Type(); }
-bool _Method_Check( PyObject *op ) { return op->ob_type == _Method_Type(); }
-bool _Module_Check( PyObject *op ) { return op->ob_type == _Module_Type(); }
-bool _Range_Check( PyObject *op ) { return op->ob_type == _Range_Type(); }
-bool _Slice_Check( PyObject *op ) { return op->ob_type == _Slice_Type(); }
-bool _TraceBack_Check( PyObject *op ) { return op->ob_type == _TraceBack_Type(); }
-bool _Tuple_Check( PyObject *op ) { return op->ob_type == _Tuple_Type(); }
-bool _Type_Check( PyObject *op ) { return op->ob_type == _Type_Type(); }
-bool _Unicode_Check( PyObject *op ) { return op->ob_type == _Unicode_Type(); }
-bool _Bytes_Check( PyObject *op ) { return op->ob_type == _Bytes_Type(); }
-
-#if defined(PY_WIN32_DELAYLOAD_PYTHON_DLL)
-
-#if defined(MS_WINDOWS)
-#include
-
-
-static HMODULE python_dll;
-
-static PyObject *ptr__Exc_ArithmeticError = NULL;
-static PyObject *ptr__Exc_AssertionError = NULL;
-static PyObject *ptr__Exc_AttributeError = NULL;
-static PyObject *ptr__Exc_EnvironmentError = NULL;
-static PyObject *ptr__Exc_EOFError = NULL;
-static PyObject *ptr__Exc_Exception = NULL;
-static PyObject *ptr__Exc_FloatingPointError = NULL;
-static PyObject *ptr__Exc_ImportError = NULL;
-static PyObject *ptr__Exc_IndexError = NULL;
-static PyObject *ptr__Exc_IOError = NULL;
-static PyObject *ptr__Exc_KeyboardInterrupt = NULL;
-static PyObject *ptr__Exc_KeyError = NULL;
-static PyObject *ptr__Exc_LookupError = NULL;
-static PyObject *ptr__Exc_MemoryError = NULL;
-static PyObject *ptr__Exc_NameError = NULL;
-static PyObject *ptr__Exc_NotImplementedError = NULL;
-static PyObject *ptr__Exc_OSError = NULL;
-static PyObject *ptr__Exc_OverflowError = NULL;
-static PyObject *ptr__Exc_RuntimeError = NULL;
-static PyObject *ptr__Exc_StandardError = NULL;
-static PyObject *ptr__Exc_SyntaxError = NULL;
-static PyObject *ptr__Exc_SystemError = NULL;
-static PyObject *ptr__Exc_SystemExit = NULL;
-static PyObject *ptr__Exc_TypeError = NULL;
-static PyObject *ptr__Exc_ValueError = NULL;
-static PyObject *ptr__Exc_ZeroDivisionError = NULL;
-
-#ifdef MS_WINDOWS
-static PyObject *ptr__Exc_WindowsError = NULL;
-#endif
-
-static PyObject *ptr__Exc_IndentationError = NULL;
-static PyObject *ptr__Exc_TabError = NULL;
-static PyObject *ptr__Exc_UnboundLocalError = NULL;
-static PyObject *ptr__Exc_UnicodeError = NULL;
-static PyObject *ptr__PyNone = NULL;
-static PyObject *ptr__PyFalse = NULL;
-static PyObject *ptr__PyTrue = NULL;
-static PyTypeObject *ptr__CFunction_Type = NULL;
-static PyTypeObject *ptr__Complex_Type = NULL;
-static PyTypeObject *ptr__Dict_Type = NULL;
-static PyTypeObject *ptr__Float_Type = NULL;
-static PyTypeObject *ptr__Function_Type = NULL;
-static PyTypeObject *ptr__List_Type = NULL;
-static PyTypeObject *ptr__Long_Type = NULL;
-static PyTypeObject *ptr__Method_Type = NULL;
-static PyTypeObject *ptr__Module_Type = NULL;
-static PyTypeObject *ptr__Range_Type = NULL;
-static PyTypeObject *ptr__Slice_Type = NULL;
-static PyTypeObject *ptr__TraceBack_Type = NULL;
-static PyTypeObject *ptr__Tuple_Type = NULL;
-static PyTypeObject *ptr__Type_Type = NULL;
-
-static int *ptr_Py_DebugFlag = NULL;
-static int *ptr_Py_InteractiveFlag = NULL;
-static int *ptr_Py_OptimizeFlag = NULL;
-static int *ptr_Py_NoSiteFlag = NULL;
-static int *ptr_Py_VerboseFlag = NULL;
-
-static char **ptr__Py_PackageContext = NULL;
-
-#ifdef Py_REF_DEBUG
-int *ptr_Py_RefTotal;
-#endif
-
-
-//--------------------------------------------------------------------------------
-class GetAddressException
-{
-public:
- GetAddressException( const char *_name )
- : name( _name )
- {}
- virtual ~GetAddressException() {}
- const char *name;
-};
-
-
-//--------------------------------------------------------------------------------
-static PyObject *GetPyObjectPointer_As_PyObjectPointer( const char *name )
-{
- FARPROC addr = GetProcAddress( python_dll, name );
- if( addr == NULL )
- throw GetAddressException( name );
-
- return *(PyObject **)addr;
-}
-
-static PyObject *GetPyObject_As_PyObjectPointer( const char *name )
-{
- FARPROC addr = GetProcAddress( python_dll, name );
- if( addr == NULL )
- throw GetAddressException( name );
-
- return (PyObject *)addr;
-}
-
-static PyTypeObject *GetPyTypeObjectPointer_As_PyTypeObjectPointer( const char *name )
-{
- FARPROC addr = GetProcAddress( python_dll, name );
- if( addr == NULL )
- throw GetAddressException( name );
-
- return *(PyTypeObject **)addr;
-}
-
-static PyTypeObject *GetPyTypeObject_As_PyTypeObjectPointer( const char *name )
-{
- FARPROC addr = GetProcAddress( python_dll, name );
- if( addr == NULL )
- throw GetAddressException( name );
-
- return (PyTypeObject *)addr;
-}
-
-static int *GetInt_as_IntPointer( const char *name )
-{
- FARPROC addr = GetProcAddress( python_dll, name );
- if( addr == NULL )
- throw GetAddressException( name );
-
- return (int *)addr;
-}
-
-static char **GetCharPointer_as_CharPointerPointer( const char *name )
-{
- FARPROC addr = GetProcAddress( python_dll, name );
- if( addr == NULL )
- throw GetAddressException( name );
-
- return (char **)addr;
-}
-
-
-#ifdef _DEBUG
-static const char python_dll_name_format[] = "PYTHON%1.1d%1.1d_D.DLL";
-#else
-static const char python_dll_name_format[] = "PYTHON%1.1d%1.1d.DLL";
-#endif
-
-//--------------------------------------------------------------------------------
-bool InitialisePythonIndirectInterface()
-{
- char python_dll_name[sizeof(python_dll_name_format)];
-
- sprintf( python_dll_name, python_dll_name_format, PY_MAJOR_VERSION, PY_MINOR_VERSION );
-
- python_dll = LoadLibrary( python_dll_name );
- if( python_dll == NULL )
- return false;
-
- try
- {
-#ifdef Py_REF_DEBUG
- ptr_Py_RefTotal = GetInt_as_IntPointer( "_Py_RefTotal" );
-#endif
- ptr_Py_DebugFlag = GetInt_as_IntPointer( "Py_DebugFlag" );
- ptr_Py_InteractiveFlag = GetInt_as_IntPointer( "Py_InteractiveFlag" );
- ptr_Py_OptimizeFlag = GetInt_as_IntPointer( "Py_OptimizeFlag" );
- ptr_Py_NoSiteFlag = GetInt_as_IntPointer( "Py_NoSiteFlag" );
- ptr_Py_VerboseFlag = GetInt_as_IntPointer( "Py_VerboseFlag" );
- ptr__Py_PackageContext = GetCharPointer_as_CharPointerPointer( "_Py_PackageContext" );
-
- ptr__Exc_ArithmeticError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_ArithmeticError" );
- ptr__Exc_AssertionError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_AssertionError" );
- ptr__Exc_AttributeError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_AttributeError" );
- ptr__Exc_EnvironmentError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_EnvironmentError" );
- ptr__Exc_EOFError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_EOFError" );
- ptr__Exc_Exception = GetPyObjectPointer_As_PyObjectPointer( "PyExc_Exception" );
- ptr__Exc_FloatingPointError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_FloatingPointError" );
- ptr__Exc_ImportError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_ImportError" );
- ptr__Exc_IndexError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_IndexError" );
- ptr__Exc_IOError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_IOError" );
- ptr__Exc_KeyboardInterrupt = GetPyObjectPointer_As_PyObjectPointer( "PyExc_KeyboardInterrupt" );
- ptr__Exc_KeyError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_KeyError" );
- ptr__Exc_LookupError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_LookupError" );
- ptr__Exc_MemoryError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_MemoryError" );
- ptr__Exc_NameError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_NameError" );
- ptr__Exc_NotImplementedError= GetPyObjectPointer_As_PyObjectPointer( "PyExc_NotImplementedError" );
- ptr__Exc_OSError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_OSError" );
- ptr__Exc_OverflowError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_OverflowError" );
- ptr__Exc_RuntimeError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_RuntimeError" );
- ptr__Exc_StandardError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_StandardError" );
- ptr__Exc_SyntaxError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_SyntaxError" );
- ptr__Exc_SystemError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_SystemError" );
- ptr__Exc_SystemExit = GetPyObjectPointer_As_PyObjectPointer( "PyExc_SystemExit" );
- ptr__Exc_TypeError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_TypeError" );
- ptr__Exc_ValueError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_ValueError" );
-#ifdef MS_WINDOWS
- ptr__Exc_WindowsError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_WindowsError" );
-#endif
- ptr__Exc_ZeroDivisionError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_ZeroDivisionError" );
- ptr__Exc_IndentationError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_IndentationError" );
- ptr__Exc_TabError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_TabError" );
- ptr__Exc_UnboundLocalError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_UnboundLocalError" );
- ptr__Exc_UnicodeError = GetPyObjectPointer_As_PyObjectPointer( "PyExc_UnicodeError" );
- ptr__PyNone = GetPyObject_As_PyObjectPointer( "_Py_NoneStruct" );
-
- ptr__PyFalse = GetPyObject_As_PyObjectPointer( "_Py_ZeroStruct" );
- ptr__PyTrue = GetPyObject_As_PyObjectPointer( "_Py_TrueStruct" );
-
- ptr__CFunction_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyCFunction_Type" );
- ptr__Complex_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyComplex_Type" );
- ptr__Dict_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyDict_Type" );
- ptr__Float_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyFloat_Type" );
- ptr__Function_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyFunction_Type" );
- ptr__List_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyList_Type" );
- ptr__Long_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyLong_Type" );
- ptr__Method_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyMethod_Type" );
- ptr__Module_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyModule_Type" );
- ptr__Range_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyRange_Type" );
- ptr__Slice_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PySlice_Type" );
- ptr__TraceBack_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyTraceBack_Type" );
- ptr__Tuple_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyTuple_Type" );
- ptr__Type_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyType_Type" );
- ptr__Unicode_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyUnicode_Type" );
- ptr__Bytes_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyBytes_Type" );
- }
- catch( GetAddressException &e )
- {
- OutputDebugString( python_dll_name );
- OutputDebugString( " does not contain symbol ");
- OutputDebugString( e.name );
- OutputDebugString( "\n" );
-
- return false;
- }
-
- return true;
-}
-
-//
-// Wrap variables as function calls
-//
-PyObject *_Exc_ArithmeticError() { return ptr__Exc_ArithmeticError; }
-PyObject *_Exc_AssertionError() { return ptr__Exc_AssertionError; }
-PyObject *_Exc_AttributeError() { return ptr__Exc_AttributeError; }
-PyObject *_Exc_EnvironmentError() { return ptr__Exc_EnvironmentError; }
-PyObject *_Exc_EOFError() { return ptr__Exc_EOFError; }
-PyObject *_Exc_Exception() { return ptr__Exc_Exception; }
-PyObject *_Exc_FloatingPointError() { return ptr__Exc_FloatingPointError; }
-PyObject *_Exc_ImportError() { return ptr__Exc_ImportError; }
-PyObject *_Exc_IndexError() { return ptr__Exc_IndexError; }
-PyObject *_Exc_IOError() { return ptr__Exc_IOError; }
-PyObject *_Exc_KeyboardInterrupt() { return ptr__Exc_KeyboardInterrupt; }
-PyObject *_Exc_KeyError() { return ptr__Exc_KeyError; }
-PyObject *_Exc_LookupError() { return ptr__Exc_LookupError; }
-PyObject *_Exc_MemoryError() { return ptr__Exc_MemoryError; }
-PyObject *_Exc_NameError() { return ptr__Exc_NameError; }
-PyObject *_Exc_NotImplementedError() { return ptr__Exc_NotImplementedError; }
-PyObject *_Exc_OSError() { return ptr__Exc_OSError; }
-PyObject *_Exc_OverflowError() { return ptr__Exc_OverflowError; }
-PyObject *_Exc_RuntimeError() { return ptr__Exc_RuntimeError; }
-PyObject *_Exc_StandardError() { return ptr__Exc_StandardError; }
-PyObject *_Exc_SyntaxError() { return ptr__Exc_SyntaxError; }
-PyObject *_Exc_SystemError() { return ptr__Exc_SystemError; }
-PyObject *_Exc_SystemExit() { return ptr__Exc_SystemExit; }
-PyObject *_Exc_TypeError() { return ptr__Exc_TypeError; }
-PyObject *_Exc_ValueError() { return ptr__Exc_ValueError; }
-#ifdef MS_WINDOWS
-PyObject *_Exc_WindowsError() { return ptr__Exc_WindowsError; }
-#endif
-PyObject *_Exc_ZeroDivisionError() { return ptr__Exc_ZeroDivisionError; }
-PyObject *_Exc_IndentationError() { return ptr__Exc_IndentationError; }
-PyObject *_Exc_TabError() { return ptr__Exc_TabError; }
-PyObject *_Exc_UnboundLocalError() { return ptr__Exc_UnboundLocalError; }
-PyObject *_Exc_UnicodeError() { return ptr__Exc_UnicodeError; }
-
-//
-// wrap items in Object.h
-//
-PyObject *_None() { return ptr__PyNone; }
-
-PyObject *_False() { return ptr__PyFalse; }
-PyObject *_True() { return ptr__PyTrue; }
-
-PyTypeObject *_CFunction_Type() { return ptr__CFunction_Type; }
-PyTypeObject *_Complex_Type() { return ptr__Complex_Type; }
-PyTypeObject *_Dict_Type() { return ptr__Dict_Type; }
-PyTypeObject *_Float_Type() { return ptr__Float_Type; }
-PyTypeObject *_Function_Type() { return ptr__Function_Type; }
-PyTypeObject *_Bool_Type() { return ptr__Bool_Type; }
-PyTypeObject *_List_Type() { return ptr__List_Type; }
-PyTypeObject *_Long_Type() { return ptr__Long_Type; }
-PyTypeObject *_Method_Type() { return ptr__Method_Type; }
-PyTypeObject *_Module_Type() { return ptr__Module_Type; }
-PyTypeObject *_Range_Type() { return ptr__Range_Type; }
-PyTypeObject *_Slice_Type() { return ptr__Slice_Type; }
-PyTypeObject *_TraceBack_Type() { return ptr__TraceBack_Type; }
-PyTypeObject *_Tuple_Type() { return ptr__Tuple_Type; }
-PyTypeObject *_Type_Type() { return ptr__Type_Type; }
-PyTypeObject *_Unicode_Type() { return ptr__Unicode_Type; }
-PyTypeObject *_Bytes_Type() { return ptr__Bytes_Type; }
-
-char *__Py_PackageContext() { return *ptr__Py_PackageContext; }
-
-
-//
-// wrap the Python Flag variables
-//
-int &_Py_DebugFlag() { return *ptr_Py_DebugFlag; }
-int &_Py_InteractiveFlag() { return *ptr_Py_InteractiveFlag; }
-int &_Py_OptimizeFlag() { return *ptr_Py_OptimizeFlag; }
-int &_Py_NoSiteFlag() { return *ptr_Py_NoSiteFlag; }
-int &_Py_VerboseFlag() { return *ptr_Py_VerboseFlag; }
-
-#if 0
-#define Py_INCREF(op) ( \
- _Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \
- ((PyObject*)(op))->ob_refcnt++)
-
-#define Py_DECREF(op) \
- if (_Py_DEC_REFTOTAL _Py_REF_DEBUG_COMMA \
- --((PyObject*)(op))->ob_refcnt != 0) \
- _Py_CHECK_REFCNT(op) \
- else \
- _Py_Dealloc((PyObject *)(op))
-#endif
-
-void _XINCREF( PyObject *op )
-{
- // This function must match the contents of Py_XINCREF(op)
- if( op == NULL )
- return;
-
-#ifdef Py_REF_DEBUG
- (*ptr_Py_RefTotal)++;
-#endif
- (op)->ob_refcnt++;
-
-}
-
-void _XDECREF( PyObject *op )
-{
- // This function must match the contents of Py_XDECREF(op);
- if( op == NULL )
- return;
-
-#ifdef Py_REF_DEBUG
- (*ptr_Py_RefTotal)--;
-#endif
-
- if (--(op)->ob_refcnt == 0)
- _Py_Dealloc((PyObject *)(op));
-}
-
-
-#else
-#error "Can only delay load under Win32"
-#endif
-
-#else
-
-//================================================================================
-//
-// Map onto Macros
-//
-//================================================================================
-
-//
-// Wrap variables as function calls
-//
-
-PyObject *_Exc_ArithmeticError() { return ::PyExc_ArithmeticError; }
-PyObject *_Exc_AssertionError() { return ::PyExc_AssertionError; }
-PyObject *_Exc_AttributeError() { return ::PyExc_AttributeError; }
-PyObject *_Exc_EnvironmentError() { return ::PyExc_EnvironmentError; }
-PyObject *_Exc_EOFError() { return ::PyExc_EOFError; }
-PyObject *_Exc_Exception() { return ::PyExc_Exception; }
-PyObject *_Exc_FloatingPointError() { return ::PyExc_FloatingPointError; }
-PyObject *_Exc_ImportError() { return ::PyExc_ImportError; }
-PyObject *_Exc_IndexError() { return ::PyExc_IndexError; }
-PyObject *_Exc_IOError() { return ::PyExc_IOError; }
-PyObject *_Exc_KeyboardInterrupt() { return ::PyExc_KeyboardInterrupt; }
-PyObject *_Exc_KeyError() { return ::PyExc_KeyError; }
-PyObject *_Exc_LookupError() { return ::PyExc_LookupError; }
-PyObject *_Exc_MemoryError() { return ::PyExc_MemoryError; }
-PyObject *_Exc_NameError() { return ::PyExc_NameError; }
-PyObject *_Exc_NotImplementedError() { return ::PyExc_NotImplementedError; }
-PyObject *_Exc_OSError() { return ::PyExc_OSError; }
-PyObject *_Exc_OverflowError() { return ::PyExc_OverflowError; }
-PyObject *_Exc_RuntimeError() { return ::PyExc_RuntimeError; }
-PyObject *_Exc_SyntaxError() { return ::PyExc_SyntaxError; }
-PyObject *_Exc_SystemError() { return ::PyExc_SystemError; }
-PyObject *_Exc_SystemExit() { return ::PyExc_SystemExit; }
-PyObject *_Exc_TypeError() { return ::PyExc_TypeError; }
-PyObject *_Exc_ValueError() { return ::PyExc_ValueError; }
-PyObject *_Exc_ZeroDivisionError() { return ::PyExc_ZeroDivisionError; }
-PyObject *_Exc_IndentationError() { return ::PyExc_IndentationError; }
-PyObject *_Exc_TabError() { return ::PyExc_TabError; }
-PyObject *_Exc_UnboundLocalError() { return ::PyExc_UnboundLocalError; }
-PyObject *_Exc_UnicodeError() { return ::PyExc_UnicodeError; }
-
-#ifdef MS_WINDOWS
-PyObject *_Exc_WindowsError() { return ::PyExc_WindowsError; }
-#endif
-
-
-
-
-//
-// wrap items in Object.h
-//
-PyObject *_None() { return &::_Py_NoneStruct; }
-
-PyObject *_False() { return Py_False; }
-PyObject *_True() { return Py_True; }
-
-PyTypeObject *_CFunction_Type() { return &PyCFunction_Type; }
-PyTypeObject *_Complex_Type() { return &PyComplex_Type; }
-PyTypeObject *_Dict_Type() { return &PyDict_Type; }
-PyTypeObject *_Float_Type() { return &PyFloat_Type; }
-PyTypeObject *_Function_Type() { return &PyFunction_Type; }
-PyTypeObject *_Bool_Type() { return &PyBool_Type; }
-PyTypeObject *_List_Type() { return &PyList_Type; }
-PyTypeObject *_Long_Type() { return &PyLong_Type; }
-PyTypeObject *_Method_Type() { return &PyMethod_Type; }
-PyTypeObject *_Module_Type() { return &PyModule_Type; }
-PyTypeObject *_Range_Type() { return &PyRange_Type; }
-PyTypeObject *_Slice_Type() { return &PySlice_Type; }
-PyTypeObject *_TraceBack_Type() { return &PyTraceBack_Type; }
-PyTypeObject *_Tuple_Type() { return &PyTuple_Type; }
-PyTypeObject *_Type_Type() { return &PyType_Type; }
-PyTypeObject *_Unicode_Type() { return &PyUnicode_Type; }
-PyTypeObject *_Bytes_Type() { return &PyBytes_Type; }
-
-//
-// wrap flags
-//
-int &_Py_DebugFlag() { return Py_DebugFlag; }
-int &_Py_InteractiveFlag() { return Py_InteractiveFlag; }
-int &_Py_OptimizeFlag() { return Py_OptimizeFlag; }
-int &_Py_NoSiteFlag() { return Py_NoSiteFlag; }
-int &_Py_VerboseFlag() { return Py_VerboseFlag; }
-char *__Py_PackageContext() { return _Py_PackageContext; }
-
-//
-// Needed to keep the abstactions for delayload interface
-//
-void _XINCREF( PyObject *op )
-{
- Py_XINCREF( op );
-}
-
-void _XDECREF( PyObject *op )
-{
- Py_XDECREF( op );
-}
-
-#endif
-}
diff --git a/CXX/Python3/Objects.hxx b/CXX/Python3/Objects.hxx
index 2847512f065a..927618f0ba06 100644
--- a/CXX/Python3/Objects.hxx
+++ b/CXX/Python3/Objects.hxx
@@ -413,7 +413,7 @@ namespace Py
{
}
- virtual bool accepts( PyObject *pyob ) const
+ virtual bool accepts( PyObject *pyob )
{
return pyob == NULL;
}
@@ -1328,7 +1328,6 @@ namespace Py
}
// Assignment acquires new ownership of pointer
-
SeqBase &operator=( const Object &rhs )
{
return *this = *rhs;
@@ -1520,7 +1519,7 @@ namespace Py
int operator-( const iterator &other ) const
{
- if( seq->ptr() != other.seq->ptr() )
+ if( seq->ptr() != other.seq->ptr() )
throw RuntimeError( "SeqBase::iterator comparison error" );
return count - other.count;
@@ -2192,8 +2191,8 @@ namespace Py
}
}
}
- // Assignment acquires new ownership of pointer
+ // Assignment acquires new ownership of pointer
Tuple &operator=( const Object &rhs )
{
return *this = *rhs;
@@ -2380,8 +2379,8 @@ namespace Py
{
return max_size();
}
- // Assignment acquires new ownership of pointer
+ // Assignment acquires new ownership of pointer
List &operator=( const Object &rhs )
{
return *this = *rhs;
@@ -3074,8 +3073,8 @@ namespace Py
set( PyDict_New(), true );
validate();
}
- // Assignment acquires new ownership of pointer
+ // Assignment acquires new ownership of pointer
Dict &operator=( const Object &rhs )
{
return *this = *rhs;
diff --git a/CXX/Python3/cxx_extensions.cxx b/CXX/Python3/cxx_extensions.cxx
index 59874ad95576..8f2a4886c251 100644
--- a/CXX/Python3/cxx_extensions.cxx
+++ b/CXX/Python3/cxx_extensions.cxx
@@ -366,7 +366,7 @@ PythonType::PythonType( size_t basic_size, int itemsize, const char *default_nam
memset( table, 0, sizeof( PyTypeObject ) ); // ensure new fields are 0
*reinterpret_cast( table ) = py_object_initializer;
- // QQQ table->ob_type = _Type_Type();
+ reinterpret_cast( table )->ob_type = _Type_Type();
// QQQ table->ob_size = 0;
table->tp_name = const_cast( default_name );
table->tp_basicsize = basic_size;
@@ -440,10 +440,10 @@ PythonType::PythonType( size_t basic_size, int itemsize, const char *default_nam
table->tp_version_tag = 0;
#ifdef COUNT_ALLOCS
- table->tp_allocs = 0;
- table->tp_frees = 0;
+ table->tp_alloc = 0;
+ table->tp_free = 0;
table->tp_maxalloc = 0;
- table->tp_prev = 0;
+ table->tp_orev = 0;
table->tp_next = 0;
#endif
}
@@ -1602,9 +1602,6 @@ extern "C" PyObject *method_keyword_call_handler( PyObject *_self_and_name_tuple
}
}
-extern "C" void do_not_dealloc( void * )
-{}
-
//--------------------------------------------------------------------------------
//
diff --git a/CXX/WrapPython.h b/CXX/WrapPython.h
index 118a8740f8ad..6a73545d2d3d 100644
--- a/CXX/WrapPython.h
+++ b/CXX/WrapPython.h
@@ -57,4 +57,15 @@
// pull in python definitions
#include
+// fix issue with Python assuming that isspace, toupper etc are macros
+#if defined(isspace)
+#undef isspace
+#undef isupper
+#undef islower
+#undef isalnum
+#undef isalpha
+#undef toupper
+#undef tolower
+#endif
+
#endif
diff --git a/INSTALL b/INSTALL
index fa03255b5844..679f0c7ba191 100644
--- a/INSTALL
+++ b/INSTALL
@@ -183,7 +183,7 @@ the libraries themselves.
`Download python `_.
:term:`numpy` |minimum_numpy_version| (or later)
- array support for python (`download `_)
+ array support for python (`download numpy `_)
libpng 1.2 (or later)
library for loading and saving :term:`PNG` files (`download
@@ -196,6 +196,16 @@ libpng 1.2 (or later)
user, you can ignore this since we build support into the
matplotlib single click installer.
+:term:`dateutil` 1.1 or later
+ Provides extensions to python datetime handling. If using pip,
+ easy_install or installing from source, the installer will attempt
+ to download and install `python_dateutil` from PyPI.
+
+`pyparsing`
+ Required for matplotlib's mathtext math rendering support. If
+ using pip, easy_install or installing from source, the installer
+ will attempt to download and install `pyparsing` from PyPI.
+
**Optional**
These are optional packages which you may want to install to use
@@ -206,9 +216,6 @@ backends and the capabilities they provide.
:term:`tk` 8.3 or later
The TCL/Tk widgets library used by the TkAgg backend
-:term:`pyqt` 3.1 or later
- The Qt3 widgets library python wrappers for the QtAgg backend
-
:term:`pyqt` 4.0 or later
The Qt4 widgets library python wrappers for the Qt4Agg backend
@@ -220,9 +227,6 @@ backends and the capabilities they provide.
The python wrappers for the wx widgets library for use with the
WX or WXAgg backend
-:term:`pyfltk` 1.0 or later
- The python wrappers of the FLTK widgets library for use with FLTKAgg
-
**Required libraries that ship with matplotlib**
:term:`agg` 2.4
@@ -230,17 +234,8 @@ backends and the capabilities they provide.
agg template source statically, so it will not affect anything on
your system outside of matplotlib.
-:term:`pytz` 2007g or later
- timezone handling for python datetime objects. By default,
- matplotlib will install pytz if it isn't already installed on your
- system. To override the default, use :file:`setup.cfg` to force or
- prevent installation of pytz.
-
-:term:`dateutil` 1.1 or later
- provides extensions to python datetime handling. By default, matplotlib
- will install dateutil if it isn't already installed on your
- system. To override the default, use :file:`setup.cfg` to force
- or prevent installation of dateutil.
+`PyCXX` 6.2.4
+ A library for writing Python extensions in C++.
.. _build_osx:
diff --git a/MANIFEST.in b/MANIFEST.in
index 9838df35c44b..0ee8e71c2677 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,20 +1,16 @@
-include CHANGELOG KNOWN_BUGS INSTALL
+include CHANGELOG INSTALL
include INTERACTIVE TODO CONTRIBUTING.md
-include Makefile make.osx MANIFEST.in MANIFEST
+include Makefile MANIFEST.in MANIFEST
include matplotlibrc.template setup.cfg.template
-include __init__.py setupext.py setup.py setupegg.py
-include examples/data/*
-include lib/mpl_toolkits
-include lib/matplotlib/mpl-data/matplotlib.conf
-include lib/matplotlib/mpl-data/matplotlib.conf.template
+include setupext.py setup.py setupegg.py
include lib/matplotlib/mpl-data/lineprops.glade
include lib/matplotlib/mpl-data/matplotlibrc
include lib/matplotlib/mpl-data/images/*
include lib/matplotlib/mpl-data/fonts/ttf/*
include lib/matplotlib/mpl-data/fonts/pdfcorefonts/*
include lib/matplotlib/mpl-data/fonts/afm/*
-recursive-include lib/matplotlib/mpl-data/sample_data/*
-recursive-include license LICENSE*
+recursive-include lib/matplotlib/mpl-data/sample_data/ *
+recursive-include LICENSE *
recursive-include examples *
recursive-include doc *
recursive-include src *.cpp *.c *.h *.m
diff --git a/Makefile b/Makefile
index 8ac97ffe718b..d333f7f88901 100644
--- a/Makefile
+++ b/Makefile
@@ -44,6 +44,11 @@ jdh_doc_snapshot:
python make.py html latex sf sfpdf;
+test:
+ ${PYTHON} tests.py
+test-coverage:
+ ${PYTHON} tests.py --with-coverage --cover-package=matplotlib
+
diff --git a/README.osx b/README.osx
index 3afcd9074578..c2ca0a59afce 100644
--- a/README.osx
+++ b/README.osx
@@ -9,7 +9,7 @@ homebrew.
Example usage::
- brew install libpng freetype
+ brew install libpng freetype pkgconfig
If you are using MacPorts, execute the following instead:
diff --git a/README.rst b/README.rst
new file mode 100644
index 000000000000..6e01ea7275cc
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,26 @@
+##########
+matplotlib
+##########
+
+matplotlib is a python 2D plotting library which produces publication
+quality figures in a variety of hardcopy formats and interactive
+environments across platforms. matplotlib can be used in python
+scripts, the python and ipython shell (ala matlab or mathematica), web
+application servers, and various graphical user interface toolkits.
+
+`Home page `_
+
+Installation
+=============
+
+For installation instructions and requirements, see the INSTALL file.
+
+Testing
+=======
+
+After installation, you can launch the test suite::
+
+ python tests.py
+
+Consider reading http://matplotlib.org/devel/coding_guide.html#testing for
+more information.
diff --git a/README.txt b/README.txt
deleted file mode 100644
index d00538e0e8ad..000000000000
--- a/README.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-matplotlib is a python 2D plotting library which produces publication
-quality figures in a variety of hardcopy formats and interactive
-environments across platforms. matplotlib can be used in python
-scripts, the python and ipython shell (ala matlab or mathematica), web
-application servers, and various graphical user interface toolkits.
-
-Home page:
-
-For installation instructions and requirements, see the INSTALL file.
diff --git a/agg24/include/agg_rasterizer_cells_aa.h b/agg24/include/agg_rasterizer_cells_aa.h
index c8f2cb80d49d..2be0efeca175 100755
--- a/agg24/include/agg_rasterizer_cells_aa.h
+++ b/agg24/include/agg_rasterizer_cells_aa.h
@@ -29,8 +29,7 @@
#ifndef AGG_RASTERIZER_CELLS_AA_INCLUDED
#define AGG_RASTERIZER_CELLS_AA_INCLUDED
-#include "CXX/Exception.hxx"
-#include
+#include
#include
#include
#include "agg_math.h"
@@ -183,9 +182,9 @@ namespace agg
{
if((m_num_cells & cell_block_mask) == 0)
{
- if(m_num_blocks >= cell_block_limit) {
- throw Py::OverflowError(
- "Agg rendering complexity exceeded. Consider downsampling or decimating your data.");
+ if (m_num_blocks >= cell_block_limit)
+ {
+ throw std::overflow_error("Allocated too many blocks");
}
allocate_block();
}
diff --git a/boilerplate.py b/boilerplate.py
index ab13a04b17b2..b7839c72beeb 100644
--- a/boilerplate.py
+++ b/boilerplate.py
@@ -108,6 +108,7 @@ def boilerplate_gen():
'contourf',
'csd',
'errorbar',
+ 'eventplot',
'fill',
'fill_between',
'fill_betweenx',
@@ -169,7 +170,7 @@ def boilerplate_gen():
#'spy' : 'sci(%(ret)s)', ### may return image or Line2D
'quiver' : 'sci(%(ret)s)',
'specgram' : 'sci(%(ret)s[-1])',
- 'streamplot' : 'sci(%(ret)s)',
+ 'streamplot' : 'sci(%(ret)s.lines)',
'tricontour' : 'if %(ret)s._A is not None: sci(%(ret)s)',
'tricontourf': 'if %(ret)s._A is not None: sci(%(ret)s)',
'tripcolor' : 'sci(%(ret)s)',
diff --git a/distribute_setup.py b/distribute_setup.py
new file mode 100755
index 000000000000..8f5b0637bf39
--- /dev/null
+++ b/distribute_setup.py
@@ -0,0 +1,515 @@
+#!python
+"""Bootstrap distribute installation
+
+If you want to use setuptools in your package's setup.py, just include this
+file in the same directory with it, and add this to the top of your setup.py::
+
+ from distribute_setup import use_setuptools
+ use_setuptools()
+
+If you want to require a specific version of setuptools, set a download
+mirror, or use an alternate download directory, you can do so by supplying
+the appropriate options to ``use_setuptools()``.
+
+This file can also be run as a script to install or upgrade setuptools.
+"""
+import os
+import sys
+import time
+import fnmatch
+import tempfile
+import tarfile
+from distutils import log
+
+try:
+ from site import USER_SITE
+except ImportError:
+ USER_SITE = None
+
+try:
+ import subprocess
+
+ def _python_cmd(*args):
+ args = (sys.executable,) + args
+ return subprocess.call(args) == 0
+
+except ImportError:
+ # will be used for python 2.3
+ def _python_cmd(*args):
+ args = (sys.executable,) + args
+ # quoting arguments if windows
+ if sys.platform == 'win32':
+ def quote(arg):
+ if ' ' in arg:
+ return '"%s"' % arg
+ return arg
+ args = [quote(arg) for arg in args]
+ return os.spawnl(os.P_WAIT, sys.executable, *args) == 0
+
+DEFAULT_VERSION = "0.6.28"
+DEFAULT_URL = "http://pypi.python.org/packages/source/d/distribute/"
+SETUPTOOLS_FAKED_VERSION = "0.6c11"
+
+SETUPTOOLS_PKG_INFO = """\
+Metadata-Version: 1.0
+Name: setuptools
+Version: %s
+Summary: xxxx
+Home-page: xxx
+Author: xxx
+Author-email: xxx
+License: xxx
+Description: xxx
+""" % SETUPTOOLS_FAKED_VERSION
+
+
+def _install(tarball, install_args=()):
+ # extracting the tarball
+ tmpdir = tempfile.mkdtemp()
+ log.warn('Extracting in %s', tmpdir)
+ old_wd = os.getcwd()
+ try:
+ os.chdir(tmpdir)
+ tar = tarfile.open(tarball)
+ _extractall(tar)
+ tar.close()
+
+ # going in the directory
+ subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0])
+ os.chdir(subdir)
+ log.warn('Now working in %s', subdir)
+
+ # installing
+ log.warn('Installing Distribute')
+ if not _python_cmd('setup.py', 'install', *install_args):
+ log.warn('Something went wrong during the installation.')
+ log.warn('See the error message above.')
+ finally:
+ os.chdir(old_wd)
+
+
+def _build_egg(egg, tarball, to_dir):
+ # extracting the tarball
+ tmpdir = tempfile.mkdtemp()
+ log.warn('Extracting in %s', tmpdir)
+ old_wd = os.getcwd()
+ try:
+ os.chdir(tmpdir)
+ tar = tarfile.open(tarball)
+ _extractall(tar)
+ tar.close()
+
+ # going in the directory
+ subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0])
+ os.chdir(subdir)
+ log.warn('Now working in %s', subdir)
+
+ # building an egg
+ log.warn('Building a Distribute egg in %s', to_dir)
+ _python_cmd('setup.py', '-q', 'bdist_egg', '--dist-dir', to_dir)
+
+ finally:
+ os.chdir(old_wd)
+ # returning the result
+ log.warn(egg)
+ if not os.path.exists(egg):
+ raise IOError('Could not build the egg.')
+
+
+def _do_download(version, download_base, to_dir, download_delay):
+ egg = os.path.join(to_dir, 'distribute-%s-py%d.%d.egg'
+ % (version, sys.version_info[0], sys.version_info[1]))
+ if not os.path.exists(egg):
+ tarball = download_setuptools(version, download_base,
+ to_dir, download_delay)
+ _build_egg(egg, tarball, to_dir)
+ sys.path.insert(0, egg)
+ import setuptools
+ setuptools.bootstrap_install_from = egg
+
+
+def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
+ to_dir=os.curdir, download_delay=15, no_fake=True):
+ # making sure we use the absolute path
+ to_dir = os.path.abspath(to_dir)
+ was_imported = 'pkg_resources' in sys.modules or \
+ 'setuptools' in sys.modules
+ try:
+ try:
+ import pkg_resources
+ if not hasattr(pkg_resources, '_distribute'):
+ if not no_fake:
+ _fake_setuptools()
+ raise ImportError
+ except ImportError:
+ return _do_download(version, download_base, to_dir, download_delay)
+ try:
+ pkg_resources.require("distribute>=" + version)
+ return
+ except pkg_resources.VersionConflict:
+ e = sys.exc_info()[1]
+ if was_imported:
+ sys.stderr.write(
+ "The required version of distribute (>=%s) is not available,\n"
+ "and can't be installed while this script is running. Please\n"
+ "install a more recent version first, using\n"
+ "'easy_install -U distribute'."
+ "\n\n(Currently using %r)\n" % (version, e.args[0]))
+ sys.exit(2)
+ else:
+ del pkg_resources, sys.modules['pkg_resources'] # reload ok
+ return _do_download(version, download_base, to_dir,
+ download_delay)
+ except pkg_resources.DistributionNotFound:
+ return _do_download(version, download_base, to_dir,
+ download_delay)
+ finally:
+ if not no_fake:
+ _create_fake_setuptools_pkg_info(to_dir)
+
+
+def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
+ to_dir=os.curdir, delay=15):
+ """Download distribute from a specified location and return its filename
+
+ `version` should be a valid distribute version number that is available
+ as an egg for download under the `download_base` URL (which should end
+ with a '/'). `to_dir` is the directory where the egg will be downloaded.
+ `delay` is the number of seconds to pause before an actual download
+ attempt.
+ """
+ # making sure we use the absolute path
+ to_dir = os.path.abspath(to_dir)
+ try:
+ from urllib.request import urlopen
+ except ImportError:
+ from urllib2 import urlopen
+ tgz_name = "distribute-%s.tar.gz" % version
+ url = download_base + tgz_name
+ saveto = os.path.join(to_dir, tgz_name)
+ src = dst = None
+ if not os.path.exists(saveto): # Avoid repeated downloads
+ try:
+ log.warn("Downloading %s", url)
+ src = urlopen(url)
+ # Read/write all in one block, so we don't create a corrupt file
+ # if the download is interrupted.
+ data = src.read()
+ dst = open(saveto, "wb")
+ dst.write(data)
+ finally:
+ if src:
+ src.close()
+ if dst:
+ dst.close()
+ return os.path.realpath(saveto)
+
+
+def _no_sandbox(function):
+ def __no_sandbox(*args, **kw):
+ try:
+ from setuptools.sandbox import DirectorySandbox
+ if not hasattr(DirectorySandbox, '_old'):
+ def violation(*args):
+ pass
+ DirectorySandbox._old = DirectorySandbox._violation
+ DirectorySandbox._violation = violation
+ patched = True
+ else:
+ patched = False
+ except ImportError:
+ patched = False
+
+ try:
+ return function(*args, **kw)
+ finally:
+ if patched:
+ DirectorySandbox._violation = DirectorySandbox._old
+ del DirectorySandbox._old
+
+ return __no_sandbox
+
+
+def _patch_file(path, content):
+ """Will backup the file then patch it"""
+ existing_content = open(path).read()
+ if existing_content == content:
+ # already patched
+ log.warn('Already patched.')
+ return False
+ log.warn('Patching...')
+ _rename_path(path)
+ f = open(path, 'w')
+ try:
+ f.write(content)
+ finally:
+ f.close()
+ return True
+
+_patch_file = _no_sandbox(_patch_file)
+
+
+def _same_content(path, content):
+ return open(path).read() == content
+
+
+def _rename_path(path):
+ new_name = path + '.OLD.%s' % time.time()
+ log.warn('Renaming %s into %s', path, new_name)
+ os.rename(path, new_name)
+ return new_name
+
+
+def _remove_flat_installation(placeholder):
+ if not os.path.isdir(placeholder):
+ log.warn('Unkown installation at %s', placeholder)
+ return False
+ found = False
+ for file in os.listdir(placeholder):
+ if fnmatch.fnmatch(file, 'setuptools*.egg-info'):
+ found = True
+ break
+ if not found:
+ log.warn('Could not locate setuptools*.egg-info')
+ return
+
+ log.warn('Removing elements out of the way...')
+ pkg_info = os.path.join(placeholder, file)
+ if os.path.isdir(pkg_info):
+ patched = _patch_egg_dir(pkg_info)
+ else:
+ patched = _patch_file(pkg_info, SETUPTOOLS_PKG_INFO)
+
+ if not patched:
+ log.warn('%s already patched.', pkg_info)
+ return False
+ # now let's move the files out of the way
+ for element in ('setuptools', 'pkg_resources.py', 'site.py'):
+ element = os.path.join(placeholder, element)
+ if os.path.exists(element):
+ _rename_path(element)
+ else:
+ log.warn('Could not find the %s element of the '
+ 'Setuptools distribution', element)
+ return True
+
+_remove_flat_installation = _no_sandbox(_remove_flat_installation)
+
+
+def _after_install(dist):
+ log.warn('After install bootstrap.')
+ placeholder = dist.get_command_obj('install').install_purelib
+ _create_fake_setuptools_pkg_info(placeholder)
+
+
+def _create_fake_setuptools_pkg_info(placeholder):
+ if not placeholder or not os.path.exists(placeholder):
+ log.warn('Could not find the install location')
+ return
+ pyver = '%s.%s' % (sys.version_info[0], sys.version_info[1])
+ setuptools_file = 'setuptools-%s-py%s.egg-info' % \
+ (SETUPTOOLS_FAKED_VERSION, pyver)
+ pkg_info = os.path.join(placeholder, setuptools_file)
+ if os.path.exists(pkg_info):
+ log.warn('%s already exists', pkg_info)
+ return
+
+ if not os.access(pkg_info, os.W_OK):
+ log.warn("Don't have permissions to write %s, skipping", pkg_info)
+
+ log.warn('Creating %s', pkg_info)
+ f = open(pkg_info, 'w')
+ try:
+ f.write(SETUPTOOLS_PKG_INFO)
+ finally:
+ f.close()
+
+ pth_file = os.path.join(placeholder, 'setuptools.pth')
+ log.warn('Creating %s', pth_file)
+ f = open(pth_file, 'w')
+ try:
+ f.write(os.path.join(os.curdir, setuptools_file))
+ finally:
+ f.close()
+
+_create_fake_setuptools_pkg_info = _no_sandbox(
+ _create_fake_setuptools_pkg_info
+)
+
+
+def _patch_egg_dir(path):
+ # let's check if it's already patched
+ pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO')
+ if os.path.exists(pkg_info):
+ if _same_content(pkg_info, SETUPTOOLS_PKG_INFO):
+ log.warn('%s already patched.', pkg_info)
+ return False
+ _rename_path(path)
+ os.mkdir(path)
+ os.mkdir(os.path.join(path, 'EGG-INFO'))
+ pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO')
+ f = open(pkg_info, 'w')
+ try:
+ f.write(SETUPTOOLS_PKG_INFO)
+ finally:
+ f.close()
+ return True
+
+_patch_egg_dir = _no_sandbox(_patch_egg_dir)
+
+
+def _before_install():
+ log.warn('Before install bootstrap.')
+ _fake_setuptools()
+
+
+def _under_prefix(location):
+ if 'install' not in sys.argv:
+ return True
+ args = sys.argv[sys.argv.index('install') + 1:]
+ for index, arg in enumerate(args):
+ for option in ('--root', '--prefix'):
+ if arg.startswith('%s=' % option):
+ top_dir = arg.split('root=')[-1]
+ return location.startswith(top_dir)
+ elif arg == option:
+ if len(args) > index:
+ top_dir = args[index + 1]
+ return location.startswith(top_dir)
+ if arg == '--user' and USER_SITE is not None:
+ return location.startswith(USER_SITE)
+ return True
+
+
+def _fake_setuptools():
+ log.warn('Scanning installed packages')
+ try:
+ import pkg_resources
+ except ImportError:
+ # we're cool
+ log.warn('Setuptools or Distribute does not seem to be installed.')
+ return
+ ws = pkg_resources.working_set
+ try:
+ setuptools_dist = ws.find(
+ pkg_resources.Requirement.parse('setuptools', replacement=False)
+ )
+ except TypeError:
+ # old distribute API
+ setuptools_dist = ws.find(
+ pkg_resources.Requirement.parse('setuptools')
+ )
+
+ if setuptools_dist is None:
+ log.warn('No setuptools distribution found')
+ return
+ # detecting if it was already faked
+ setuptools_location = setuptools_dist.location
+ log.warn('Setuptools installation detected at %s', setuptools_location)
+
+ # if --root or --preix was provided, and if
+ # setuptools is not located in them, we don't patch it
+ if not _under_prefix(setuptools_location):
+ log.warn('Not patching, --root or --prefix is installing Distribute'
+ ' in another location')
+ return
+
+ # let's see if its an egg
+ if not setuptools_location.endswith('.egg'):
+ log.warn('Non-egg installation')
+ res = _remove_flat_installation(setuptools_location)
+ if not res:
+ return
+ else:
+ log.warn('Egg installation')
+ pkg_info = os.path.join(setuptools_location, 'EGG-INFO', 'PKG-INFO')
+ if (os.path.exists(pkg_info) and
+ _same_content(pkg_info, SETUPTOOLS_PKG_INFO)):
+ log.warn('Already patched.')
+ return
+ log.warn('Patching...')
+ # let's create a fake egg replacing setuptools one
+ res = _patch_egg_dir(setuptools_location)
+ if not res:
+ return
+ log.warn('Patched done.')
+ _relaunch()
+
+
+def _relaunch():
+ log.warn('Relaunching...')
+ # we have to relaunch the process
+ # pip marker to avoid a relaunch bug
+ _cmd = ['-c', 'install', '--single-version-externally-managed']
+ if sys.argv[:3] == _cmd:
+ sys.argv[0] = 'setup.py'
+ args = [sys.executable] + sys.argv
+ sys.exit(subprocess.call(args))
+
+
+def _extractall(self, path=".", members=None):
+ """Extract all members from the archive to the current working
+ directory and set owner, modification time and permissions on
+ directories afterwards. `path' specifies a different directory
+ to extract to. `members' is optional and must be a subset of the
+ list returned by getmembers().
+ """
+ import copy
+ import operator
+ from tarfile import ExtractError
+ directories = []
+
+ if members is None:
+ members = self
+
+ for tarinfo in members:
+ if tarinfo.isdir():
+ # Extract directories with a safe mode.
+ directories.append(tarinfo)
+ tarinfo = copy.copy(tarinfo)
+ tarinfo.mode = 448 # decimal for oct 0700
+ self.extract(tarinfo, path)
+
+ # Reverse sort directories.
+ if sys.version_info < (2, 4):
+ def sorter(dir1, dir2):
+ return cmp(dir1.name, dir2.name)
+ directories.sort(sorter)
+ directories.reverse()
+ else:
+ directories.sort(key=operator.attrgetter('name'), reverse=True)
+
+ # Set correct owner, mtime and filemode on directories.
+ for tarinfo in directories:
+ dirpath = os.path.join(path, tarinfo.name)
+ try:
+ self.chown(tarinfo, dirpath)
+ self.utime(tarinfo, dirpath)
+ self.chmod(tarinfo, dirpath)
+ except ExtractError:
+ e = sys.exc_info()[1]
+ if self.errorlevel > 1:
+ raise
+ else:
+ self._dbg(1, "tarfile: %s" % e)
+
+
+def _build_install_args(argv):
+ install_args = []
+ user_install = '--user' in argv
+ if user_install and sys.version_info < (2, 6):
+ log.warn("--user requires Python 2.6 or later")
+ raise SystemExit(1)
+ if user_install:
+ install_args.append('--user')
+ return install_args
+
+
+def main(argv, version=DEFAULT_VERSION):
+ """Install or upgrade setuptools and EasyInstall"""
+ tarball = download_setuptools()
+ _install(tarball, _build_install_args(argv))
+
+
+if __name__ == '__main__':
+ main(sys.argv[1:])
diff --git a/doc/README.txt b/doc/README.txt
index 7d0ca4b68378..9ae05cb477bc 100644
--- a/doc/README.txt
+++ b/doc/README.txt
@@ -39,6 +39,15 @@ for the initial run (which builds the example gallery) to be done,
then run "python make.py html" again. The top file of the results will
be ./build/html/index.html
+Note that Sphinx uses the installed version of the package to build
+the documentation, so matplotlib must be installed *before* the docs
+can be generated. Even if that is the case, one of the files needed
+to do this, '../lib/matplotlib/mpl-data/matplotlibrc', is not version
+controlled, but created when matplotlib is built. This means that the
+documentation cannot be generated immediately after checking out the
+source code, even if matplotlib is installed on your system: you will
+have to run ``python setup.py build`` first.
+
To build a smaller version of the documentation (without
high-resolution PNGs and PDF examples), type "python make.py --small
html".
diff --git a/doc/_static/logo_sidebar_horiz.png b/doc/_static/logo_sidebar_horiz.png
index b9bf002c1c62..cb543d4101a1 100644
Binary files a/doc/_static/logo_sidebar_horiz.png and b/doc/_static/logo_sidebar_horiz.png differ
diff --git a/doc/_static/mpl.css b/doc/_static/mpl.css
index 7aa01b731654..bd174f670d49 100644
--- a/doc/_static/mpl.css
+++ b/doc/_static/mpl.css
@@ -505,3 +505,64 @@ ul.search li div.context {
ul.keywordmatches li.goodmatch a {
font-weight: bold;
}
+
+table.docutils {
+ border-spacing: 2px;
+ border-collapse: collapse;
+ border-top-width: 1px;
+ border-right-width: 0px;
+ border-bottom-width: 1px;
+ border-left-width: 0px;
+}
+
+table.docutils tr:nth-child(even) {
+ background-color: #F3F3FF;
+}
+table.docutils tr:nth-child(odd) {
+ background-color: #FFFFEE;
+}
+
+table.docutils tr {
+ border-style: solid none solid none;
+ border-width: 1px 0 1px 0;
+ border-color: #AAAAAA;
+}
+
+table.docutils th {
+ padding: 1px 8px 1px 5px;
+}
+
+table.docutils td {
+ border-width: 1px 0 1px 0;
+}
+
+#matplotlib-examples ul li{
+ font-size: large;
+}
+
+#matplotlib-examples ul li ul{
+ margin-bottom:20px;
+ overflow:hidden;
+ border-top:1px solid #ccc;
+}
+
+#matplotlib-examples ul li ul li {
+ font-size: small;
+ line-height:1.75em;
+ display:inline;
+ float: left;
+ width: 22em;
+}
+
+#overview ul li ul{
+ margin-bottom:20px;
+ overflow:hidden;
+ border-top:1px solid #ccc;
+}
+
+#overview ul li ul li {
+ display:inline;
+ float: left;
+ width: 30em;
+}
+
diff --git a/doc/_static/webagg_screenshot.png b/doc/_static/webagg_screenshot.png
new file mode 100644
index 000000000000..7480241a593d
Binary files /dev/null and b/doc/_static/webagg_screenshot.png differ
diff --git a/doc/_templates/index.html b/doc/_templates/index.html
index 1d88871b96f6..2768472bc8c8 100644
--- a/doc/_templates/index.html
+++ b/doc/_templates/index.html
@@ -1,34 +1,44 @@
{% extends "layout.html" %}
{% set title = 'matplotlib: python plotting' %}
+{% block extrahead %}
+
+
+ {{ super() }}
+{% endblock %}
{% block body %}
- John Hunter (1968-2012)
-
-
-
-
-
- |
-
-
- On August 28 2012, John D. Hunter, the creator of matplotlib, died
- from complications arising from cancer treatment, after a brief but
- intense battle with this terrible illness. John is survived by his
- wife Miriam, his three daughters Rahel, Ava and Clara, his sisters
- Layne and Mary, and his mother Sarah.
-
-
- If you have benefited from John's many contributions, please say
- thanks in the way that would matter most to him. Please consider
- making a donation to
- the John Hunter Memorial
- Fund.
- |
-
-
-
Introduction
matplotlib is a python 2D plotting library which produces
@@ -66,6 +76,32 @@
Introduction
properties, axes properties, etc, via an object oriented interface
or via a set of functions familiar to MATLAB users.
+
+
John Hunter (1968-2012)
+
+
+
+
+ |
+
+
+ On August 28 2012, John D. Hunter, the creator of matplotlib, died
+ from complications arising from cancer treatment, after a brief but
+ intense battle with this terrible illness. John is survived by his
+ wife Miriam, his three daughters Rahel, Ava and Clara, his sisters
+ Layne and Mary, and his mother Sarah.
+
+
+ If you have benefited from John's many contributions, please say
+ thanks in the way that would matter most to him. Please consider
+ making a donation to
+ the John Hunter Memorial
+ Fund.
+ |
+
+
+
+
Download
Visit the
@@ -132,41 +168,41 @@ Need help?
Toolkits
-There are several matplotlib add-on toolkits, including the projection
-and mapping toolkit
-basemap, 3d plotting with mplot3d, axes and axis helpers in axes_grid and more.
+
There are several matplotlib add-on toolkits,
+including a choice of two projection and mapping toolkits basemap and
+cartopy,
+3d plotting with mplot3d,
+axes and axis helpers in axes_grid and more.
Citing matplotlib
- matplotlib is the brainchild of John Hunter (1968-2012), who has put an
- inordinate amount of effort into producing a piece of software utilized by
- thousands of scientists worldwide.
+ matplotlib is the brainchild of John Hunter (1968-2012), who, along with its many
+ contributors, have put an immeasurable amount of time and effort into producing a
+ piece of software utilized by thousands of scientists worldwide.
If matplotlib contributes to a project that leads to a scientific publication,
- please acknowledge this fact by citing the project. You can use this
+ please acknowledge this work by citing the project. You can use this
ready-made citation entry.
Open source
-Please
-consider donating
-to support matplotlib development or to
-the John Hunter Memorial
-Fund.
+
+Please consider donating
+to support matplotlib development or to the John Hunter Memorial Fund.
+
-The matplotlib license
-is based on the Python Software Foundation
-(PSF) license.
+
+The matplotlib license is based on the Python Software Foundation
+(PSF) license.
+
-There is an active developer community and a long list of people
-who have made significant contributions.
+
+There is an active developer community and a long list of people
+who have made significant contributions.
+