@skirpichev 
$ The problem is that on the next line you just reset this to a new value.
Can you point the line number. If you are referring to the line 4263, then it is now fixed.

$ Anyway, what's supposed to be a return value for this case?
When I run test_solvers.py, it fails since one input is like above case and needs it to calculate the coefficient of gen value in power. I tested it with old code and it worked as above.
Example:
degree(4**x + 5**(2*x)) -----> 2
degree(3**(3*x)+x**2) -----> 3