13
13
from xml .dom import minidom
14
14
15
15
if len (sys .argv ) < 2 or len (sys .argv ) > 3 :
16
- print """
16
+ print ( """
17
17
[ERROR] Please specify a version.
18
18
19
19
./update_version.py <MAJOR>.<MINOR>.<MICRO> [<RC version>]
20
20
21
21
Example:
22
22
./update_version.py 3.7.1 2
23
- """
23
+ """ )
24
24
exit (1 )
25
25
26
26
NEW_VERSION = sys .argv [1 ]
27
27
NEW_VERSION_INFO = [int (x ) for x in NEW_VERSION .split ('.' )]
28
28
if len (NEW_VERSION_INFO ) != 3 :
29
- print """
29
+ print ( """
30
30
[ERROR] Version must be in the format <MAJOR>.<MINOR>.<MICRO>
31
31
32
32
Example:
33
33
./update_version.py 3.7.3
34
- """
34
+ """ )
35
35
exit (1 )
36
36
37
37
RC_VERSION = - 1
@@ -71,9 +71,9 @@ def RewriteXml(filename, rewriter, add_xml_prefix=True):
71
71
content = document .toxml ().replace ('<?xml version="1.0" ?>' , '' )
72
72
file_handle = open (filename , 'wb' )
73
73
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 ' )
77
77
file_handle .close ()
78
78
79
79
@@ -83,7 +83,7 @@ def RewriteTextFile(filename, line_rewriter):
83
83
for line in lines :
84
84
updated_lines .append (line_rewriter (line ))
85
85
if lines == updated_lines :
86
- print '%s was not updated. Please double check.' % filename
86
+ print ( '%s was not updated. Please double check.' % filename )
87
87
f = open (filename , 'w' )
88
88
f .write ('' .join (updated_lines ))
89
89
f .close ()
@@ -245,11 +245,11 @@ def UpdateMakefile():
245
245
protobuf_version_offset = 11
246
246
expected_major_version = 3
247
247
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
249
249
update_version.py to readjust the protobuf_version_offset and
250
250
expected_major_version such that the PROTOBUF_VERSION in src/Makefile.am is
251
251
always increasing.
252
- """
252
+ """ )
253
253
exit (1 )
254
254
255
255
protobuf_version_info = '%d:%d:0' % (
0 commit comments