@@ -693,7 +693,8 @@ def save_if_modified(location, content):
693
693
return False
694
694
695
695
if TRACE : print (f'Saving ABOUT (and NOTICE) files for: { self } ' )
696
- with open (location , 'w' ) as fo :
696
+ wmode = 'wb' if isinstance (content , bytes ) else 'w'
697
+ with open (location , wmode , encoding = "utf-8" ) as fo :
697
698
fo .write (content )
698
699
return True
699
700
@@ -725,6 +726,8 @@ def load_about_data(self, about_filename_or_data=None, dest_dir=THIRDPARTY_DIR):
725
726
if os .path .exists (about_path ):
726
727
with open (about_path ) as fi :
727
728
about_data = saneyaml .load (fi .read ())
729
+ if not about_data :
730
+ return False
728
731
else :
729
732
return False
730
733
else :
@@ -1842,7 +1845,7 @@ def get(self, path_or_url, as_text=True):
1842
1845
if not os .path .exists (cached ):
1843
1846
content = get_file_content (path_or_url = path_or_url , as_text = as_text )
1844
1847
wmode = 'w' if as_text else 'wb'
1845
- with open (cached , wmode ) as fo :
1848
+ with open (cached , wmode , encoding = "utf-8" ) as fo :
1846
1849
fo .write (content )
1847
1850
return content
1848
1851
else :
@@ -1854,7 +1857,7 @@ def put(self, filename, content):
1854
1857
"""
1855
1858
cached = os .path .join (self .directory , filename )
1856
1859
wmode = 'wb' if isinstance (content , bytes ) else 'w'
1857
- with open (cached , wmode ) as fo :
1860
+ with open (cached , wmode , encoding = "utf-8" ) as fo :
1858
1861
fo .write (content )
1859
1862
1860
1863
@@ -2362,7 +2365,7 @@ def update_requirements(name, version=None, requirements_file='requirements.txt'
2362
2365
updated_name_versions = sorted (updated_name_versions )
2363
2366
nvs = '\n ' .join (f'{ name } =={ version } ' for name , version in updated_name_versions )
2364
2367
2365
- with open (requirements_file , 'w' ) as fo :
2368
+ with open (requirements_file , 'w' , encoding = "utf-8" ) as fo :
2366
2369
fo .write (nvs )
2367
2370
2368
2371
@@ -2380,7 +2383,7 @@ def hash_requirements(dest_dir=THIRDPARTY_DIR, requirements_file='requirements.t
2380
2383
raise Exception (f'Missing required package { name } =={ version } ' )
2381
2384
hashed .append (package .specifier_with_hashes )
2382
2385
2383
- with open (requirements_file , 'w' ) as fo :
2386
+ with open (requirements_file , 'w' , encoding = "utf-8" ) as fo :
2384
2387
fo .write ('\n ' .join (hashed ))
2385
2388
2386
2389
################################################################################
0 commit comments