Merge pull request #104 from codl/fix-string-ids

fix string id support to also include in_reply_to_... fields
This commit is contained in:
Lorenz Diener 2017-11-27 11:59:27 +01:00 cometido por GitHub
commit 52d57d9d43
No se encontró ninguna clave conocida en la base de datos para esta firma
ID de clave GPG: 4AEE18F83AFDEB23

Veure arxiu

@ -17,6 +17,7 @@ import re
import copy import copy
import threading import threading
import sys import sys
import six
try: try:
from urllib.parse import urlparse from urllib.parse import urlparse
@ -1083,17 +1084,13 @@ class Mastodon:
""" """
Converts json string IDs to native python bignums. Converts json string IDs to native python bignums.
""" """
if sys.version_info.major >= 3: for key in ('id', 'in_reply_to_id', 'in_reply_to_account_id'):
str_type = str if (key in json_object and
else: isinstance(json_object[key], six.text_type)):
str_type = unicode try:
json_object[key] = int(json_object[key])
if ('id' in json_object and except ValueError:
isinstance(json_object['id'], str_type)): pass
try:
json_object['id'] = int(json_object['id'])
except ValueError:
pass
return json_object return json_object