Commit graph

613 commits

Author SHA1 Message Date
William S Fulton
1a64e74c46 Add python runtime test for dynamically added attributes
From #320
2015-04-11 12:35:58 +01: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
06fb68af5b Merge branch 'ptomulik-fix/py-object-const'
* ptomulik-fix/py-object-const:
  constant_directive_runme.py and classic classes
  additional fixes to %constant directive
  make %constant directive to work with structs/classes
2015-01-15 20:18:21 +00:00
William S Fulton
afba5b755a Fix Python default args when using kwargs
Recent default arg handling fixes didn't fix the case when kwargs is turned on
2015-01-15 07:54:36 +00:00
William S Fulton
9d87b9f099 Revert introduction of python:defaultargs feature
See issue #294
2015-01-12 21:35:47 +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
Paweł Tomulik
2f6dee3adb constant_directive_runme.py and classic classes 2015-01-02 18:50:49 +01:00
Paweł Tomulik
cfaf2f97fd additional fixes to %constant directive 2015-01-02 18:50:49 +01:00
Paweł Tomulik
c21e2423a0 make %constant directive to work with structs/classes 2015-01-02 18:50:49 +01:00
William S Fulton
5c57a8c877 Warning suppressions in tests 2014-12-22 20:35:13 +00:00
William S Fulton
93d58cd3ed Fix use of preprocessor null directive
This was broken recently in commit 255c929c56
for issue #217
2014-12-20 17:05:13 +00:00
William S Fulton
68a936a638 Add testcase for nested inner class deriving from a templated base class and defined outside of the outer class.
For languages that don't support nested class support, use flatnested.
See issue #270
2014-12-19 19:35:38 +00:00
Vadim Zeitlin
e12a1d7671 Ignore E402 (import not on top of file) PEP8 error.
Travis uses the latest pep8 sources from Git and since

f3a12babd4

this error is given for all Python files generated by SWIG with -builtin
option.
2014-12-16 17:28:27 +01:00
Vadim Zeitlin
cb53e3063b Add PEP8_FLAGS variable to the test suite Python makefile.
Put pep8 options into this variable to avoid repeating them twice.

No real changes.
2014-12-16 17:28:25 +01:00
William S Fulton
80ae335319 Enhance C++11 strongly typed enums testcase 2014-11-27 19:56:08 +00:00
William S Fulton
7ffea44d80 C++11 strongly typed enums runtime test for python 2014-11-25 19:56:34 +00:00
William S Fulton
6029b2f7d8 Fix for 'self' being used as a parameter name 2014-10-30 07:22:59 +00:00
William S Fulton
fc1eaa5213 Fix autodoc testcase for python -builtin 2014-10-29 12:23:51 +00:00
William S Fulton
7d4af72dde Revert "Fix when is 'self' used as a parameter name in Python"
This reverts commit a6efdb7999.
2014-10-29 09:42:11 +00:00
William S Fulton
a6efdb7999 Fix when is 'self' used as a parameter name in Python
Fix corner case for variable names called 'self' after merging in patch #201
2014-10-28 07:07:44 +00:00
William S Fulton
5d71f91b29 Fix autodoc testcase for new named python arguments when using python -builtin
For the changes in #201.
2014-10-28 07:07:00 +00:00
William S Fulton
36ae32e941 Merge remote-tracking branch 'vadz/py-args'
* vadz/py-args:
  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.
2014-10-27 20:02:59 +00:00
William S Fulton
bfde148887 The kwargs feature no longer turns on compactdefaultargs for languages that don't support kwargs.
Affects all languages except Python and Ruby.

Closes #242
2014-10-21 07:34:51 +01:00
Yann Diorcet
aeacff3b14 Improve cpp11_function_objects test for python 2014-10-11 20:20:10 +02:00
William S Fulton
78b904764a Merge branch 'diorcety-python_property'
* diorcety-python_property:
  Changes file entry for Python director property fix
  Python: Fix property access with director

Conflicts:
	CHANGES.current
2014-10-11 00:22:21 +01:00
William S Fulton
ef4d44e92d Fix syntax error in autodoc testcase when using Python 2.4 and earlier 2014-10-10 23:56:14 +01:00
William S Fulton
49038b30b7 Bypass Python tests not supported by -builtin
Builtin types can't inherit from pure-python abstract bases
2014-10-07 20:58:40 +01:00
William S Fulton
ab79441151 Bypass Python tests not supported by -builtin
The base class is needed for the builtin class hierarchy, like many
other languages
2014-10-07 20:58:40 +01:00
William S Fulton
185d65895f Bypass Python tests not supported by -builtin
There are a number of autodoc comment differences when using -builtin.
Some of which might need fixing, but for now we'll accept them as they
are.
2014-10-07 20:58:39 +01:00
William S Fulton
afcd61388a Bypass Python tests not supported by -builtin
The old static syntax (e.g., dc.new_A() rather than dc.A()) is not
supported with -builtin
2014-10-07 20:58:39 +01:00
William S Fulton
9f1b051c16 Bypass Python tests failing with -builtin
Reverse operators not supported in builtin types
2014-10-07 20:58:39 +01:00
William S Fulton
bbad7f96ab Bypass Python tests throwing base classes as exceptions for -builtin
Throwing builtin classes as exceptions is not supported
2014-10-07 20:58:30 +01:00
William S Fulton
34eb4b15d3 Add some more Python -builtin tests that don't work 2014-10-02 19:08:58 +01:00
Yann Diorcet
558af639bd Python: Fix property access with director 2014-10-01 11:07:02 +02:00
William S Fulton
0fb34cb019 Disable test not relevant for Python -builtin 2014-10-01 07:57:23 +01:00
Thomas Maslach
de6b433cb1 Fix Python crash when using -threads iterating containers
Also fixes li_std_vector_enum testcase when run with -threads.

Patch supplied on swig-devel mailing list on 12 Sep with details...

==============================================
I just wanted to mention that I found a crash issue in bug..

I am using SWIG 2.0.11 with python and have –threads enabled.  I have a C++ std::vector that I instantiate in SWIG with %template.  I also have a method in a class that returns this vector.  I also include std_vector.i, btw..

When I iterate like so:

children = Action.getActionList()
for child in children:
  pass

Everything is fine..

When I iterate like this:

for child in Action.getActionList()
  pass

Product crashes.

The problem is the following.  This code gets called first:

SWIGINTERN PyObject *_wrap_delete_SwigPyIterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
  PyObject *resultobj = 0;
  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  PyObject * obj0 = 0 ;

  if(!PyArg_UnpackTuple(args,(char *)"delete_SwigPyIterator",1,1,&obj0)) SWIG_fail;
  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_DISOWN |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_SwigPyIterator" "', argument " "1"" of type '" "swig::SwigPyIterator *""'");
  }
  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
  {
    SWIG_PYTHON_THREAD_BEGIN_ALLOW;
    delete arg1;
    SWIG_PYTHON_THREAD_END_ALLOW;
  }
  resultobj = SWIG_Py_Void();
  return resultobj;
fail:
  return NULL;
}

Note the SWIG_PYTHON_THREAD_BEGIN_ALLOW/END_ALLOW. In between those two statements, we delete arg1.  That in turn will eventually end up in this code:

namespace swig {
  class SwigPtr_PyObject {
  protected:
    PyObject *_obj;

  public:
    … snip! …
    ~SwigPtr_PyObject()
    {
      Py_XDECREF(_obj);
    }

Uh-oh!  We call Py_XDECREF when we aren’t supposed to because we are in a SWIG_PYTHON_THREAD_BEGIN_ALLOW/END_ALLOW section!

This takes care of the issue:

namespace swig {
  class SwigPtr_PyObject {
  protected:
    PyObject *_obj;

  public:
    … snip! …
    ~SwigPtr_PyObject()
    {
      SWIG_PYTHON_THREAD_BEGIN_BLOCK;
      Py_XDECREF(_obj);
      SWIG_PYTHON_THREAD_END_BLOCK;
    }

There are several other methods in this class that use the Python API, but don’t have the BEGIN/END block defined.  I’m not sure if they are required for all of them, but I believe they are..

I have attached a modified pyclasses.swg with what I believe are the correct changes.  This code is from 2.0.11, but as far as I can tell, it’s the same as what is in 3.0.2…

Apologies for not doing more here (making/running tests, getting it in the code repository, etc..), but I’m under some pressure to get some unrelated things done…
2014-09-23 22:33:25 +01: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
Julien Schueller
11b5a61879 Check multi-module examples. Dont use sed. 2014-06-10 08:59:55 +02:00
Julien Schueller
7a4cef998c Enable pep8 check 2014-06-07 13:10:27 +02:00
Karl Wette
b8026cc02f Fix cleaning of Python runme.py scripts for in-source-tree builds 2014-05-29 14:40:50 +02:00
Karl Wette
cc0738bbda Fully clean Python examples and test-suite 2014-05-29 02:29:27 +02:00
Harvey Falcic
91e93838fc unicode_strings test: manually check values instead of using assert 2014-05-24 18:00:04 -04:00
Harvey Falcic
ab527b0e4b unicode_strings_runme.py: fix version check
Python 3.0.1 shouldn't pass.
2014-05-24 17:57:16 -04:00
Harvey Falcic
2533d0210f unicode_strings test: check return values 2014-05-24 16:50:33 -04:00
Harvey Falcic
5c5dfc106f Python unicode_strings test case: restrict to Python > 3.0
Also adjust the test method names and content to match the docs.
2014-05-24 15:39:53 -04:00
Harvey Falcic
791f070e66 Add "unicode_strings" test case for new Python 3 behavior 2014-05-23 15:40:01 -04:00
William S Fulton
2b5499a262 Slight simplification of test-suite build for new out-of-source changes
Provide default SRCDIR and SCRIPTDIR variables in common.mk and override
only where needed.
2014-05-15 23:11:07 +01:00
Karl Wette
f574a34155 Allow examples and test-suite to be built out of source tree
- Examples/Makefile.in rules use SRCDIR as the relative source directory

- ./config.status replicates Examples/ source directory tree in build
  directory, and copies each Makefile to build directory, prefixed with
  a header which sets SRCDIR to source directory

- Examples/test-suite/.../Makefile.in set SRCDIR from Autoconf-set srcdir

- Examples/test-suite/errors/Makefile.in needs to filter out source
  directory from SWIG error messages

- Lua: embedded interpreters are passed location of run-time test

- Python: copy run-time scripts to build directory because of 2to3
  conversion; import_packages example copies __init__.py from source
  directory; test-suite sets SCRIPTDIR to location of run-time tests

- Javascript: binding.gyp renamed to binding.gyp.in so that $srcdir
  can be substituted with SRCDIR; removed './' from require() statements
  so that NODE_PATH can be used to point Node.js to build directory
2014-05-11 23:21:10 +02:00