From: <wsf...@us...> - 2011-03-09 22:31:15
|
Revision: 12525 http://swig.svn.sourceforge.net/swig/?rev=12525&view=rev Author: wsfulton Date: 2011-03-09 22:31:08 +0000 (Wed, 09 Mar 2011) Log Message: ----------- Fix SF #3194294 - corner case bug when 'NULL' is used as the default value for a primitive type parameter in a method declaration. Modified Paths: -------------- trunk/CHANGES.current trunk/Examples/test-suite/common.mk trunk/Source/Modules/python.cxx Added Paths: ----------- trunk/Examples/test-suite/default_arg_values.i trunk/Examples/test-suite/python/default_arg_values_runme.py Modified: trunk/CHANGES.current =================================================================== --- trunk/CHANGES.current 2011-03-09 21:42:38 UTC (rev 12524) +++ trunk/CHANGES.current 2011-03-09 22:31:08 UTC (rev 12525) @@ -5,6 +5,10 @@ Version 2.0.3 (in progress) =========================== +2011-03-09: wsfulton + [Python] Fix SF #3194294 - corner case bug when 'NULL' is used as the default value + for a primitive type parameter in a method declaration. + 2011-03-07: olly [PHP] Don't use zend_error_noreturn() for cases where the function returns void - now this issue can only matter if you have a function Modified: trunk/Examples/test-suite/common.mk =================================================================== --- trunk/Examples/test-suite/common.mk 2011-03-09 21:42:38 UTC (rev 12524) +++ trunk/Examples/test-suite/common.mk 2011-03-09 22:31:08 UTC (rev 12525) @@ -148,6 +148,7 @@ cpp_static \ cpp_typedef \ default_args \ + default_arg_values \ default_constructor \ defvalue_constructor \ derived_byvalue \ Added: trunk/Examples/test-suite/default_arg_values.i =================================================================== --- trunk/Examples/test-suite/default_arg_values.i (rev 0) +++ trunk/Examples/test-suite/default_arg_values.i 2011-03-09 22:31:08 UTC (rev 12525) @@ -0,0 +1,10 @@ +%module default_arg_values + +%inline %{ +struct Display { + // Bad Python wrappers were being generated when NULL used for primitive type + float draw1(float v = NULL) { return v; } + float draw2(float *v = NULL) { return v ? *v : 0; } +}; +float* createPtr(float v) { static float val; val = v; return &val; } +%} Added: trunk/Examples/test-suite/python/default_arg_values_runme.py =================================================================== --- trunk/Examples/test-suite/python/default_arg_values_runme.py (rev 0) +++ trunk/Examples/test-suite/python/default_arg_values_runme.py 2011-03-09 22:31:08 UTC (rev 12525) @@ -0,0 +1,17 @@ +from default_arg_values import * + +d = Display() + +if d.draw1() != 0: + raise RuntimeError + +if d.draw1(12) != 12: + raise RuntimeError + +p = createPtr(123); +if d.draw2() != 0: + raise RuntimeError + +if d.draw2(p) != 123: + raise RuntimeError + Modified: trunk/Source/Modules/python.cxx =================================================================== --- trunk/Source/Modules/python.cxx 2011-03-09 21:42:38 UTC (rev 12524) +++ trunk/Source/Modules/python.cxx 2011-03-09 22:31:08 UTC (rev 12525) @@ -1437,7 +1437,7 @@ if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0) return NewString("False"); if (Strcmp(v, "NULL") == 0) - return NewString("None"); + return SwigType_ispointer(t) ? NewString("None") : NewString("0"); } return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |