Closed Bug 1674162 Opened 4 years ago Closed 4 years ago

Use of deprecated function `plistlib.readPlist()` in `mozinstall.py`

Categories

(Testing :: Mozbase, defect, P3)

Default
defect

Tracking

(firefox-esr78 fixed, firefox84 fixed)

RESOLVED FIXED
84 Branch
Tracking Status
firefox-esr78 --- fixed
firefox84 --- fixed

People

(Reporter: rstewart, Assigned: rstewart)

References

Details

Attachments

(1 file)

We import this function which was deprecated in Python 3.4 and deleted in Python 3.9. We should be using plist.load() instead.

This patch seems fine, but I don't know how to test it.

diff --git a/testing/mozbase/mozinstall/mozinstall/mozinstall.py b/testing/mozbase/mozinstall/mozinstall/mozinstall.py
index 4b6231888c7f..7822da5c123b 100644
--- a/testing/mozbase/mozinstall/mozinstall/mozinstall.py
+++ b/testing/mozbase/mozinstall/mozinstall/mozinstall.py
@@ -28,9 +28,6 @@ try:
 except ImportError:
     has_pefile = False
 
-if mozinfo.isMac:
-    from plistlib import readPlist
-
 
 TIMEOUT_UNINSTALL = 60
 
@@ -69,13 +66,15 @@ def get_binary(path, app_name):
 
     # On OS X we can get the real binary from the app bundle
     if mozinfo.isMac:
+        import plistlib
         plist = "%s/Contents/Info.plist" % path
         if not os.path.isfile(plist):
             raise InvalidBinary("%s/Contents/Info.plist not found" % path)
 
-        binary = os.path.join(
-            path, "Contents/MacOS/", readPlist(plist)["CFBundleExecutable"]
-        )
+        with open(plist, "rb") as fp:
+            binary = os.path.join(
+                path, "Contents/MacOS/", plistlib.load(fp)["CFBundleExecutable"]
+            )
 
     else:
         app_name = app_name.lower()

I think you can remove the skip-if = os == "mac" lines in mozinstall/tests/manifest.ini and try mach python-test testing/mozbase/mozinstall/.

I'm not a big fan of imports inside functions. I think it would be better if we conditionally imported plistlib and defined a new function readPlist at global scope. What do you think?

Assignee: nobody → rstewart
Status: NEW → ASSIGNED
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → DUPLICATE

Sorry, same problem, different file.

Status: RESOLVED → REOPENED
Resolution: DUPLICATE → ---
Pushed by rstewart@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/9f3d1f4e24e2 Remove reference to deleted function `plistlib.readPlist()` r=bc

lol

Flags: needinfo?(rstewart)
Priority: -- → P3
Severity: -- → S3

I just ran into this while trying to bootstrap under macOS, this breaks bootstrap when downloading nodejs

Pushed by rstewart@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/bad32157ee4d Remove reference to deleted function `plistlib.readPlist()` r=bc
Status: REOPENED → RESOLVED
Closed: 4 years ago4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 84 Branch
Depends on: 1678037

Comment on attachment 9184645 [details]
Bug 1674162 - Remove reference to deleted function plistlib.readPlist()

ESR Uplift Approval Request

  • If this is not a sec:{high,crit} bug, please state case for ESR consideration: ESR78 doesn't build for downstream developers with Python 3.9.
  • User impact if declined: They will have to downgrade their python (to 3.8).
  • Fix Landed on Version: 84
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Build patch.
  • String or UUID changes made by this patch:
Attachment #9184645 - Flags: approval-mozilla-esr78?

Comment on attachment 9184645 [details]
Bug 1674162 - Remove reference to deleted function plistlib.readPlist()

Approved for 78.8esr.

Attachment #9184645 - Flags: approval-mozilla-esr78? → approval-mozilla-esr78+
No longer blocks: 1677790
Blocks: 1678037
No longer depends on: 1678037
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: