[Python-checkins] r75601 - in python/branches/py3k: Lib/test/test_peepholer.py Misc/NEWS Python/peephole.c
raymond.hettinger
python-checkins at python.org
Thu Oct 22 13:22:50 CEST 2009
Author: raymond.hettinger
Date: Thu Oct 22 13:22:50 2009
New Revision: 75601
Log:
Peephole constant folding had missed UNARY_POSITIVE.
Modified:
python/branches/py3k/Lib/test/test_peepholer.py
python/branches/py3k/Misc/NEWS
python/branches/py3k/Python/peephole.c
Modified: python/branches/py3k/Lib/test/test_peepholer.py
==============================================================================
--- python/branches/py3k/Lib/test/test_peepholer.py (original)
+++ python/branches/py3k/Lib/test/test_peepholer.py Thu Oct 22 13:22:50 2009
@@ -150,6 +150,7 @@
for line, elem in (
('-0.5', '(-0.5)'), # unary negative
('~-2', '(1)'), # unary invert
+ ('+1', '(1)'), # unary positive
):
asm = dis_single(line)
self.assertTrue(elem in asm, asm)
Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Thu Oct 22 13:22:50 2009
@@ -12,6 +12,8 @@
Core and Builtins
-----------------
+- Peephole constant folding had missed UNARY_POSITIVE.
+
- Issue #1722344: threading._shutdown() is now called in Py_Finalize(), which
fixes the problem of some exceptions being thrown at shutdown when the
interpreter is killed. Patch by Adam Olsen.
Modified: python/branches/py3k/Python/peephole.c
==============================================================================
--- python/branches/py3k/Python/peephole.c (original)
+++ python/branches/py3k/Python/peephole.c Thu Oct 22 13:22:50 2009
@@ -197,6 +197,9 @@
case UNARY_INVERT:
newconst = PyNumber_Invert(v);
break;
+ case UNARY_POSITIVE:
+ newconst = PyNumber_Positive(v);
+ break;
default:
/* Called with an unknown opcode */
PyErr_Format(PyExc_SystemError,
@@ -500,6 +503,7 @@
LOAD_CONST c1 UNARY_OP --> LOAD_CONST unary_op(c) */
case UNARY_NEGATIVE:
case UNARY_INVERT:
+ case UNARY_POSITIVE:
if (lastlc >= 1 &&
ISBASICBLOCK(blocks, i-3, 4) &&
fold_unaryops_on_constants(&codestr[i-3], consts)) {
More information about the Python-checkins
mailing list