Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 810335aedc77ee993ef069afcb91a65831cd4764
https://github.com/WebKit/WebKit/commit/810335aedc77ee993ef069afcb91a65831cd4764
Author: Sam Sneddon <[email protected]>
Date: 2025-01-09 (Thu, 09 Jan 2025)
Changed paths:
M Tools/Scripts/libraries/webkitcorepy/webkitcorepy/autoinstall.py
Log Message:
-----------
AutoInstall.find_spec should return a spec
https://bugs.webkit.org/show_bug.cgi?id=285094
Reviewed by Jonathan Bedard.
Previously, we returned None, via very indirect means. (We returned
what importmachinery.SourceFileLoader.create_module(None) returned,
which, as of Python 3.9-13, is always None.)
Returning None via such indirect means is silly; we should either
embrace the fact we return None and do it ourselves (thereby claiming
our MetaPathFinder cannot find a spec for the given name), or make
some attempt to actually do what is likely intended, and find the
module we installed.
We go with the latter, at least in the simple case (where a top-level
module is being imported, where we previously had code using
SourceFileLoader).
In the cases where None is returned, we may still end up with
something autoinstalled having a spec found, because we've added
AutoInstall.directory to sys.path, and AutoInstall is installed at the
start of sys.meta_path before PathFinder. We should longer term aim to
not be mutating sys.path, and take ownership of finding specs for what
we autoinstall (this is bug 284088).
* Tools/Scripts/libraries/webkitcorepy/webkitcorepy/autoinstall.py:
(Package.install): Invalidate importlib caches after we install new modules.
(AutoInstall): Make AutoInstall inherit from importlib.abc.MetaPathFinder.
(AutoInstall.find_spec): Use the standard PathFinder to find the spec.
(AutoInstall.find_module): Deleted. Unused since we dropped support for Python
2.
Canonical link: https://commits.webkit.org/288677@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes