Skip to content

Commit 78330e9

Browse files
committed
update code to handle unicodeEncodeError
1 parent 10916a5 commit 78330e9

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

about_code_tool/genabout.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ def write_licenses(self, license_context_list):
275275
for gen_license_path, license_context in license_context_list:
276276
try:
277277
with open(gen_license_path, 'wb') as output:
278-
output.write(license_context.encode('utf8'))
279-
except Exception:
278+
output.write(license_context)
279+
except Exception as e:
280280
self.errors.append(Error('Unknown', gen_license_path, "Something is wrong."))
281281

282282
def get_license_text_from_api(self, url, username, api_key, license_key):

about_code_tool/genattrib.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ def main(args, opts):
140140
# input_path = abspath(input_path)
141141
output_path = abspath(output_path)
142142

143+
# Add the following to solve the
144+
# UnicodeEncodeError: 'ascii' codec can't encode character
145+
reload(sys)
146+
sys.setdefaultencoding('utf-8')
147+
143148
if not exists(input_path):
144149
print('Input path does not exist.')
145150
option_usage()

0 commit comments

Comments
 (0)