Object_data_add "'int' object is not iterable"

I’m trying to make an addon that adds a wireframe tree to my scene, but whenever my script runs the bpy_extras.object_utils.object_data_add() function, I get a TypeError saying “'int object is not iterable”.


When I handle the exception, the mesh is created as expected. What is causing this error?

If it helps, my script is based on the operator_mesh_add.py template.

It looks like the property operator.layers itself is returning a number, while the any() builtin expects it to be an iterable, or sequence of objects.

any() is used to check the truth value of a sequence: if any of the objects in a sequence evaluates to True the function will return True. However an integer is a singular object, so any() doesn’t understand it.