tools/licenses.py: Python 3 compatible
* cgi.escape() has been removed in Python 3.8. Use html.escape() in Python 3. Note that this causes quotes to be escaped in Python 3. This doesn't seem to be an issue. * Read the licence in text mode, so we can use it with html.escape(), which excepts strings not bytes. Still works with Python 2. Fixed backtraces: Traceback (most recent call last): File "../../tools/licenses.py", line 810, in <module> sys.exit(main()) File "../../tools/licenses.py", line 792, in main if not GenerateCredits(args.file_template, args.entry_template, File "../../tools/licenses.py", line 662, in GenerateCredits entries.append(MetadataToTemplateEntry(chromium_license_metadata, File "../../tools/licenses.py", line 632, in MetadataToTemplateEntry 'content': EvaluateTemplate(entry_template, env), File "../../tools/licenses.py", line 620, in EvaluateTemplate val = cgi.escape(val) AttributeError: module 'cgi' has no attribute 'escape' Traceback (most recent call last): File "../../tools/licenses.py", line 809, in <module> sys.exit(main()) File "../../tools/licenses.py", line 791, in main if not GenerateCredits(args.file_template, args.entry_template, File "../../tools/licenses.py", line 661, in GenerateCredits entries.append(MetadataToTemplateEntry(chromium_license_metadata, File "../../tools/licenses.py", line 631, in MetadataToTemplateEntry 'content': EvaluateTemplate(entry_template, env), File "../../tools/licenses.py", line 619, in EvaluateTemplate val = html.escape(val) File "C:\Program Files\Python38\lib\html\__init__.py", line 19, in escape s = s.replace("&", "&") # Must be done first! TypeError: a bytes-like object is required, not 'str' Bug: 941669 Change-Id: If203c49a425db733825df1867e65bef7a20060fa Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1857321 Auto-Submit: Raul Tambre <raul@tambre.ee> Reviewed-by:Dirk Pranke <dpranke@chromium.org> Commit-Queue: Raul Tambre <raul@tambre.ee> Cr-Commit-Position: refs/heads/master@{#705846}
Showing
Please register or sign in to comment