Remove special handling for Python < 2.6

See #701.
This commit is contained in:
Olly Betts 2018-05-18 15:52:46 +12:00
commit 7c034ead32
9 changed files with 56 additions and 454 deletions

View file

@ -150,9 +150,9 @@
<p>
This chapter describes SWIG's support of Python. SWIG is compatible
with most recent Python versions including Python 3.0 and Python 2.6,
as well as older versions dating back to Python 2.0. For the best results,
consider using Python 2.3 or newer.
with most recent Python versions (Python 2.6 and later, including Python 3).
If you still need to generate bindings which work with older versions of
Python, you'll have to use SWIG 3.0.x.
</p>
<p>
@ -860,8 +860,8 @@ installation under "Additional include directories".
<li>Finally, select the settings for the entire project and go to
"Link Options". Add the Python library file to your link libraries.
For example "python21.lib". Also, set the name of the output file to
match the name of your Python module, ie. _example.pyd - Note that _example.dll also worked with Python-2.4 and earlier.
For example "python27.lib". Also, set the name of the output file to
match the name of your Python module, i.e. <tt>_example.pyd</tt>
<li>Build your project.
</ul>
@ -2290,13 +2290,6 @@ please refer to the python documentation:</p>
<p>Use of the <tt>-builtin</tt> option implies a couple of limitations:
<ul>
<li><p>python version support:</p>
<ul>
<li>Versions 2.5 and up are fully supported</li>
<li>Versions 2.3 and 2.4 are mostly supported; there are problems with director classes and/or sub-classing a wrapped type in python.</li>
<li>Versions older than 2.3 are not supported.</li>
</ul>
</li>
<li><p>Some legacy syntax is no longer supported; in particular:</p>
<ul>
<li>The functional interface is no longer exposed. For example, you may no longer call <tt>Whizzo.new_CrunchyFrog()</tt>. Instead, you must use <tt>Whizzo.CrunchyFrog()</tt>.</li>
@ -2808,43 +2801,6 @@ It is also possible to deal with situations like this using
typemaps--an advanced topic discussed later.
</p>
<H3><a name="Python_nn31">38.4.4 Python 2.2 and classic classes</a></H3>
<p>
SWIG makes every attempt to preserve backwards compatibility with
older versions of Python to the extent that it is possible. However,
in Python-2.2, an entirely new type of class system was introduced.
This new-style class system offers many enhancements including static
member functions, properties (managed attributes), and class methods.
Details about all of these changes can be found on <a
href="https://www.python.org">www.python.org</a> and is not repeated here.
</p>
<p>
To address differences between Python versions, SWIG currently emits
dual-mode proxy class wrappers. In Python-2.2 and newer releases,
these wrappers encapsulate C++ objects in new-style classes that take
advantage of new features (static methods and properties). However,
if these very same wrappers are imported into an older version of Python,
old-style classes are used instead.
</p>
<p>
This dual-nature of the wrapper code means that you can create extension
modules with SWIG and those modules will work with all versions of Python
ranging from Python-2.0 to the very latest release. Moreover, the wrappers take
advantage of Python-2.2 features when available.
</p>
<p>
For the most part, the interface presented to users is the same regardless
of what version of Python is used. The only incompatibility lies in the handling
of static member functions. In Python-2.2, they can be accessed via the
class itself. In Python-2.1 and earlier, they have to be accessed as a global
function or through an instance (see the earlier section).
</p>
<H2><a name="Python_directors">38.5 Cross language polymorphism</a></H2>
@ -3430,7 +3386,9 @@ statements.
</p>
<p>
The following shows example usage for Python 2.6 to use <tt>print</tt> as it can in Python 3, that is, as a function instead of a statement:
The following example for Python 2.x shows how to insert code into the
generated wrapper to enable <tt>print</tt> to be used as a Python3-compatible
function instead of a statement:
</p>
<div class="code">
@ -3447,13 +3405,13 @@ print("Loading", "Whizz", "Bang", sep=' ... ')
</div>
<p>
which can be seen when viewing the first few lines of the generated <tt>.py</tt> file:
The insert code can be seen at the start of the generated <tt>.py</tt> file:
</p>
<div class="code">
<pre>
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 2.0.11
# Version 4.0.0
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
@ -6255,8 +6213,8 @@ to do this (remember you are now the Python importer) or use dynamic linking.
<p>
SWIG is able to support Python 3.0. The wrapper code generated by
SWIG can be compiled with both Python 2.x or 3.0. Further more, by
SWIG is able to support Python 3.x. The wrapper code generated by
SWIG can be compiled with both Python 2.x or 3.x. Further more, by
passing the <tt>-py3</tt> command line option to SWIG, wrapper code
with some Python 3 specific features can be generated (see below
subsections for details of these features). The <tt>-py3</tt> option also
@ -6274,7 +6232,7 @@ There is a list of known-to-be-broken features in Python 3:
</ul>
<p>
The following are Python 3.0 new features that are currently supported by
The following are Python 3 new features that are currently supported by
SWIG.
</p>
@ -6333,8 +6291,8 @@ void get_path(char *s);
<p>
Then you can write a typemap like this: (the following example is
applied to both Python 3.0 and 2.6, since the <tt>bytearray</tt> type
is backported to 2.6.
applied to both Python 2 and 3, since the <tt>bytearray</tt> type
was backported to 2.6.
</p>