Skip to content

Commit 71a0629

Browse files
Delta456harsha509
andauthored
firefox_profile.py: use with statement in zipfile as Python 2.x support is dropped (#14489)
--------- Co-authored-by: Sri Harsha <[email protected]>
1 parent 33c110e commit 71a0629

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

py/selenium/webdriver/firefox/firefox_profile.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -276,17 +276,11 @@ def parse_manifest_json(content):
276276

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

287283
manifest = compressed_file.read("install.rdf")
288-
finally:
289-
compressed_file.close()
290284
elif os.path.isdir(addon_path):
291285
manifest_json_filename = os.path.join(addon_path, "manifest.json")
292286
if os.path.exists(manifest_json_filename):

0 commit comments

Comments
 (0)