fix bytes-object required error in python 3

this fixes the following error for http.query
```
    An exception occurred in this state: Traceback (most recent call last):
                File "/usr/local/lib/python3.6/site-packages/salt/state.py", line 1843, in call
                  **cdata['kwargs'])
                File "/usr/local/lib/python3.6/site-packages/salt/loader.py", line 1795, in wrapper
                  return f(*args, **kwargs)
                File "/usr/local/lib/python3.6/site-packages/salt/states/http.py", line 95, in query
                  if match in data.get('text', ''):
              TypeError: a bytes-like object is required, not 'str'
```
This commit is contained in:
angeloudy 2018-01-03 14:49:04 +11:00 committed by GitHub
parent cf411f8984
commit 14aba24111
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -531,6 +531,8 @@ def query(url,
'charset' in res_params and \
not isinstance(result_text, six.text_type):
result_text = result_text.decode(res_params['charset'])
if isinstance(result_text, bytes):
result_text = result_text.decode('utf-8')
ret['body'] = result_text
if 'Set-Cookie' in result_headers.keys() and cookies is not None:
result_cookies = parse_cookie_header(result_headers['Set-Cookie'])