Commit graph

963 commits

Author SHA1 Message Date
William S Fulton
4f184500d7 Merge commit '8245277ad3' into c99-complex
* commit '8245277ad3':
  Remove test for unsupported complex or _Complex by itself
  More C99 complex fixes, plus Python tests
  Restore _Complex as standalone type
  Small corrections for handling C99 _Complex
  Properly handle C99 complex types even in C++ mode

Conflicts:
	Examples/test-suite/python/complextest_runme.py
2020-10-10 14:53:33 +01:00
William S Fulton
b456449940 Update python_pybuffer_runme.py syntax for working under both python 2 and 3 2020-10-07 22:41:04 +01:00
William S Fulton
4d5f4bcd33 Merge branch 'PyBuffer_Release-pybuffer'
* PyBuffer_Release-pybuffer:
  Add tests.
  Fix the error handling for the PyObject_GetBuffer() calls in pybuffer.i
2020-10-07 22:37:17 +01:00
Gareth Francis
6db3ab0d05 Add test for wchar_t members to li_std_string.i 2020-09-12 17:04:28 +01:00
William S Fulton
b1c0145fd3 Python 3.2 syntax error fixes in tests 2020-08-15 23:51:40 +01:00
William S Fulton
c5e078c437 Revert 2to3 modification
Use sys.maxint still for Python 2
2020-08-15 23:50:31 +01:00
William S Fulton
baec830f75 Merge branch 'remove-dependency-on-2to3'
* remove-dependency-on-2to3:
  Remove need for Python 2to3
  Modify examples to be both Python 2 and 3 compatible
  Remove python3 specific runme3.py test files
  Convert python tests using 2to3
  Convert python test scripts to be Python 2 and 3 compatible
  Convert swigobject python test to be python 2 and 3 compatible
  Convert two tests to work with both Python 2 and 3
  Improve director_exception Python test
  Remove further print statements from Python tests
  Improve Python testing catching exceptions
  Improve contract Python testcase testing
  Remove print statements from Python tests
2020-08-15 19:03:38 +01:00
William S Fulton
cc94e5168f Add missing test to python test-suite 2020-08-15 19:02:52 +01:00
William S Fulton
ec2b47ef2a Remove need for Python 2to3
All Python examples and tests have been written to be both Python 2 and Python 3
compatible, removing the need for 2to3 to run the examples or test-suite.

The 2to3 executable is not always available and even when available does not
always work, e.g. with pyenv. An alternative would be to use the lib2to3 Python
module instead, but this isn't available in some older versions of Python 3.

I had this problem on Ubuntu Bionic on Travis:

  checking Examples/python/callback
  pyenv: 2to3-3.8: command not found
  The `2to3-3.8' command exists in these Python versions:
    3.8
    3.8.1

Reference issues:
  https://github.com/pypa/virtualenv/issues/1399
  https://travis-ci.community/t/2to3-command-not-found-in-venv-in-bionic/4495
2020-08-15 18:04:58 +01:00
William S Fulton
2af35cb4ff Remove python3 specific runme3.py test files
This file can be run using Python 2, the test is just ignored
2020-08-15 12:20:23 +01:00
William S Fulton
d4ffa46f41 Convert python tests using 2to3
These tests were converted using 2to3 and should be valid using
Python 2.7 and Python 3+.
2020-08-15 00:16:04 +01:00
William S Fulton
66df0bd224 Convert python test scripts to be Python 2 and 3 compatible
Unicode testing
2020-08-15 00:09:31 +01:00
William S Fulton
36bb54f01d Convert swigobject python test to be python 2 and 3 compatible 2020-08-14 23:27:35 +01:00
William S Fulton
982b08dced Convert two tests to work with both Python 2 and 3
Now these two tests work without having to use 2to3
2020-08-13 23:34:28 +01:00
William S Fulton
d820045336 Improve director_exception Python test
Add code to handle missed exceptons.
Remove print statement.
2020-08-13 22:00:01 +01:00
William S Fulton
9169555628 Remove further print statements from Python tests
Use exceptions instead of printing to stdout.
Part of an effort to convert Python tests to python 3 syntax.
2020-08-13 21:47:20 +01:00
William S Fulton
64d3617b3c Improve Python testing catching exceptions
Catch expected exceptions only
2020-08-13 21:40:11 +01:00
William S Fulton
7c34d3828f Improve contract Python testcase testing
Catch expected exceptions only - fix bug in test
2020-08-13 21:31:56 +01:00
William S Fulton
365d4961d4 Remove print statements from Python tests
Use exceptions instead of printing to stdout.
Part of an effort to convert Python tests to python 3 syntax.
2020-08-13 21:22:47 +01:00
William S Fulton
a38f30a194 Add basic std::pair Python testing
Based on Ruby's li_std_pair_runme.rb
2020-08-13 16:06:48 +01:00
Leo Singer
8245277ad3 Remove test for unsupported complex or _Complex by itself 2020-06-24 20:21:47 -04:00
Leo Singer
511df0e642 More C99 complex fixes, plus Python tests 2020-06-24 20:21:47 -04:00
Zackery Spytz
c4c8751892 Add tests. 2020-06-15 01:33:59 -06:00
William S Fulton
ee7eb6b58a Merge branch 'directors-comparison-operators'
* directors-comparison-operators:
  Use %rename
  Fix wrapping of virtual comparison operators with directors
2020-06-14 22:23:57 +01:00
William S Fulton
991c2afe11 Merge branch 'python-doxygen-quotes'
* python-doxygen-quotes:
  Fix generated Python code for Doxygen comments with triple quotes
  Fix generated Python code for Doxygen comments ending with quote
2020-06-07 10:23:33 +01:00
Zackery Spytz
4e57c5536d Fix wrapping of virtual comparison operators with directors
Closes #1642.
2020-06-05 10:25:20 -06:00
William S Fulton
f68d0c6da3
Merge pull request #1788 from mcfarljm/Issue-1757
Fix for missing space after \endlink in doxygen
2020-05-28 22:25:53 +01:00
Vadim Zeitlin
6c5d00bd0d Ignore ambiguous variable names error from pycodestyle 2.6
This error is given for any use of variable called "l" (and also "I" and
"O", but we don't seem to have any of those) and it doesn't seem to be
worth changing this variable name in the tests code, as it's really not
that meaningful there anyhow, so just disable the warning to let the CI
builds, which now use pycodestyle 2.6, instead of 2.5 which didn't have
this error and which is still the latest available in Debian Sid, pass.
2020-05-22 16:17:45 +02:00
John McFarland
61dbc4b50c Fix for missing space after \endlink in doxygen
The "endlink" command is processed in processWordCommands, which by
default skips space occuring after the command, which is intended for
removing leading space from a command argument.  For "end" commands,
we don't want to do this.  Note that certain end commands such as
"endcode" aren't processed by processWordCommands (believe
addCommandUnique ends up handling them).

Update usage of \link in doxygen_translate_all_tags.i to test handling
of space after \endlink.

Tweaking some of the usage in doxygen_misc_constructs.i to remove what
seems to be an extra space from the input (otherwise we would need to
add an extra space to the expected output).
2020-05-02 18:42:55 -05:00
Vadim Zeitlin
f57b096c92 Fix generated Python code for Doxygen comments with triple quotes
In addition to the changes in the previous commit, also avoid syntax
errors in the generated Python docstrings by splitting them into several
parts if there are 3 quotes in a row in the input, as it's impossible to
have them inside triple-quoted strings, generally speaking (i.e. if
there are occurrences of both """ and ''' inside the string).
2020-03-04 00:57:31 +01:00
Vadim Zeitlin
b81cd1bdab Fix generated Python code for Doxygen comments ending with quote
Single-line Doxygen comments ending with a double quote resulted in
syntactically-invalid Python docstrings in the output, so use triple
single quotes as delimiters in this case to avoid it.
2020-03-04 00:56:27 +01:00
William S Fulton
fc2f0204ba Port Ruby test of vector<shared_ptr<>> to Python
This test code tests the upcast code:
  swig_assert_equal_simple(-1, base_num2([Derived(7)]))
Although there is no explicit memory leak fix test, it does at least run the code.

Handling of None needs fixing in Python (it is working in Ruby)
Note that the Ruby implementation has a partial template specialization
for shared_ptr, whereas the Python implementation is in the generic
code!

Issue #1512
2020-02-13 19:21:30 +00:00
William S Fulton
a01e8474f6 Fixing setting this in Python when using __slots__
Don't attempt to use the class's __dict__ for setting 'this' when
a user has extended a class with:
    __slots__ = ['this'].
Was segfaulting. Now we fall back to a simple PyObject_SetAttr if the
usual approach to setting 'this' in __dict__ does not work.

Closes #1673 Closes #1674
2020-02-06 07:08:16 +00:00
William S Fulton
0c00daf3a1 Merge branch 'autodoc-doxygen-fix'
* autodoc-doxygen-fix:
  Fix crash in Python backend when using empty docstrings
2020-01-31 18:57:47 +00:00
Vadim Zeitlin
e14532ce52 Fix crash in Python backend when using empty docstrings
Due to confusion in build_combined_docstring(), we could call
DohDelete() on the "feature:docstring" string, which resulted in a crash
when trying to use it later.

Fix this and simplify the code at the same time by ensuring that we
always use a copy of "feature:docstring" if it's not empty or don't use
it at all if it's empty -- like this we don't have to check for its
length each time before using it.

Closes #1648.
2020-01-30 16:11:18 +01:00
William S Fulton
7405bd6a88 Minor tweak to director_wstring_runme.py test 2020-01-28 20:35:29 +00:00
William S Fulton
45963937d5 Test shared_ptr upcasts in Python 2020-01-24 19:54:29 +00:00
William S Fulton
7051753fdf Correct recently expanded testcase from a merge for doxygen default parameter support 2020-01-16 19:49:16 +00:00
William S Fulton
aa59c81205 Merge branch 'Issue-1643'
* Issue-1643:
  Fix pydoc null pointer dereference with missing arg type
2020-01-16 18:54:47 +00:00
William S Fulton
55d36e3fd3 Merge branch 'Issue-1632'
* Issue-1632:
  Minor workaround in doxygen_basic_translate_style3 test
  Add new test doxygen_basic_translate_style3.i
  Fix for newline handling in doxygen "///" style comments
2020-01-16 07:19:29 +00:00
William S Fulton
00b47d4d1d Merge branch 'doxy/commands'
* doxy/commands:
  Update documentation for doxygen tags
  Fix doxygen translation of \p command for python
  Fix doxygen handling of \em tag for python
  Minor formatting updates to doxygen docs
  Reformat tag lists in doxygen documentation
  Add doxygen_code_blocks_runme.java
  Special handling for python doctest code blocks
  Add new doxygen test doxygen_code_blocks
  Handle doxygen code command with language option
  Improve doxygen parser handling of \code content
  Flag optional arguments in doxygen pydoc output
  Add parameter direction to doxygen pydoc output
  Support doxygen \param[] commands
2020-01-14 18:36:50 +00:00
William S Fulton
67e8334ac8 Python -builtin constructors silently ignored keyword arguments.
Instead of silenty ignoring them, now a "TypeError: f() takes no keyword arguments"
exception is thrown if keyword arguments are used. Hence constructors and normal
methods/functions behave in the same way.

Closes issue #1595
2020-01-13 19:26:22 +00:00
John McFarland
e46e1655cd Minor workaround in doxygen_basic_translate_style3 test
With the "///" doxygen comment style, comments within a code block do
not get handled correctly.  Modifying the test to remove this case and
adding a note about it for future reference.
2019-11-02 10:43:52 -05:00
John McFarland
feea39f352 Add new test doxygen_basic_translate_style3.i
This is used to test the "///" style of doxygen comments.  Previously,
newlines in these doxygen comments were not handled correctly.
2019-11-02 10:43:52 -05:00
William S Fulton
cb5d7398b5 Fix bug in Python builtin support for keyword args
The fix is when using kwargs feature or -keyword.
The fix is in the argument error checking when wrapping zero
argument constructors only. Supplied keyword args were silently
ignored.

Issue #1595
2019-11-01 19:46:42 +00:00
John McFarland
f99eb0058b Fix pydoc null pointer dereference with missing arg type
Processing doxygen @param comments for a parameter whose name did not
appear in the function declaration would cause a segfault due to a
null pointer dereference.

Adding test cases for both variadic function (no specified arguments)
and @param comment that references an argument that is not named in
the function prototype.  Both of these cases previously segfaulted.
2019-10-27 18:19:42 -05:00
John McFarland
f8ed9d71a7 Fix doxygen translation of \p command for python
Doxygen writes this using typewriter font, so wrap in `` for python
2019-09-15 10:59:03 -05:00
John McFarland
c11172587c Fix doxygen handling of \em tag for python
In doxygen, \em is used for italics, so it should be wrapped in "*".
2019-09-15 10:59:03 -05:00
John McFarland
4a5a86ba91 Special handling for python doctest code blocks
A doctest code block begins with ">>>" and is not indented.  Identify
these in doxygen comments and treat them accordingly.  Also add check
to padCodeAndVerbatimBlocks for these because Sphinx requires an empty
line before.

Add test case to doxygen_code_blocks.i.
2019-08-07 17:04:12 -05:00
John McFarland
5230afb3e1 Add new doxygen test doxygen_code_blocks
This does somewhat more detailed testing of the code block parsing,
and also exercises the language identification of python doctest
features.  For now, it is only tested by python (javadoc translation
may not correctly handle some of the characters that are used here).
2019-08-07 16:55:38 -05:00