py: Improve exception bases, reduces ROM usage.

Thanks to @pfalcon for the tip!