1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-13 07:47:14 +03:00

Explanation comment on try/except

This commit is contained in:
A_D 2020-12-02 16:08:06 +02:00
parent 9ec03008ce
commit 8bb9cecfc0
No known key found for this signature in database
GPG Key ID: 4BE9EB7DF45076C4

View File

@ -173,6 +173,11 @@ sys.path: {sys.path}'''
if args.j:
logger.debug('Import and collate from JSON dump')
# Import and collate from JSON dump
#
# Try twice, once with the system locale and once enforcing utf-8. If the file was made on the current
# system, chances are its the current locale, and not utf-8. Otherwise if it was copied, its probably
# utf8. Either way, try the system FIRST because reading something like cp1251 in UTF-8 results in garbage
# but the reverse results in an exception.
try:
data = json.load(open(args.j))
except UnicodeDecodeError: