diff options
author | Joris Roovers <jroovers@cisco.com> | 2018-04-15 12:20:28 +0200 |
---|---|---|
committer | Joris Roovers <jroovers@cisco.com> | 2018-04-15 12:20:28 +0200 |
commit | 03eec2042d97a4414b45e0f5f7e67fa85ce9f80b (patch) | |
tree | 994dfa2eafcc1baba53e25468dd83ad0aa04eefb /qa | |
parent | f0c4acf161a23f37c8af8985d281254822280227 (diff) |
Unicode byte decode fixes
Added better handling for decoding bytes to unicode strings in the ustr()
function. This fixed the test_stdin_file integration in python 3.6.
Also fixed a python 2.6 linting issue.
Diffstat (limited to 'qa')
-rw-r--r-- | qa/base.py | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -16,12 +16,15 @@ def ustr(obj): if sys.version_info[0] == 2: # If we are getting a string, then do an explicit decode # else, just call the unicode method of the object - if type(obj) in [str, basestring]: # pragma: no cover # noqa # pylint: disable=unidiomatic-typecheck + if type(obj) in [str, basestring]: # pragma: no cover # noqa return unicode(obj, DEFAULT_ENCODING) # pragma: no cover # noqa else: return unicode(obj) # pragma: no cover # noqa else: - return str(obj) + if type(obj) in [bytes]: + return obj.decode(DEFAULT_ENCODING) + else: + return str(obj) class BaseTestCase(TestCase): |