BUG: Allow IOErrors when attempting to retrieve default client encoding.
- [X] closes #21552 

When using mod_wsgi, access to sys.stdout is restricted by default. To handle this case, catch a base exception instead of a more specific AttributeError during this process to include the thrown IOError by mod_wsgi.
