diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2010-06-17 12:33:22 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2010-06-17 12:33:22 (GMT) |
commit | d35a32e12eb7e3cf863cff80218e10c9bf3f351f (patch) | |
tree | cd4fd1e5290e5e24c488533464aee681c2d42083 /Lib/test | |
parent | a1b3740d042206efada2b8e1d97349c4d95e34e1 (diff) | |
download | cpython-d35a32e12eb7e3cf863cff80218e10c9bf3f351f.zip cpython-d35a32e12eb7e3cf863cff80218e10c9bf3f351f.tar.gz cpython-d35a32e12eb7e3cf863cff80218e10c9bf3f351f.tar.bz2 |
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.)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_parser.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py index a36b544..071d362 100644 --- a/Lib/test/test_parser.py +++ b/Lib/test/test_parser.py @@ -484,8 +484,18 @@ class CompileTestCase(unittest.TestCase): 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): |