1. Mikhail Korobov
  2. vkontakte

Commits

ramusus  committed d6141df

encode parameters after dumping them to json format

  • Participants
  • Parent commits 8a36749
  • Branches default

Comments (0)

Files changed (1)

File vkontakte/api.py

View file
         return "Error(code = '%s', description = '%s', params = '%s')" % (self.code, self.description, self.params)
 
 def _encode(s):
+    if isinstance(s, (dict, list, tuple)):
+        s = json.dumps(s, ensure_ascii=False, encoding=REQUEST_ENCODING)
+
     if isinstance(s, unicode):
-        return s.encode(REQUEST_ENCODING)
-
-    if isinstance(s, (dict, list, tuple)):
-        return json.dumps(s, ensure_ascii=False, encoding=REQUEST_ENCODING)
+        s = s.encode(REQUEST_ENCODING)
 
     return s # this can be number, etc.