Commit graph

867 commits

Author SHA1 Message Date
William S Fulton
631e26ae48 Python std::unordered_set tidy up and additional testing 2018-09-23 19:10:26 +01:00
William S Fulton
72ccea5080 Python std::unordered_map std::unordered_multimap improvements
- Fixes for -builtin
- Fix missing iterator support
2018-09-23 19:10:00 +01:00
William S Fulton
603285ecb6 Python std::unordered_map improvements
Pick up various bug fixes and improvements from the std::map
implementation.
2018-09-23 19:09:59 +01:00
William S Fulton
146998ce81 Python builtin - add indexing support to std::unordered_set 2018-09-23 19:09:59 +01:00
William S Fulton
05d6717de9 Python builtin - add indexing support to std::set 2018-09-23 19:09:54 +01:00
William S Fulton
4715a4e72c Python -builtin __contains__ fix for map and set like containers.
Fix when using -builtin and wrapping std::map, std::set, std::unordered_map or
std::unordered_set to ensure __contains__ is called. This is a wrapper for the STL
container's find method. Without it, Python will do its own slower sequence search.
2018-09-21 08:51:22 +01:00
William S Fulton
3af1b74e57 Python implicitconv assert fix using debug build of the Python interpreter
An error was not being set if an implicit conversion was attempted
calling an explicit constructor.

Fixes:
Fatal Python error: a function returned NULL without setting an error
SystemError: <built-in function new_A> returned NULL without setting an error

File "Examples/test-suite/python/implicittest.py", line 106 in __init_
2018-09-04 07:22:20 +01:00
Andreas Gaeer
0165180735 Fix assert in PyTuple_GET_SIZE
Occurs in debug interpreter builds of python-3.7 when calling tp_new in
a few testcases such as Examples/python/extend.

Closes #1321
2018-09-03 19:52:43 +01:00
William S Fulton
b3f736a9d1 Python typo fix 2018-08-31 20:30:35 +01:00
William S Fulton
2f31c3e94e Python C++11 hash tables compilation fixes
- std::unordered_map compilation fix when just using std_unordered_map.i standalone
- std::unordered_multimap compilation fix when just using std_unordered_multimap.i standalone
- Add in the standalone unordered STL test cases

Closes #1319
2018-08-31 20:26:46 +01:00
William S Fulton
c9cac931c7 Re-implement Python -fastproxy option.
The previous implementation failed with Python 3 and abstract base clases.
The new implementation replaces the Python 2 implementation using new.instancemethod with C API PyMethod_New to match the equivalent Python 3 implementation which uses PyInstanceMethod_New.

Closes #1310
2018-08-18 00:36:23 +01:00
William S Fulton
4313c2c168 Update pybuffer.i library to use new-style Python buffer C API.
Removed old API altogether as Python 2.7 is now the minimum version
supported and it supports the new-style buffer API.
2018-08-12 15:02:28 +01:00
William S Fulton
33f3dbb005 Merge branch 'gmazzamuto-pybuf_test'
* gmazzamuto-pybuf_test:
  pybuffer: don't use the old deprecated buffer protocol for Python 3
  Enable test case for python_pybuf
2018-08-12 14:19:40 +01:00
William S Fulton
91e9743014 Fix to make ISOC89 compliant: -Werror=declaration-after-statement 2018-08-10 12:44:23 +01:00
William S Fulton
4f7406624d Python fastdispatch error message improvements
When overloaded C++ methods are called, the fastdispatch mode sometimes
optimises out the generation of the typecheck typemap code, resulting in
the 'Possible C/C++ prototypes' information not being in the error message.
Now when a TypeError is thrown, the exception message is modified to contain the
'Possible C/C++ prototypes'.

See issue #1293
2018-08-10 08:14:19 +01:00
William S Fulton
e0b23969d0 Correct PyErr_Fetch/PyErr_Restore variable names 2018-08-10 08:14:19 +01:00
William S Fulton
5ce880ee41 Fix SWIG_Py_None regression from last commit 2018-07-18 11:44:27 +01:00
William S Fulton
344e9fefa8 Python singletons tidy up 2018-07-17 20:23:55 +01:00
William S Fulton
d56d7a7253 Initialize Python function-local statics (singletons)
Singletons are created during Python module initialization in order to avoid
deadlocks with subsequent multi-threaded usage.
Fixes #1275 #1279
2018-07-17 19:56:12 +01:00
William S Fulton
8e6799d783 Revert "Merge branch 'petrmitrichev-remove-function-local-statics'"
This reverts commit b8ed7759d5, reversing
changes made to 6f2399e86d.
2018-07-17 08:46:53 +01:00
Giacomo Mazzamuto
3594e54f7e pybuffer: don't use the old deprecated buffer protocol for Python 3 2018-07-05 00:29:28 +02:00
William S Fulton
f8ffc04215 Use SWIGRUNTIME for SwigPyObject_repr2 2018-06-30 19:30:58 +01:00
William S Fulton
4b4e0180f4 Python initialization code tidy up
I've moved the initialization of statics a little earlier on - a little
safer as it is hard to follow exactly when some of these were being
used, such as SWIG_Py_None which sometimes replaces Py_None.
2018-06-30 19:28:03 +01:00
William S Fulton
b3763c8dc8 Remove SWIG_STATIC_POINTER (Python)
It's use has been removed to discourage thread unsafe static
initialisation.
2018-06-30 17:47:01 +01:00
Petr Mitrichev
40ea0a9606 Add comments that explain the need for globals. 2018-06-28 17:33:31 +02:00
Petr Mitrichev
d956081fd3 Avoid function-local statics that call Python code to avoid deadlocks with GIL 2018-06-28 14:27:52 +02:00
William S Fulton
1665712fcb Python 3.7 support: Remove use of deprecated PyUnicode_GetSize 2018-06-15 19:39:19 +01:00
William S Fulton
e96316bf31 Fix seg fault using Python 2 invalid utf-8 strings and wstring
Fixes seg fault when passing a Python string, containing invalid utf-8 content,
to a wstring or wchar * parameter.  A TypeError is thrown instead, eg:

  %include <std_wstring.i>
  void instring(const std::wstring& s);

  instring(b"h\xe9llooo") # Python
2018-06-15 19:39:12 +01:00
William S Fulton
3915e7bd08 Remove final remnants of GCJ - jstring.i 2018-06-15 06:57:53 +01:00
William S Fulton
4079fb927b Python 3.7 support - deprecation of classes in the collections module
Change the base classes in the pyabc.i file to use the
collections.abc module instead of collections due to the deprecation
of the classes in the collections module in Python 3.7.
2018-06-12 21:05:07 +01:00
William S Fulton
ecf61f8e39 Restore Python 3.2/3.3 support 2018-06-12 08:02:23 +01:00
Olly Betts
7f98830110 [Python] Fix new GCC8 warnings in generated code
Avoid casts between incompatible function types where possible (when
keyword args are in use, it is not possible to avoid such warnings as
they are inherent in the design of Python's C API in that particular
case).  Fixes #1259.
2018-06-11 15:51:53 +12:00
Olly Betts
2ea976f1d8 Always use PyCapsule
It is supported by all the Python versions we now support.
2018-06-08 11:08:31 +12:00
Olly Betts
a82c1b943b Drop support for Python 3.0 to 3.3
See #701.
2018-06-08 11:08:31 +12:00
Olly Betts
1198155083 Drop Python 2.6 support too
See #701.
2018-06-08 11:08:31 +12:00
Olly Betts
7c034ead32 Remove special handling for Python < 2.6
See #701.
2018-06-08 09:34:48 +12:00
Olly Betts
c9d2275a0c Remove lingering trace of support for Python 1.x 2018-06-08 08:47:24 +12:00
William S Fulton
33921666a1 Merge branch 'vadz-doxygen'
This is the Doxygen work begun in Google Summer of Code projects 2008
and 2012 and subsequently improved by numerous contributors.

* vadz-doxygen: (314 commits)
  Add changes entry for Doxygen support
  Add some missing doctype tyemaps
  Doxygen warnings cleanup
  Move doxygen warning numbers
  Add Python doxygen example
  Doxygen example
  Add Doxygen to include paths
  Doxygen source rename
  More merge fixes from doxygen branches
  Correct python example headers
  Correct source code headers
  Another merge fix from doxygen branches
  Java enums output format fixes
  Add omitted doxygen_parsing_enums testcase
  PEP8 conformance for comment verifier module
  Clean up merge problem
  Doxygen html tweaks
  Update html chapter numbering for added Doxygen chapter
  Fixes to makechap.py to detect ill-formed headers
  html fixes for Doxygen
  Add missing CPlusPlus17.html file
  Format files to unix format
  Doxygen testcase tweak to match that in the html docs
  Doxygen html documentation updates and corrections
  Remove doxygen Examples subdirectory
  Beautify doxygen source code
  Code formatting fixes in doxygen code
  Remove unused doxygen code
  new_node refactor
  Various merge fixes in doxygen branches
  Unused variable warning fix
  Fix wrongly resetting indent after formulae in Doxygen comments
  Add support for doxygen:alias feature
  Get rid of meaningless return type of DoxygenParser methods
  Return enum, not untyped int, when classifying Doxygen commands
  Get rid of unnecessary "typedef enum" in C++ code
  Use slash, not backslash, in "C/C++" in the documentation
  Replace literal "<" with "&lt;" in HTML documentation
  Fix broken link to java.sun.com in Doxygen documentation
  Fix using com.sun.tools.javadoc package under macOS
  Fix error reporting for special characters in Doxygen parsing code
  Switch Python Doxygen unit tests to use inspect.getdoc()
  Use correct separator in Java class path under Windows.
  Remove executable permission from appveyor.yml.
  Use JAVA_HOME value in configure to detect Java.
  Display JAVA_HOME value in "make java_version".
  Fix harmless MSVC warning in DoxygenTranslator code.
  Reset "_last" for all but first enum elements.
  Don't duplicate Javadoc from global enum Doxygen comments twice.
  Move Doxygen comments concatenation from the parser to the lexer.
  Fix shift/reduce conflicts in Doxygen pre/post comment parsing.
  Rewrote part of the grammar dealing with Doxygen comments for enums.
  No changes, just remove spurious white space only differences.
  Move Doxygen comment mangling from the parser to the lexer.
  Merge "-builtin" autodoc bugs workarounds from master into test.
  Quote JAVA_HOME variable value in Java test suite makefile.
  Remove unused C_COMMENT_STRING terminal from the grammar.
  Fix missing returns in the Doxygen test suite code.
  Fix trimming whitespace from Doxygen comments.
  Remove code not doing anything from PyDocConverter.
  Remove unused <sstream> header.
  Remove unreferenced struct declaration.
  Remove unused Swig_warn() function.
  Remove any whitespace before ignored Doxygen commands.
  Remove trailing space from one of Doxygen tests.
  Fix autodoc strings generated in Python builtin case and the test.
  Fix Doxygen unit test in Python "-builtin" case.
  Use class docstrings in "-builtin" Python case.
  Don't indent Doxygen doc strings in generated Python code.
  Add a possibility to flexibly ignore custom Doxygen tags.
  Stop completely ignoring many Doxygen comments.
  Fix structural Doxygen comment recognition in the parser.
  No changes, just make checking for Doxygen structural tags more sane.
  Use "//", not "#", for comments in SWIG input.
  Allow upper case letters and digits in Doxygen words.
  Pass the node the Doxygen comment is attached to to DoxygenParser.
  Get rid of findCommand() which duplicaed commandBelongs().
  Recognize unknown Doxygen tags correctly.
  No real changes, just pass original command to commandBelongs().
  Describe Doxygen-specific %features in a single place.
  Give warnings for unknown Doxygen commands in Doxygen parser.
  Document the return type when translating Doxygen @return to Python.
  Fix translated Doxygen comments for overloaded functions in Python.
  Also merge Doxygen comments for overloaded constructors in Python.
  Allow using enum elements as default values for Python functions.
  Don't always use "*args" for all Python wrapper functions.
  No real changes, just make PYTHON::check_kwargs() const.
  Refactor: move makeParameterName() to common Language base class.
  Remove long line wrapping from Python parameter list generation code.
  Simplify and make more efficient building Python docstrings.
  Translate Doxygen code blocks to Sphinx code blocks.
  Add a simple test of multiple parameters to Doxygen test suite.
  Make Python parameters types hyperlinks in the doc strings.
  Make Language::classLookup() and enumLookup() static.
  Fix arguments of @param, @return etc translations to Python.
  Remove unused method from PyDocConverter.
  No real changes, just remove an unnecessary variable.
  Preserve relative indentation when parsing Doxygen comments.
  Use Sphinx-friendly formatting for overloaded functions documentation.
  Add poor man trailing white space detection to Doxygen Python tests.
  ...
2018-06-07 08:13:10 +01:00
William S Fulton
088d7c7773 Add some missing doctype tyemaps 2018-06-05 18:52:30 +01:00
luz.paz
6f69830321 follow-up typos 2018-05-17 10:26:00 -04:00
luz.paz
60dfa31a67 Misc. typos
found via `codespell` and `grep`
2018-05-17 10:04:23 -04:00
Vadim Zeitlin
b7f78dd5a7 Merge branch 'master' into doxygen 2018-03-19 21:54:46 +01:00
William S Fulton
cd9b7c3c34 std_basic_string.i fixes
- Remove python code from octave's std_basic_string.i
- Correctly return an error to fix error handling when using std::basic_string in
  overloaded methods - issue #1171.
2018-01-04 07:00:26 +00:00
William S Fulton
b0e29fbdf3 Add missing checks for failures in calls to PyUnicode_AsUTF8String.
Previously a seg fault could occur when passing invalid UTF8 strings (low
surrogates), eg passing u"\udcff" to the C layer (Python 3).
2017-12-04 20:14:04 +00:00
William S Fulton
3f8b8fe734 Enhancements for directorin typemaps
The directorin typemaps will now generate a temporary variable
(specified after the type), such as:
%typemap(directorin) MyType (MyType *temp) { ... use temp ... }

The shared_ptr director typemaps have been fixed for use in functions
that take more than one parameter.
2017-10-16 19:28:27 +01:00
William S Fulton
6470fe8c36 Director shared_ptr typemaps for scripting languages
Modify the Python and Ruby director shared_ptr typemaps to be language neutral.
Port the director modifications to other scripting languages that
have shared_ptr support - Octave, R and Scilab. Scilab shared_ptr
support is not fully working and needs work though.
2017-10-13 07:34:38 +01:00
William S Fulton
d0615d98a9 Merge branch 'radarsat1-fix-null-shared_ptr-directors'
* radarsat1-fix-null-shared_ptr-directors:
  Remove duplicate director shared_ptr pointer reference typemaps
  For shared_ptr directorin, make copy of shared_ptr in all cases.
  Add directorin typemap for Python and Ruby shared_ptr.
2017-10-11 09:03:01 +01:00
William S Fulton
000e63e0f8 Remove duplicate director shared_ptr pointer reference typemaps 2017-10-11 07:08:46 +01:00
Olly Betts
5a9422d980 Remove GCJ support
GCC7 dropped GCJ.

Closes https://sourceforge.net/p/swig/bugs/823/
2017-10-09 08:32:01 +13:00
William S Fulton
e01cfd70c7 Add missing declaration for std::complex
Fixes missing type information for std::complex in scripting languages.
Closes #732.

Update Javascript and Octave complextest, although they don't actually
get run as they don't work
2017-10-02 19:07:24 +01:00