Skip to content

Commit

Permalink
build: Fix build with Python 3.5
Browse files Browse the repository at this point in the history
Starting in Python 3.6, Python will convert bytes to strings inside
json.load, assuming UTF-8 if I understand correctly.  In Python 3.5,
you either need to do that yourself, or open the files as text instead
of binary.  So this opens all JSON files as text to fix Python 3.5
support.

Although Python 3.5 went EOL a couple months ago, it was very recent,
and Python 3.5 is still shipping in the Debian-based distro we are
using.  So probably others still have it, as well.

Closes shaka-project#3004

Change-Id: I0c829fa1af6a92bcf7f40c4ca41a76de278d3eb1
  • Loading branch information
joeyparrish committed Nov 23, 2020
1 parent 65143a6 commit feffedf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def __init__(self, config_path):

# To avoid getting out of sync with the source files jsdoc actually reads,
# parse the config file and locate all source files based on that.
with open(self.config_path, 'rb') as f:
with open(self.config_path, 'r') as f:
config = json.load(f)
for path in config['source']['include']:
full_path = _get_source_path(path)
Expand Down
2 changes: 1 addition & 1 deletion build/generateLocalizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def main(args):
combined_localizations = {}
for locale in args.locales:
path = os.path.join(args.source, locale + '.json')
with open(path, 'rb') as f:
with open(path, 'r') as f:
combined_localizations[locale] = json.load(f)

doc = GenerateLocalizations(combined_localizations, args.class_name)
Expand Down

0 comments on commit feffedf

Please sign in to comment.