Adding better unicode support for Python 3
import json as json_import
import os
import requests
+import sys
from requests.structures import CaseInsensitiveDict
try:
@@ -271,6 +272,9 @@ class WatsonDeveloperCloudService(object):
data = _remove_null_values(data)
files = _remove_null_values(files)
+ if sys.version_info >= (3, 0) and isinstance(data, str):
+ data = data.encode('utf-8')
+
# Support versions of requests older than 2.4.2 without the json input
if not data and json is not None:
data = json_import.dumps(json)
