gh-36651: enhancements in infinite polynomial rings
This make a few little changes, nothing serious.
This catches more precise exceptions, not `Exception`.
URL: https://github.com/sagemath/sage/pull/36651
Reported by: Frédéric Chapoton
Reviewer(s): Martin Rubey