1313from xml .dom import minidom
1414
1515if len (sys .argv ) < 2 or len (sys .argv ) > 3 :
16- print """
16+ print ( """
1717[ERROR] Please specify a version.
1818
1919./update_version.py <MAJOR>.<MINOR>.<MICRO> [<RC version>]
2020
2121Example:
2222./update_version.py 3.7.1 2
23- """
23+ """ )
2424 exit (1 )
2525
2626NEW_VERSION = sys .argv [1 ]
2727NEW_VERSION_INFO = [int (x ) for x in NEW_VERSION .split ('.' )]
2828if len (NEW_VERSION_INFO ) != 3 :
29- print """
29+ print ( """
3030[ERROR] Version must be in the format <MAJOR>.<MINOR>.<MICRO>
3131
3232Example:
3333./update_version.py 3.7.3
34- """
34+ """ )
3535 exit (1 )
3636
3737RC_VERSION = - 1
@@ -71,9 +71,9 @@ def RewriteXml(filename, rewriter, add_xml_prefix=True):
7171 content = document .toxml ().replace ('<?xml version="1.0" ?>' , '' )
7272 file_handle = open (filename , 'wb' )
7373 if add_xml_prefix :
74- file_handle .write ('<?xml version="1.0" encoding="UTF-8"?>\n ' )
75- file_handle .write (content )
76- file_handle .write ('\n ' )
74+ file_handle .write (b '<?xml version="1.0" encoding="UTF-8"?>\n ' )
75+ file_handle .write (content . encode ( 'utf-8' ) )
76+ file_handle .write (b '\n ' )
7777 file_handle .close ()
7878
7979
@@ -83,7 +83,7 @@ def RewriteTextFile(filename, line_rewriter):
8383 for line in lines :
8484 updated_lines .append (line_rewriter (line ))
8585 if lines == updated_lines :
86- print '%s was not updated. Please double check.' % filename
86+ print ( '%s was not updated. Please double check.' % filename )
8787 f = open (filename , 'w' )
8888 f .write ('' .join (updated_lines ))
8989 f .close ()
@@ -245,11 +245,11 @@ def UpdateMakefile():
245245 protobuf_version_offset = 11
246246 expected_major_version = 3
247247 if NEW_VERSION_INFO [0 ] != expected_major_version :
248- print """[ERROR] Major protobuf version has changed. Please update
248+ print ( """[ERROR] Major protobuf version has changed. Please update
249249update_version.py to readjust the protobuf_version_offset and
250250expected_major_version such that the PROTOBUF_VERSION in src/Makefile.am is
251251always increasing.
252- """
252+ """ )
253253 exit (1 )
254254
255255 protobuf_version_info = '%d:%d:0' % (
0 commit comments