Skip to content

Commit 8d87fd2

Browse files
smilesa-maurice
smiles
authored andcommitted
Fixed exception when printing app IDs with python3.
Passing a byte array (output of str.encode()) to sys.stdout.write() in python3 throws an exceeption so this changes generate_xml_from_google_services_json.py to write an unencoded string as sys.stdout.write() encodes the string for the output terminal anyway. In addition, this migrates generate_xml_from_google_services_json.py to be compatible with python3, expands test cases for the script and adds python2 and python3 testing to the presubmit. PiperOrigin-RevId: 281637905
1 parent f300770 commit 8d87fd2

2 files changed

+3
-5
lines changed
4.04 MB
Binary file not shown.

generate_xml_from_google_services_json.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ def main():
336336
if not project_info:
337337
sys.stderr.write('No project info found in %s.' % input_filename)
338338
return 1
339-
for field, value in project_info.iteritems():
339+
for field, value in sorted(project_info.items()):
340340
sys.stdout.write('%s=%s\n' % (field, value))
341341
return 0
342342

@@ -425,11 +425,9 @@ def main():
425425
indent(root)
426426

427427
if args.l:
428-
for package in packages:
428+
for package in sorted(packages):
429429
if package:
430-
# Encode the output string in case the system's default encoding differs
431-
# from the encoding of the string being printed.
432-
sys.stdout.write((package + '\n').encode(sys.getdefaultencoding()))
430+
sys.stdout.write(package + '\n')
433431
else:
434432
path = os.path.dirname(output_filename)
435433

0 commit comments

Comments
 (0)