Fixed a bug in lockhandler when entering a lock string containing upper-case AND/OR/NOT as part of a word (such as MAYOR). Thanks to lagos for suggesting the fix! Resolves Issue 303.

This commit is contained in:
Griatch 2012-10-21 23:52:54 +02:00
parent 3f01ab8006
commit 32b6becd33

View file

@ -211,7 +211,9 @@ class LockHandler(object):
# parse the lock functions and separators
funclist = _RE_FUNCS.findall(rhs)
evalstring = rhs.replace('AND','and').replace('OR','or').replace('NOT','not')
evalstring = rhs
for pattern in ('AND', 'OR', 'NOT'):
evalstring = re.sub(r"\b%s\b" % pattern, pattern.lower(), evalstring)
nfuncs = len(funclist)
for funcstring in funclist:
funcname, rest = (part.strip().strip(')') for part in funcstring.split('(', 1))
@ -226,7 +228,7 @@ class LockHandler(object):
if len(lock_funcs) < nfuncs:
continue
try:
# purge the eval string of any superfluos items, then test it
# purge the eval string of any superfluous items, then test it
evalstring = " ".join(_RE_OK.findall(evalstring))
eval(evalstring % tuple(True for func in funclist), {}, {})
except Exception: