mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2024-12-28 02:20:04 +01:00
Fix Python 2 TypeError: write() argument 1 must be unicode, not str (see issue #2856)
This commit is contained in:
parent
e1132672ee
commit
894ac21532
@ -32,7 +32,12 @@ def write_file(name, data):
|
||||
try:
|
||||
with open(name, 'w', encoding='utf-8') as f:
|
||||
# write the data
|
||||
f.write(data)
|
||||
try:
|
||||
# Python 2
|
||||
f.write(data.decode('utf-8'))
|
||||
except Exception as e:
|
||||
# Python 3
|
||||
f.write(data)
|
||||
except IOError as e:
|
||||
(errno, strerror) = e.args
|
||||
sys.stderr.write('Failed to write file ' + name + ': ' + strerror)
|
||||
|
Loading…
Reference in New Issue
Block a user