From 7b4711ad542a03d044357bf4701b619a85421e0e Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Tue, 11 Aug 2015 13:52:14 -0700 Subject: [PATCH] fallback to builtin json module when importing simplejson fails --- wakatime/base.py | 5 ++++- wakatime/logger.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/wakatime/base.py b/wakatime/base.py index ee1419a..3270557 100644 --- a/wakatime/base.py +++ b/wakatime/base.py @@ -33,11 +33,14 @@ from .compat import u, open, is_py3 from .logger import setup_logging from .offlinequeue import Queue from .packages import argparse -from .packages import simplejson as json from .packages.requests.exceptions import RequestException from .project import get_project_info from .session_cache import SessionCache from .stats import get_file_stats +try: + from .packages import simplejson as json +except (ImportError, SyntaxError): + import json try: from .packages import tzlocal except: # pragma: nocover diff --git a/wakatime/logger.py b/wakatime/logger.py index 2dc453e..2ec303f 100644 --- a/wakatime/logger.py +++ b/wakatime/logger.py @@ -13,12 +13,15 @@ import logging import os import sys -from .packages import simplejson as json from .compat import u try: from collections import OrderedDict except ImportError: from .packages.ordereddict import OrderedDict +try: + from .packages import simplejson as json +except (ImportError, SyntaxError): + import json class CustomEncoder(json.JSONEncoder):