Avoid AttributeError for DiskLabel formats without disklabel type #949
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Simple instance of DiskLabel without label_type specified in the
constructor results in a AttributeError when trying to print the
format name. This makes sure the name is always valid.
Resolves: rhbz#1945914
Anaconda hits this when it's gathering format types for some DBus shenanigans. Simple reproducer is to get disklabel without specifying type
blivet.formats.get_format("disklabel")and it will fail when printing the disklabel info (because__repr__printsname). Alternatively we could make sure the_default_label_typeis neverNonebut that might break more things. It might be also better to have a specialnamefor this "disklabel without type" but I wasn't able to come up with something that makes sense, so feel free to suggest something better.