In the ESPResSo 4.2 line, we generalized the use of the script interface methods make_Vector3d() and make_Vector3i, but we forgot to add the except * keyword to propagate exceptions. When we call methods with arguments that are not homologous to a list of size 3, such as a list of size 2 or a string of length 2 or an integer or a float, a TypeError is raised and immediately silenced with a message printed to the terminal. The returned Vector3d or Vector3i then contains uninitialized data and the simulation script continues running.
TypeError: 'float' object is not iterable
Exception ignored in: 'espressomd.utils.make_Vector3d'
Traceback (most recent call last):
File "/work/jgrad/espresso/build/src/python/espressomd/actors.py", line 59, in add
actor._activate()
TypeError: 'float' object is not iterable
script continues
[1.00000000e-002 1.00000000e+000 1.10940916e-310]
Expected output:
Traceback (most recent call last):
File "/work/jgrad/espresso/build/mwe.py", line 7, in <module>
system.actors.add(lb_fluid)
File "/work/jgrad/espresso/build/src/python/espressomd/actors.py", line 59, in add
actor._activate()
File "lb.pyx", line 69, in espressomd.lb.FluidActor._activate
File "lb.pyx", line 556, in espressomd.lb.LBFluid._activate_method
File "lb.pyx", line 293, in espressomd.lb.HydrodynamicInteraction._set_params_in_es_core
File "lb.pyx", line 489, in espressomd.lb.HydrodynamicInteraction.ext_force_density.__set__
File "utils.pyx", line 246, in espressomd.utils.make_Vector3d
TypeError: 'float' object is not iterable
While the bug was also present in the 4.1 line, all call sites would first check whether the argument was homologous to a vector of size 3 before passing it to make_Vector3d(). In the python branch, these functions were replaced by a safer alternative that raises a RuntimeError.
Many thanks to @pm-blanco for reporting this issue to us.
In the ESPResSo 4.2 line, we generalized the use of the script interface methods
make_Vector3d()
andmake_Vector3i
, but we forgot to add theexcept *
keyword to propagate exceptions. When we call methods with arguments that are not homologous to a list of size 3, such as a list of size 2 or a string of length 2 or an integer or a float, aTypeError
is raised and immediately silenced with a message printed to the terminal. The returnedVector3d
orVector3i
then contains uninitialized data and the simulation script continues running.Here is a MWE:
Output:
Expected output:
While the bug was also present in the 4.1 line, all call sites would first check whether the argument was homologous to a vector of size 3 before passing it to
make_Vector3d()
. In the python branch, these functions were replaced by a safer alternative that raises aRuntimeError
.Many thanks to @pm-blanco for reporting this issue to us.