Fix Python UMR on round(x) for reference type
The "reference" extension type for the VTK wrappers has a slot for x.__round__(digits=0)
, and if the "digits" parameter was not set, then an unitialized pointer would be passed instead. This change initializes the optional parameter, and also initializes all non-optional parameters out of an abundance of caution.
Here is a demonstration of the uninitialized pointer causing a segfault.
Python 3.10.12 (main, Nov 6 2024, 20:22:13) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from vtkmodules.vtkCommonCore import reference
>>> x = reference(3.14)
>>> round(x,1) # optional 'digits' parameter is set
3.1
>>> round(x) # optional 'digits' parameter is not set
Segmentation fault (core dumped)
Note that the UMR doesn't always cause a segfault. Sometimes the code works as expected, and sometimes round() receives the optional parameter as some random Python object.
Backport: release
Edited by David Gobbi