Fixed #21189: Cleaned up usage of bare except clauses.

Thanks to berkerpeksag for the report.