Multivariate polynomial cannot be evaluated at vector despite length being correct
I am writing a function which involves a polynomial ring with a variable number of variables. I want to evaluate a polynomial at a vector with the appropriate number of entries. I'm sure that the length of the input vector is the same as the number of variables in the ring, but it raises a type error:
sage: p = 5 # any prime power
sage: l = 3 # number of variables
sage: F = GF(p) # coeff field
sage: R = PolynomialRing(F, 'x', l); R
Multivariate Polynomial Ring in x0, x1, x2 over Finite Field of size 5
sage: R.inject_variables()
Defining x0, x1, x2
sage: f = x0*x1 - x2 # polynomial in R
sage: inp = random_vector(F, l) # to be inputted into f
sage: len(R.gens()) == len(inp) # check if inp has the right number of entries to serve as the input of a polynomial over R
True
sage: f(inp)
-------------------------------------------------------------------------------------
TypeError Traceback (most recent call last)
# error text
...
TypeError: x must be of correct length