diff --git a/CHANGES.current b/CHANGES.current index f04bbd9b0..cc36f9397 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -9,18 +9,13 @@ Version 3.0.4 (in progress) [PHP] Fix segfault in director upcall check when using PHP built with ZTS enabled. Fixes #155, reported by Pierre Labastie. -2015-01-08: wsfulton +2015-01-12: vadz [Python] Fix #294 #296 - Regression introduced in SWIG-3.0.3 when - wrapping functions with default arguments. Now any method with default - arguments obtains the default arguments from C++ instead of generating - Python code with the default arguments. - - The "python:defaultargs" feature has been introduced for users to - optionally generate Python methods with the default arguments instead - the default *args. + wrapping functions with default arguments. Invalid or missing default + arguments were sometimes being generated into the python layer. 2015-01-08: olly - Allow C++11 "explicit constexpr". Fixes github issue#284 reported + Allow C++11 "explicit constexpr". Fixes github issue #284 reported by Paweł Tomulik. Also handle "constexpr explicit" and "constexpr static". diff --git a/Examples/test-suite/default_args.i b/Examples/test-suite/default_args.i index 2bbd6738d..53f88fe37 100644 --- a/Examples/test-suite/default_args.i +++ b/Examples/test-suite/default_args.i @@ -13,7 +13,7 @@ %inline %{ #include - // All kinds of numbers: hex, octal (which pose special problems to Python (using %pythondefaultargs), negative... + // All kinds of numbers: hex, octal (which pose special problems to Python), negative... void trickyvalue1(int first, int pos = -1) {} void trickyvalue2(int first, unsigned rgb = 0xabcdef) {} void trickyvalue3(int first, int mode = 0644) {} @@ -23,6 +23,10 @@ // Long long arguments are not handled at Python level currently but still work. void seek(long long offset = 0LL) {} + void seek2(unsigned long long offset = 0ULL) {} + void seek3(long offset = 0L) {} + void seek4(unsigned long offset = 0UL) {} + void seek5(unsigned long offset = 0U) {} // Anonymous arguments int anonymous(int = 7771); diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 3c87577a2..82a0e9db1 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -58,7 +58,6 @@ CPP_TEST_CASES += \ primitive_types \ python_abstractbase \ python_append \ - python_default_args \ python_director \ python_nondynamic \ python_overload_simple_cast \ diff --git a/Examples/test-suite/python/python_default_args_runme.py b/Examples/test-suite/python/python_default_args_runme.py deleted file mode 100644 index 7f35fbed6..000000000 --- a/Examples/test-suite/python/python_default_args_runme.py +++ /dev/null @@ -1,3 +0,0 @@ -# Test %feature("python:defaultargs") using the test code in default_args_runme.py (which does not use the feature) -import default_args_runme -default_args_runme.run('python_default_args') diff --git a/Examples/test-suite/python_default_args.i b/Examples/test-suite/python_default_args.i deleted file mode 100644 index f8f2072c4..000000000 --- a/Examples/test-suite/python_default_args.i +++ /dev/null @@ -1,6 +0,0 @@ -%module python_default_args - -// Testing use of %pythondefaultargs -%pythondefaultargs; - -%include "default_args.i" diff --git a/Lib/python/pyuserdir.swg b/Lib/python/pyuserdir.swg index 2a1d80790..00aec07d5 100644 --- a/Lib/python/pyuserdir.swg +++ b/Lib/python/pyuserdir.swg @@ -185,17 +185,6 @@ These methods "may be called" if needed. #define %clearpythonappend %feature("pythonappend","") -/* ------------------------------------------------------------------------- */ -/* - Python default argument handling (for non-builtin) -*/ - -#define %pythondefaultargs %feature("python:defaultargs") -#define %nopythondefaultargs %feature("python:defaultargs", "0") -#define %clearpythondefaultargs %feature("python:defaultargs", "") - - - /* ------------------------------------------------------------------------- */ /* %extend_smart_pointer extend the smart pointer support. diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 00eec707a..abfe29823 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1975,33 +1975,29 @@ public: bool is_representable = true; if (Getattr(n, "sym:overloaded")) { - if (GetFlag(n, "feature:python:defaultargs")) { - ParmList *plist = CopyParmList(Getattr(n, "parms")); - Parm *p; - Parm *pnext; + ParmList *plist = CopyParmList(Getattr(n, "parms")); + Parm *p; + Parm *pnext; - for (p = plist; p; p = pnext) { - pnext = NIL; - String *tm = Getattr(p, "tmap:in"); - if (tm) { - pnext = Getattr(p, "tmap:in:next"); - if (checkAttribute(p, "tmap:in:numinputs", "0")) { - continue; - } - } - if (!pnext) { - pnext = nextSibling(p); - } - if (String *value = Getattr(p, "value")) { - String *type = Getattr(p, "type"); - if (!convertValue(value, type)) { - is_representable = false; - break; - } + for (p = plist; p; p = pnext) { + pnext = NIL; + String *tm = Getattr(p, "tmap:in"); + if (tm) { + pnext = Getattr(p, "tmap:in:next"); + if (checkAttribute(p, "tmap:in:numinputs", "0")) { + continue; + } + } + if (!pnext) { + pnext = nextSibling(p); + } + if (String *value = Getattr(p, "value")) { + String *type = Getattr(p, "type"); + if (!convertValue(value, type)) { + is_representable = false; + break; } } - } else { - is_representable = false; } } return is_representable;