summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b>2015-10-29 13:35:44 +0000
committerptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b>2015-10-29 13:35:44 +0000
commit7000d600e5e7a29acc60c3ad8e13d3751e5cc8b4 (patch)
treea29624514b2c1accd495931d420d6f0cbff34d34
parent59672e04e3956347c221b644a31c26386ace408e (diff)
downloadpyparsing-7000d600e5e7a29acc60c3ad8e13d3751e5cc8b4.tar.gz
(#($&(#& print statements in runTests broke Py3 compatibility!
git-svn-id: svn://svn.code.sf.net/p/pyparsing/code/trunk@294 9bf210a0-9d2d-494c-87cf-cfb32e7dff7b
-rw-r--r--src/CHANGES6
-rw-r--r--src/pyparsing.py65
-rw-r--r--src/unitTests.py2
3 files changed, 31 insertions, 42 deletions
diff --git a/src/CHANGES b/src/CHANGES
index 09def63..7c51766 100644
--- a/src/CHANGES
+++ b/src/CHANGES
@@ -2,6 +2,12 @@
Change Log
==========
+Version 2.0.5 -
+---------------------------
+- (&$(@#&$(@!!!! Some "print" statements snuck into pyparsing v2.0.4,
+ breaking Python 3 compatibility! Fixed. Reported by jenshn, thanks!
+
+
Version 2.0.4 -
---------------------------
- Added ParserElement.addCondition, to simplify adding parse actions
diff --git a/src/pyparsing.py b/src/pyparsing.py
index 81c82ce..ef429db 100644
--- a/src/pyparsing.py
+++ b/src/pyparsing.py
@@ -57,8 +57,8 @@ The pyparsing module handles some of the problems that are typically vexing when
- embedded comments
"""
-__version__ = "2.0.4"
-__versionTime__ = "28 Oct 2015 21:50"
+__version__ = "2.0.5"
+__versionTime__ = "29 Oct 2015 08:08"
__author__ = "Paul McGuire <ptmcg@users.sourceforge.net>"
import string
@@ -1553,18 +1553,20 @@ class ParserElement(object):
test, the parsed results or where the parse failed. Quick and easy way to
run a parse expression against a list of sample strings.
"""
+ if isinstance(tests, basestring):
+ tests = map(str.strip, tests.splitlines())
for t in tests:
- print t
+ print (t)
try:
- print self.parseString(t).dump()
+ print (self.parseString(t).dump())
except ParseException as pe:
if '\n' in t:
- print line(pe.loc, t)
- print ' '*(col(pe.loc,t)-1) + '^'
+ print (line(pe.loc, t))
+ print (' '*(col(pe.loc,t)-1) + '^')
else:
- print ' '*pe.loc + '^'
- print pe
- print
+ print (' '*pe.loc + '^')
+ print (pe)
+ print()
class Token(ParserElement):
@@ -3759,22 +3761,6 @@ commaSeparatedList = delimitedList( Optional( quotedString.copy() | _commasepite
if __name__ == "__main__":
- def test( teststring ):
- try:
- tokens = simpleSQL.parseString( teststring )
- tokenlist = tokens.asList()
- print (teststring + "->" + str(tokenlist))
- print ("tokens = " + str(tokens))
- print ("tokens.columns = " + str(tokens.columns))
- print ("tokens.tables = " + str(tokens.tables))
- print (tokens.asXML("SQL",True))
- except ParseBaseException as err:
- print (teststring + "->")
- print (err.line)
- print (" "*(err.column-1) + "^")
- print (err)
- print()
-
selectToken = CaselessLiteral( "select" )
fromToken = CaselessLiteral( "from" )
@@ -3788,19 +3774,16 @@ if __name__ == "__main__":
fromToken + \
tableNameList.setResultsName( "tables" ) )
- test( "SELECT * from XYZZY, ABC" )
- test( "select * from SYS.XYZZY" )
- test( "Select A from Sys.dual" )
- test( "Select AA,BB,CC from Sys.dual" )
- test( "Select A, B, C from Sys.dual" )
- test( "Select A, B, C from Sys.dual" )
- test( "Xelect A, B, C from Sys.dual" )
- test( "Select A, B, C frox Sys.dual" )
- test( "Select" )
- test( "Select ^^^ frox Sys.dual" )
- test( "Select A, B, C from Sys.dual, Table2 " )
-
-"""
-CHANGES
-UnitTests.py
-""" \ No newline at end of file
+ simpleSQL.runTests("""\
+ SELECT * from XYZZY, ABC
+ select * from SYS.XYZZY
+ Select A from Sys.dual
+ Select AA,BB,CC from Sys.dual
+ Select A, B, C from Sys.dual
+ Select A, B, C from Sys.dual
+ Xelect A, B, C from Sys.dual
+ Select A, B, C frox Sys.dual
+ Select
+ Select ^^^ frox Sys.dual
+ Select A, B, C from Sys.dual, Table2""")
+
diff --git a/src/unitTests.py b/src/unitTests.py
index 10ad99e..a675ffe 100644
--- a/src/unitTests.py
+++ b/src/unitTests.py
@@ -2241,7 +2241,7 @@ class AddConditionTest(ParseTestCase):
numParser.addCondition(lambda s,l,t: t[0] >= 7)
result = numParser.searchString("1 2 3 4 5 6 7 8 9 10")
- print result.asList()
+ print_(result.asList())
assert result.asList() == [[7],[9]], "failed to properly process conditions"