[Python-checkins] cpython (merge default -> default): Merge (original) (raw)

raymond.hettinger python-checkins at python.org
Wed Mar 23 21:05:27 CET 2011


http://hg.python.org/cpython/rev/09b34be885ac changeset: 68880:09b34be885ac parent: 68879:bffdd7e9265c parent: 68877:d9a779be9736 user: Raymond Hettinger <python at rcn.com> date: Wed Mar 23 12:53:32 2011 -0700 summary: Merge

files: Lib/email/quoprimime.py | 6 +- Lib/test/regrtest.py | 7 + Lib/test/support.py | 5 +- Lib/test/test_email/test_email.py | 209 ++++++++++++++++- Lib/test/test_peepholer.py | 11 + Misc/ACKS | 1 + Misc/NEWS | 3 + Python/peephole.c | 6 +- 8 files changed, 223 insertions(+), 25 deletions(-)

diff --git a/Lib/email/quoprimime.py b/Lib/email/quoprimime.py --- a/Lib/email/quoprimime.py +++ b/Lib/email/quoprimime.py @@ -135,9 +135,9 @@ charset names the character set to use in the RFC 2046 header. It defaults to iso-8859-1. """ - # Return empty headers unchanged + # Return empty headers as an empty string. if not header_bytes: - return str(header_bytes) + return '' # Iterate over every byte, encoding if necessary. encoded = [] for octet in header_bytes: @@ -268,7 +268,7 @@ if i == n: decoded += eol # Special case if original string did not end with eol - if not encoded.endswith(eol) and decoded.endswith(eol): + if encoded[-1] not in '\r\n' and decoded.endswith(eol): decoded = decoded[:-1] return decoded diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -374,6 +374,13 @@ forever = True elif o in ('-j', '--multiprocess'): use_mp = int(a) + if use_mp <= 0: + try: + import multiprocessing + # Use all cores + extras for tests that like to sleep + use_mp = 2 + multiprocessing.cpu_count() + except (ImportError, NotImplementedError): + use_mp = 3 elif o == '--header': header = True elif o == '--slaveargs': diff --git a/Lib/test/support.py b/Lib/test/support.py --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -1389,9 +1389,8 @@ v = getattr(sys.flags, flag) if v > 0: args.append('-' + opt * v) - if sys.warnoptions: - args.append('-W') - args.extend(sys.warnoptions) + for opt in sys.warnoptions: + args.append('-W' + opt) return args #============================================================ diff --git a/Lib/test/test_email/test_email.py b/Lib/test/test_email/test_email.py --- a/Lib/test/test_email/test_email.py +++ b/Lib/test/test_email/test_email.py @@ -3344,21 +3344,200 @@ c = chr(x) self.assertEqual(quoprimime.unquote(quoprimime.quote(c)), c) - def test_header_encode(self): - eq = self.assertEqual - he = quoprimime.header_encode - eq(he(b'hello'), '=?iso-8859-1?q?hello?=') - eq(he(b'hello', charset='iso-8859-2'), '=?iso-8859-2?q?hello?=') - eq(he(b'hello\nworld'), '=?iso-8859-1?q?hello=0Aworld?=') - # Test a non-ASCII character - eq(he(b'hello\xc7there'), '=?iso-8859-1?q?hello=C7there?=')

diff --git a/Lib/test/test_peepholer.py b/Lib/test/test_peepholer.py --- a/Lib/test/test_peepholer.py +++ b/Lib/test/test_peepholer.py @@ -3,6 +3,7 @@ import sys from io import StringIO import unittest +from math import copysign def disassemble(func): f = StringIO() @@ -207,6 +208,9 @@ def test_folding_of_unaryops_on_constants(self): for line, elem in ( ('-0.5', '(-0.5)'), # unary negative + ('-0.0', '(-0.0)'), # -0.0 + ('-(1.0-1.0)','(-0.0)'), # -0.0 after folding + ('-0', '(0)'), # -0 ('~-2', '(1)'), # unary invert ('+1', '(1)'), # unary positive ): @@ -214,6 +218,13 @@ self.assertIn(elem, asm, asm) self.assertNotIn('UNARY_', asm) + # Check that -0.0 works after marshaling + def negzero(): + return -(1.0-1.0) + + self.assertNotIn('UNARY_', disassemble(negzero)) + self.assertTrue(copysign(1.0, negzero()) < 0) + # Verify that unfoldables are skipped for line, elem in ( ('-"abc"', "('abc')"), # unary negative diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -867,6 +867,7 @@ Frank J. Tobin R Lindsay Todd Bennett Todd +Eugene Toder Matias Torchinsky Sandro Tosi Richard Townsend diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ Core and Builtins

+- Issue #11244: Remove an unnecessary peepholer check that was preventing

@@ -250,9 +250,7 @@ opcode = codestr[3]; switch (opcode) { case UNARY_NEGATIVE:

-- Repository URL: http://hg.python.org/cpython



More information about the Python-checkins mailing list