Mercurial > cpython-lru_cache-weakref
diff Lib/test/test_parser.py @ 62374:2cc09f06950b 3.1
Merged revisions 82043 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r82043 | mark.dickinson | 2010-06-17 13:33:22 +0100 (Thu, 17 Jun 2010) | 6 lines
Issue #9011: Remove buggy and unnecessary ST->AST compilation code
dealing with unary minus applied to a constant. The removed code was
mutating the ST, causing a second compilation to fail. (The peephole
optimizer already takes care of optimizing this case, so there's no
lost optimization opportunity here.)
........
| author | Mark Dickinson <dickinsm@gmail.com> |
|---|---|
| date | Thu, 17 Jun 2010 12:37:17 +0000 |
| parents | 0bb232078b8c |
| children | d34ce0de941c |
line wrap: on
line diff
--- a/Lib/test/test_parser.py Thu Jun 17 02:06:12 2010 +0000 +++ b/Lib/test/test_parser.py Thu Jun 17 12:37:17 2010 +0000 @@ -479,8 +479,18 @@ st = parser.suite('a = "\\u1"') self.assertRaises(SyntaxError, parser.compilest, st) + def test_issue_9011(self): + # Issue 9011: compilation of an unary minus expression changed + # the meaning of the ST, so that a second compilation produced + # incorrect results. + st = parser.expr('-3') + code1 = parser.compilest(st) + self.assertEqual(eval(code1), -3) + code2 = parser.compilest(st) + self.assertEqual(eval(code2), -3) + class ParserStackLimitTestCase(unittest.TestCase): - """try to push the parser to/over it's limits. + """try to push the parser to/over its limits. see http://bugs.python.org/issue1881 for a discussion """ def _nested_expression(self, level):
