From ca11ef77acf60fdee5f20fbdb4c3e6ce5f2cbacc Mon Sep 17 00:00:00 2001 From: codl Date: Sun, 26 Nov 2017 22:33:08 +0100 Subject: [PATCH 1/2] use six instead of relying on python version --- mastodon/Mastodon.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index 88f4906..9e6d3ce 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -17,6 +17,7 @@ import re import copy import threading import sys +import six try: from urllib.parse import urlparse @@ -1083,13 +1084,8 @@ class Mastodon: """ Converts json string IDs to native python bignums. """ - if sys.version_info.major >= 3: - str_type = str - else: - str_type = unicode - if ('id' in json_object and - isinstance(json_object['id'], str_type)): + isinstance(json_object['id'], six.text_type)): try: json_object['id'] = int(json_object['id']) except ValueError: From b9e6a1e9baf9ec5238dcc3b4344b2a0ae07411ac Mon Sep 17 00:00:00 2001 From: codl Date: Sun, 26 Nov 2017 22:49:32 +0100 Subject: [PATCH 2/2] fix string id support to also include in_reply_to_... fields --- mastodon/Mastodon.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index 9e6d3ce..c4e50f3 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -1084,12 +1084,13 @@ class Mastodon: """ Converts json string IDs to native python bignums. """ - if ('id' in json_object and - isinstance(json_object['id'], six.text_type)): - try: - json_object['id'] = int(json_object['id']) - except ValueError: - pass + for key in ('id', 'in_reply_to_id', 'in_reply_to_account_id'): + if (key in json_object and + isinstance(json_object[key], six.text_type)): + try: + json_object[key] = int(json_object[key]) + except ValueError: + pass return json_object