Control: forwarded 944648 https://trac.sagemath.org/ticket/28795

On 11/28/19 2:09 AM, peter green wrote:
>> All three failures give the error message
>>
>> OverflowError: Python int too large to convert to C long
>>
>> from
>>
>> File "sage/rings/polynomial/polynomial_integer_dense_flint.pyx", line 284, 
>> in 
>> sage.rings.polynomial.polynomial_integer_dense_flint.Polynomial_integer_dense_flint.__init__
>>  
>> (build/cythonized/sage/rings/polynomial/polynomial_integer_dense_flint.cpp:6548)
>>         fmpz_poly_set_coeff_si(self.__poly, i, a)
>>
>> Help on finding a fix would be appreciated.
> On line 282 of that file (assuming the version at 
> https://github.com/sagemath/sage/blob/master/src/sage/rings/polynomial/polynomial_integer_dense_flint.pyx
>  is the same as the one in the Debian package).
> 
> "if type(a) is int:"
> 
> If that conditional is true then the code takes a fast path, which assumes 
> that the value of "a" fits in a C long.
> 
> In python 2 "int" was a type limited to the size of a c long, so the check 
> was appropriate. However in python 3 "int" is an arbitrary precision type, so 
> we need to check if it will fit in the range of a C long.
> 
> There are several other conditionals on types being "int" in the file that 
> presumably need fixing in the same way. I also spotted a "isinstance(x0, 
> long):" which i'm pretty sure will fail in python 3 as there is no type long 
> in python 3.
> 
> I have attached a completely untested patch.
> 

Thanks, that helped a lot. Knowing this I was able to find the upstream ticket 
were this was fixed only 3 days ago:
https://trac.sagemath.org/ticket/28795

I'll apply that upstream patch soon. Sagemath 9.0 will be the first release 
with Python 3 as default so I hope it will have less problems than 8.9.

Best,

Tobias

Reply via email to