Skip to content

Commit a95687d

Browse files
committed
Merge pull request #7781 from germangh/master
BUG: Prevent config paths to contain python keywords
2 parents 8c60b3d + e8be09c commit a95687d

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

pandas/core/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ def register_option(key, defval, doc='', validator=None, cb=None):
445445
for k in path:
446446
if not bool(re.match('^' + tokenize.Name + '$', k)):
447447
raise ValueError("%s is not a valid identifier" % k)
448-
if keyword.iskeyword(key):
448+
if keyword.iskeyword(k):
449449
raise ValueError("%s is a python keyword" % k)
450450

451451
cursor = _global_config

pandas/tests/test_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def test_register_option(self):
5959

6060
# no python keywords
6161
self.assertRaises(ValueError, self.cf.register_option, 'for', 0)
62+
self.assertRaises(ValueError, self.cf.register_option, 'a.for.b', 0)
6263
# must be valid identifier (ensure attribute access works)
6364
self.assertRaises(ValueError, self.cf.register_option,
6465
'Oh my Goddess!', 0)

0 commit comments

Comments
 (0)