summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b>2014-06-28 14:35:17 +0000
committerptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b>2014-06-28 14:35:17 +0000
commit48ddb33000fd910851e26a7066acb596d8e19e37 (patch)
treed363f938c2168596950035c290af2f94ac1fd33c
parent57764dad5ddbbe29bd7a5ba01f03b301f2a7dd91 (diff)
downloadpyparsing-48ddb33000fd910851e26a7066acb596d8e19e37.tar.gz
Fixed UnboundLocalError in oneOf based on new scoping rules in Python 3.4
git-svn-id: svn://svn.code.sf.net/p/pyparsing/code/trunk@272 9bf210a0-9d2d-494c-87cf-cfb32e7dff7b
-rw-r--r--src/CHANGES3
-rw-r--r--src/pyparsing.py3
2 files changed, 6 insertions, 0 deletions
diff --git a/src/CHANGES b/src/CHANGES
index 6e072c0..07aaa01 100644
--- a/src/CHANGES
+++ b/src/CHANGES
@@ -15,6 +15,9 @@ Version 2.0.3 -
- Fixed bug in And class when initializing using a generator.
+- Fixed UnboundLocalError under Python 3.4 in oneOf method, reported
+ on Sourceforge by aldanor, thanks!
+
Version 2.0.2 - April, 2014
---------------------------
diff --git a/src/pyparsing.py b/src/pyparsing.py
index 12b011c..468fb01 100644
--- a/src/pyparsing.py
+++ b/src/pyparsing.py
@@ -3231,6 +3231,7 @@ def oneOf( strs, caseless=False, useRegex=True ):
masks = ( lambda a,b: b.startswith(a) )
parseElementClass = Literal
+ symbols = []
if isinstance(strs,basestring):
symbols = strs.split()
elif isinstance(strs, collections.Sequence):
@@ -3240,6 +3241,8 @@ def oneOf( strs, caseless=False, useRegex=True ):
else:
warnings.warn("Invalid argument to oneOf, expected string or list",
SyntaxWarning, stacklevel=2)
+ if not symbols:
+ return NoMatch()
i = 0
while i < len(symbols)-1: