gh-37201: Fix univariate polynomial reverse
For univariate polynomials over "non-prime" finite fields, the reverse
method had an issue when specifying `degree=0`: it raised an error
saying that this optional argument should be... nonnegative (which 0
is).
Example:
```
sage: ring.<x> = GF(9)[]
sage: pol = ring(1)
sage: pol.reverse(degree=2)
x^2
sage: pol.reverse()
1
sage: pol.reverse(degree=0)
------------------------------------------------------------------------
---
ValueError Traceback (most recent call
last)
Cell In[5], line 1
----> 1 pol.reverse(degree=Integer(0))
File ~/repositories/software/sage/src/sage/rings/polynomial/polynomial_z
z_pex.pyx:537, in
sage.rings.polynomial.polynomial_zz_pex.Polynomial_ZZ_pEX.reverse()
535 if degree is not None:
536 if degree <= 0:
--> 537 raise ValueError("degree argument must be a non-negative
integer, got %s" % (degree))
538 try:
539 d = degree
ValueError: degree argument must be a non-negative integer, got 0
```
This is fixed in this PR, along with fixes in similar code where the
error message was not the expected one ("cannot convert to long",
instead of "degree must be nonnegative").
URL: https://github.com/sagemath/sage/pull/37201
Reported by: Vincent Neiger
Reviewer(s): Xavier Caruso