Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

guarantee that options.rm_safe never fails #14238

Merged
merged 1 commit into from
Jul 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions conans/model/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,8 @@ def get_safe(self, field, default=None):
return self._data.get(field, default)

def rm_safe(self, field):
try:
delattr(self, field)
except ConanException:
pass
# This should never raise any exception, in any case
self._data.pop(field, None)

def validate(self):
for child in self._data.values():
Expand All @@ -151,10 +149,6 @@ def copy_conaninfo_options(self):
result._data[k] = v.copy_conaninfo_option()
return result

@property
def fields(self):
return sorted(list(self._data.keys()))

def _ensure_exists(self, field):
if self._constrained and field not in self._data:
raise ConanException(option_not_exist_msg(field, list(self._data.keys())))
Expand All @@ -168,7 +162,6 @@ def __getattr__(self, field):

def __delattr__(self, field):
assert field[0] != "_", "ERROR %s" % field
current_value = self._data.get(field)
# It is always possible to remove an option, even if it is frozen (freeze=True),
# and it got a value, because it is the only way an option could be removed
# conditionally to other option value (like fPIC if shared)
Expand Down