Error message, if a vector component is -1

I run into a strange problem today, but i don’t know if it’s mine or Blenders (2.57.1) fault:
In my script code, i create a vector:
vec = mathutils.Vector((x,y,z))

The script runs fine, until one or more of the components, e.g. z = -1.0.
The the script crashed witth he following error message in the console:
ValueError: mathutils.Vector(): sequence index 2 expected a number, found ‘int’
type,
The error only happens only exactly for -1. I hardcoded -1 into the statement
vec = mathutils.Vector((-1,y,z)) to force the error.

Another “strange” fact is, that the error is thrown every second time i run the script.:confused:

Can anybody shed some light on this for me? Did i miss something in the docs?

Thanks,
Stephan

Try -1.0.
-1 is just an INT, -1.0 is a FLOAT.

or the laborious version…

float(-1)

Your right, it shouldn’t really happen, but we should also enforce type checking…


    print("n:",str(-1))
    print("n:",str(float(-1)))

Therefore:


vec = mathutils.Vector((float(x),float(y),float(z)))

or


def v(x,y,z):
    return mathutils.Vector((float(x),float(y),float(z)))