$ So, the point is - this line can raise an exception, right?
Yes. In the earlier code, for degree(1); it should raise an exception but not for degree(1,x).

$ But then, you should do same for elif f.is_number, isn't?
No. The earlier one gives degree(pi), 0. 

$ Also, you should catch PolificationFailed there. It doesn't make sense for the whole code.
Admit. I changed the code.