Skip to content

Commit

Permalink
firefox_profile.py: use with statement in zipfile as Python 2.x sup…
Browse files Browse the repository at this point in the history
…port is dropped (#14489)



---------

Co-authored-by: Sri Harsha <12621691+harsha509@users.noreply.github.com>
  • Loading branch information
Delta456 and harsha509 committed Sep 12, 2024
1 parent 33c110e commit 71a0629
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions py/selenium/webdriver/firefox/firefox_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,17 +276,11 @@ def parse_manifest_json(content):

try:
if zipfile.is_zipfile(addon_path):
# Bug 944361 - We cannot use 'with' together with zipFile because
# it will cause an exception thrown in Python 2.6.
# TODO: use with statement when Python 2.x is no longer supported
try:
compressed_file = zipfile.ZipFile(addon_path, "r")
with zipfile.ZipFile(addon_path, "r") as compressed_file:
if "manifest.json" in compressed_file.namelist():
return parse_manifest_json(compressed_file.read("manifest.json"))

manifest = compressed_file.read("install.rdf")
finally:
compressed_file.close()
elif os.path.isdir(addon_path):
manifest_json_filename = os.path.join(addon_path, "manifest.json")
if os.path.exists(manifest_json_filename):
Expand Down

0 comments on commit 71a0629

Please sign in to comment.