Commit Graph

24 Commits

Author SHA1 Message Date
William S Fulton cf8788c411 Update Python tests to not use flatstaticmethod access
Use Python class staticmethod syntax to access C++ static member functions,
such as Klass.memberfunction, instead of Klass_memberfunction.
Examples and test-suite changes in preparation for issue #2137.
2022-01-14 22:48:11 +00: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
Dmitry D. Chernov fa5f519bf9 Test-suite: Unify string quoting in the Python sources 2019-07-14 12:58:21 +10:00
Olly Betts 728b8955bd Drop support for Python classic classes
There were only needed to support Python < 2.2, and we now require at
least Python 2.6.

 Conflicts:
	.travis.yml
	Examples/test-suite/python/autodoc_runme.py
	Source/Modules/python.cxx

This is a cherry-pick and merge from patch in #1261
2018-10-12 07:10:47 +01:00
William S Fulton dcf8730cf3 Avoid can of worms testing minimum signed int value
Specifying the minimum 32 bit signed int value is not easily portable.
Remove min_32bit_int2 method, min_32bit_int1 provides runtime coverage.

g++ 32bit resulted in:
warning: this decimal constant is unsigned only in ISO C90

and some versions of clang++ resulted in:
error: integer literal is too large to be represented in type 'long' and is subject to undefined behavior under C++98, interpreting as 'unsigned long'; this literal will have type 'long long' in C++11 onwards [-Werror,-Wc++11-compat]
2017-10-07 15:04:19 +01:00
William S Fulton 4a7976a5d8 Fix platorm inconsistency in Python default argument handling.
32 bit and 64 bit compiled versions of SWIG generated different Python files
when default arguments were outside the range of 32 bit signed integers.
The default arguments specified in Python are now only those that are in the
range of a 32 bit signed integer, otherwise the default is obtained from C/C++ code.

Closes #1108
2017-10-06 21:57:04 +01:00
Michael Thon 80ffb169c1 [Python] fix and improve default argument handling
1. Fix negative octals. Currently not handled correctly by `-py3`
   (unusual case, but incorrect).
2. Fix arguments of type "octal + something" (e.g. `0640 | 04`).
   Currently drops everything after the first octal. Nasty!
3. Fix bool arguments "0 + something" (e.g. `0 | 1`) are always
   "False" (unusual case, but incorrect).
4. Remove special handling of "TRUE" and "FALSE" from
   `convertValue` since there's no reason these have to match
   "true" and "false".
5. Remove the Python 2 vs. Python 3 distinction based on the
   `-py3` flag. Now the same python code is produced for default
   arguments for Python 2 and Python 3. For this, octal default
   arguments, e.g. 0644, are now wrapped as `int('644', 8)`. This
   is required, as Python 2 and Python 3 have incompatible syntax
   for octal literals.

Fixes #707
2017-06-23 13:38:49 +12:00
William S Fulton 81ba06e59e Fix Python negative unsigned default values
Closes #993
2017-05-21 00:02:08 +01:00
William S Fulton 62c34fc9d9 Add tests for enum values and static const member variables chars containing escape sequences 2016-01-26 20:16:47 +00:00
William S Fulton b8e1a66a38 Add new feature "python:cdefaultargs"
Controls default argument code generation to obtain the default
arguments from the C++ layer instead of the Python layer.
2015-05-28 20:11:57 +01:00
Jon Schlueter b77f3afafb autopep8 cleanup of Examples/test-suite/python
automated cleanup of python pep8 whitespace compliance
2015-05-08 21:35:52 -04:00
Vadim Zeitlin 6988b00aba Fix handling of default arguments after ignored ones in Python.
Don't skip checking subsequent arguments just because one of them has "in"
typemap with numinputs=0 attribute.

Add a unit test showing the problem which is relatively rare as it doesn't
happen for the class methods and is hidden unless autodoc feature is used for
the global functions.

Closes #377.
2015-04-27 23:17:14 +02:00
Vadim Zeitlin 5569d91bd0 Fix handling of "default" typemap in Python.
Use "compact" arguments form for the function if "default" typemap is defined
for any of its arguments to allow omitting this argument when calling it from
Python.

Closes #377.
2015-04-23 15:11:05 +02:00
Vadim Zeitlin 0eae8a8efa Fix handling of NULL default argument values for pointer types.
Accept not only manifest pointer types (such as e.g. "void *") but also types
that are typedefs for pointer types when checking whether C++ value of 0 must
be represented as 0 or None in Python.

Closes #365, #376.
2015-04-23 15:11:02 +02:00
William S Fulton f1213809a2 Fix python tests for old versions of Python 2015-01-31 17:39:36 +00:00
William S Fulton 76bcec1d87 Test-suite fixes for python -classic
These are mostly workarounds for static class members not being supported for
old style classes, as documented in Python.html, "C++ classes".
2015-01-31 15:04:35 +00:00
William S Fulton efb8784c8b Fix python default_args testcase for Python 3
Changes for the default_args testcase to run under Python 3 when called
from python_default_args testcase
2015-01-09 00:37:23 +00:00
William S Fulton 38ba81811e Fix Python default argument handing broken since swig-3.0.3
Default values are no longer generated as Python code by default.
They must be explicitly turned on using the "python:defaultargs" feature.

Closes #294
Closes #296

The problems in these two issues when "python:defaultargs" is turned
on still need to be fixed and should be addressed in separate patches.
The important thing is the default code generation is now fixed.
2015-01-09 00:34:17 +00:00
Vadim Zeitlin 15b369028f Allow using enum elements as default values for Python functions.
Enum values are just (integer) constants in Python and so can be used as the
function default values just as well as literal numbers, account for this when
checking whether function parameters can be represented in Python.

Also rename is_primitive_defaultargs() to is_representable_as_pyargs() to
describe better what this function does.
2014-08-17 01:08:32 +02:00
Marcelo Matus 26d42ec95d fixes for python 2.1
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8877 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-02-23 09:08:49 +00:00
Marcelo Matus bef269c021 fix for 'staticmethod' kw name
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6911 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-12-22 20:32:31 +00:00
William S Fulton 263b2af0c5 more %ignore tests
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6707 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-11-09 21:28:04 +00:00
Marcelo Matus 9d3cce855e remove old patch for features + def arg, but save the ignore/rename part. Now everything seems to be working.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6668 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-11-04 23:18:01 +00:00
Marcelo Matus b19d0dc05e fix serious bug with def args + static methods
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6644 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-11-03 10:22:15 +00:00