diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2023-03-05 20:19:04 -0500 |
|---|---|---|
| committer | Jason R. Coombs <jaraco@jaraco.com> | 2023-03-05 20:19:04 -0500 |
| commit | fc03481f36b90d3a9331aa081832c2eaabff3a5e (patch) | |
| tree | 8f1060fa9754a73fcbd0138a4dfe57d9f047e4da /setuptools | |
| parent | 265356ea587a320f37fc944ae777cf10631baf7c (diff) | |
| download | python-setuptools-git-fc03481f36b90d3a9331aa081832c2eaabff3a5e.tar.gz | |
Use try/except in __setitem__.
Diffstat (limited to 'setuptools')
| -rw-r--r-- | setuptools/config/setupcfg.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/setuptools/config/setupcfg.py b/setuptools/config/setupcfg.py index 26ea37d8..d6e5f0bf 100644 --- a/setuptools/config/setupcfg.py +++ b/setuptools/config/setupcfg.py @@ -279,15 +279,14 @@ class ConfigHandler(Generic[Target]): ) def __setitem__(self, option_name, value): - unknown = tuple() target_obj = self.target_obj # Translate alias into real name. option_name = self.aliases.get(option_name, option_name) - current_value = getattr(target_obj, option_name, unknown) - - if current_value is unknown: + try: + current_value = getattr(target_obj, option_name) + except AttributeError: raise KeyError(option_name) if current_value: |
