mirror of
https://github.com/wakatime/sublime-wakatime.git
synced 2023-08-10 21:13:02 +03:00
fix #17 by removing non-utf8 characters
This commit is contained in:
parent
03ec38bb67
commit
049bc57019
@ -63,6 +63,9 @@ def parseConfigFile(configFile):
|
||||
'verbose': False,
|
||||
}
|
||||
|
||||
if not os.path.isfile(configFile):
|
||||
return configs
|
||||
|
||||
try:
|
||||
with open(configFile) as fh:
|
||||
for line in fh:
|
||||
|
@ -25,7 +25,12 @@ class CustomEncoder(json.JSONEncoder):
|
||||
if isinstance(obj, bytes):
|
||||
obj = bytes.decode(obj)
|
||||
return json.dumps(obj)
|
||||
return super(CustomEncoder, self).default(obj)
|
||||
try:
|
||||
encoded = super(CustomEncoder, self).default(obj)
|
||||
except UnicodeDecodeError:
|
||||
obj = obj.decode('utf-8', 'ignore')
|
||||
encoded = super(CustomEncoder, self).default(obj)
|
||||
return encoded
|
||||
|
||||
|
||||
class JsonFormatter(logging.Formatter):
|
||||
|
Loading…
Reference in New Issue
Block a user