Katello/katello — pull request #1509 by xsuchy (2013-02-04 16:22:26+00:00)
Title: 880019 - learn optparser how to handle unicode errors

addressing:
```
2013-02-04 00:29:37,299 [ERROR][MainThread] error() @ base.py:191 - Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/katello/client/cli/base.py", line 203, in main
ret_code = super(KatelloCLI, self).main(args, command_name, parent_usage)
File "/usr/lib/python2.6/site-packages/katello/client/core/base.py", line 312, in main
return subcommand.main(self.args[1:], self.args[0], self._get_usage_line(command_name, parent_usage))
File "/usr/lib/python2.6/site-packages/katello/client/core/base.py", line 312, in main
return subcommand.main(self.args[1:], self.args[0], self._get_usage_line(command_name, parent_usage))
File "/usr/lib/python2.6/site-packages/katello/client/core/base.py", line 389, in main
self.setup_action(args, command_name, parent_usage)
File "/usr/lib/python2.6/site-packages/katello/client/core/base.py", line 375, in setup_action
self.process_options(parser, args)
File "/usr/lib/python2.6/site-packages/katello/client/core/base.py", line 225, in process_options
self.opts, self.args = parser.parse_args(args)
File "/usr/lib64/python2.6/optparse.py", line 1396, in parse_args
self.error(str(err))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)
```

The problem is as follows:
Variable err (in optparse.py +1396) is instance of OptionError. str(err) will just
call err.__str__ (which just return self.msg), but then it will also try to encode and then decode
to/from default systemencoding, which is in RHEL6 "ascii". And that will fail.
Passing encoded utf-8 does not help, because it will fail during decoding.
And changing default system encoding is not nice.

So we just bypass str() and call __str__() directly without that encodede/decode() stuff, which is not needed anyway.