From: <fwi...@us...> - 2008-08-13 19:48:16
|
Revision: 5171 http://jython.svn.sourceforge.net/jython/?rev=5171&view=rev Author: fwierzbicki Date: 2008-08-13 19:48:08 +0000 (Wed, 13 Aug 2008) Log Message: ----------- Make errtext optional in test_syntax and fixed illegal delete of function call. Modified Paths: -------------- branches/asm/Lib/test/test_syntax.py branches/asm/grammar/PythonWalker.g branches/asm/src/org/python/antlr/GrammarActions.java Modified: branches/asm/Lib/test/test_syntax.py =================================================================== --- branches/asm/Lib/test/test_syntax.py 2008-08-13 19:25:13 UTC (rev 5170) +++ branches/asm/Lib/test/test_syntax.py 2008-08-13 19:48:08 UTC (rev 5171) @@ -424,27 +424,34 @@ class SyntaxTestCase(unittest.TestCase): - def _check_error(self, code, errtext, + def _check_error(self, code, errtext=None, filename="<testcase>", mode="exec", subclass=None): """Check that compiling code raises SyntaxError with errtext. errtest is a regular expression that must be present in the test of the exception raised. If subclass is specified it is the expected subclass of SyntaxError (e.g. IndentationError). + + XXX: Made errtext optional, since the exact wording of exceptions + is implementation dependant. """ try: compile(code, filename, mode) except SyntaxError, err: if subclass and not isinstance(err, subclass): self.fail("SyntaxError is not a %s" % subclass.__name__) - mo = re.search(errtext, str(err)) - if mo is None: - self.fail("SyntaxError did not contain '%r'" % (errtext,)) + if errtext is not None: + mo = re.search(errtext, str(err)) + if mo is None: + self.fail("SyntaxError did not contain '%r'" % (errtext,)) else: self.fail("compile() did not raise SyntaxError") def test_assign_call(self): - self._check_error("f() = 1", "assign") + if test_support.is_jython: + self._check_error("f() = 1") + else: + self._check_error("f() = 1", "assign") def test_assign_del(self): self._check_error("del f()", "delete") @@ -489,7 +496,10 @@ subclass=IndentationError) def test_kwargs_last(self): - self._check_error("int(base=10, '2')", "non-keyword arg") + if test_support.is_jython: + self._check_error("int(base=10, '2')") + else: + self._check_error("int(base=10, '2')", "non-keyword arg") def test_main(): test_support.run_unittest(SyntaxTestCase) Modified: branches/asm/grammar/PythonWalker.g =================================================================== --- branches/asm/grammar/PythonWalker.g 2008-08-13 19:25:13 UTC (rev 5170) +++ branches/asm/grammar/PythonWalker.g 2008-08-13 19:48:08 UTC (rev 5171) @@ -439,6 +439,7 @@ del_stmt : ^(DELETE elts[expr_contextType.Del]) { exprType[] t = (exprType[])$elts.etypes.toArray(new exprType[$elts.etypes.size()]); + actions.checkDelete(t); $stmts::statements.add(new Delete($DELETE, t)); } ; Modified: branches/asm/src/org/python/antlr/GrammarActions.java =================================================================== --- branches/asm/src/org/python/antlr/GrammarActions.java 2008-08-13 19:25:13 UTC (rev 5170) +++ branches/asm/src/org/python/antlr/GrammarActions.java 2008-08-13 19:48:08 UTC (rev 5171) @@ -499,4 +499,13 @@ } } } + + void checkDelete(exprType[] exprs) { + for(int i=0;i<exprs.length;i++) { + if (exprs[i] instanceof Call) { + errorHandler.error("can't delete function call", exprs[i]); + } + } + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |