Skip to content

Commit e66ddf2

Browse files
committed
[py] use context manager for encoding
1 parent 22ef533 commit e66ddf2

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

py/selenium/webdriver/firefox/webdriver.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,8 @@ def install_addon(self, path, temporary=None) -> str:
246246
247247
driver.install_addon('/path/to/firebug.xpi')
248248
"""
249-
file_ = open(path, 'rb')
250-
addon = (base64.b64encode(file_.read()).decode('UTF-8'))
251-
file_.close()
249+
with open(path, 'rb') as file:
250+
addon = (base64.b64encode(file.read()).decode('UTF-8'))
252251

253252
payload = {"addon": addon}
254253
if temporary:

0 commit comments

Comments
 (0)