Skip to content

Commit cb131b3

Browse files
authored
Raise OptionError instead of KeyError in __getattr__. Fixes pandas-dev#19789.
1 parent 740ad9a commit cb131b3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pandas/core/config.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,10 @@ def __getattr__(self, key):
196196
if prefix:
197197
prefix += "."
198198
prefix += key
199-
v = object.__getattribute__(self, "d")[key]
199+
d = object.__getattribute__(self, "d")
200+
if not key in d:
201+
raise OptionError("No such option")
202+
v = d[key]
200203
if isinstance(v, dict):
201204
return DictWrapper(v, prefix)
202205
else:

0 commit comments

Comments
 (0)