@@ -59,7 +59,7 @@ def __init__(self, profile_directory=None):
5959 DeprecationWarning , stacklevel = 2 )
6060 if not FirefoxProfile .DEFAULT_PREFERENCES :
6161 with open (os .path .join (os .path .dirname (__file__ ),
62- WEBDRIVER_PREFERENCES )) as default_prefs :
62+ WEBDRIVER_PREFERENCES ), encoding = 'utf-8' ) as default_prefs :
6363 FirefoxProfile .DEFAULT_PREFERENCES = json .load (default_prefs )
6464
6565 self .default_preferences = copy .deepcopy (
@@ -180,7 +180,7 @@ def _write_user_prefs(self, user_prefs):
180180 """
181181 writes the current user prefs dictionary to disk
182182 """
183- with open (self .userPrefs , "w" ) as f :
183+ with open (self .userPrefs , "w" , encoding = 'utf-8' ) as f :
184184 for key , value in user_prefs .items ():
185185 f .write (f'user_pref("{ key } ", { json .dumps (value )} );\n ' )
186186
@@ -189,7 +189,7 @@ def _read_existing_userjs(self, userjs):
189189
190190 PREF_RE = re .compile (r'user_pref\("(.*)",\s(.*)\)' )
191191 try :
192- with open (userjs ) as f :
192+ with open (userjs , encoding = 'utf-8' ) as f :
193193 for usr in f :
194194 matches = re .search (PREF_RE , usr )
195195 try :
@@ -322,10 +322,10 @@ def parse_manifest_json(content):
322322 elif os .path .isdir (addon_path ):
323323 manifest_json_filename = os .path .join (addon_path , 'manifest.json' )
324324 if os .path .exists (manifest_json_filename ):
325- with open (manifest_json_filename ) as f :
325+ with open (manifest_json_filename , encoding = 'utf-8' ) as f :
326326 return parse_manifest_json (f .read ())
327327
328- with open (os .path .join (addon_path , 'install.rdf' )) as f :
328+ with open (os .path .join (addon_path , 'install.rdf' ), encoding = 'utf-8' ) as f :
329329 manifest = f .read ()
330330 else :
331331 raise OSError ('Add-on path is neither an XPI nor a directory: %s' % addon_path )
0 commit comments