Skip to content

Commit 7d6165e

Browse files
José Ángel Galindo DuarteJosé Ángel Galindo Duarte
authored andcommitted
fix(z3): guard missing source model in false-optional operation
Replace the broken exception guard (cast never raises and the caught type was wrong) with an explicit check for the attached source model, and fix the copied PySAT logger name.
1 parent 878bc34 commit 7d6165e

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

flamapy/metamodels/z3_metamodel/operations/z3_false_optional_features.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from flamapy.metamodels.z3_metamodel.models import Z3Model
1111

1212

13-
LOGGER = logging.getLogger('PySATFalseOptionalFeatures')
13+
LOGGER = logging.getLogger('Z3FalseOptionalFeatures')
1414

1515

1616
class Z3FalseOptionalFeatures(FalseOptionalFeatures):
@@ -26,11 +26,11 @@ def get_result(self) -> list[Any]:
2626

2727
def execute(self, model: VariabilityModel) -> 'Z3FalseOptionalFeatures':
2828
z3_model = cast(Z3Model, model)
29-
try:
30-
feature_model = cast(FeatureModel, model.original_model)
31-
except FlamaException:
32-
LOGGER.exception("The transformation didn't attach the source model, "
33-
"which is required for this operation.")
29+
original_model = getattr(model, 'original_model', None)
30+
if original_model is None:
31+
raise FlamaException("The transformation didn't attach the source model, "
32+
"which is required for this operation.")
33+
feature_model = cast(FeatureModel, original_model)
3434
self._result = get_false_optional_features(z3_model, feature_model)
3535
return self
3636

0 commit comments

Comments
 (0)