diff --git a/pandas/core/config.py b/pandas/core/config.py index 3e8d76500d128..60dc1d7d0341e 100644 --- a/pandas/core/config.py +++ b/pandas/core/config.py @@ -445,7 +445,7 @@ def register_option(key, defval, doc='', validator=None, cb=None): for k in path: if not bool(re.match('^' + tokenize.Name + '$', k)): raise ValueError("%s is not a valid identifier" % k) - if keyword.iskeyword(key): + if keyword.iskeyword(k): raise ValueError("%s is a python keyword" % k) cursor = _global_config diff --git a/pandas/tests/test_config.py b/pandas/tests/test_config.py index e60c9d5bd0fdf..dc5e9a67bdb65 100644 --- a/pandas/tests/test_config.py +++ b/pandas/tests/test_config.py @@ -59,6 +59,7 @@ def test_register_option(self): # no python keywords self.assertRaises(ValueError, self.cf.register_option, 'for', 0) + self.assertRaises(ValueError, self.cf.register_option, 'a.for.b', 0) # must be valid identifier (ensure attribute access works) self.assertRaises(ValueError, self.cf.register_option, 'Oh my Goddess!', 0)