You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ju...@apache.org on 2024/11/29 12:08:55 UTC
(buildstream) branch juerg/loader updated (f3d7215f8 -> 6cd5981e8)
This is an automated email from the ASF dual-hosted git repository.
juergbi pushed a change to branch juerg/loader
in repository https://gitbox.apache.org/repos/asf/buildstream.git
discard f3d7215f8 _loader/loader.py: Add `None` checks for shallow loading
new 6cd5981e8 _loader/loader.py: Add `None` checks for shallow loading
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (f3d7215f8)
\
N -- N -- N refs/heads/juerg/loader (6cd5981e8)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
src/buildstream/_loader/loader.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
(buildstream) 01/01: _loader/loader.py: Add `None` checks for shallow loading
Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
juergbi pushed a commit to branch juerg/loader
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 6cd5981e8cb9d4d09a79700fd8d2dcce7ff6c189
Author: Jürg Billeter <j...@bitron.ch>
AuthorDate: Fri Nov 29 11:57:33 2024 +0000
_loader/loader.py: Add `None` checks for shallow loading
When performing shallow loads without loading subprojects,
`get_loader()` may return `None`. Add checks for that to fix crashes
dereferencing `None`.
---
src/buildstream/_loader/loader.py | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/buildstream/_loader/loader.py b/src/buildstream/_loader/loader.py
index f142b2655..63b890743 100644
--- a/src/buildstream/_loader/loader.py
+++ b/src/buildstream/_loader/loader.py
@@ -437,6 +437,11 @@ class Loader:
link_target = element.link_target.as_str() # pylint: disable=no-member
_, filename, loader = self._parse_name(link_target, element.link_target, load_subprojects=load_subprojects)
+ if not loader:
+ # `loader` should never be None if `load_subprojects` is True
+ assert not load_subprojects
+ return None
+
#
# Redirect the loading of the file and it's dependencies to the appropriate loader,
# which might or might not be the same loader.
@@ -465,6 +470,11 @@ class Loader:
top_element = self._load_one_file(filename, provenance_node, load_subprojects=load_subprojects)
+ if not top_element:
+ # `_load_one_file` should not return None if `load_subprojects` is True
+ assert not load_subprojects
+ return None
+
# Already loaded dependencies for a fully loaded element, early return.
#
if top_element.fully_loaded:
@@ -501,6 +511,11 @@ class Loader:
dep_element = self._load_one_file(dep.name, dep.node, load_subprojects=load_subprojects)
+ if not dep_element:
+ # `_load_one_file` should not return None if `load_subprojects` is True
+ assert not load_subprojects
+ return None
+
# If the loaded element is not fully loaded, queue up the dependencies to be loaded in this loop.
#
if not dep_element.fully_loaded:
@@ -773,6 +788,11 @@ class Loader:
_, filename, loader = self._parse_name(
load_element.link_target.as_str(), load_element.link_target, load_subprojects=load_subprojects
)
+ if not loader:
+ # `loader` should never be None if `load_subprojects` is True
+ assert not load_subprojects
+ return None
+
return loader.get_loader(filename, load_element.link_target, load_subprojects=load_subprojects)
# If we're only performing a lookup, we're done here.