From solipsis at pitrou.net Mon Feb 1 04:45:47 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Mon, 01 Feb 2016 09:45:47 +0000 Subject: [Python-checkins] Daily reference leaks (3b211ee66b82): sum=4 Message-ID: <20160201094544.58300.42736@psf.io> results for 3b211ee66b82 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogZIzLRB', '--timeout', '7200'] From python-checkins at python.org Mon Feb 1 06:09:44 2016 From: python-checkins at python.org (martin.panter) Date: Mon, 01 Feb 2016 11:09:44 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2319587=3A_Merge_test=5Fbytes_cleanup_from_3=2E5?= Message-ID: <20160201110831.58306.74790@psf.io> https://hg.python.org/cpython/rev/8545a082fcaa changeset: 100136:8545a082fcaa parent: 100133:3b211ee66b82 parent: 100135:22c2dd04a3d3 user: Martin Panter date: Tue Feb 02 10:54:10 2016 +0000 summary: Issue #19587: Merge test_bytes cleanup from 3.5 files: Lib/test/buffer_tests.py | 46 +-------------------------- Lib/test/string_tests.py | 10 ++--- Lib/test/test_bytes.py | 13 ------- 3 files changed, 6 insertions(+), 63 deletions(-) diff --git a/Lib/test/buffer_tests.py b/Lib/test/buffer_tests.py --- a/Lib/test/buffer_tests.py +++ b/Lib/test/buffer_tests.py @@ -1,11 +1,8 @@ -# Tests that work for both bytes and buffer objects. +# Tests that work for bytearray objects. Could be merged into string_tests. # See PEP 3137. -import struct -import sys - class MixinBytesBufferCommonTests(object): - """Tests that work for both bytes and buffer objects. + """Tests that work for bytearray objects. See PEP 3137. """ @@ -88,16 +85,6 @@ self.assertRaises(TypeError, self.marshal(b'abc').isdigit, 42) - def test_lower(self): - self.assertEqual(b'hello', self.marshal(b'HeLLo').lower()) - self.assertEqual(b'hello', self.marshal(b'hello').lower()) - self.assertRaises(TypeError, self.marshal(b'hello').lower, 42) - - def test_upper(self): - self.assertEqual(b'HELLO', self.marshal(b'HeLLo').upper()) - self.assertEqual(b'HELLO', self.marshal(b'HELLO').upper()) - self.assertRaises(TypeError, self.marshal(b'hello').upper, 42) - def test_capitalize(self): self.assertEqual(b' hello ', self.marshal(b' hello ').capitalize()) self.assertEqual(b'Hello ', self.marshal(b'Hello ').capitalize()) @@ -153,35 +140,6 @@ self.assertRaises(TypeError, self.marshal(b'123').zfill) - def test_expandtabs(self): - self.assertEqual(b'abc\rab def\ng hi', - self.marshal(b'abc\rab\tdef\ng\thi').expandtabs()) - self.assertEqual(b'abc\rab def\ng hi', - self.marshal(b'abc\rab\tdef\ng\thi').expandtabs(8)) - self.assertEqual(b'abc\rab def\ng hi', - self.marshal(b'abc\rab\tdef\ng\thi').expandtabs(4)) - self.assertEqual(b'abc\r\nab def\ng hi', - self.marshal(b'abc\r\nab\tdef\ng\thi').expandtabs()) - self.assertEqual(b'abc\r\nab def\ng hi', - self.marshal(b'abc\r\nab\tdef\ng\thi').expandtabs(8)) - self.assertEqual(b'abc\r\nab def\ng hi', - self.marshal(b'abc\r\nab\tdef\ng\thi').expandtabs(4)) - self.assertEqual(b'abc\r\nab\r\ndef\ng\r\nhi', - self.marshal(b'abc\r\nab\r\ndef\ng\r\nhi').expandtabs(4)) - # check keyword args - self.assertEqual(b'abc\rab def\ng hi', - self.marshal(b'abc\rab\tdef\ng\thi').expandtabs(tabsize=8)) - self.assertEqual(b'abc\rab def\ng hi', - self.marshal(b'abc\rab\tdef\ng\thi').expandtabs(tabsize=4)) - - self.assertEqual(b' a\n b', self.marshal(b' \ta\n\tb').expandtabs(1)) - - self.assertRaises(TypeError, self.marshal(b'hello').expandtabs, 42, 42) - # This test is only valid when sizeof(int) == sizeof(void*) == 4. - if sys.maxsize < (1 << 32) and struct.calcsize('P') == 4: - self.assertRaises(OverflowError, - self.marshal(b'\ta\n\tb').expandtabs, sys.maxsize) - def test_title(self): self.assertEqual(b' Hello ', self.marshal(b' hello ').title()) self.assertEqual(b'Hello ', self.marshal(b'hello ').title()) diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py --- a/Lib/test/string_tests.py +++ b/Lib/test/string_tests.py @@ -1,5 +1,5 @@ """ -Common tests shared by test_unicode, test_userstring and test_string. +Common tests shared by test_unicode, test_userstring and test_bytes. """ import unittest, string, sys, struct @@ -686,8 +686,7 @@ class CommonTest(BaseTest): # This testcase contains tests that can be used in all - # stringlike classes. Currently this is str, unicode - # UserString and the string module. + # stringlike classes. Currently this is str and UserString. def test_hash(self): # SF bug 1054139: += optimization was not invalidating cached hash value @@ -857,8 +856,7 @@ class MixinStrUnicodeUserStringTest: # additional tests that only work for - # stringlike objects, i.e. str, unicode, UserString - # (but not the string module) + # stringlike objects, i.e. str, UserString def test_islower(self): self.checkequal(False, '', 'islower') @@ -1343,7 +1341,7 @@ class MixinStrUnicodeTest: - # Additional tests that only work with str and unicode. + # Additional tests that only work with str. def test_bug1001011(self): # Make sure join returns a NEW object for single item sequences diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -1562,24 +1562,11 @@ class FixedStringTest(test.string_tests.BaseTest): - def fixtype(self, obj): if isinstance(obj, str): return obj.encode("utf-8") return super().fixtype(obj) - # Currently the bytes containment testing uses a single integer - # value. This may not be the final design, but until then the - # bytes section with in a bytes containment not valid - def test_contains(self): - pass - def test_expandtabs(self): - pass - def test_upper(self): - pass - def test_lower(self): - pass - class ByteArrayAsStringTest(FixedStringTest, unittest.TestCase): type2test = bytearray contains_bytes = True -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 1 06:09:45 2016 From: python-checkins at python.org (martin.panter) Date: Mon, 01 Feb 2016 11:09:45 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzE5NTg3?= =?utf-8?q?=3A_Remove_masked_and_redundant_tests_in_test=5Fbytes?= Message-ID: <20160201110830.45919.48271@psf.io> https://hg.python.org/cpython/rev/22c2dd04a3d3 changeset: 100135:22c2dd04a3d3 branch: 3.5 parent: 100132:6d068205b580 user: Martin Panter date: Tue Feb 02 10:37:15 2016 +0000 summary: Issue #19587: Remove masked and redundant tests in test_bytes * test_contains() did not override anything * test_expandtabs/upper/lower() in FixedStringTest were masking usable tests in string_tests. These tests now get run for bytearray() and bytes(). * test_expandtabs/upper/lower() in buffer_tests were only run on bytearray() and are redundant with string_tests files: Lib/test/buffer_tests.py | 46 +-------------------------- Lib/test/string_tests.py | 10 ++--- Lib/test/test_bytes.py | 13 ------- 3 files changed, 6 insertions(+), 63 deletions(-) diff --git a/Lib/test/buffer_tests.py b/Lib/test/buffer_tests.py --- a/Lib/test/buffer_tests.py +++ b/Lib/test/buffer_tests.py @@ -1,11 +1,8 @@ -# Tests that work for both bytes and buffer objects. +# Tests that work for bytearray objects. Could be merged into string_tests. # See PEP 3137. -import struct -import sys - class MixinBytesBufferCommonTests(object): - """Tests that work for both bytes and buffer objects. + """Tests that work for bytearray objects. See PEP 3137. """ @@ -88,16 +85,6 @@ self.assertRaises(TypeError, self.marshal(b'abc').isdigit, 42) - def test_lower(self): - self.assertEqual(b'hello', self.marshal(b'HeLLo').lower()) - self.assertEqual(b'hello', self.marshal(b'hello').lower()) - self.assertRaises(TypeError, self.marshal(b'hello').lower, 42) - - def test_upper(self): - self.assertEqual(b'HELLO', self.marshal(b'HeLLo').upper()) - self.assertEqual(b'HELLO', self.marshal(b'HELLO').upper()) - self.assertRaises(TypeError, self.marshal(b'hello').upper, 42) - def test_capitalize(self): self.assertEqual(b' hello ', self.marshal(b' hello ').capitalize()) self.assertEqual(b'Hello ', self.marshal(b'Hello ').capitalize()) @@ -153,35 +140,6 @@ self.assertRaises(TypeError, self.marshal(b'123').zfill) - def test_expandtabs(self): - self.assertEqual(b'abc\rab def\ng hi', - self.marshal(b'abc\rab\tdef\ng\thi').expandtabs()) - self.assertEqual(b'abc\rab def\ng hi', - self.marshal(b'abc\rab\tdef\ng\thi').expandtabs(8)) - self.assertEqual(b'abc\rab def\ng hi', - self.marshal(b'abc\rab\tdef\ng\thi').expandtabs(4)) - self.assertEqual(b'abc\r\nab def\ng hi', - self.marshal(b'abc\r\nab\tdef\ng\thi').expandtabs()) - self.assertEqual(b'abc\r\nab def\ng hi', - self.marshal(b'abc\r\nab\tdef\ng\thi').expandtabs(8)) - self.assertEqual(b'abc\r\nab def\ng hi', - self.marshal(b'abc\r\nab\tdef\ng\thi').expandtabs(4)) - self.assertEqual(b'abc\r\nab\r\ndef\ng\r\nhi', - self.marshal(b'abc\r\nab\r\ndef\ng\r\nhi').expandtabs(4)) - # check keyword args - self.assertEqual(b'abc\rab def\ng hi', - self.marshal(b'abc\rab\tdef\ng\thi').expandtabs(tabsize=8)) - self.assertEqual(b'abc\rab def\ng hi', - self.marshal(b'abc\rab\tdef\ng\thi').expandtabs(tabsize=4)) - - self.assertEqual(b' a\n b', self.marshal(b' \ta\n\tb').expandtabs(1)) - - self.assertRaises(TypeError, self.marshal(b'hello').expandtabs, 42, 42) - # This test is only valid when sizeof(int) == sizeof(void*) == 4. - if sys.maxsize < (1 << 32) and struct.calcsize('P') == 4: - self.assertRaises(OverflowError, - self.marshal(b'\ta\n\tb').expandtabs, sys.maxsize) - def test_title(self): self.assertEqual(b' Hello ', self.marshal(b' hello ').title()) self.assertEqual(b'Hello ', self.marshal(b'hello ').title()) diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py --- a/Lib/test/string_tests.py +++ b/Lib/test/string_tests.py @@ -1,5 +1,5 @@ """ -Common tests shared by test_unicode, test_userstring and test_string. +Common tests shared by test_unicode, test_userstring and test_bytes. """ import unittest, string, sys, struct @@ -686,8 +686,7 @@ class CommonTest(BaseTest): # This testcase contains tests that can be used in all - # stringlike classes. Currently this is str, unicode - # UserString and the string module. + # stringlike classes. Currently this is str and UserString. def test_hash(self): # SF bug 1054139: += optimization was not invalidating cached hash value @@ -857,8 +856,7 @@ class MixinStrUnicodeUserStringTest: # additional tests that only work for - # stringlike objects, i.e. str, unicode, UserString - # (but not the string module) + # stringlike objects, i.e. str, UserString def test_islower(self): self.checkequal(False, '', 'islower') @@ -1343,7 +1341,7 @@ class MixinStrUnicodeTest: - # Additional tests that only work with str and unicode. + # Additional tests that only work with str. def test_bug1001011(self): # Make sure join returns a NEW object for single item sequences diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -1467,24 +1467,11 @@ class FixedStringTest(test.string_tests.BaseTest): - def fixtype(self, obj): if isinstance(obj, str): return obj.encode("utf-8") return super().fixtype(obj) - # Currently the bytes containment testing uses a single integer - # value. This may not be the final design, but until then the - # bytes section with in a bytes containment not valid - def test_contains(self): - pass - def test_expandtabs(self): - pass - def test_upper(self): - pass - def test_lower(self): - pass - class ByteArrayAsStringTest(FixedStringTest, unittest.TestCase): type2test = bytearray contains_bytes = True -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 1 06:42:38 2016 From: python-checkins at python.org (victor.stinner) Date: Mon, 01 Feb 2016 11:42:38 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogdGVzdF9hc3luY2lv?= =?utf-8?q?=3A_fix_test=5Ftimeout=5Ftime=28=29?= Message-ID: <20160201114238.28352.84707@psf.io> https://hg.python.org/cpython/rev/fe6be84981e2 changeset: 100137:fe6be84981e2 branch: 3.5 parent: 100135:22c2dd04a3d3 user: Victor Stinner date: Mon Feb 01 12:39:50 2016 +0100 summary: test_asyncio: fix test_timeout_time() Accept time delta up to 0.12 second, instead of 0.11, for the "AMD64 FreeBSD 9.x" buildbot slave. files: Lib/test/test_asyncio/test_tasks.py | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py --- a/Lib/test/test_asyncio/test_tasks.py +++ b/Lib/test/test_asyncio/test_tasks.py @@ -2352,7 +2352,8 @@ foo_running = False dt = self.loop.time() - start - self.assertTrue(0.09 < dt < 0.11, dt) + # tolerate a small delta for slow delta or unstable clocks + self.assertTrue(0.09 < dt < 0.12, dt) self.assertFalse(foo_running) self.loop.run_until_complete(go()) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 1 06:42:39 2016 From: python-checkins at python.org (victor.stinner) Date: Mon, 01 Feb 2016 11:42:39 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy41ICh0ZXN0X2FzeW5jaW8p?= Message-ID: <20160201114238.62660.43550@psf.io> https://hg.python.org/cpython/rev/fb192db73ab1 changeset: 100138:fb192db73ab1 parent: 100136:8545a082fcaa parent: 100137:fe6be84981e2 user: Victor Stinner date: Mon Feb 01 12:41:24 2016 +0100 summary: Merge 3.5 (test_asyncio) files: Lib/test/test_asyncio/test_tasks.py | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py --- a/Lib/test/test_asyncio/test_tasks.py +++ b/Lib/test/test_asyncio/test_tasks.py @@ -2352,7 +2352,8 @@ foo_running = False dt = self.loop.time() - start - self.assertTrue(0.09 < dt < 0.11, dt) + # tolerate a small delta for slow delta or unstable clocks + self.assertTrue(0.09 < dt < 0.12, dt) self.assertFalse(foo_running) self.loop.run_until_complete(go()) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 1 06:48:05 2016 From: python-checkins at python.org (victor.stinner) Date: Mon, 01 Feb 2016 11:48:05 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Merge_3=2E5_=28asyncio=29?= Message-ID: <20160201114805.16775.919@psf.io> https://hg.python.org/cpython/rev/c7f1acdd8be1 changeset: 100140:c7f1acdd8be1 parent: 100138:fb192db73ab1 parent: 100139:97c80e317ab8 user: Victor Stinner date: Mon Feb 01 12:47:15 2016 +0100 summary: Merge 3.5 (asyncio) files: Lib/asyncio/selector_events.py | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py --- a/Lib/asyncio/selector_events.py +++ b/Lib/asyncio/selector_events.py @@ -682,8 +682,8 @@ def write(self, data): if not isinstance(data, (bytes, bytearray, memoryview)): - raise TypeError('data argument must be byte-ish (%r)', - type(data)) + raise TypeError('data argument must be a bytes-like object, ' + 'not %r' % type(data).__name__) if self._eof: raise RuntimeError('Cannot call write() after write_eof()') if not data: @@ -954,8 +954,8 @@ def write(self, data): if not isinstance(data, (bytes, bytearray, memoryview)): - raise TypeError('data argument must be byte-ish (%r)', - type(data)) + raise TypeError('data argument must be a bytes-like object, ' + 'not %r' % type(data).__name__) if not data: return @@ -1010,8 +1010,8 @@ def sendto(self, data, addr=None): if not isinstance(data, (bytes, bytearray, memoryview)): - raise TypeError('data argument must be byte-ish (%r)', - type(data)) + raise TypeError('data argument must be a bytes-like object, ' + 'not %r' % type(data).__name__) if not data: return -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 1 06:48:05 2016 From: python-checkins at python.org (victor.stinner) Date: Mon, 01 Feb 2016 11:48:05 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Fix_error_mess?= =?utf-8?q?age_in_asyncio=2Eselector=5Fevents=2E?= Message-ID: <20160201114805.16746.53956@psf.io> https://hg.python.org/cpython/rev/97c80e317ab8 changeset: 100139:97c80e317ab8 branch: 3.5 parent: 100137:fe6be84981e2 user: Victor Stinner date: Mon Feb 01 12:46:38 2016 +0100 summary: Fix error message in asyncio.selector_events. Patch written by Carlo Beccarini . files: Lib/asyncio/selector_events.py | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py --- a/Lib/asyncio/selector_events.py +++ b/Lib/asyncio/selector_events.py @@ -682,8 +682,8 @@ def write(self, data): if not isinstance(data, (bytes, bytearray, memoryview)): - raise TypeError('data argument must be byte-ish (%r)', - type(data)) + raise TypeError('data argument must be a bytes-like object, ' + 'not %r' % type(data).__name__) if self._eof: raise RuntimeError('Cannot call write() after write_eof()') if not data: @@ -954,8 +954,8 @@ def write(self, data): if not isinstance(data, (bytes, bytearray, memoryview)): - raise TypeError('data argument must be byte-ish (%r)', - type(data)) + raise TypeError('data argument must be a bytes-like object, ' + 'not %r' % type(data).__name__) if not data: return @@ -1010,8 +1010,8 @@ def sendto(self, data, addr=None): if not isinstance(data, (bytes, bytearray, memoryview)): - raise TypeError('data argument must be byte-ish (%r)', - type(data)) + raise TypeError('data argument must be a bytes-like object, ' + 'not %r' % type(data).__name__) if not data: return -- Repository URL: https://hg.python.org/cpython From lp_benchmark_robot at intel.com Mon Feb 1 11:47:39 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Mon, 1 Feb 2016 16:47:39 +0000 Subject: [Python-checkins] GOOD Benchmark Results for Python Default 2016-02-01 Message-ID: <98da03fd-4add-4740-a57d-b8f00108a40c@irsmsx153.ger.corp.intel.com> Results for project Python default, build date 2016-02-01 03:08:17 +0000 commit: 3b211ee66b82 previous commit: d5d0b62c2830 revision date: 2016-02-01 22:13:43 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.24% 1.15% 9.84% 15.66% :-| pybench 0.09% 1.27% -1.17% 4.45% :-( regex_v8 2.79% 1.40% -3.28% 4.11% :-| nbody 0.10% 0.09% 0.44% 4.04% :-| json_dump_v2 0.26% 0.49% -1.56% 9.13% :-| normal_startup 0.84% 0.39% 0.13% 5.13% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/good-benchmark-results-for-python-default-2016-02-01/ Note: Benchmark results are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Mon Feb 1 11:49:47 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Mon, 1 Feb 2016 16:49:47 +0000 Subject: [Python-checkins] NEUTRAL Benchmark Results for Python 2.7 2016-02-01 Message-ID: <7dcc284c-4ad7-4af8-8cef-1b2c3c219276@irsmsx153.ger.corp.intel.com> Results for project Python 2.7, build date 2016-02-01 03:59:51 +0000 commit: 296fb7c10a7d previous commit: 14463726a4a0 revision date: 2016-01-30 01:06:00 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dc from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-| django_v2 0.42% -0.53% 1.63% 6.94% :-) pybench 0.17% 0.01% 6.07% 4.03% :-( regex_v8 0.58% 0.16% -2.36% 11.07% :-) nbody 0.14% -0.03% 8.02% 1.06% :-) json_dump_v2 0.26% -0.02% 4.67% 11.74% :-( normal_startup 2.17% -0.76% -5.85% 2.57% :-| ssbench 0.21% -0.16% 0.91% 2.18% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/neutral-benchmark-results-for-python-2-7-2016-02-01/ Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Tue Feb 2 00:21:48 2016 From: python-checkins at python.org (raymond.hettinger) Date: Tue, 02 Feb 2016 05:21:48 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2MTk0?= =?utf-8?q?=3A__Inserting_into_a_full_deque_to_raise_an_IndexError?= Message-ID: <20160202052148.2661.7260@psf.io> https://hg.python.org/cpython/rev/7dabb94bdf63 changeset: 100141:7dabb94bdf63 branch: 3.5 parent: 100139:97c80e317ab8 user: Raymond Hettinger date: Mon Feb 01 21:19:22 2016 -0800 summary: Issue #26194: Inserting into a full deque to raise an IndexError files: Doc/library/collections.rst | 4 ++-- Lib/test/test_deque.py | 23 ++++++++++++----------- Misc/NEWS | 4 ++-- Modules/_collectionsmodule.c | 7 ++----- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst --- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -477,8 +477,8 @@ Insert *x* into the deque at position *i*. - If the insertion causes a bounded deque to grow beyond *maxlen*, the - rightmost element is then removed to restore the size limit. + If the insertion would cause a bounded deque to grow beyond *maxlen*, + an :exc:`IndexError` is raised. .. versionadded:: 3.5 diff --git a/Lib/test/test_deque.py b/Lib/test/test_deque.py --- a/Lib/test/test_deque.py +++ b/Lib/test/test_deque.py @@ -304,19 +304,20 @@ s.insert(i, 'Z') self.assertEqual(list(d), s) - def test_index_bug_26194(self): + def test_insert_bug_26194(self): data = 'ABC' - for i in range(len(data) + 1): - d = deque(data, len(data)) - d.insert(i, None) - s = list(data) - s.insert(i, None) - s.pop() - self.assertEqual(list(d), s) - if i < len(data): - self.assertIsNone(d[i]) + d = deque(data, maxlen=len(data)) + with self.assertRaises(IndexError): + d.insert(2, None) + + elements = 'ABCDEFGHI' + for i in range(-len(elements), len(elements)): + d = deque(elements, maxlen=len(elements)+1) + d.insert(i, 'Z') + if i >= 0: + self.assertEqual(d[i], 'Z') else: - self.assertTrue(None not in d) + self.assertEqual(d[i-1], 'Z') def test_imul(self): for n in (-10, -1, 0, 1, 2, 10, 1000): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -22,8 +22,8 @@ compiler issues. - Issue #26194: Deque.insert() gave odd results for bounded deques that had - reached their maximum size. Now, the insert will happen normally and then - any overflowing element will be truncated from the right side. + reached their maximum size. Now an IndexError will be raised when attempting + to insert into a full deque. - Issue #25843: When compiling code, don't merge constants if they are equal but have a different types. For example, ``f1, f2 = lambda: 1, lambda: 1.0`` diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -973,16 +973,13 @@ Py_ssize_t index; Py_ssize_t n = Py_SIZE(deque); PyObject *value; - PyObject *oldvalue; PyObject *rv; if (!PyArg_ParseTuple(args, "nO:insert", &index, &value)) return NULL; if (deque->maxlen == Py_SIZE(deque)) { - if (index >= deque->maxlen || Py_SIZE(deque) == 0) - Py_RETURN_NONE; - oldvalue = deque_pop(deque, NULL); - Py_DECREF(oldvalue); + PyErr_SetString(PyExc_IndexError, "deque already at its maximum size"); + return NULL; } if (index >= n) return deque_append(deque, value); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Feb 2 00:21:50 2016 From: python-checkins at python.org (raymond.hettinger) Date: Tue, 02 Feb 2016 05:21:50 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_merge?= Message-ID: <20160202052149.77411.58810@psf.io> https://hg.python.org/cpython/rev/0731f097157b changeset: 100142:0731f097157b parent: 100140:c7f1acdd8be1 user: Raymond Hettinger date: Mon Feb 01 21:21:19 2016 -0800 summary: merge files: Doc/library/collections.rst | 4 ++-- Lib/test/test_deque.py | 23 ++++++++++++----------- Modules/_collectionsmodule.c | 7 ++----- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst --- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -477,8 +477,8 @@ Insert *x* into the deque at position *i*. - If the insertion causes a bounded deque to grow beyond *maxlen*, the - rightmost element is then removed to restore the size limit. + If the insertion would cause a bounded deque to grow beyond *maxlen*, + an :exc:`IndexError` is raised. .. versionadded:: 3.5 diff --git a/Lib/test/test_deque.py b/Lib/test/test_deque.py --- a/Lib/test/test_deque.py +++ b/Lib/test/test_deque.py @@ -304,19 +304,20 @@ s.insert(i, 'Z') self.assertEqual(list(d), s) - def test_index_bug_26194(self): + def test_insert_bug_26194(self): data = 'ABC' - for i in range(len(data) + 1): - d = deque(data, len(data)) - d.insert(i, None) - s = list(data) - s.insert(i, None) - s.pop() - self.assertEqual(list(d), s) - if i < len(data): - self.assertIsNone(d[i]) + d = deque(data, maxlen=len(data)) + with self.assertRaises(IndexError): + d.insert(2, None) + + elements = 'ABCDEFGHI' + for i in range(-len(elements), len(elements)): + d = deque(elements, maxlen=len(elements)+1) + d.insert(i, 'Z') + if i >= 0: + self.assertEqual(d[i], 'Z') else: - self.assertTrue(None not in d) + self.assertEqual(d[i-1], 'Z') def test_imul(self): for n in (-10, -1, 0, 1, 2, 10, 1000): diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -1085,16 +1085,13 @@ Py_ssize_t index; Py_ssize_t n = Py_SIZE(deque); PyObject *value; - PyObject *oldvalue; PyObject *rv; if (!PyArg_ParseTuple(args, "nO:insert", &index, &value)) return NULL; if (deque->maxlen == Py_SIZE(deque)) { - if (index >= deque->maxlen || Py_SIZE(deque) == 0) - Py_RETURN_NONE; - oldvalue = deque_pop(deque, NULL); - Py_DECREF(oldvalue); + PyErr_SetString(PyExc_IndexError, "deque already at its maximum size"); + return NULL; } if (index >= n) return deque_append(deque, value); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Feb 2 00:59:14 2016 From: python-checkins at python.org (martin.panter) Date: Tue, 02 Feb 2016 05:59:14 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2324421=3A_Compile_?= =?utf-8?q?=5Fmath=2Ec_separately_to_avoid_race_condition?= Message-ID: <20160202055913.14143.4410@psf.io> https://hg.python.org/cpython/rev/76624d47ee99 changeset: 100143:76624d47ee99 user: Martin Panter date: Wed Feb 03 05:19:44 2016 +0000 summary: Issue #24421: Compile _math.c separately to avoid race condition files: Makefile.pre.in | 6 +++++- Misc/NEWS | 4 ++++ setup.py | 12 ++++++++---- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -586,11 +586,15 @@ exit 1 ; \ fi +# This is shared by the math and cmath modules +Modules/_math.o: Modules/_math.c Modules/_math.h + $(CC) -c $(CCSHARED) $(PY_CORE_CFLAGS) -o $@ $< + # Build the shared modules # Under GNU make, MAKEFLAGS are sorted and normalized; the 's' for # -s, --silent or --quiet is always the first char. # Under BSD make, MAKEFLAGS might be " -s -v x=y". -sharedmods: $(BUILDPYTHON) pybuilddir.txt +sharedmods: $(BUILDPYTHON) pybuilddir.txt Modules/_math.o @case "$$MAKEFLAGS" in \ *\ -s*|s*) quiet="-q";; \ *) quiet="";; \ diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -671,6 +671,10 @@ - Issue #24986: It is now possible to build Python on Windows without errors when external libraries are not available. +- Issue #24421: Compile Modules/_math.c once, before building extensions. + Previously it could fail to compile properly if the math and cmath builds + were concurrent. + - Issue #25798: Update OS X 10.5 installer to use OpenSSL 1.0.2e. Windows diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -582,13 +582,17 @@ # array objects exts.append( Extension('array', ['arraymodule.c']) ) + + shared_math = 'Modules/_math.o' # complex math library functions - exts.append( Extension('cmath', ['cmathmodule.c', '_math.c'], - depends=['_math.h'], + exts.append( Extension('cmath', ['cmathmodule.c'], + extra_objects=[shared_math], + depends=['_math.h', shared_math], libraries=math_libs) ) # math library functions, e.g. sin() - exts.append( Extension('math', ['mathmodule.c', '_math.c'], - depends=['_math.h'], + exts.append( Extension('math', ['mathmodule.c'], + extra_objects=[shared_math], + depends=['_math.h', shared_math], libraries=math_libs) ) # time libraries: librt may be needed for clock_gettime() -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Feb 2 02:52:44 2016 From: python-checkins at python.org (martin.panter) Date: Tue, 02 Feb 2016 07:52:44 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI2MjQ0?= =?utf-8?q?=3A_Clarify_default_zlib_compression_level_in_documentation?= Message-ID: <20160202075243.14147.4670@psf.io> https://hg.python.org/cpython/rev/650cf38fba28 changeset: 100144:650cf38fba28 branch: 2.7 parent: 100134:6f7b2b7a029a user: Martin Panter date: Wed Feb 03 07:06:33 2016 +0000 summary: Issue #26244: Clarify default zlib compression level in documentation Based on patch by Aviv Palivoda. files: Doc/library/zlib.rst | 6 ++++-- Misc/ACKS | 1 + Modules/zlibmodule.c | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Doc/library/zlib.rst b/Doc/library/zlib.rst --- a/Doc/library/zlib.rst +++ b/Doc/library/zlib.rst @@ -71,10 +71,12 @@ .. function:: compressobj([level[, method[, wbits[, memlevel[, strategy]]]]]) Returns a compression object, to be used for compressing data streams that won't - fit into memory at once. *level* is an integer from ``0`` to ``9`` controlling + fit into memory at once. *level* is an integer from + ``0`` to ``9`` or ``-1``, controlling the level of compression; ``1`` is fastest and produces the least compression, ``9`` is slowest and produces the most. ``0`` is no compression. The default - value is ``6``. + value is ``-1`` (Z_DEFAULT_COMPRESSION). Z_DEFAULT_COMPRESSION represents a default + compromise between speed and compression (currently equivalent to level 6). *method* is the compression algorithm. Currently, the only supported value is ``DEFLATED``. diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1019,6 +1019,7 @@ Martin Packman Shriphani Palakodety Julien Palard +Aviv Palivoda Ondrej Palkovsky Mike Pall Todd R. Palmer diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c --- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -101,7 +101,7 @@ PyDoc_STRVAR(compressobj__doc__, "compressobj([level]) -- Return a compressor object.\n" "\n" -"Optional arg level is the compression level, in 0-9."); +"Optional arg level is the compression level, in 0-9 or -1."); PyDoc_STRVAR(decompressobj__doc__, "decompressobj([wbits]) -- Return a decompressor object.\n" -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Feb 2 02:52:44 2016 From: python-checkins at python.org (martin.panter) Date: Tue, 02 Feb 2016 07:52:44 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326244=3A_Merge_zlib_documentation_from_3=2E5?= Message-ID: <20160202075244.11235.89373@psf.io> https://hg.python.org/cpython/rev/03708c680eca changeset: 100146:03708c680eca parent: 100143:76624d47ee99 parent: 100145:950e0bfe94ae user: Martin Panter date: Wed Feb 03 07:52:06 2016 +0000 summary: Issue #26244: Merge zlib documentation from 3.5 files: Doc/library/zlib.rst | 7 ++++--- Misc/ACKS | 1 + Modules/clinic/zlibmodule.c.h | 7 ++++--- Modules/zlibmodule.c | 7 ++++--- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Doc/library/zlib.rst b/Doc/library/zlib.rst --- a/Doc/library/zlib.rst +++ b/Doc/library/zlib.rst @@ -60,10 +60,11 @@ Returns a compression object, to be used for compressing data streams that won't fit into memory at once. - *level* is the compression level -- an integer from ``0`` to ``9``. A value - of ``1`` is fastest and produces the least compression, while a value of + *level* is the compression level -- an integer from ``0`` to ``9`` or ``-1``. + A value of ``1`` is fastest and produces the least compression, while a value of ``9`` is slowest and produces the most. ``0`` is no compression. The default - value is ``6``. + value is ``-1`` (Z_DEFAULT_COMPRESSION). Z_DEFAULT_COMPRESSION represents a default + compromise between speed and compression (currently equivalent to level 6). *method* is the compression algorithm. Currently, the only supported value is ``DEFLATED``. diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1075,6 +1075,7 @@ Martin Packman Shriphani Palakodety Julien Palard +Aviv Palivoda Ondrej Palkovsky Mike Pall Todd R. Palmer diff --git a/Modules/clinic/zlibmodule.c.h b/Modules/clinic/zlibmodule.c.h --- a/Modules/clinic/zlibmodule.c.h +++ b/Modules/clinic/zlibmodule.c.h @@ -89,8 +89,9 @@ "Return a compressor object.\n" "\n" " level\n" -" The compression level (an integer in the range 0-9; default is 6).\n" -" Higher compression levels are slower, but produce smaller results.\n" +" The compression level (an integer in the range 0-9 or -1; default is\n" +" currently equivalent to 6). Higher compression levels are slower,\n" +" but produce smaller results.\n" " method\n" " The compression algorithm. If given, this must be DEFLATED.\n" " wbits\n" @@ -438,4 +439,4 @@ #ifndef ZLIB_COMPRESS_COPY_METHODDEF #define ZLIB_COMPRESS_COPY_METHODDEF #endif /* !defined(ZLIB_COMPRESS_COPY_METHODDEF) */ -/*[clinic end generated code: output=7734aec079550bc8 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=cf81e1deae3af0ce input=a9049054013a1b77]*/ diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c --- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -390,8 +390,9 @@ zlib.compressobj level: int(c_default="Z_DEFAULT_COMPRESSION") = Z_DEFAULT_COMPRESSION - The compression level (an integer in the range 0-9; default is 6). - Higher compression levels are slower, but produce smaller results. + The compression level (an integer in the range 0-9 or -1; default is + currently equivalent to 6). Higher compression levels are slower, + but produce smaller results. method: int(c_default="DEFLATED") = DEFLATED The compression algorithm. If given, this must be DEFLATED. wbits: int(c_default="MAX_WBITS") = MAX_WBITS @@ -413,7 +414,7 @@ static PyObject * zlib_compressobj_impl(PyModuleDef *module, int level, int method, int wbits, int memLevel, int strategy, Py_buffer *zdict) -/*[clinic end generated code: output=2949bbb9a5723ccd input=b034847f8821f6af]*/ +/*[clinic end generated code: output=2949bbb9a5723ccd input=de2ffab6e910cd8b]*/ { compobject *self = NULL; int err; -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Feb 2 02:52:44 2016 From: python-checkins at python.org (martin.panter) Date: Tue, 02 Feb 2016 07:52:44 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2MjQ0?= =?utf-8?q?=3A_Clarify_default_zlib_compression_level_in_documentation?= Message-ID: <20160202075244.10890.18000@psf.io> https://hg.python.org/cpython/rev/950e0bfe94ae changeset: 100145:950e0bfe94ae branch: 3.5 parent: 100141:7dabb94bdf63 user: Martin Panter date: Wed Feb 03 07:06:33 2016 +0000 summary: Issue #26244: Clarify default zlib compression level in documentation Based on patch by Aviv Palivoda. files: Doc/library/zlib.rst | 7 ++++--- Misc/ACKS | 1 + Modules/clinic/zlibmodule.c.h | 7 ++++--- Modules/zlibmodule.c | 7 ++++--- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Doc/library/zlib.rst b/Doc/library/zlib.rst --- a/Doc/library/zlib.rst +++ b/Doc/library/zlib.rst @@ -60,10 +60,11 @@ Returns a compression object, to be used for compressing data streams that won't fit into memory at once. - *level* is the compression level -- an integer from ``0`` to ``9``. A value - of ``1`` is fastest and produces the least compression, while a value of + *level* is the compression level -- an integer from ``0`` to ``9`` or ``-1``. + A value of ``1`` is fastest and produces the least compression, while a value of ``9`` is slowest and produces the most. ``0`` is no compression. The default - value is ``6``. + value is ``-1`` (Z_DEFAULT_COMPRESSION). Z_DEFAULT_COMPRESSION represents a default + compromise between speed and compression (currently equivalent to level 6). *method* is the compression algorithm. Currently, the only supported value is ``DEFLATED``. diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1071,6 +1071,7 @@ Martin Packman Shriphani Palakodety Julien Palard +Aviv Palivoda Ondrej Palkovsky Mike Pall Todd R. Palmer diff --git a/Modules/clinic/zlibmodule.c.h b/Modules/clinic/zlibmodule.c.h --- a/Modules/clinic/zlibmodule.c.h +++ b/Modules/clinic/zlibmodule.c.h @@ -89,8 +89,9 @@ "Return a compressor object.\n" "\n" " level\n" -" The compression level (an integer in the range 0-9; default is 6).\n" -" Higher compression levels are slower, but produce smaller results.\n" +" The compression level (an integer in the range 0-9 or -1; default is\n" +" currently equivalent to 6). Higher compression levels are slower,\n" +" but produce smaller results.\n" " method\n" " The compression algorithm. If given, this must be DEFLATED.\n" " wbits\n" @@ -438,4 +439,4 @@ #ifndef ZLIB_COMPRESS_COPY_METHODDEF #define ZLIB_COMPRESS_COPY_METHODDEF #endif /* !defined(ZLIB_COMPRESS_COPY_METHODDEF) */ -/*[clinic end generated code: output=7734aec079550bc8 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=cf81e1deae3af0ce input=a9049054013a1b77]*/ diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c --- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -390,8 +390,9 @@ zlib.compressobj level: int(c_default="Z_DEFAULT_COMPRESSION") = Z_DEFAULT_COMPRESSION - The compression level (an integer in the range 0-9; default is 6). - Higher compression levels are slower, but produce smaller results. + The compression level (an integer in the range 0-9 or -1; default is + currently equivalent to 6). Higher compression levels are slower, + but produce smaller results. method: int(c_default="DEFLATED") = DEFLATED The compression algorithm. If given, this must be DEFLATED. wbits: int(c_default="MAX_WBITS") = MAX_WBITS @@ -413,7 +414,7 @@ static PyObject * zlib_compressobj_impl(PyModuleDef *module, int level, int method, int wbits, int memLevel, int strategy, Py_buffer *zdict) -/*[clinic end generated code: output=2949bbb9a5723ccd input=b034847f8821f6af]*/ +/*[clinic end generated code: output=2949bbb9a5723ccd input=de2ffab6e910cd8b]*/ { compobject *self = NULL; int err; -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Tue Feb 2 04:45:47 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Tue, 02 Feb 2016 09:45:47 +0000 Subject: [Python-checkins] Daily reference leaks (0731f097157b): sum=4 Message-ID: <20160202094547.52246.9630@psf.io> results for 0731f097157b on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogHbfF3e', '--timeout', '7200'] From lp_benchmark_robot at intel.com Tue Feb 2 07:08:50 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Tue, 2 Feb 2016 12:08:50 +0000 Subject: [Python-checkins] GOOD Benchmark Results for Python Default 2016-02-02 Message-ID: <7444b2d5-ca58-4516-8fe0-ada9bc2d8fbe@irsmsx105.ger.corp.intel.com> Results for project Python default, build date 2016-02-02 03:08:41 +0000 commit: 3b211ee66b82 previous commit: c7f1acdd8be1 revision date: 2016-02-01 11:47:15 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.24% 1.13% 9.84% 15.66% :-| pybench 0.09% -0.10% -1.17% 4.45% :-( regex_v8 2.79% -0.04% -3.28% 4.11% :-| nbody 0.10% -0.06% 0.44% 4.04% :-| json_dump_v2 0.26% 0.21% -1.56% 9.13% :-| normal_startup 0.84% -0.17% 0.25% 5.13% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/good-benchmark-results-for-python-default-2016-02-02/ Note: Benchmark results are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Tue Feb 2 07:09:20 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Tue, 2 Feb 2016 12:09:20 +0000 Subject: [Python-checkins] NEUTRAL Benchmark Results for Python 2.7 2016-02-02 Message-ID: Results for project Python 2.7, build date 2016-02-02 04:00:11 +0000 commit: 6f7b2b7a029a previous commit: 296fb7c10a7d revision date: 2016-02-01 21:58:11 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dc from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.18% 0.78% 2.40% 4.82% :-) pybench 0.17% 0.14% 6.20% 4.74% :-( regex_v8 0.63% -0.04% -2.41% 11.11% :-) nbody 0.18% 0.10% 8.11% 1.16% :-) json_dump_v2 0.27% -0.01% 4.66% 10.40% :-( normal_startup 2.01% 0.83% -4.97% 2.11% :-| ssbench 0.21% -0.18% 0.73% 1.65% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/neutral-benchmark-results-for-python-2-7-2016-02-02/ Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Tue Feb 2 11:46:23 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 02 Feb 2016 16:46:23 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI1OTQ1?= =?utf-8?q?=3A_Fixed_bugs_in_functools=2Epartial=2E?= Message-ID: <20160202164622.2653.87950@psf.io> https://hg.python.org/cpython/rev/628ce2975e29 changeset: 100149:628ce2975e29 branch: 2.7 parent: 100144:650cf38fba28 user: Serhiy Storchaka date: Tue Feb 02 18:45:59 2016 +0200 summary: Issue #25945: Fixed bugs in functools.partial. Fixed a crash when unpickle the functools.partial object with wrong state. Fixed a leak in failed functools.partial constructor. "args" and "keywords" attributes of functools.partial have now always types tuple and dict correspondingly. files: Lib/test/test_functools.py | 101 +++++++++++++++++++++++- Misc/NEWS | 5 + Modules/_functoolsmodule.c | 66 ++++++++++------ 3 files changed, 142 insertions(+), 30 deletions(-) diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -1,3 +1,4 @@ +import copy import functools import sys import unittest @@ -25,6 +26,16 @@ """ return the signature of a partial object """ return (part.func, part.args, part.keywords, part.__dict__) +class MyTuple(tuple): + pass + +class BadTuple(tuple): + def __add__(self, other): + return list(self) + list(other) + +class MyDict(dict): + pass + class TestPartial(unittest.TestCase): thetype = functools.partial @@ -146,11 +157,84 @@ self.assertEqual(join(data), '0123456789') def test_pickle(self): - f = self.thetype(signature, 'asdf', bar=True) - f.add_something_to__dict__ = True + f = self.thetype(signature, ['asdf'], bar=[True]) + f.attr = [] for proto in range(pickle.HIGHEST_PROTOCOL + 1): f_copy = pickle.loads(pickle.dumps(f, proto)) - self.assertEqual(signature(f), signature(f_copy)) + self.assertEqual(signature(f_copy), signature(f)) + + def test_copy(self): + f = self.thetype(signature, ['asdf'], bar=[True]) + f.attr = [] + f_copy = copy.copy(f) + self.assertEqual(signature(f_copy), signature(f)) + self.assertIs(f_copy.attr, f.attr) + self.assertIs(f_copy.args, f.args) + self.assertIs(f_copy.keywords, f.keywords) + + def test_deepcopy(self): + f = self.thetype(signature, ['asdf'], bar=[True]) + f.attr = [] + f_copy = copy.deepcopy(f) + self.assertEqual(signature(f_copy), signature(f)) + self.assertIsNot(f_copy.attr, f.attr) + self.assertIsNot(f_copy.args, f.args) + self.assertIsNot(f_copy.args[0], f.args[0]) + self.assertIsNot(f_copy.keywords, f.keywords) + self.assertIsNot(f_copy.keywords['bar'], f.keywords['bar']) + + def test_setstate(self): + f = self.thetype(signature) + f.__setstate__((capture, (1,), dict(a=10), dict(attr=[]))) + self.assertEqual(signature(f), + (capture, (1,), dict(a=10), dict(attr=[]))) + self.assertEqual(f(2, b=20), ((1, 2), {'a': 10, 'b': 20})) + + f.__setstate__((capture, (1,), dict(a=10), None)) + self.assertEqual(signature(f), (capture, (1,), dict(a=10), {})) + self.assertEqual(f(2, b=20), ((1, 2), {'a': 10, 'b': 20})) + + f.__setstate__((capture, (1,), None, None)) + #self.assertEqual(signature(f), (capture, (1,), {}, {})) + self.assertEqual(f(2, b=20), ((1, 2), {'b': 20})) + self.assertEqual(f(2), ((1, 2), {})) + self.assertEqual(f(), ((1,), {})) + + f.__setstate__((capture, (), {}, None)) + self.assertEqual(signature(f), (capture, (), {}, {})) + self.assertEqual(f(2, b=20), ((2,), {'b': 20})) + self.assertEqual(f(2), ((2,), {})) + self.assertEqual(f(), ((), {})) + + def test_setstate_errors(self): + f = self.thetype(signature) + self.assertRaises(TypeError, f.__setstate__, (capture, (), {})) + self.assertRaises(TypeError, f.__setstate__, (capture, (), {}, {}, None)) + self.assertRaises(TypeError, f.__setstate__, [capture, (), {}, None]) + self.assertRaises(TypeError, f.__setstate__, (None, (), {}, None)) + self.assertRaises(TypeError, f.__setstate__, (capture, None, {}, None)) + self.assertRaises(TypeError, f.__setstate__, (capture, [], {}, None)) + self.assertRaises(TypeError, f.__setstate__, (capture, (), [], None)) + + def test_setstate_subclasses(self): + f = self.thetype(signature) + f.__setstate__((capture, MyTuple((1,)), MyDict(a=10), None)) + s = signature(f) + self.assertEqual(s, (capture, (1,), dict(a=10), {})) + self.assertIs(type(s[1]), tuple) + self.assertIs(type(s[2]), dict) + r = f() + self.assertEqual(r, ((1,), {'a': 10})) + self.assertIs(type(r[0]), tuple) + self.assertIs(type(r[1]), dict) + + f.__setstate__((capture, BadTuple((1,)), {}, None)) + s = signature(f) + self.assertEqual(s, (capture, (1,), {}, {})) + self.assertIs(type(s[1]), tuple) + r = f(2) + self.assertEqual(r, ((1, 2), {})) + self.assertIs(type(r[0]), tuple) # Issue 6083: Reference counting bug def test_setstate_refcount(self): @@ -167,7 +251,7 @@ raise IndexError f = self.thetype(object) - self.assertRaises(SystemError, f.__setstate__, BadSequence()) + self.assertRaises(TypeError, f.__setstate__, BadSequence()) class PartialSubclass(functools.partial): pass @@ -181,7 +265,14 @@ thetype = PythonPartial # the python version isn't picklable - test_pickle = test_setstate_refcount = None + test_pickle = None + test_setstate = None + test_setstate_errors = None + test_setstate_subclasses = None + test_setstate_refcount = None + + # the python version isn't deepcopyable + test_deepcopy = None # the python version isn't a type test_attributes = None diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -48,6 +48,11 @@ Library ------- +- Issue #25945: Fixed a crash when unpickle the functools.partial object with + wrong state. Fixed a leak in failed functools.partial constructor. + "args" and "keywords" attributes of functools.partial have now always types + tuple and dict correspondingly. + - Issue #19883: Fixed possible integer overflows in zipimport. - Issue #26147: xmlrpclib now works with unicode not encodable with used diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -128,7 +128,6 @@ Py_INCREF(func); pto->args = PyTuple_GetSlice(args, 1, PY_SSIZE_T_MAX); if (pto->args == NULL) { - pto->kw = NULL; Py_DECREF(pto); return NULL; } @@ -138,10 +137,6 @@ return NULL; } - - pto->weakreflist = NULL; - pto->dict = NULL; - return (PyObject *)pto; } @@ -162,11 +157,11 @@ partial_call(partialobject *pto, PyObject *args, PyObject *kw) { PyObject *ret; - PyObject *argappl = NULL, *kwappl = NULL; + PyObject *argappl, *kwappl; assert (PyCallable_Check(pto->fn)); assert (PyTuple_Check(pto->args)); - assert (pto->kw == Py_None || PyDict_Check(pto->kw)); + assert (PyDict_Check(pto->kw)); if (PyTuple_GET_SIZE(pto->args) == 0) { argappl = args; @@ -178,11 +173,12 @@ argappl = PySequence_Concat(pto->args, args); if (argappl == NULL) return NULL; + assert(PyTuple_Check(argappl)); } - if (pto->kw == Py_None) { + if (PyDict_Size(pto->kw) == 0) { kwappl = kw; - Py_XINCREF(kw); + Py_XINCREF(kwappl); } else { kwappl = PyDict_Copy(pto->kw); if (kwappl == NULL) { @@ -289,25 +285,45 @@ partial_setstate(partialobject *pto, PyObject *state) { PyObject *fn, *fnargs, *kw, *dict; - if (!PyArg_ParseTuple(state, "OOOO", - &fn, &fnargs, &kw, &dict)) + + if (!PyTuple_Check(state) || + !PyArg_ParseTuple(state, "OOOO", &fn, &fnargs, &kw, &dict) || + !PyCallable_Check(fn) || + !PyTuple_Check(fnargs) || + (kw != Py_None && !PyDict_Check(kw))) + { + PyErr_SetString(PyExc_TypeError, "invalid partial state"); return NULL; - Py_XDECREF(pto->fn); - Py_XDECREF(pto->args); - Py_XDECREF(pto->kw); - Py_XDECREF(pto->dict); - pto->fn = fn; - pto->args = fnargs; - pto->kw = kw; - if (dict != Py_None) { - pto->dict = dict; - Py_INCREF(dict); - } else { - pto->dict = NULL; } + + if(!PyTuple_CheckExact(fnargs)) + fnargs = PySequence_Tuple(fnargs); + else + Py_INCREF(fnargs); + if (fnargs == NULL) + return NULL; + + if (kw == Py_None) + kw = PyDict_New(); + else if(!PyDict_CheckExact(kw)) + kw = PyDict_Copy(kw); + else + Py_INCREF(kw); + if (kw == NULL) { + Py_DECREF(fnargs); + return NULL; + } + Py_INCREF(fn); - Py_INCREF(fnargs); - Py_INCREF(kw); + if (dict == Py_None) + dict = NULL; + else + Py_INCREF(dict); + + Py_SETREF(pto->fn, fn); + Py_SETREF(pto->args, fnargs); + Py_SETREF(pto->kw, kw); + Py_SETREF(pto->dict, dict); Py_RETURN_NONE; } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Feb 2 11:46:31 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 02 Feb 2016 16:46:31 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325945=3A_Fixed_bugs_in_functools=2Epartial=2E?= Message-ID: <20160202164622.77427.44084@psf.io> https://hg.python.org/cpython/rev/33109176538d changeset: 100148:33109176538d parent: 100146:03708c680eca parent: 100147:542b5744ddc3 user: Serhiy Storchaka date: Tue Feb 02 18:45:47 2016 +0200 summary: Issue #25945: Fixed bugs in functools.partial. Fixed a crash when unpickle the functools.partial object with wrong state. Fixed a leak in failed functools.partial constructor. "args" and "keywords" attributes of functools.partial have now always types tuple and dict correspondingly. files: Lib/test/test_functools.py | 93 ++++++++++++++++- Misc/NEWS | 5 + Modules/_functoolsmodule.c | 128 +++++++++++++----------- 3 files changed, 160 insertions(+), 66 deletions(-) diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -30,6 +30,16 @@ """ return the signature of a partial object """ return (part.func, part.args, part.keywords, part.__dict__) +class MyTuple(tuple): + pass + +class BadTuple(tuple): + def __add__(self, other): + return list(self) + list(other) + +class MyDict(dict): + pass + class TestPartial: @@ -208,11 +218,84 @@ for kwargs_repr in kwargs_reprs]) def test_pickle(self): - f = self.partial(signature, 'asdf', bar=True) - f.add_something_to__dict__ = True + f = self.partial(signature, ['asdf'], bar=[True]) + f.attr = [] for proto in range(pickle.HIGHEST_PROTOCOL + 1): f_copy = pickle.loads(pickle.dumps(f, proto)) - self.assertEqual(signature(f), signature(f_copy)) + self.assertEqual(signature(f_copy), signature(f)) + + def test_copy(self): + f = self.partial(signature, ['asdf'], bar=[True]) + f.attr = [] + f_copy = copy.copy(f) + self.assertEqual(signature(f_copy), signature(f)) + self.assertIs(f_copy.attr, f.attr) + self.assertIs(f_copy.args, f.args) + self.assertIs(f_copy.keywords, f.keywords) + + def test_deepcopy(self): + f = self.partial(signature, ['asdf'], bar=[True]) + f.attr = [] + f_copy = copy.deepcopy(f) + self.assertEqual(signature(f_copy), signature(f)) + self.assertIsNot(f_copy.attr, f.attr) + self.assertIsNot(f_copy.args, f.args) + self.assertIsNot(f_copy.args[0], f.args[0]) + self.assertIsNot(f_copy.keywords, f.keywords) + self.assertIsNot(f_copy.keywords['bar'], f.keywords['bar']) + + def test_setstate(self): + f = self.partial(signature) + f.__setstate__((capture, (1,), dict(a=10), dict(attr=[]))) + self.assertEqual(signature(f), + (capture, (1,), dict(a=10), dict(attr=[]))) + self.assertEqual(f(2, b=20), ((1, 2), {'a': 10, 'b': 20})) + + f.__setstate__((capture, (1,), dict(a=10), None)) + self.assertEqual(signature(f), (capture, (1,), dict(a=10), {})) + self.assertEqual(f(2, b=20), ((1, 2), {'a': 10, 'b': 20})) + + f.__setstate__((capture, (1,), None, None)) + #self.assertEqual(signature(f), (capture, (1,), {}, {})) + self.assertEqual(f(2, b=20), ((1, 2), {'b': 20})) + self.assertEqual(f(2), ((1, 2), {})) + self.assertEqual(f(), ((1,), {})) + + f.__setstate__((capture, (), {}, None)) + self.assertEqual(signature(f), (capture, (), {}, {})) + self.assertEqual(f(2, b=20), ((2,), {'b': 20})) + self.assertEqual(f(2), ((2,), {})) + self.assertEqual(f(), ((), {})) + + def test_setstate_errors(self): + f = self.partial(signature) + self.assertRaises(TypeError, f.__setstate__, (capture, (), {})) + self.assertRaises(TypeError, f.__setstate__, (capture, (), {}, {}, None)) + self.assertRaises(TypeError, f.__setstate__, [capture, (), {}, None]) + self.assertRaises(TypeError, f.__setstate__, (None, (), {}, None)) + self.assertRaises(TypeError, f.__setstate__, (capture, None, {}, None)) + self.assertRaises(TypeError, f.__setstate__, (capture, [], {}, None)) + self.assertRaises(TypeError, f.__setstate__, (capture, (), [], None)) + + def test_setstate_subclasses(self): + f = self.partial(signature) + f.__setstate__((capture, MyTuple((1,)), MyDict(a=10), None)) + s = signature(f) + self.assertEqual(s, (capture, (1,), dict(a=10), {})) + self.assertIs(type(s[1]), tuple) + self.assertIs(type(s[2]), dict) + r = f() + self.assertEqual(r, ((1,), {'a': 10})) + self.assertIs(type(r[0]), tuple) + self.assertIs(type(r[1]), dict) + + f.__setstate__((capture, BadTuple((1,)), {}, None)) + s = signature(f) + self.assertEqual(s, (capture, (1,), {}, {})) + self.assertIs(type(s[1]), tuple) + r = f(2) + self.assertEqual(r, ((1, 2), {})) + self.assertIs(type(r[0]), tuple) # Issue 6083: Reference counting bug def test_setstate_refcount(self): @@ -229,9 +312,7 @@ raise IndexError f = self.partial(object) - self.assertRaisesRegex(SystemError, - "new style getargs format but argument is not a tuple", - f.__setstate__, BadSequence()) + self.assertRaises(TypeError, f.__setstate__, BadSequence()) class TestPartialPy(TestPartial, unittest.TestCase): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -166,6 +166,11 @@ Library ------- +- Issue #25945: Fixed a crash when unpickle the functools.partial object with + wrong state. Fixed a leak in failed functools.partial constructor. + "args" and "keywords" attributes of functools.partial have now always types + tuple and dict correspondingly. + - Issue #26202: copy.deepcopy() now correctly copies range() objects with non-atomic attributes. diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -34,7 +34,7 @@ return NULL; } - pargs = pkw = Py_None; + pargs = pkw = NULL; func = PyTuple_GET_ITEM(args, 0); if (Py_TYPE(func) == &partial_type && type == &partial_type) { partialobject *part = (partialobject *)func; @@ -42,6 +42,8 @@ pargs = part->args; pkw = part->kw; func = part->fn; + assert(PyTuple_Check(pargs)); + assert(PyDict_Check(pkw)); } } if (!PyCallable_Check(func)) { @@ -60,12 +62,10 @@ nargs = PyTuple_GetSlice(args, 1, PY_SSIZE_T_MAX); if (nargs == NULL) { - pto->args = NULL; - pto->kw = NULL; Py_DECREF(pto); return NULL; } - if (pargs == Py_None || PyTuple_GET_SIZE(pargs) == 0) { + if (pargs == NULL || PyTuple_GET_SIZE(pargs) == 0) { pto->args = nargs; Py_INCREF(nargs); } @@ -76,47 +76,36 @@ else { pto->args = PySequence_Concat(pargs, nargs); if (pto->args == NULL) { - pto->kw = NULL; + Py_DECREF(nargs); Py_DECREF(pto); return NULL; } + assert(PyTuple_Check(pto->args)); } Py_DECREF(nargs); - if (kw != NULL) { - if (pkw == Py_None) { - pto->kw = PyDict_Copy(kw); + if (pkw == NULL || PyDict_Size(pkw) == 0) { + if (kw == NULL) { + pto->kw = PyDict_New(); } else { - pto->kw = PyDict_Copy(pkw); - if (pto->kw != NULL) { - if (PyDict_Merge(pto->kw, kw, 1) != 0) { - Py_DECREF(pto); - return NULL; - } - } - } - if (pto->kw == NULL) { - Py_DECREF(pto); - return NULL; + Py_INCREF(kw); + pto->kw = kw; } } else { - if (pkw == Py_None) { - pto->kw = PyDict_New(); - if (pto->kw == NULL) { + pto->kw = PyDict_Copy(pkw); + if (kw != NULL && pto->kw != NULL) { + if (PyDict_Merge(pto->kw, kw, 1) != 0) { Py_DECREF(pto); return NULL; } } - else { - pto->kw = pkw; - Py_INCREF(pkw); - } } - - pto->weakreflist = NULL; - pto->dict = NULL; + if (pto->kw == NULL) { + Py_DECREF(pto); + return NULL; + } return (PyObject *)pto; } @@ -138,11 +127,11 @@ partial_call(partialobject *pto, PyObject *args, PyObject *kw) { PyObject *ret; - PyObject *argappl = NULL, *kwappl = NULL; + PyObject *argappl, *kwappl; assert (PyCallable_Check(pto->fn)); assert (PyTuple_Check(pto->args)); - assert (pto->kw == Py_None || PyDict_Check(pto->kw)); + assert (PyDict_Check(pto->kw)); if (PyTuple_GET_SIZE(pto->args) == 0) { argappl = args; @@ -154,11 +143,12 @@ argappl = PySequence_Concat(pto->args, args); if (argappl == NULL) return NULL; + assert(PyTuple_Check(argappl)); } - if (pto->kw == Py_None) { + if (PyDict_Size(pto->kw) == 0) { kwappl = kw; - Py_XINCREF(kw); + Py_XINCREF(kwappl); } else { kwappl = PyDict_Copy(pto->kw); if (kwappl == NULL) { @@ -217,6 +207,7 @@ PyObject *arglist; PyObject *tmp; Py_ssize_t i, n; + PyObject *key, *value; arglist = PyUnicode_FromString(""); if (arglist == NULL) { @@ -234,17 +225,14 @@ arglist = tmp; } /* Pack keyword arguments */ - assert (pto->kw == Py_None || PyDict_Check(pto->kw)); - if (pto->kw != Py_None) { - PyObject *key, *value; - for (i = 0; PyDict_Next(pto->kw, &i, &key, &value);) { - tmp = PyUnicode_FromFormat("%U, %U=%R", arglist, - key, value); - Py_DECREF(arglist); - if (tmp == NULL) - return NULL; - arglist = tmp; - } + assert (PyDict_Check(pto->kw)); + for (i = 0; PyDict_Next(pto->kw, &i, &key, &value);) { + tmp = PyUnicode_FromFormat("%U, %U=%R", arglist, + key, value); + Py_DECREF(arglist); + if (tmp == NULL) + return NULL; + arglist = tmp; } result = PyUnicode_FromFormat("%s(%R%U)", Py_TYPE(pto)->tp_name, pto->fn, arglist); @@ -271,25 +259,45 @@ partial_setstate(partialobject *pto, PyObject *state) { PyObject *fn, *fnargs, *kw, *dict; - if (!PyArg_ParseTuple(state, "OOOO", - &fn, &fnargs, &kw, &dict)) + + if (!PyTuple_Check(state) || + !PyArg_ParseTuple(state, "OOOO", &fn, &fnargs, &kw, &dict) || + !PyCallable_Check(fn) || + !PyTuple_Check(fnargs) || + (kw != Py_None && !PyDict_Check(kw))) + { + PyErr_SetString(PyExc_TypeError, "invalid partial state"); return NULL; - Py_XDECREF(pto->fn); - Py_XDECREF(pto->args); - Py_XDECREF(pto->kw); - Py_XDECREF(pto->dict); - pto->fn = fn; - pto->args = fnargs; - pto->kw = kw; - if (dict != Py_None) { - pto->dict = dict; - Py_INCREF(dict); - } else { - pto->dict = NULL; } + + if(!PyTuple_CheckExact(fnargs)) + fnargs = PySequence_Tuple(fnargs); + else + Py_INCREF(fnargs); + if (fnargs == NULL) + return NULL; + + if (kw == Py_None) + kw = PyDict_New(); + else if(!PyDict_CheckExact(kw)) + kw = PyDict_Copy(kw); + else + Py_INCREF(kw); + if (kw == NULL) { + Py_DECREF(fnargs); + return NULL; + } + Py_INCREF(fn); - Py_INCREF(fnargs); - Py_INCREF(kw); + if (dict == Py_None) + dict = NULL; + else + Py_INCREF(dict); + + Py_SETREF(pto->fn, fn); + Py_SETREF(pto->args, fnargs); + Py_SETREF(pto->kw, kw); + Py_SETREF(pto->dict, dict); Py_RETURN_NONE; } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Feb 2 11:46:26 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 02 Feb 2016 16:46:26 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1OTQ1?= =?utf-8?q?=3A_Fixed_bugs_in_functools=2Epartial=2E?= Message-ID: <20160202164622.4745.18429@psf.io> https://hg.python.org/cpython/rev/542b5744ddc3 changeset: 100147:542b5744ddc3 branch: 3.5 parent: 100145:950e0bfe94ae user: Serhiy Storchaka date: Tue Feb 02 18:45:17 2016 +0200 summary: Issue #25945: Fixed bugs in functools.partial. Fixed a crash when unpickle the functools.partial object with wrong state. Fixed a leak in failed functools.partial constructor. "args" and "keywords" attributes of functools.partial have now always types tuple and dict correspondingly. files: Lib/test/test_functools.py | 93 ++++++++++++++++- Misc/NEWS | 5 + Modules/_functoolsmodule.c | 128 +++++++++++++----------- 3 files changed, 160 insertions(+), 66 deletions(-) diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -30,6 +30,16 @@ """ return the signature of a partial object """ return (part.func, part.args, part.keywords, part.__dict__) +class MyTuple(tuple): + pass + +class BadTuple(tuple): + def __add__(self, other): + return list(self) + list(other) + +class MyDict(dict): + pass + class TestPartial: @@ -208,11 +218,84 @@ for kwargs_repr in kwargs_reprs]) def test_pickle(self): - f = self.partial(signature, 'asdf', bar=True) - f.add_something_to__dict__ = True + f = self.partial(signature, ['asdf'], bar=[True]) + f.attr = [] for proto in range(pickle.HIGHEST_PROTOCOL + 1): f_copy = pickle.loads(pickle.dumps(f, proto)) - self.assertEqual(signature(f), signature(f_copy)) + self.assertEqual(signature(f_copy), signature(f)) + + def test_copy(self): + f = self.partial(signature, ['asdf'], bar=[True]) + f.attr = [] + f_copy = copy.copy(f) + self.assertEqual(signature(f_copy), signature(f)) + self.assertIs(f_copy.attr, f.attr) + self.assertIs(f_copy.args, f.args) + self.assertIs(f_copy.keywords, f.keywords) + + def test_deepcopy(self): + f = self.partial(signature, ['asdf'], bar=[True]) + f.attr = [] + f_copy = copy.deepcopy(f) + self.assertEqual(signature(f_copy), signature(f)) + self.assertIsNot(f_copy.attr, f.attr) + self.assertIsNot(f_copy.args, f.args) + self.assertIsNot(f_copy.args[0], f.args[0]) + self.assertIsNot(f_copy.keywords, f.keywords) + self.assertIsNot(f_copy.keywords['bar'], f.keywords['bar']) + + def test_setstate(self): + f = self.partial(signature) + f.__setstate__((capture, (1,), dict(a=10), dict(attr=[]))) + self.assertEqual(signature(f), + (capture, (1,), dict(a=10), dict(attr=[]))) + self.assertEqual(f(2, b=20), ((1, 2), {'a': 10, 'b': 20})) + + f.__setstate__((capture, (1,), dict(a=10), None)) + self.assertEqual(signature(f), (capture, (1,), dict(a=10), {})) + self.assertEqual(f(2, b=20), ((1, 2), {'a': 10, 'b': 20})) + + f.__setstate__((capture, (1,), None, None)) + #self.assertEqual(signature(f), (capture, (1,), {}, {})) + self.assertEqual(f(2, b=20), ((1, 2), {'b': 20})) + self.assertEqual(f(2), ((1, 2), {})) + self.assertEqual(f(), ((1,), {})) + + f.__setstate__((capture, (), {}, None)) + self.assertEqual(signature(f), (capture, (), {}, {})) + self.assertEqual(f(2, b=20), ((2,), {'b': 20})) + self.assertEqual(f(2), ((2,), {})) + self.assertEqual(f(), ((), {})) + + def test_setstate_errors(self): + f = self.partial(signature) + self.assertRaises(TypeError, f.__setstate__, (capture, (), {})) + self.assertRaises(TypeError, f.__setstate__, (capture, (), {}, {}, None)) + self.assertRaises(TypeError, f.__setstate__, [capture, (), {}, None]) + self.assertRaises(TypeError, f.__setstate__, (None, (), {}, None)) + self.assertRaises(TypeError, f.__setstate__, (capture, None, {}, None)) + self.assertRaises(TypeError, f.__setstate__, (capture, [], {}, None)) + self.assertRaises(TypeError, f.__setstate__, (capture, (), [], None)) + + def test_setstate_subclasses(self): + f = self.partial(signature) + f.__setstate__((capture, MyTuple((1,)), MyDict(a=10), None)) + s = signature(f) + self.assertEqual(s, (capture, (1,), dict(a=10), {})) + self.assertIs(type(s[1]), tuple) + self.assertIs(type(s[2]), dict) + r = f() + self.assertEqual(r, ((1,), {'a': 10})) + self.assertIs(type(r[0]), tuple) + self.assertIs(type(r[1]), dict) + + f.__setstate__((capture, BadTuple((1,)), {}, None)) + s = signature(f) + self.assertEqual(s, (capture, (1,), {}, {})) + self.assertIs(type(s[1]), tuple) + r = f(2) + self.assertEqual(r, ((1, 2), {})) + self.assertIs(type(r[0]), tuple) # Issue 6083: Reference counting bug def test_setstate_refcount(self): @@ -229,9 +312,7 @@ raise IndexError f = self.partial(object) - self.assertRaisesRegex(SystemError, - "new style getargs format but argument is not a tuple", - f.__setstate__, BadSequence()) + self.assertRaises(TypeError, f.__setstate__, BadSequence()) class TestPartialPy(TestPartial, unittest.TestCase): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -70,6 +70,11 @@ Library ------- +- Issue #25945: Fixed a crash when unpickle the functools.partial object with + wrong state. Fixed a leak in failed functools.partial constructor. + "args" and "keywords" attributes of functools.partial have now always types + tuple and dict correspondingly. + - Issue #26202: copy.deepcopy() now correctly copies range() objects with non-atomic attributes. diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -34,7 +34,7 @@ return NULL; } - pargs = pkw = Py_None; + pargs = pkw = NULL; func = PyTuple_GET_ITEM(args, 0); if (Py_TYPE(func) == &partial_type && type == &partial_type) { partialobject *part = (partialobject *)func; @@ -42,6 +42,8 @@ pargs = part->args; pkw = part->kw; func = part->fn; + assert(PyTuple_Check(pargs)); + assert(PyDict_Check(pkw)); } } if (!PyCallable_Check(func)) { @@ -60,12 +62,10 @@ nargs = PyTuple_GetSlice(args, 1, PY_SSIZE_T_MAX); if (nargs == NULL) { - pto->args = NULL; - pto->kw = NULL; Py_DECREF(pto); return NULL; } - if (pargs == Py_None || PyTuple_GET_SIZE(pargs) == 0) { + if (pargs == NULL || PyTuple_GET_SIZE(pargs) == 0) { pto->args = nargs; Py_INCREF(nargs); } @@ -76,47 +76,36 @@ else { pto->args = PySequence_Concat(pargs, nargs); if (pto->args == NULL) { - pto->kw = NULL; + Py_DECREF(nargs); Py_DECREF(pto); return NULL; } + assert(PyTuple_Check(pto->args)); } Py_DECREF(nargs); - if (kw != NULL) { - if (pkw == Py_None) { - pto->kw = PyDict_Copy(kw); + if (pkw == NULL || PyDict_Size(pkw) == 0) { + if (kw == NULL) { + pto->kw = PyDict_New(); } else { - pto->kw = PyDict_Copy(pkw); - if (pto->kw != NULL) { - if (PyDict_Merge(pto->kw, kw, 1) != 0) { - Py_DECREF(pto); - return NULL; - } - } - } - if (pto->kw == NULL) { - Py_DECREF(pto); - return NULL; + Py_INCREF(kw); + pto->kw = kw; } } else { - if (pkw == Py_None) { - pto->kw = PyDict_New(); - if (pto->kw == NULL) { + pto->kw = PyDict_Copy(pkw); + if (kw != NULL && pto->kw != NULL) { + if (PyDict_Merge(pto->kw, kw, 1) != 0) { Py_DECREF(pto); return NULL; } } - else { - pto->kw = pkw; - Py_INCREF(pkw); - } } - - pto->weakreflist = NULL; - pto->dict = NULL; + if (pto->kw == NULL) { + Py_DECREF(pto); + return NULL; + } return (PyObject *)pto; } @@ -138,11 +127,11 @@ partial_call(partialobject *pto, PyObject *args, PyObject *kw) { PyObject *ret; - PyObject *argappl = NULL, *kwappl = NULL; + PyObject *argappl, *kwappl; assert (PyCallable_Check(pto->fn)); assert (PyTuple_Check(pto->args)); - assert (pto->kw == Py_None || PyDict_Check(pto->kw)); + assert (PyDict_Check(pto->kw)); if (PyTuple_GET_SIZE(pto->args) == 0) { argappl = args; @@ -154,11 +143,12 @@ argappl = PySequence_Concat(pto->args, args); if (argappl == NULL) return NULL; + assert(PyTuple_Check(argappl)); } - if (pto->kw == Py_None) { + if (PyDict_Size(pto->kw) == 0) { kwappl = kw; - Py_XINCREF(kw); + Py_XINCREF(kwappl); } else { kwappl = PyDict_Copy(pto->kw); if (kwappl == NULL) { @@ -217,6 +207,7 @@ PyObject *arglist; PyObject *tmp; Py_ssize_t i, n; + PyObject *key, *value; arglist = PyUnicode_FromString(""); if (arglist == NULL) { @@ -234,17 +225,14 @@ arglist = tmp; } /* Pack keyword arguments */ - assert (pto->kw == Py_None || PyDict_Check(pto->kw)); - if (pto->kw != Py_None) { - PyObject *key, *value; - for (i = 0; PyDict_Next(pto->kw, &i, &key, &value);) { - tmp = PyUnicode_FromFormat("%U, %U=%R", arglist, - key, value); - Py_DECREF(arglist); - if (tmp == NULL) - return NULL; - arglist = tmp; - } + assert (PyDict_Check(pto->kw)); + for (i = 0; PyDict_Next(pto->kw, &i, &key, &value);) { + tmp = PyUnicode_FromFormat("%U, %U=%R", arglist, + key, value); + Py_DECREF(arglist); + if (tmp == NULL) + return NULL; + arglist = tmp; } result = PyUnicode_FromFormat("%s(%R%U)", Py_TYPE(pto)->tp_name, pto->fn, arglist); @@ -271,25 +259,45 @@ partial_setstate(partialobject *pto, PyObject *state) { PyObject *fn, *fnargs, *kw, *dict; - if (!PyArg_ParseTuple(state, "OOOO", - &fn, &fnargs, &kw, &dict)) + + if (!PyTuple_Check(state) || + !PyArg_ParseTuple(state, "OOOO", &fn, &fnargs, &kw, &dict) || + !PyCallable_Check(fn) || + !PyTuple_Check(fnargs) || + (kw != Py_None && !PyDict_Check(kw))) + { + PyErr_SetString(PyExc_TypeError, "invalid partial state"); return NULL; - Py_XDECREF(pto->fn); - Py_XDECREF(pto->args); - Py_XDECREF(pto->kw); - Py_XDECREF(pto->dict); - pto->fn = fn; - pto->args = fnargs; - pto->kw = kw; - if (dict != Py_None) { - pto->dict = dict; - Py_INCREF(dict); - } else { - pto->dict = NULL; } + + if(!PyTuple_CheckExact(fnargs)) + fnargs = PySequence_Tuple(fnargs); + else + Py_INCREF(fnargs); + if (fnargs == NULL) + return NULL; + + if (kw == Py_None) + kw = PyDict_New(); + else if(!PyDict_CheckExact(kw)) + kw = PyDict_Copy(kw); + else + Py_INCREF(kw); + if (kw == NULL) { + Py_DECREF(fnargs); + return NULL; + } + Py_INCREF(fn); - Py_INCREF(fnargs); - Py_INCREF(kw); + if (dict == Py_None) + dict = NULL; + else + Py_INCREF(dict); + + Py_SETREF(pto->fn, fn); + Py_SETREF(pto->args, fnargs); + Py_SETREF(pto->kw, kw); + Py_SETREF(pto->dict, dict); Py_RETURN_NONE; } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Feb 2 18:05:34 2016 From: python-checkins at python.org (zach.ware) Date: Tue, 02 Feb 2016 23:05:34 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogRml4IHR5cG8u?= Message-ID: <20160202230533.2659.91912@psf.io> https://hg.python.org/cpython/rev/e4eb2a8fdb7c changeset: 100150:e4eb2a8fdb7c branch: 3.5 parent: 100147:542b5744ddc3 user: Zachary Ware date: Tue Feb 02 17:04:41 2016 -0600 summary: Fix typo. Reported by Jon Tetlak on docs@ files: Doc/library/typing.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -20,7 +20,7 @@ def greeting(name: str) -> str: return 'Hello ' + name -In the function ``greeting``, the argument ``name`` is expected to by of type +In the function ``greeting``, the argument ``name`` is expected to be of type :class:`str` and the return type :class:`str`. Subtypes are accepted as arguments. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Feb 2 18:05:36 2016 From: python-checkins at python.org (zach.ware) Date: Tue, 02 Feb 2016 23:05:36 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Merge_with_3=2E5?= Message-ID: <20160202230534.89766.79979@psf.io> https://hg.python.org/cpython/rev/5873cfb42ebe changeset: 100151:5873cfb42ebe parent: 100148:33109176538d parent: 100150:e4eb2a8fdb7c user: Zachary Ware date: Tue Feb 02 17:04:56 2016 -0600 summary: Merge with 3.5 files: Doc/library/typing.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -20,7 +20,7 @@ def greeting(name: str) -> str: return 'Hello ' + name -In the function ``greeting``, the argument ``name`` is expected to by of type +In the function ``greeting``, the argument ``name`` is expected to be of type :class:`str` and the return type :class:`str`. Subtypes are accepted as arguments. -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Wed Feb 3 04:50:55 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Wed, 03 Feb 2016 09:50:55 +0000 Subject: [Python-checkins] Daily reference leaks (5873cfb42ebe): sum=4 Message-ID: <20160203095055.16560.87031@psf.io> results for 5873cfb42ebe on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogT_C_La', '--timeout', '7200'] From python-checkins at python.org Wed Feb 3 09:21:37 2016 From: python-checkins at python.org (victor.stinner) Date: Wed, 03 Feb 2016 14:21:37 +0000 Subject: [Python-checkins] =?utf-8?q?benchmarks=3A_Add_--affinity_command_?= =?utf-8?q?line_option?= Message-ID: <20160203142136.130861.82449@psf.io> https://hg.python.org/benchmarks/rev/a97acad3bbf7 changeset: 238:a97acad3bbf7 user: Victor Stinner date: Wed Feb 03 15:20:02 2016 +0100 summary: Add --affinity command line option If used, run the benchmark using taskset to pin the process to a set of CPU cores to reduce context switching. See taskset manual page for more information. Patch written by Florin Papa. files: perf.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 40 insertions(+), 0 deletions(-) diff --git a/perf.py b/perf.py --- a/perf.py +++ b/perf.py @@ -88,6 +88,30 @@ info = logging.info +def check_taskset(): + """Check the taskset command is available. + + Taskset specifies CPU affinity for a given workload, meaning that we can + run the benchmarks on a given core to minimize run to run variation. + + Return None on success. Return an error message on error. + """ + with open(os.devnull, "wb") as dev_null: + # Try to pin a temporary Python process to CPU #0 + command = ["taskset", "--cpu-list", "0", + sys.executable, "-c", "pass"] + try: + exitcode = subprocess.call(command, + stdout=dev_null, stderr=dev_null) + except OSError as exc: + return ("Command taskset not found: %s" % exc) + + if exitcode != 0: + return ("Command taskset failed with exit code %s" % exitcode) + + return None + + def interpreter_version(python, _cache={}): """Return the interpreter version for the given Python interpreter. *python* is the base command (as a list) to execute the interpreter. @@ -2557,6 +2581,11 @@ " Unladen Swallow binaries. This is useful for" " examining many benchmarks for optimization" " effects.")) + parser.add_option("--affinity", metavar="CPU_LIST", default=None, + help=("Specify CPU affinity for benchmark runs. This " + "way, benchmarks can be forced to run on a given " + "CPU to minimize run to run variation. This uses " + "the taskset command.")) options, args = parser.parse_args(argv) @@ -2575,6 +2604,17 @@ base_cmd_prefix = [base] + base_args changed_cmd_prefix = [changed] + changed_args + if options.affinity: + err_msg = check_taskset() + if err_msg: + print("ERROR: Option --affinity not available. %s" % err_msg, + file=sys.stderr) + sys.exit(1) + + taskset_prefix = ["taskset", "--cpu-list", options.affinity] + base_cmd_prefix = taskset_prefix + base_cmd_prefix + changed_cmd_prefix = taskset_prefix + changed_cmd_prefix + logging.basicConfig(level=logging.INFO) if options.track_memory: -- Repository URL: https://hg.python.org/benchmarks From lp_benchmark_robot at intel.com Wed Feb 3 12:08:51 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Wed, 3 Feb 2016 17:08:51 +0000 Subject: [Python-checkins] UGLY Benchmark Results for Python Default 2016-02-03 Message-ID: <46d8e686-f323-4097-b8f7-90321c4138ae@irsmsx153.ger.corp.intel.com> Results for project Python default, build date 2016-02-03 03:06:10 +0000 commit: 5873cfb42ebe previous commit: 3b211ee66b82 revision date: 2016-02-02 23:04:56 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.32% -1.69% 8.32% 15.47% :-| pybench 0.10% 0.02% -1.15% 4.91% :-( regex_v8 2.74% -0.41% -3.70% 4.65% :-| nbody 0.86% -0.77% -0.32% 8.81% :-( json_dump_v2 0.18% -2.94% -4.55% 11.88% :-) normal_startup 1.14% 3.12% 3.49% 5.27% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/ugly-benchmark-results-for-python-default-2016-02-03/ Note: Benchmark results are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Wed Feb 3 12:09:34 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Wed, 3 Feb 2016 17:09:34 +0000 Subject: [Python-checkins] UGLY Benchmark Results for Python 2.7 2016-02-03 Message-ID: Results for project Python 2.7, build date 2016-02-03 03:57:26 +0000 commit: 628ce2975e29 previous commit: 6f7b2b7a029a revision date: 2016-02-02 16:45:59 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dc from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.14% 0.50% 2.89% 4.28% :-) pybench 0.12% -0.38% 5.85% 5.30% :-( regex_v8 0.55% -0.04% -2.45% 11.14% :-) nbody 0.17% -0.06% 8.05% -0.17% :-) json_dump_v2 0.23% -1.05% 3.66% 9.83% :-) normal_startup 1.25% 4.47% -0.28% -2.53% :-| ssbench 0.22% 0.54% 1.27% 1.83% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/ugly-benchmark-results-for-python-2-7-2016-02-03/ Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Wed Feb 3 15:19:46 2016 From: python-checkins at python.org (zach.ware) Date: Wed, 03 Feb 2016 20:19:46 +0000 Subject: [Python-checkins] =?utf-8?q?benchmarks=3A_Issue_=2325774=3A_Add_r?= =?utf-8?q?aw_mode_to_perf=2Epy=2E?= Message-ID: <20160203201945.130847.93721@psf.io> https://hg.python.org/benchmarks/rev/9923b81a1d34 changeset: 239:9923b81a1d34 user: Zachary Ware date: Wed Feb 03 14:19:18 2016 -0600 summary: Issue #25774: Add raw mode to perf.py. Raw mode runs the benchmark(s) on a single interpreter and returns the result from main() as a dict. files: perf.py | 75 ++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 71 insertions(+), 4 deletions(-) diff --git a/perf.py b/perf.py --- a/perf.py +++ b/perf.py @@ -818,6 +818,8 @@ try: changed_data = benchmark_function(changed_python, options, *args, **kwargs) + if options.raw: + return FormatRawData(changed_data, options) base_data = benchmark_function(base_python, options, *args, **kwargs) except subprocess.CalledProcessError as e: @@ -1113,6 +1115,33 @@ std_changed, delta_std, significant, timeline_link) +class RawBenchmarkResult(dict): + + def __init__(self, average, min=None, max=None, std_dev=None): + self['average'] = average + if min is not None: + self['min'] = min + if max is not None: + self['max'] = max + if std_dev is not None: + self['std_dev'] = std_dev + + def __str__(self): + return '\n'.join('%s: %s' % i for i in sorted(self.items())) + + +def FormatRawData(bm_data, options): + # XXX implement track_memory handling? + times = sorted(bm_data.runtimes) + average = avg(times) + mn = mx = std = None + if len(times) > 1: + mn = times[0] + mx = times[-1] + std = SampleStdDev(times) + return RawBenchmarkResult(average, mn, mx, std) + + def CompareBenchmarkData(base_data, exp_data, options): """Compare performance and memory usage. @@ -1665,6 +1694,8 @@ try: changed_data = MeasureSpitfire(changed_python, options, spitfire_env, extra_args) + if options.raw: + return FormatRawData(changed_data, options) base_data = MeasureSpitfire(base_python, options, spitfire_env, extra_args) except subprocess.CalledProcessError as e: @@ -2069,6 +2100,8 @@ opts = [] changed_data = MeasureStartup(changed_python, opts, num_loops, options.track_memory, options.inherit_env) + if options.raw: + return FormatRawData(changed_data, options) base_data = MeasureStartup(base_python, opts, num_loops, options.track_memory, options.inherit_env) @@ -2086,6 +2119,8 @@ opts = ["-S"] changed_data = MeasureStartup(changed_python, opts, num_loops, options.track_memory, options.inherit_env) + if options.raw: + return FormatRawData(changed_data, options) base_data = MeasureStartup(base_python, opts, num_loops, options.track_memory, options.inherit_env) @@ -2370,6 +2405,8 @@ SLOW_BENCHMARKS = ["hexiom2"] +NON_RAW_BENCHMARKS = ["pybench"] + def _ExpandBenchmarkName(bm_name, bench_groups): """Recursively expand name benchmark names. @@ -2389,7 +2426,7 @@ yield bm_name -def ParseBenchmarksOption(benchmarks_opt, bench_groups, fast=False): +def ParseBenchmarksOption(benchmarks_opt, bench_groups, fast=False, raw=False): """Parses and verifies the --benchmarks option. Args: @@ -2431,6 +2468,12 @@ logging.info("Skipping slow benchmarks (%s) in fast mode", ', '.join(sorted(to_skip))) should_run = should_run - to_skip + if raw: + to_skip = should_run & set(NON_RAW_BENCHMARKS) + if to_skip: + logging.info("Skipping raw-incompatible benchmarks (%s) " + "in raw mode", ', '.join(sorted(to_skip))) + should_run = should_run - to_skip return should_run @@ -2581,6 +2624,10 @@ " Unladen Swallow binaries. This is useful for" " examining many benchmarks for optimization" " effects.")) + parser.add_option("--raw", action="store_true", + help="Run the benchmarks on only one interpreter and " + "return the timing information for each benchmark. " + "Provide only baseline_python, not changed_python.") parser.add_option("--affinity", metavar="CPU_LIST", default=None, help=("Specify CPU affinity for benchmark runs. This " "way, benchmarks can be forced to run on a given " @@ -2589,9 +2636,13 @@ options, args = parser.parse_args(argv) - if len(args) != 2: + expected = 1 if options.raw else 2 + if len(args) != expected: parser.error("incorrect number of arguments") - base, changed = args + if expected == 1: + base = changed = args[0] + else: + base, changed = args options.base_binary = base options.changed_binary = changed @@ -2601,6 +2652,16 @@ options.experiment_label = options.changed_binary base_args, changed_args = ParsePythonArgsOption(options.args) + if options.raw: + if base_args != changed_args: + parser.error('provide args for only one interpreter in raw mode') + if options.track_memory: + # XXX this might be worth fixing someday? + parser.error('raw mode is not compatible with memory tracking') + if options.diff_instrumentation: + parser.error('raw mode is not compatible with instrumentation') + if options.csv: + parser.error('raw mode does not support csv output') base_cmd_prefix = [base] + base_args changed_cmd_prefix = [changed] + changed_args @@ -2633,7 +2694,7 @@ info("Automatically selected timer: %s", options.timer) should_run = ParseBenchmarksOption(options.benchmarks, bench_groups, - options.fast) + options.fast, options.raw) should_run = FilterBenchmarks(should_run, bench_funcs, base_cmd_prefix, changed_cmd_prefix) @@ -2653,6 +2714,12 @@ print("Report on %s" % " ".join(platform.uname())) if multiprocessing: print("Total CPU cores:", multiprocessing.cpu_count()) + if options.raw: + for name, result in results: + print() + print("###", name, "###") + print(result) + return dict(results) hidden = [] if not options.verbose: shown = [] -- Repository URL: https://hg.python.org/benchmarks From python-checkins at python.org Wed Feb 3 23:09:06 2016 From: python-checkins at python.org (zach.ware) Date: Thu, 04 Feb 2016 04:09:06 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogUHl0aG9uIGZvciAu?= =?utf-8?q?NET_has_moved_to_Github=2E?= Message-ID: <20160204040906.11229.16354@psf.io> https://hg.python.org/cpython/rev/c8e43e55f2ce changeset: 100154:c8e43e55f2ce branch: 2.7 parent: 100149:628ce2975e29 user: Zachary Ware date: Wed Feb 03 22:05:46 2016 -0600 summary: Python for .NET has moved to Github. Reported by Denis Akhiyarov on docs@ files: Doc/reference/introduction.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/reference/introduction.rst b/Doc/reference/introduction.rst --- a/Doc/reference/introduction.rst +++ b/Doc/reference/introduction.rst @@ -59,7 +59,7 @@ This implementation actually uses the CPython implementation, but is a managed .NET application and makes .NET libraries available. It was created by Brian Lloyd. For more information, see the `Python for .NET home page - `_. + `_. IronPython An alternate Python for .NET. Unlike Python.NET, this is a complete Python -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Feb 3 23:09:06 2016 From: python-checkins at python.org (zach.ware) Date: Thu, 04 Feb 2016 04:09:06 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Merge_with_3=2E5?= Message-ID: <20160204040906.130843.25007@psf.io> https://hg.python.org/cpython/rev/5c19bdf5ba3f changeset: 100153:5c19bdf5ba3f parent: 100151:5873cfb42ebe parent: 100152:78f32effc87a user: Zachary Ware date: Wed Feb 03 22:07:08 2016 -0600 summary: Merge with 3.5 files: Doc/reference/introduction.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/reference/introduction.rst b/Doc/reference/introduction.rst --- a/Doc/reference/introduction.rst +++ b/Doc/reference/introduction.rst @@ -60,7 +60,7 @@ This implementation actually uses the CPython implementation, but is a managed .NET application and makes .NET libraries available. It was created by Brian Lloyd. For more information, see the `Python for .NET home page - `_. + `_. IronPython An alternate Python for .NET. Unlike Python.NET, this is a complete Python -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Feb 3 23:09:07 2016 From: python-checkins at python.org (zach.ware) Date: Thu, 04 Feb 2016 04:09:07 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogUHl0aG9uIGZvciAu?= =?utf-8?q?NET_has_moved_to_Github=2E?= Message-ID: <20160204040906.130847.53269@psf.io> https://hg.python.org/cpython/rev/78f32effc87a changeset: 100152:78f32effc87a branch: 3.5 parent: 100150:e4eb2a8fdb7c user: Zachary Ware date: Wed Feb 03 22:05:46 2016 -0600 summary: Python for .NET has moved to Github. Reported by Denis Akhiyarov on docs@ files: Doc/reference/introduction.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/reference/introduction.rst b/Doc/reference/introduction.rst --- a/Doc/reference/introduction.rst +++ b/Doc/reference/introduction.rst @@ -60,7 +60,7 @@ This implementation actually uses the CPython implementation, but is a managed .NET application and makes .NET libraries available. It was created by Brian Lloyd. For more information, see the `Python for .NET home page - `_. + `_. IronPython An alternate Python for .NET. Unlike Python.NET, this is a complete Python -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 4 01:25:20 2016 From: python-checkins at python.org (yury.selivanov) Date: Thu, 04 Feb 2016 06:25:20 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1NjYw?= =?utf-8?q?=3A_Fix_TAB_key_behaviour_in_REPL=2E?= Message-ID: <20160204062520.16570.59387@psf.io> https://hg.python.org/cpython/rev/64417e7a1760 changeset: 100155:64417e7a1760 branch: 3.5 parent: 100152:78f32effc87a user: Yury Selivanov date: Thu Feb 04 01:23:05 2016 -0500 summary: Issue #25660: Fix TAB key behaviour in REPL. files: Lib/rlcompleter.py | 4 +++- Misc/NEWS | 3 +++ 2 files changed, 6 insertions(+), 1 deletions(-) diff --git a/Lib/rlcompleter.py b/Lib/rlcompleter.py --- a/Lib/rlcompleter.py +++ b/Lib/rlcompleter.py @@ -75,7 +75,9 @@ if not text.strip(): if state == 0: - return '\t' + readline.insert_text('\t') + readline.redisplay() + return '' else: return None diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -67,6 +67,9 @@ - Issue #26171: Fix possible integer overflow and heap corruption in zipimporter.get_data(). +- Issue #25660: Fix TAB key behaviour in REPL with readline. + + Library ------- -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 4 01:25:20 2016 From: python-checkins at python.org (yury.selivanov) Date: Thu, 04 Feb 2016 06:25:20 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy41IChpc3N1ZSAjMjU2NjAp?= Message-ID: <20160204062520.8751.79567@psf.io> https://hg.python.org/cpython/rev/87dfadd61e0d changeset: 100156:87dfadd61e0d parent: 100153:5c19bdf5ba3f parent: 100155:64417e7a1760 user: Yury Selivanov date: Thu Feb 04 01:24:56 2016 -0500 summary: Merge 3.5 (issue #25660) files: Lib/rlcompleter.py | 4 +++- Misc/NEWS | 3 +++ 2 files changed, 6 insertions(+), 1 deletions(-) diff --git a/Lib/rlcompleter.py b/Lib/rlcompleter.py --- a/Lib/rlcompleter.py +++ b/Lib/rlcompleter.py @@ -75,7 +75,9 @@ if not text.strip(): if state == 0: - return '\t' + readline.insert_text('\t') + readline.redisplay() + return '' else: return None diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -163,6 +163,9 @@ - Issue #26171: Fix possible integer overflow and heap corruption in zipimporter.get_data(). +- Issue #25660: Fix TAB key behaviour in REPL with readline. + + Library ------- -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Thu Feb 4 04:44:12 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Thu, 04 Feb 2016 09:44:12 +0000 Subject: [Python-checkins] Daily reference leaks (5c19bdf5ba3f): sum=6 Message-ID: <20160204094412.42632.697@psf.io> results for 5c19bdf5ba3f on branch "default" -------------------------------------------- test_asyncio leaked [0, -17, 17] references, sum=0 test_asyncio leaked [0, -6, 8] memory blocks, sum=2 test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogXseUqh', '--timeout', '7200'] From python-checkins at python.org Thu Feb 4 05:46:25 2016 From: python-checkins at python.org (raymond.hettinger) Date: Thu, 04 Feb 2016 10:46:25 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Add_early-out_for_the_comm?= =?utf-8?q?on_case_where_kwds_is_NULL_=28gives_1=2E1=25_speedup=29=2E?= Message-ID: <20160204104624.2659.16592@psf.io> https://hg.python.org/cpython/rev/7fb10bdbe01b changeset: 100157:7fb10bdbe01b user: Raymond Hettinger date: Thu Feb 04 02:46:16 2016 -0800 summary: Add early-out for the common case where kwds is NULL (gives 1.1% speedup). files: Objects/setobject.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/setobject.c b/Objects/setobject.c --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -1088,7 +1088,8 @@ { PyObject *iterable = NULL, *result; - if (type == &PyFrozenSet_Type && !_PyArg_NoKeywords("frozenset()", kwds)) + if (kwds != NULL && type == &PyFrozenSet_Type + && !_PyArg_NoKeywords("frozenset()", kwds)) return NULL; if (!PyArg_UnpackTuple(args, type->tp_name, 0, 1, &iterable)) @@ -1130,7 +1131,7 @@ static PyObject * set_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - if (type == &PySet_Type && !_PyArg_NoKeywords("set()", kwds)) + if (kwds != NULL && type == &PySet_Type && !_PyArg_NoKeywords("set()", kwds)) return NULL; return make_new_set(type, NULL); -- Repository URL: https://hg.python.org/cpython From lp_benchmark_robot at intel.com Thu Feb 4 07:27:02 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Thu, 4 Feb 2016 12:27:02 +0000 Subject: [Python-checkins] UGLY Benchmark Results for Python Default 2016-02-04 Message-ID: <9d5dc883-0863-4ea3-9a65-88a0d977fea9@irsmsx101.ger.corp.intel.com> No new revisions. Here are the previous results: Results for project Python default, build date 2016-02-04 03:03:01 +0000 commit: 5873cfb42ebe previous commit: 3b211ee66b82 revision date: 2016-02-02 23:04:56 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.32% -1.69% 8.32% 15.47% :-| pybench 0.10% 0.02% -1.15% 4.91% :-( regex_v8 2.74% -0.41% -3.70% 4.65% :-| nbody 0.86% -0.77% -0.32% 8.81% :-( json_dump_v2 0.18% -2.94% -4.55% 11.88% :-) normal_startup 1.14% 3.12% 3.49% 5.27% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/ugly-benchmark-results-for-python-default-2016-02-04/ Note: Benchmark results are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Thu Feb 4 11:08:09 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Thu, 4 Feb 2016 16:08:09 +0000 Subject: [Python-checkins] BAD Benchmark Results for Python 2.7 2016-02-04 Message-ID: <80f2bdb6-84ab-4d57-8f36-9c57c1f0e968@irsmsx102.ger.corp.intel.com> Results for project Python 2.7, build date 2016-02-04 12:36:50 +0000 commit: c8e43e55f2ce previous commit: 628ce2975e29 revision date: 2016-02-04 04:05:46 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dc from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.23% 0.12% 3.00% 3.26% :-) pybench 0.17% 0.37% 6.20% 4.85% :-( regex_v8 0.57% -0.00% -2.45% 11.02% :-) nbody 0.13% 0.10% 8.14% 2.58% :-) json_dump_v2 0.16% -0.24% 3.43% 9.99% :-( normal_startup 1.94% -5.49% -5.79% 3.32% :-| ssbench 0.14% -0.40% 0.87% 1.33% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/bad-benchmark-results-for-python-2-7-2016-02-04/ Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Thu Feb 4 14:08:30 2016 From: python-checkins at python.org (yury.selivanov) Date: Thu, 04 Feb 2016 19:08:30 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy41?= Message-ID: <20160204190827.130865.85890@psf.io> https://hg.python.org/cpython/rev/d00a1c46fff7 changeset: 100159:d00a1c46fff7 parent: 100157:7fb10bdbe01b parent: 100158:980ea968444c user: Yury Selivanov date: Thu Feb 04 14:08:23 2016 -0500 summary: Merge 3.5 files: Lib/rlcompleter.py | 12 ++++++++---- Lib/test/test_rlcompleter.py | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Lib/rlcompleter.py b/Lib/rlcompleter.py --- a/Lib/rlcompleter.py +++ b/Lib/rlcompleter.py @@ -75,9 +75,12 @@ if not text.strip(): if state == 0: - readline.insert_text('\t') - readline.redisplay() - return '' + if _readline_available: + readline.insert_text('\t') + readline.redisplay() + return '' + else: + return '\t' else: return None @@ -192,10 +195,11 @@ try: import readline except ImportError: - pass + _readline_available = False else: readline.set_completer(Completer().complete) # Release references early at shutdown (the readline module's # contents are quasi-immortal, and the completer function holds a # reference to globals). atexit.register(lambda: readline.set_completer(None)) + _readline_available = True diff --git a/Lib/test/test_rlcompleter.py b/Lib/test/test_rlcompleter.py --- a/Lib/test/test_rlcompleter.py +++ b/Lib/test/test_rlcompleter.py @@ -101,6 +101,7 @@ completer = rlcompleter.Completer(dict(f=Foo())) self.assertEqual(completer.complete('f.', 0), 'f.bar') + @unittest.mock.patch('rlcompleter._readline_available', False) def test_complete(self): completer = rlcompleter.Completer() self.assertEqual(completer.complete('', 0), '\t') -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 4 14:08:30 2016 From: python-checkins at python.org (yury.selivanov) Date: Thu, 04 Feb 2016 19:08:30 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1NjYw?= =?utf-8?q?=3A_Fix_a_unittest_and_rlcompleter_when_readline_isn=27t_availa?= =?utf-8?q?ble?= Message-ID: <20160204190827.89786.59020@psf.io> https://hg.python.org/cpython/rev/980ea968444c changeset: 100158:980ea968444c branch: 3.5 parent: 100155:64417e7a1760 user: Yury Selivanov date: Thu Feb 04 14:00:26 2016 -0500 summary: Issue #25660: Fix a unittest and rlcompleter when readline isn't available files: Lib/rlcompleter.py | 12 ++++++++---- Lib/test/test_rlcompleter.py | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Lib/rlcompleter.py b/Lib/rlcompleter.py --- a/Lib/rlcompleter.py +++ b/Lib/rlcompleter.py @@ -75,9 +75,12 @@ if not text.strip(): if state == 0: - readline.insert_text('\t') - readline.redisplay() - return '' + if _readline_available: + readline.insert_text('\t') + readline.redisplay() + return '' + else: + return '\t' else: return None @@ -170,10 +173,11 @@ try: import readline except ImportError: - pass + _readline_available = False else: readline.set_completer(Completer().complete) # Release references early at shutdown (the readline module's # contents are quasi-immortal, and the completer function holds a # reference to globals). atexit.register(lambda: readline.set_completer(None)) + _readline_available = True diff --git a/Lib/test/test_rlcompleter.py b/Lib/test/test_rlcompleter.py --- a/Lib/test/test_rlcompleter.py +++ b/Lib/test/test_rlcompleter.py @@ -1,4 +1,5 @@ import unittest +import unittest.mock import builtins import rlcompleter @@ -77,6 +78,7 @@ self.assertEqual(completer.complete('f.b', 0), 'f.bar') self.assertEqual(f.calls, 1) + @unittest.mock.patch('rlcompleter._readline_available', False) def test_complete(self): completer = rlcompleter.Completer() self.assertEqual(completer.complete('', 0), '\t') -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 4 20:22:16 2016 From: python-checkins at python.org (martin.panter) Date: Fri, 05 Feb 2016 01:22:16 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzEyOTIz?= =?utf-8?q?=3A_Reset_FancyURLopener=27s_redirect_counter_even_on_exception?= Message-ID: <20160205012215.2643.88239@psf.io> https://hg.python.org/cpython/rev/eb69070e5382 changeset: 100160:eb69070e5382 branch: 3.5 parent: 100158:980ea968444c user: Martin Panter date: Thu Feb 04 06:01:35 2016 +0000 summary: Issue #12923: Reset FancyURLopener's redirect counter even on exception Based on patches by Brian Brazil and Daniel Rocco. files: Lib/test/test_urllib.py | 31 +++++++++++++++++++++++----- Lib/urllib/request.py | 24 ++++++++++++---------- Misc/ACKS | 1 + Misc/NEWS | 3 ++ 4 files changed, 42 insertions(+), 17 deletions(-) diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py --- a/Lib/test/test_urllib.py +++ b/Lib/test/test_urllib.py @@ -39,10 +39,7 @@ if proxies is not None: opener = urllib.request.FancyURLopener(proxies=proxies) elif not _urlopener: - with support.check_warnings( - ('FancyURLopener style of invoking requests is deprecated.', - DeprecationWarning)): - opener = urllib.request.FancyURLopener() + opener = FancyURLopener() _urlopener = opener else: opener = _urlopener @@ -52,6 +49,13 @@ return opener.open(url, data) +def FancyURLopener(): + with support.check_warnings( + ('FancyURLopener style of invoking requests is deprecated.', + DeprecationWarning)): + return urllib.request.FancyURLopener() + + def fakehttp(fakedata): class FakeSocket(io.BytesIO): io_refs = 1 @@ -291,11 +295,26 @@ Content-Type: text/html; charset=iso-8859-1 ''') try: - self.assertRaises(urllib.error.HTTPError, urlopen, - "http://python.org/") + msg = "Redirection to url 'file:" + with self.assertRaisesRegex(urllib.error.HTTPError, msg): + urlopen("http://python.org/") finally: self.unfakehttp() + def test_redirect_limit_independent(self): + # Ticket #12923: make sure independent requests each use their + # own retry limit. + for i in range(FancyURLopener().maxtries): + self.fakehttp(b'''HTTP/1.1 302 Found +Location: file://guidocomputer.athome.com:/python/license +Connection: close +''') + try: + self.assertRaises(urllib.error.HTTPError, urlopen, + "http://something") + finally: + self.unfakehttp() + def test_empty_socket(self): # urlopen() raises OSError if the underlying socket does not send any # data. (#1680230) diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -2050,18 +2050,20 @@ def http_error_302(self, url, fp, errcode, errmsg, headers, data=None): """Error 302 -- relocated (temporarily).""" self.tries += 1 - if self.maxtries and self.tries >= self.maxtries: - if hasattr(self, "http_error_500"): - meth = self.http_error_500 - else: - meth = self.http_error_default + try: + if self.maxtries and self.tries >= self.maxtries: + if hasattr(self, "http_error_500"): + meth = self.http_error_500 + else: + meth = self.http_error_default + return meth(url, fp, 500, + "Internal Server Error: Redirect Recursion", + headers) + result = self.redirect_internal(url, fp, errcode, errmsg, + headers, data) + return result + finally: self.tries = 0 - return meth(url, fp, 500, - "Internal Server Error: Redirect Recursion", headers) - result = self.redirect_internal(url, fp, errcode, errmsg, headers, - data) - self.tries = 0 - return result def redirect_internal(self, url, fp, errcode, errmsg, headers, data): if 'location' in headers: diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1214,6 +1214,7 @@ Mark Roberts Andy Robinson Jim Robinson +Daniel Rocco Mark Roddy Kevin Rodgers Sean Rodman diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -73,6 +73,9 @@ Library ------- +- Issue #12923: Reset FancyURLopener's redirect counter even if there is an + exception. Based on patches by Brian Brazil and Daniel Rocco. + - Issue #25945: Fixed a crash when unpickle the functools.partial object with wrong state. Fixed a leak in failed functools.partial constructor. "args" and "keywords" attributes of functools.partial have now always types -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 4 20:22:16 2016 From: python-checkins at python.org (martin.panter) Date: Fri, 05 Feb 2016 01:22:16 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzEyOTIz?= =?utf-8?q?=3A_Reset_FancyURLopener=27s_redirect_counter_even_on_exception?= Message-ID: <20160205012215.19985.58398@psf.io> https://hg.python.org/cpython/rev/a8aa7944c5a8 changeset: 100161:a8aa7944c5a8 branch: 2.7 parent: 100154:c8e43e55f2ce user: Martin Panter date: Thu Feb 04 06:01:35 2016 +0000 summary: Issue #12923: Reset FancyURLopener's redirect counter even on exception Based on patches by Brian Brazil and Daniel Rocco. files: Lib/test/test_urllib.py | 18 +++++++++++++++++- Lib/urllib.py | 24 +++++++++++++----------- Misc/ACKS | 1 + Misc/NEWS | 3 +++ 4 files changed, 34 insertions(+), 12 deletions(-) diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py --- a/Lib/test/test_urllib.py +++ b/Lib/test/test_urllib.py @@ -209,10 +209,26 @@ Content-Type: text/html; charset=iso-8859-1 """) try: - self.assertRaises(IOError, urllib.urlopen, "http://python.org/") + msg = "Redirection to url 'file:" + with self.assertRaisesRegexp(IOError, msg): + urllib.urlopen("http://python.org/") finally: self.unfakehttp() + def test_redirect_limit_independent(self): + # Ticket #12923: make sure independent requests each use their + # own retry limit. + for i in range(urllib.FancyURLopener().maxtries): + self.fakehttp(b'''HTTP/1.1 302 Found +Location: file://guidocomputer.athome.com:/python/license +Connection: close +''') + try: + self.assertRaises(IOError, urllib.urlopen, + "http://something") + finally: + self.unfakehttp() + def test_empty_socket(self): # urlopen() raises IOError if the underlying socket does not send any # data. (#1680230) diff --git a/Lib/urllib.py b/Lib/urllib.py --- a/Lib/urllib.py +++ b/Lib/urllib.py @@ -629,18 +629,20 @@ def http_error_302(self, url, fp, errcode, errmsg, headers, data=None): """Error 302 -- relocated (temporarily).""" self.tries += 1 - if self.maxtries and self.tries >= self.maxtries: - if hasattr(self, "http_error_500"): - meth = self.http_error_500 - else: - meth = self.http_error_default + try: + if self.maxtries and self.tries >= self.maxtries: + if hasattr(self, "http_error_500"): + meth = self.http_error_500 + else: + meth = self.http_error_default + return meth(url, fp, 500, + "Internal Server Error: Redirect Recursion", + headers) + result = self.redirect_internal(url, fp, errcode, errmsg, + headers, data) + return result + finally: self.tries = 0 - return meth(url, fp, 500, - "Internal Server Error: Redirect Recursion", headers) - result = self.redirect_internal(url, fp, errcode, errmsg, headers, - data) - self.tries = 0 - return result def redirect_internal(self, url, fp, errcode, errmsg, headers, data): if 'location' in headers: diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1154,6 +1154,7 @@ Mark Roberts Andy Robinson Jim Robinson +Daniel Rocco Mark Roddy Kevin Rodgers Sean Rodman diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -48,6 +48,9 @@ Library ------- +- Issue #12923: Reset FancyURLopener's redirect counter even if there is an + exception. Based on patches by Brian Brazil and Daniel Rocco. + - Issue #25945: Fixed a crash when unpickle the functools.partial object with wrong state. Fixed a leak in failed functools.partial constructor. "args" and "keywords" attributes of functools.partial have now always types -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 4 20:22:16 2016 From: python-checkins at python.org (martin.panter) Date: Fri, 05 Feb 2016 01:22:16 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2312923=3A_Merge_FancyURLopener_fix_from_3=2E5?= Message-ID: <20160205012215.20003.85568@psf.io> https://hg.python.org/cpython/rev/d3be5c4507b4 changeset: 100162:d3be5c4507b4 parent: 100159:d00a1c46fff7 parent: 100160:eb69070e5382 user: Martin Panter date: Sat Feb 06 01:08:40 2016 +0000 summary: Issue #12923: Merge FancyURLopener fix from 3.5 files: Lib/test/test_urllib.py | 31 +++++++++++++++++++++++----- Lib/urllib/request.py | 24 ++++++++++++---------- Misc/ACKS | 1 + Misc/NEWS | 3 ++ 4 files changed, 42 insertions(+), 17 deletions(-) diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py --- a/Lib/test/test_urllib.py +++ b/Lib/test/test_urllib.py @@ -39,10 +39,7 @@ if proxies is not None: opener = urllib.request.FancyURLopener(proxies=proxies) elif not _urlopener: - with support.check_warnings( - ('FancyURLopener style of invoking requests is deprecated.', - DeprecationWarning)): - opener = urllib.request.FancyURLopener() + opener = FancyURLopener() _urlopener = opener else: opener = _urlopener @@ -52,6 +49,13 @@ return opener.open(url, data) +def FancyURLopener(): + with support.check_warnings( + ('FancyURLopener style of invoking requests is deprecated.', + DeprecationWarning)): + return urllib.request.FancyURLopener() + + def fakehttp(fakedata): class FakeSocket(io.BytesIO): io_refs = 1 @@ -291,11 +295,26 @@ Content-Type: text/html; charset=iso-8859-1 ''') try: - self.assertRaises(urllib.error.HTTPError, urlopen, - "http://python.org/") + msg = "Redirection to url 'file:" + with self.assertRaisesRegex(urllib.error.HTTPError, msg): + urlopen("http://python.org/") finally: self.unfakehttp() + def test_redirect_limit_independent(self): + # Ticket #12923: make sure independent requests each use their + # own retry limit. + for i in range(FancyURLopener().maxtries): + self.fakehttp(b'''HTTP/1.1 302 Found +Location: file://guidocomputer.athome.com:/python/license +Connection: close +''') + try: + self.assertRaises(urllib.error.HTTPError, urlopen, + "http://something") + finally: + self.unfakehttp() + def test_empty_socket(self): # urlopen() raises OSError if the underlying socket does not send any # data. (#1680230) diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -2110,18 +2110,20 @@ def http_error_302(self, url, fp, errcode, errmsg, headers, data=None): """Error 302 -- relocated (temporarily).""" self.tries += 1 - if self.maxtries and self.tries >= self.maxtries: - if hasattr(self, "http_error_500"): - meth = self.http_error_500 - else: - meth = self.http_error_default + try: + if self.maxtries and self.tries >= self.maxtries: + if hasattr(self, "http_error_500"): + meth = self.http_error_500 + else: + meth = self.http_error_default + return meth(url, fp, 500, + "Internal Server Error: Redirect Recursion", + headers) + result = self.redirect_internal(url, fp, errcode, errmsg, + headers, data) + return result + finally: self.tries = 0 - return meth(url, fp, 500, - "Internal Server Error: Redirect Recursion", headers) - result = self.redirect_internal(url, fp, errcode, errmsg, headers, - data) - self.tries = 0 - return result def redirect_internal(self, url, fp, errcode, errmsg, headers, data): if 'location' in headers: diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1218,6 +1218,7 @@ Mark Roberts Andy Robinson Jim Robinson +Daniel Rocco Mark Roddy Kevin Rodgers Sean Rodman diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -169,6 +169,9 @@ Library ------- +- Issue #12923: Reset FancyURLopener's redirect counter even if there is an + exception. Based on patches by Brian Brazil and Daniel Rocco. + - Issue #25945: Fixed a crash when unpickle the functools.partial object with wrong state. Fixed a leak in failed functools.partial constructor. "args" and "keywords" attributes of functools.partial have now always types -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Feb 5 01:23:33 2016 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 05 Feb 2016 06:23:33 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzIyODQ3?= =?utf-8?q?=3A_Improve_method_cache_efficiency=2E?= Message-ID: <20160205062333.61986.94903@psf.io> https://hg.python.org/cpython/rev/6357d851029d changeset: 100163:6357d851029d branch: 2.7 parent: 100161:a8aa7944c5a8 user: Antoine Pitrou date: Sat Nov 15 00:56:27 2014 +0100 summary: Issue #22847: Improve method cache efficiency. files: Misc/NEWS | 2 + Objects/typeobject.c | 43 ++++++++++++++++++++++++++++--- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,8 @@ Core and Builtins ----------------- +- Issue #22847: Improve method cache efficiency. + - Issue #25843: When compiling code, don't merge constants if they are equal but have a different types. For example, ``f1, f2 = lambda: 1, lambda: 1.0`` is now correctly compiled to two different functions: ``f1()`` returns ``1`` diff --git a/Objects/typeobject.c b/Objects/typeobject.c --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -13,10 +13,11 @@ MCACHE_MAX_ATTR_SIZE, since it might be a problem if very large strings are used as attribute names. */ #define MCACHE_MAX_ATTR_SIZE 100 -#define MCACHE_SIZE_EXP 10 +#define MCACHE_SIZE_EXP 12 #define MCACHE_HASH(version, name_hash) \ - (((unsigned int)(version) * (unsigned int)(name_hash)) \ - >> (8*sizeof(unsigned int) - MCACHE_SIZE_EXP)) + (((unsigned int)(version) ^ (unsigned int)(name_hash)) \ + & ((1 << MCACHE_SIZE_EXP) - 1)) + #define MCACHE_HASH_METHOD(type, name) \ MCACHE_HASH((type)->tp_version_tag, \ ((PyStringObject *)(name))->ob_shash) @@ -33,12 +34,32 @@ static struct method_cache_entry method_cache[1 << MCACHE_SIZE_EXP]; static unsigned int next_version_tag = 0; +#define MCACHE_STATS 0 + +#if MCACHE_STATS +static size_t method_cache_hits = 0; +static size_t method_cache_misses = 0; +static size_t method_cache_collisions = 0; +#endif + unsigned int PyType_ClearCache(void) { Py_ssize_t i; unsigned int cur_version_tag = next_version_tag - 1; +#if MCACHE_STATS + size_t total = method_cache_hits + method_cache_collisions + method_cache_misses; + fprintf(stderr, "-- Method cache hits = %zd (%d%%)\n", + method_cache_hits, (int) (100.0 * method_cache_hits / total)); + fprintf(stderr, "-- Method cache true misses = %zd (%d%%)\n", + method_cache_misses, (int) (100.0 * method_cache_misses / total)); + fprintf(stderr, "-- Method cache collisions = %zd (%d%%)\n", + method_cache_collisions, (int) (100.0 * method_cache_collisions / total)); + fprintf(stderr, "-- Method cache size = %zd KB\n", + sizeof(method_cache) / 1024); +#endif + for (i = 0; i < (1 << MCACHE_SIZE_EXP); i++) { method_cache[i].version = 0; Py_CLEAR(method_cache[i].name); @@ -2505,8 +2526,12 @@ /* fast path */ h = MCACHE_HASH_METHOD(type, name); if (method_cache[h].version == type->tp_version_tag && - method_cache[h].name == name) + method_cache[h].name == name) { +#if MCACHE_STATS + method_cache_hits++; +#endif return method_cache[h].value; + } } /* Look in tp_dict of types in MRO */ @@ -2540,7 +2565,15 @@ method_cache[h].version = type->tp_version_tag; method_cache[h].value = res; /* borrowed */ Py_INCREF(name); - Py_SETREF(method_cache[h].name, name); + assert(((PyASCIIObject *)(name))->hash != -1); +#if MCACHE_STATS + if (method_cache[h].name != Py_None && method_cache[h].name != name) + method_cache_collisions++; + else + method_cache_misses++; +#endif + Py_DECREF(method_cache[h].name); + method_cache[h].name = name; } return res; } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Feb 5 01:26:15 2016 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 05 Feb 2016 06:26:15 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_fix_debug_asse?= =?utf-8?q?rtion?= Message-ID: <20160205062615.20005.22722@psf.io> https://hg.python.org/cpython/rev/4e262cecd962 changeset: 100164:4e262cecd962 branch: 2.7 user: Benjamin Peterson date: Thu Feb 04 22:26:10 2016 -0800 summary: fix debug assertion files: Objects/typeobject.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Objects/typeobject.c b/Objects/typeobject.c --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -2565,7 +2565,7 @@ method_cache[h].version = type->tp_version_tag; method_cache[h].value = res; /* borrowed */ Py_INCREF(name); - assert(((PyASCIIObject *)(name))->hash != -1); + assert(((PyStringObject *)(name))->hash != -1); #if MCACHE_STATS if (method_cache[h].name != Py_None && method_cache[h].name != name) method_cache_collisions++; -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Fri Feb 5 04:45:41 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Fri, 05 Feb 2016 09:45:41 +0000 Subject: [Python-checkins] Daily reference leaks (d3be5c4507b4): sum=6 Message-ID: <20160205094525.2661.72089@psf.io> results for d3be5c4507b4 on branch "default" -------------------------------------------- test_collections leaked [2, 0, 0] references, sum=2 test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogyqUfPC', '--timeout', '7200'] From lp_benchmark_robot at intel.com Fri Feb 5 12:39:03 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Fri, 5 Feb 2016 17:39:03 +0000 Subject: [Python-checkins] UGLY Benchmark Results for Python Default 2016-02-05 Message-ID: <923c2323-4583-471d-bff3-245568335510@irsmsx101.ger.corp.intel.com> Results for project Python default, build date 2016-02-05 03:08:09 +0000 commit: d3be5c4507b4 previous commit: 5873cfb42ebe revision date: 2016-02-06 01:08:40 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.18% 1.04% 9.27% 13.97% :-| pybench 0.12% 0.10% -1.05% 5.10% :-( regex_v8 2.69% -1.12% -4.86% 5.96% :-| nbody 0.10% 0.40% 0.08% 6.64% :-) json_dump_v2 0.22% 2.37% -2.07% 10.64% :-( normal_startup 0.86% -3.22% 0.10% 5.68% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/ugly-benchmark-results-for-python-default-2016-02-05/ Note: Benchmark results are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Fri Feb 5 12:39:54 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Fri, 5 Feb 2016 17:39:54 +0000 Subject: [Python-checkins] GOOD Benchmark Results for Python 2.7 2016-02-05 Message-ID: Results for project Python 2.7, build date 2016-02-05 03:59:40 +0000 commit: c8e43e55f2ce previous commit: a8aa7944c5a8 revision date: 2016-02-04 06:01:35 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dc from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.23% 1.70% 3.00% 3.26% :-) pybench 0.17% 0.04% 6.20% 4.85% :-( regex_v8 0.57% -0.02% -2.45% 11.02% :-) nbody 0.13% -0.02% 8.14% 2.58% :-) json_dump_v2 0.16% -0.27% 3.43% 9.99% :-( normal_startup 1.94% -0.47% -5.79% 3.32% :-| ssbench 0.14% 0.17% 0.87% 1.33% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/good-benchmark-results-for-python-2-7-2016-02-05/ Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Fri Feb 5 18:23:13 2016 From: python-checkins at python.org (eric.smith) Date: Fri, 05 Feb 2016 23:23:13 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Fix_issue_26287=3A_While_h?= =?utf-8?q?andling_FORMAT=5FVALUE_opcode=2C_the_top_of_stack_was_being?= Message-ID: <20160205232312.61974.72346@psf.io> https://hg.python.org/cpython/rev/9095a5787a82 changeset: 100165:9095a5787a82 parent: 100162:d3be5c4507b4 user: Eric V. Smith date: Fri Feb 05 18:23:08 2016 -0500 summary: Fix issue 26287: While handling FORMAT_VALUE opcode, the top of stack was being corrupted if an error occurred in PyObject_Format(). files: Lib/test/test_fstring.py | 11 +++++++++++ Python/ceval.c | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_fstring.py b/Lib/test/test_fstring.py --- a/Lib/test/test_fstring.py +++ b/Lib/test/test_fstring.py @@ -692,6 +692,17 @@ r"f'{a(4]}'", ]) + def test_errors(self): + # see issue 26287 + self.assertAllRaise(TypeError, 'non-empty', + [r"f'{(lambda: 0):x}'", + r"f'{(0,):x}'", + ]) + self.assertAllRaise(ValueError, 'Unknown format code', + [r"f'{1000:j}'", + r"f'{1000:j}'", + ]) + def test_loop(self): for i in range(1000): self.assertEqual(f'i:{i}', 'i:' + str(i)) diff --git a/Python/ceval.c b/Python/ceval.c --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3383,7 +3383,7 @@ int have_fmt_spec = (oparg & FVS_MASK) == FVS_HAVE_SPEC; fmt_spec = have_fmt_spec ? POP() : NULL; - value = TOP(); + value = POP(); /* See if any conversion is specified. */ switch (which_conversion) { @@ -3426,7 +3426,7 @@ goto error; } - SET_TOP(result); + PUSH(result); DISPATCH(); } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Feb 5 18:26:24 2016 From: python-checkins at python.org (eric.smith) Date: Fri, 05 Feb 2016 23:26:24 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Switch_to_more_idiomatic_C?= =?utf-8?q?_code=2E?= Message-ID: <20160205232624.2661.83390@psf.io> https://hg.python.org/cpython/rev/f6a89f6cadd0 changeset: 100166:f6a89f6cadd0 user: Eric V. Smith date: Fri Feb 05 18:26:20 2016 -0500 summary: Switch to more idiomatic C code. files: Python/ceval.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3399,10 +3399,10 @@ /* If there's a conversion function, call it and replace value with that result. Otherwise, just use value, without conversion. */ - if (conv_fn) { + if (conv_fn != NULL) { result = conv_fn(value); Py_DECREF(value); - if (!result) { + if (result == NULL) { Py_XDECREF(fmt_spec); goto error; } @@ -3422,8 +3422,9 @@ result = PyObject_Format(value, fmt_spec); Py_DECREF(value); Py_XDECREF(fmt_spec); - if (!result) + if (result == NULL) { goto error; + } } PUSH(result); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Feb 5 19:40:08 2016 From: python-checkins at python.org (yury.selivanov) Date: Sat, 06 Feb 2016 00:40:08 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2326288=3A_Optimize?= =?utf-8?q?_PyLong=5FAsDouble=2E?= Message-ID: <20160206004005.6661.25251@psf.io> https://hg.python.org/cpython/rev/986184c355e8 changeset: 100167:986184c355e8 user: Yury Selivanov date: Fri Feb 05 19:40:01 2016 -0500 summary: Issue #26288: Optimize PyLong_AsDouble. files: Misc/NEWS | 1 + Objects/longobject.c | 7 +++++++ 2 files changed, 8 insertions(+), 0 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -165,6 +165,7 @@ - Issue #25660: Fix TAB key behaviour in REPL with readline. +- Issue #26288: Optimize PyLong_AsDouble. Library ------- diff --git a/Objects/longobject.c b/Objects/longobject.c --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -2769,6 +2769,13 @@ PyErr_SetString(PyExc_TypeError, "an integer is required"); return -1.0; } + if (Py_ABS(Py_SIZE(v)) <= 1) { + /* Fast path; single digit will always fit decimal. + This improves performance of FP/long operations by at + least 20%. This is even visible on macro-benchmarks. + */ + return (double)MEDIUM_VALUE((PyLongObject *)v); + } x = _PyLong_Frexp((PyLongObject *)v, &exponent); if ((x == -1.0 && PyErr_Occurred()) || exponent > DBL_MAX_EXP) { PyErr_SetString(PyExc_OverflowError, -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Feb 5 22:36:19 2016 From: python-checkins at python.org (senthil.kumaran) Date: Sat, 06 Feb 2016 03:36:19 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Fix_userinfo_e?= =?utf-8?q?xample_presented_in_urllib2_howto=2E?= Message-ID: <20160206033619.16560.89170@psf.io> https://hg.python.org/cpython/rev/a2a9ff290cb2 changeset: 100168:a2a9ff290cb2 branch: 2.7 parent: 100164:4e262cecd962 user: Senthil Kumaran date: Fri Feb 05 19:35:57 2016 -0800 summary: Fix userinfo example presented in urllib2 howto. files: Doc/howto/urllib2.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/howto/urllib2.rst b/Doc/howto/urllib2.rst --- a/Doc/howto/urllib2.rst +++ b/Doc/howto/urllib2.rst @@ -499,7 +499,7 @@ e.g. "http://example.com/" *or* an "authority" (i.e. the hostname, optionally including the port number) e.g. "example.com" or "example.com:8080" (the latter example includes a port number). The authority, if present, must -NOT contain the "userinfo" component - for example "joe at password:example.com" is +NOT contain the "userinfo" component - for example "joe:password at example.com" is not correct. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Feb 5 22:39:52 2016 From: python-checkins at python.org (senthil.kumaran) Date: Sat, 06 Feb 2016 03:39:52 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Fix_userinfo_e?= =?utf-8?q?xample_presented_in_urllib2_howto=2E?= Message-ID: <20160206033952.15931.78087@psf.io> https://hg.python.org/cpython/rev/aca6b47a260c changeset: 100169:aca6b47a260c branch: 3.5 parent: 100160:eb69070e5382 user: Senthil Kumaran date: Fri Feb 05 19:37:23 2016 -0800 summary: Fix userinfo example presented in urllib2 howto. files: Doc/howto/urllib2.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/howto/urllib2.rst b/Doc/howto/urllib2.rst --- a/Doc/howto/urllib2.rst +++ b/Doc/howto/urllib2.rst @@ -514,7 +514,7 @@ e.g. "http://example.com/" *or* an "authority" (i.e. the hostname, optionally including the port number) e.g. "example.com" or "example.com:8080" (the latter example includes a port number). The authority, if present, must -NOT contain the "userinfo" component - for example "joe at password:example.com" is +NOT contain the "userinfo" component - for example "joe:password at example.com" is not correct. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Feb 5 22:39:52 2016 From: python-checkins at python.org (senthil.kumaran) Date: Sat, 06 Feb 2016 03:39:52 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_merge_from_3=2E5?= Message-ID: <20160206033952.40070.74735@psf.io> https://hg.python.org/cpython/rev/0c0a531fd269 changeset: 100170:0c0a531fd269 parent: 100167:986184c355e8 parent: 100169:aca6b47a260c user: Senthil Kumaran date: Fri Feb 05 19:37:47 2016 -0800 summary: merge from 3.5 files: Doc/howto/urllib2.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/howto/urllib2.rst b/Doc/howto/urllib2.rst --- a/Doc/howto/urllib2.rst +++ b/Doc/howto/urllib2.rst @@ -514,7 +514,7 @@ e.g. "http://example.com/" *or* an "authority" (i.e. the hostname, optionally including the port number) e.g. "example.com" or "example.com:8080" (the latter example includes a port number). The authority, if present, must -NOT contain the "userinfo" component - for example "joe at password:example.com" is +NOT contain the "userinfo" component - for example "joe:password at example.com" is not correct. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Feb 6 00:27:06 2016 From: python-checkins at python.org (nick.coghlan) Date: Sat, 06 Feb 2016 05:27:06 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_487=3A_New_version_from_M?= =?utf-8?q?artin?= Message-ID: <20160206052706.11225.52593@psf.io> https://hg.python.org/peps/rev/0c19c53f807e changeset: 6219:0c19c53f807e user: Nick Coghlan date: Sat Feb 06 15:26:52 2016 +1000 summary: PEP 487: New version from Martin files: pep-0487.txt | 358 ++++++++++++++------------------------ 1 files changed, 134 insertions(+), 224 deletions(-) diff --git a/pep-0487.txt b/pep-0487.txt --- a/pep-0487.txt +++ b/pep-0487.txt @@ -7,8 +7,8 @@ Type: Standards Track Content-Type: text/x-rst Created: 27-Feb-2015 -Python-Version: 3.5 -Post-History: 27-Feb-2015 +Python-Version: 3.6 +Post-History: 27-Feb-2015, 5-Feb-2016 Replaces: 422 @@ -20,127 +20,80 @@ creating the potential for spurious metaclass conflicts. This PEP proposes to instead support a wide range of customisation -scenarios through a new ``namespace`` parameter in the class header, and -a new ``__init_subclass__`` hook in the class body. +scenarios through a new ``__init_subclass__`` hook in the class body, +a hook to initialize descriptors, and a way to keep the order in which +attributes are defined. + +Those hooks should at first be defined in a metaclass in the standard +library, with the option that this metaclass eventually becomes the +default ``type`` metaclass. The new mechanism should be easier to understand and use than implementing a custom metaclass, and thus should provide a gentler introduction to the full power Python's metaclass machinery. -Connection to other PEP -======================= - -This is a competing proposal to PEP 422 by Nick Coughlan and Daniel Urban. -It shares both most of the PEP text and proposed code, but has major -differences in how to achieve its goals. - Background ========== -For an already created class ``cls``, the term "metaclass" has a clear -meaning: it is the value of ``type(cls)``. +Metaclasses are a powerful tool to customize class creation. They have, +however, the problem that there is no automatic way to combine metaclasses. +If one wants to use two metaclasses for a class, a new metaclass combining +those two needs to be created, typically manually. -*During* class creation, it has another meaning: it is also used to refer to -the metaclass hint that may be provided as part of the class definition. -While in many cases these two meanings end up referring to one and the same -object, there are two situations where that is not the case: - -* If the metaclass hint refers to an instance of ``type``, then it is - considered as a candidate metaclass along with the metaclasses of all of - the parents of the class being defined. If a more appropriate metaclass is - found amongst the candidates, then it will be used instead of the one - given in the metaclass hint. -* Otherwise, an explicit metaclass hint is assumed to be a factory function - and is called directly to create the class object. In this case, the final - metaclass will be determined by the factory function definition. In the - typical case (where the factory functions just calls ``type``, or, in - Python 3.3 or later, ``types.new_class``) the actual metaclass is then - determined based on the parent classes. - -It is notable that only the actual metaclass is inherited - a factory -function used as a metaclass hook sees only the class currently being -defined, and is not invoked for any subclasses. - -In Python 3, the metaclass hint is provided using the ``metaclass=Meta`` -keyword syntax in the class header. This allows the ``__prepare__`` method -on the metaclass to be used to create the ``locals()`` namespace used during -execution of the class body (for example, specifying the use of -``collections.OrderedDict`` instead of a regular ``dict``). - -In Python 2, there was no ``__prepare__`` method (that API was added for -Python 3 by PEP 3115). Instead, a class body could set the ``__metaclass__`` -attribute, and the class creation process would extract that value from the -class namespace to use as the metaclass hint. There is `published code`_ that -makes use of this feature. - -Another new feature in Python 3 is the zero-argument form of the ``super()`` -builtin, introduced by PEP 3135. This feature uses an implicit ``__class__`` -reference to the class being defined to replace the "by name" references -required in Python 2. Just as code invoked during execution of a Python 2 -metaclass could not call methods that referenced the class by name (as the -name had not yet been bound in the containing scope), similarly, Python 3 -metaclasses cannot call methods that rely on the implicit ``__class__`` -reference (as it is not populated until after the metaclass has returned -control to the class creation machinery). - -Finally, when a class uses a custom metaclass, it can pose additional -challenges to the use of multiple inheritance, as a new class cannot -inherit from parent classes with unrelated metaclasses. This means that -it is impossible to add a metaclass to an already published class: such -an addition is a backwards incompatible change due to the risk of metaclass -conflicts. - +This need often occurs as a surprise to a user: inheriting from two base +classes coming from two different libraries suddenly raises the necessity +to manually create a combined metaclass, where typically one is not +interested in those details about the libraries at all. This becomes +even worse if one library starts to make use of a metaclass which it +has not done before. While the library itself continues to work perfectly, +suddenly every code combining those classes with classes from another library +fails. Proposal ======== -This PEP proposes that a new mechanism to customise class creation be -added to Python 3.5 that meets the following criteria: +While there are many possible ways to use a metaclass, the vast majority +of use cases falls into just three categories: some initialization code +running after class creation, the initalization of descriptors and +keeping the order in which class attributes were defined. -1. Integrates nicely with class inheritance structures (including mixins and - multiple inheritance), -2. Integrates nicely with the implicit ``__class__`` reference and - zero-argument ``super()`` syntax introduced by PEP 3135, -3. Can be added to an existing base class without a significant risk of - introducing backwards compatibility problems, and -4. Restores the ability for class namespaces to have some influence on the - class creation process (above and beyond populating the namespace itself), - but potentially without the full flexibility of the Python 2 style - ``__metaclass__`` hook. +Those three use cases can easily be performed by just one metaclass. If +this metaclass is put into the standard library, and all libraries that +wish to customize class creation use this very metaclass, no combination +of metaclasses is necessary anymore. -Those goals can be achieved by adding two functionalities: +The three use cases are achieved as follows: -1. A ``__init_subclass__`` hook that initializes all subclasses of a - given class, and -2. A new keyword parameter ``namespace`` to the class creation statement, - that gives an initialization of the namespace. +1. The metaclass contains an ``__init_subclass__`` hook that initializes + all subclasses of a given class, +2. the metaclass calls an ``__init_descriptor__`` hook for all descriptors + defined in the class, and +3. an ``__attribute_order__`` tuple is left in the class in order to inspect + the order in which attributes were defined. -As an example, the first proposal looks as follows:: +For ease of use, a base class ``SubclassInit`` is defined, which uses said +metaclass and contains an empty stub for the hook described for use case 1. - class SpamBase: +As an example, the first use case looks as follows:: + + class SpamBase(SubclassInit): # this is implicitly a @classmethod - def __init_subclass__(cls, ns, **kwargs): + def __init_subclass__(cls, **kwargs): # This is invoked after a subclass is created, but before # explicit decorators are called. # The usual super() mechanisms are used to correctly support # multiple inheritance. - # ns is the classes namespace # **kwargs are the keyword arguments to the subclasses' # class creation statement - super().__init_subclass__(cls, ns, **kwargs) + super().__init_subclass__(cls, **kwargs) class Spam(SpamBase): pass # the new hook is called on Spam -To simplify the cooperative multiple inheritance case, ``object`` will gain -a default implementation of the hook that does nothing:: - - class object: - def __init_subclass__(cls, ns): - pass - +The base class ``SubclassInit`` contains an empty ``__init_subclass__`` +method which serves as an endpoint for cooperative multiple inheritance. Note that this method has no keyword arguments, meaning that all methods which are more specialized have to process all keyword arguments. @@ -151,58 +104,46 @@ but the situation has changed sufficiently in recent years that the idea is worth reconsidering for inclusion. -The second part of the proposal is to have a ``namespace`` keyword -argument to the class declaration statement. If present, its value -will be called without arguments to initialize a subclasses -namespace, very much like a metaclass ``__prepare__`` method would -do. +The second part of the proposal adds an ``__init_descriptor__`` +initializer for descriptors. Descriptors are defined in the body of a +class, but they do not know anything about that class, they do not +even know the name they are accessed with. They do get to know their +owner once ``__get__`` is called, but still they do not know their +name. This is unfortunate, for example they cannot put their +associated value into their object's ``__dict__`` under their name, +since they do not know that name. This problem has been solved many +times, and is one of the most important reasons to have a metaclass in +a library. While it would be easy to implement such a mechanism using +the first part of the proposal, it makes sense to have one solution +for this problem for everyone. -In addition, the introduction of the metaclass ``__prepare__`` method -in PEP 3115 allows a further enhancement that was not possible in -Python 2: this PEP also proposes that ``type.__prepare__`` be updated -to accept a factory function as a ``namespace`` keyword-only argument. -If present, the value provided as the ``namespace`` argument will be -called without arguments to create the result of ``type.__prepare__`` -instead of using a freshly created dictionary instance. For example, -the following will use an ordered dictionary as the class namespace:: +To give an example of its usage, imagine a descriptor representing weak +referenced values (this is an insanely simplified, yet working example):: - class OrderedBase(namespace=collections.OrderedDict): - pass + import weakref - class Ordered(OrderedBase): - # cls.__dict__ is still a read-only proxy to the class namespace, - # but the underlying storage is an OrderedDict instance + class WeakAttribute: + def __get__(self, instance, owner): + return instance.__dict__[self.name] + def __set__(self, instance, value): + instance.__dict__[self.name] = weakref.ref(value) -.. note:: + # this is the new initializer: + def __init_descriptor__(self, owner, name): + self.name = name - This PEP, along with the existing ability to use __prepare__ to share a - single namespace amongst multiple class objects, highlights a possible - issue with the attribute lookup caching: when the underlying mapping is - updated by other means, the attribute lookup cache is not invalidated - correctly (this is a key part of the reason class ``__dict__`` attributes - produce a read-only view of the underlying storage). - - Since the optimisation provided by that cache is highly desirable, - the use of a preexisting namespace as the class namespace may need to - be declared as officially unsupported (since the observed behaviour is - rather strange when the caches get out of sync). +The third part of the proposal is to leave a tuple called +``__attribute_order__`` in the class that contains the order in which +the attributes were defined. This is a very common usecase, many +libraries use an ``OrderedDict`` to store this order. This is a very +simple way to achieve the same goal. Key Benefits ============ -Easier use of custom namespaces for a class -------------------------------------------- - -Currently, to use a different type (such as ``collections.OrderedDict``) for -a class namespace, or to use a pre-populated namespace, it is necessary to -write and use a custom metaclass. With this PEP, using a custom namespace -becomes as simple as specifying an appropriate factory function in the -class header. - - Easier inheritance of definition time behaviour ----------------------------------------------- @@ -235,40 +176,20 @@ breaching backwards compatibility guarantees. -Integrates cleanly with \PEP 3135 ---------------------------------- - -Given that the method is called on already existing classes, the new -hook will be able to freely invoke class methods that rely on the -implicit ``__class__`` reference introduced by PEP 3135, including -methods that use the zero argument form of ``super()``. - - -Replaces many use cases for dynamic setting of ``__metaclass__`` ----------------------------------------------------------------- - -For use cases that don't involve completely replacing the defined -class, Python 2 code that dynamically set ``__metaclass__`` can now -dynamically set ``__init_subclass__`` instead. For more advanced use -cases, introduction of an explicit metaclass (possibly made available -as a required base class) will still be necessary in order to support -Python 3. - - A path of introduction into Python ================================== Most of the benefits of this PEP can already be implemented using a simple metaclass. For the ``__init_subclass__`` hook this works -all the way down to python 2.7, while the namespace needs python 3.0 +all the way down to Python 2.7, while the attribute order needs Python 3.0 to work. Such a class has been `uploaded to PyPI`_. The only drawback of such a metaclass are the mentioned problems with metaclasses and multiple inheritance. Two classes using such a metaclass can only be combined, if they use exactly the same such metaclass. This fact calls for the inclusion of such a class into the -standard library, let's call it ``SubclassMeta``, with a base class -using it called ``SublassInit``. Once all users use this standard +standard library, let's call it ``SubclassMeta``, with the base class +using it called ``SubclassInit``. Once all users use this standard library metaclass, classes from different packages can easily be combined. @@ -277,21 +198,32 @@ mind and inherit from the standard metaclass if it seems useful for users of the metaclass to add more functionality. Ultimately, if the need for combining with other metaclasses is strong enough, -the proposed functionality may be introduced into python's ``type``. +the proposed functionality may be introduced into Python's ``type``. Those arguments strongly hint to the following procedure to include -the proposed functionality into python: +the proposed functionality into Python: 1. The metaclass implementing this proposal is put onto PyPI, so that it can be used and scrutinized. -2. Once the code is properly mature, it can be added to the python +2. Once the code is properly mature, it can be added to the Python standard library. There should be a new module called ``metaclass`` which collects tools for metaclass authors, as well as a documentation of the best practices of how to write metaclasses. 3. If the need of combining this metaclass with other metaclasses is - strong enough, it may be included into python itself. + strong enough, it may be included into Python itself. +While the metaclass is still in the standard library and not in the +language, it may still clash with other metaclasses. The most +prominent metaclass in use is probably ABCMeta. It is also a +particularly good example for the need of combining metaclasses. For +users who want to define a ABC with subclass initialization, we should +support a ``ABCSubclassInit`` class, or let ABCMeta inherit from this +PEP's metaclass. + +Extensions written in C or C++ also often define their own metaclass. +It would be very useful if those could also inherit from the metaclass +defined here, but this is probably not possible. New Ways of Using Classes ========================= @@ -309,8 +241,8 @@ class PluginBase(SubclassInit): subclasses = [] - def __init_subclass__(cls, ns, **kwargs): - super().__init_subclass__(ns, **kwargs) + def __init_subclass__(cls, **kwargs): + super().__init_subclass__(**kwargs) cls.subclasses.append(cls) One should note that this also works nicely as a mixin class. @@ -318,7 +250,7 @@ Trait descriptors ----------------- -There are many designs of python descriptors in the wild which, for +There are many designs of Python descriptors in the wild which, for example, check boundaries of values. Often those "traits" need some support of a metaclass to work. This is how this would look like with this PEP:: @@ -330,55 +262,14 @@ def __set__(self, instance, value): instance.__dict__[self.key] = value + def __init_descriptor__(self, owner, name): + self.key = name + class Int(Trait): def __set__(self, instance, value): # some boundary check code here super().__set__(instance, value) - class HasTraits(SubclassInit): - def __init_subclass__(cls, ns, **kwargs): - super().__init_subclass__(ns, **kwargs) - for k, v in ns.items(): - if isinstance(v, Trait): - v.key = k - -The new ``namespace`` keyword in the class header enables a number of -interesting options for controlling the way a class is initialised, -including some aspects of the object models of both Javascript and Ruby. - - -Order preserving classes ------------------------- - -:: - - class OrderedClassBase(namespace=collections.OrderedDict): - pass - - class OrderedClass(OrderedClassBase): - a = 1 - b = 2 - c = 3 - - -Prepopulated namespaces ------------------------ - -:: - - seed_data = dict(a=1, b=2, c=3) - class PrepopulatedClass(namespace=seed_data.copy): - pass - - -Cloning a prototype class -------------------------- - -:: - - class NewClass(namespace=Prototype.__dict__.copy): - pass - Rejected Design Options ======================= @@ -402,7 +293,7 @@ The original proposal also made major changes in the class initialization process, rendering it impossible to back-port the -proposal to older python versions. +proposal to older Python versions. Other variants of calling the hook @@ -430,28 +321,47 @@ explicitly say anything one way or the other). -Passing in the namespace directly rather than a factory function ----------------------------------------------------------------- +Defining arbitrary namespaces +----------------------------- -At one point, PEP 422 proposed that the class namespace be passed -directly as a keyword argument, rather than passing a factory function. -However, this encourages an unsupported behaviour (that is, passing the -same namespace to multiple classes, or retaining direct write access -to a mapping used as a class namespace), so the API was switched to -the factory function version. +PEP 422 defined a generic way to add arbitrary namespaces for class +definitions. This approach is much more flexible than just leaving +the definition order in a tuple. The ``__prepare__`` method in a metaclass +supports exactly this behavior. But given that effectively +the only use cases that could be found out in the wild were the +``OrderedDict`` way of determining the attribute order, it seemed +reasonable to only support this special case. +The metaclass described in this PEP has been designed to be very simple +such that it could be reasonably made the default metaclass. This was +especially important when designing the attribute order functionality: +This was a highly demanded feature and has been enabled through the +``__prepare__`` method of metaclasses. This method can be abused in +very weird ways, making it hard to correctly maintain this feature in +CPython. This is why it has been proposed to deprecated this feature, +and instead use ``OrderedDict`` as the standard namespace, supporting +the most important feature while dropping most of the complexity. But +this would have meant that ``OrderedDict`` becomes a language builtin +like dict and set, and not just a standard library class. The choice +of the ``__attribute_order__`` tuple is a much simpler solution to the +problem. -Possible Extensions -=================== +A more ``__new__``-like hook +---------------------------- -Some extensions to this PEP are imaginable, which are postponed to a -later pep: +In PEP 422 the hook worked more like the ``__new__`` method than the +``__init__`` method, meaning that it returned a class instead of +modifying one. This allows a bit more flexibility, but at the cost +of much harder implementation and undesired side effects. -* A ``__new_subclass__`` method could be defined which acts like a - ``__new__`` for classes. This would be very close to - ``__autodecorate__`` in PEP 422. -* ``__subclasshook__`` could be made a classmethod in a class instead - of a method in the metaclass. + +History +======= + +This used to be a competing proposal to PEP 422 by Nick Coughlan and +Daniel Urban. It shares both most of the PEP text and proposed code, but +has major differences in how to achieve its goals. In the meantime, PEP 422 +has been withdrawn favouring this approach. References ========== -- Repository URL: https://hg.python.org/peps From solipsis at pitrou.net Sat Feb 6 04:45:14 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Sat, 06 Feb 2016 09:45:14 +0000 Subject: [Python-checkins] Daily reference leaks (0c0a531fd269): sum=4 Message-ID: <20160206094514.11223.37505@psf.io> results for 0c0a531fd269 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogDugeiy', '--timeout', '7200'] From python-checkins at python.org Sat Feb 6 12:21:32 2016 From: python-checkins at python.org (yury.selivanov) Date: Sat, 06 Feb 2016 17:21:32 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2326288=3A_Fix_comm?= =?utf-8?q?ent?= Message-ID: <20160206172132.6675.95910@psf.io> https://hg.python.org/cpython/rev/cfb77ccdc23a changeset: 100171:cfb77ccdc23a user: Yury Selivanov date: Sat Feb 06 12:21:33 2016 -0500 summary: Issue #26288: Fix comment files: Objects/longobject.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Objects/longobject.c b/Objects/longobject.c --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -2770,9 +2770,9 @@ return -1.0; } if (Py_ABS(Py_SIZE(v)) <= 1) { - /* Fast path; single digit will always fit decimal. - This improves performance of FP/long operations by at - least 20%. This is even visible on macro-benchmarks. + /* Fast path; single digit long (31 bits) will cast safely + to double. This improves performance of FP/long operations + by 20%. */ return (double)MEDIUM_VALUE((PyLongObject *)v); } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Feb 6 15:37:56 2016 From: python-checkins at python.org (steve.dower) Date: Sat, 06 Feb 2016 20:37:56 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Add_PEP_514=3A_Python_registr?= =?utf-8?q?ation_in_the_Windows_registry?= Message-ID: <20160206203755.68432.14150@psf.io> https://hg.python.org/peps/rev/1b9459d7021e changeset: 6220:1b9459d7021e user: Steve Dower date: Sat Feb 06 12:37:37 2016 -0800 summary: Add PEP 514: Python registration in the Windows registry files: pep-0514.txt | 250 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 250 insertions(+), 0 deletions(-) diff --git a/pep-0514.txt b/pep-0514.txt new file mode 100644 --- /dev/null +++ b/pep-0514.txt @@ -0,0 +1,250 @@ +PEP: 514 +Title: Python registration in the Windows registry +Version: $Revision$ +Last-Modified: $Date$ +Author: Steve Dower +Status: Draft +Type: Informational +Content-Type: text/x-rst +Created: 02-Feb-2016 +Post-History: 02-Feb-2016 + +Abstract +======== + +This PEP defines a schema for the Python registry key to allow third-party +installers to register their installation, and to allow applications to detect +and correctly display all Python environments on a user's machine. No +implementation changes to Python are proposed with this PEP. + +Python environments are not required to be registered unless they want to be +automatically discoverable by external tools. + +The schema matches the registry values that have been used by the official +installer since at least Python 2.5, and the resolution behaviour matches the +behaviour of the official Python releases. + +Motivation +========== + +When installed on Windows, the official Python installer creates a registry key +for discovery and detection by other applications. This allows tools such as +installers or IDEs to automatically detect and display a user's Python +installations. + +Third-party installers, such as those used by distributions, typically create +identical keys for the same purpose. Most tools that use the registry to detect +Python installations only inspect the keys used by the official installer. As a +result, third-party installations that wish to be discoverable will overwrite +these values, resulting in users "losing" their Python installation. + +By describing a layout for registry keys that allows third-party installations +to register themselves uniquely, as well as providing tool developers guidance +for discovering all available Python installations, these collisions should be +prevented. + +Definitions +=========== + +A "registry key" is the equivalent of a file-system path into the registry. Each +key may contain "subkeys" (keys nested within keys) and "values" (named and +typed attributes attached to a key). + +``HKEY_CURRENT_USER`` is the root of settings for the currently logged-in user, +and this user can generally read and write all settings under this root. + +``HKEY_LOCAL_MACHINE`` is the root of settings for all users. Generally, any +user can read these settings but only administrators can modify them. It is +typical for values under ``HKEY_CURRENT_USER`` to take precedence over those in +``HKEY_LOCAL_MACHINE``. + +On 64-bit Windows, ``HKEY_LOCAL_MACHINE\Software\Wow6432Node`` is a special key +that 32-bit processes transparently read and write to rather than accessing the +``Software`` key directly. + +Structure +========= + +We consider there to be a single collection of Python environments on a machine, +where the collection may be different for each user of the machine. There are +three potential registry locations where the collection may be stored based on +the installation options of each environment:: + + HKEY_CURRENT_USER\Software\Python\\ + HKEY_LOCAL_MACHINE\Software\Python\\ + HKEY_LOCAL_MACHINE\Software\Wow6432Node\Python\\ + +Environments are uniquely identified by their Company-Tag pair, with two options +for conflict resolution: include everything, or give priority to user +preferences. + +Tools that include every installed environment, even where the Company-Tag pairs +match, should ensure users can easily identify whether the registration was +per-user or per-machine. + +Tools that give priority to user preferences must ignore values from +``HKEY_LOCAL_MACHINE`` when a matching Company-Tag pair exists is in +``HKEY_CURRENT_USER``. + +Official Python releases use ``PythonCore`` for Company, and the value of +``sys.winver`` for Tag. Other registered environments may use any values for +Company and Tag. Recommendations are made in the following sections. + +Python environments are not required to register themselves unless they want to +be automatically discoverable by external tools. + +Backwards Compatibility +----------------------- + +Python 3.4 and earlier did not distinguish between 32-bit and 64-bit builds in +``sys.winver``. As a result, it is possible to have valid side-by-side +installations of both 32-bit and 64-bit interpreters. + +To ensure backwards compatibility, applications should treat environments listed +under the following two registry keys as distinct, even when the Tag matches:: + + HKEY_LOCAL_MACHINE\Software\Python\PythonCore\ + HKEY_LOCAL_MACHINE\Software\Wow6432Node\Python\PythonCore\ + +Environments listed under ``HKEY_CURRENT_USER`` may be treated as distinct from +both of the above keys, potentially resulting in three environments discovered +using the same Tag. Alternatively, a tool may determine whether the per-user +environment is 64-bit or 32-bit and give it priority over the per-machine +environment, resulting in a maximum of two discovered environments. + +It is not possible to detect side-by-side installations of both 64-bit and +32-bit versions of Python prior to 3.5 when they have been installed for the +current user. Python 3.5 and later always uses different Tags for 64-bit and +32-bit versions. + +Environments registered under other Company names must use distinct Tags to +support side-by-side installations. There is no backwards compatibility +allowance. + +Company +------- + +The Company part of the key is intended to group related environments and to +ensure that Tags are namespaced appropriately. The key name should be +alphanumeric without spaces and likely to be unique. For example, a trademarked +name, a UUID, or a hostname would be appropriate:: + + HKEY_CURRENT_USER\Software\Python\ExampleCorp + HKEY_CURRENT_USER\Software\Python\6C465E66-5A8C-4942-9E6A-D29159480C60 + HKEY_CURRENT_USER\Software\Python\www.example.com + +The company name ``PyLauncher`` is reserved for the PEP 397 launcher +(``py.exe``). It does not follow this convention and should be ignored by tools. + +If a string value named ``DisplayName`` exists, it should be used to identify +the environment category to users. Otherwise, the name of the key should be +used. + +If a string value named ``SupportUrl`` exists, it may be displayed or otherwise +used to direct users to a web site related to the environment. + +A complete example may look like:: + + HKEY_CURRENT_USER\Software\Python\ExampleCorp + (Default) = (value not set) + DisplayName = "Example Corp" + SupportUrl = "http://www.example.com" + +Tag +--- + +The Tag part of the key is intended to uniquely identify an environment within +those provided by a single company. The key name should be alphanumeric without +spaces and stable across installations. For example, the Python language +version, a UUID or a partial/complete hash would be appropriate; an integer +counter that increases for each new environment may not:: + + HKEY_CURRENT_USER\Software\Python\ExampleCorp\3.6 + HKEY_CURRENT_USER\Software\Python\ExampleCorp\6C465E66 + +If a string value named ``DisplayName`` exists, it should be used to identify +the environment to users. Otherwise, the name of the key should be used. + +If a string value named ``SupportUrl`` exists, it may be displayed or otherwise +used to direct users to a web site related to the environment. + +If a string value named ``Version`` exists, it should be used to identify the +version of the environment. This is independent from the version of Python +implemented by the environment. + +If a string value named ``SysVersion`` exists, it must be in ``x.y`` or +``x.y.z`` format matching the version returned by ``sys.version_info`` in the +interpreter. Otherwise, if the Tag matches this format it is used. If not, the +Python version is unknown. + +Note that each of these values is recommended, but optional. A complete example +may look like this:: + + HKEY_CURRENT_USER\Software\Python\ExampleCorp\6C465E66 + (Default) = (value not set) + DisplayName = "Distro 3" + SupportUrl = "http://www.example.com/distro-3" + Version = "3.0.12345.0" + SysVersion = "3.6.0" + +InstallPath +----------- + +Beneath the environment key, an ``InstallPath`` key must be created. This key is +always named ``InstallPath``, and the default value must match ``sys.prefix``:: + + HKEY_CURRENT_USER\Software\Python\ExampleCorp\3.6\InstallPath + (Default) = "C:\ExampleCorpPy36" + +If a string value named ``ExecutablePath`` exists, it must be a path to the +``python.exe`` (or equivalent) executable. Otherwise, the interpreter executable +is assumed to be called ``python.exe`` and exist in the directory referenced by +the default value. + +If a string value named ``WindowedExecutablePath`` exists, it must be a path to +the ``pythonw.exe`` (or equivalent) executable. Otherwise, the windowed +interpreter executable is assumed to be called ``pythonw.exe`` and exist in the +directory referenced by the default value. + +A complete example may look like:: + + HKEY_CURRENT_USER\Software\Python\ExampleCorp\6C465E66\InstallPath + (Default) = "C:\ExampleDistro30" + ExecutablePath = "C:\ExampleDistro30\ex_python.exe" + WindowedExecutablePath = "C:\ExampleDistro30\ex_pythonw.exe" + +Help +---- + +Beneath the environment key, a ``Help`` key may be created. This key is always +named ``Help`` if present and has no default value. + +Each subkey of ``Help`` specifies a documentation file, tool, or URL associated +with the environment. The subkey may have any name, and the default value is a +string appropriate for passing to ``os.startfile`` or equivalent. + +If a string value named ``DisplayName`` exists, it should be used to identify +the help file to users. Otherwise, the key name should be used. + +A complete example may look like:: + + HKEY_CURRENT_USER\Software\Python\ExampleCorp\6C465E66\Help + Python\ + (Default) = "C:\ExampleDistro30\python36.chm" + DisplayName = "Python Documentation" + Extras\ + (Default) = "http://www.example.com/tutorial" + DisplayName = "Example Distro Online Tutorial" + +Other Keys +---------- + +Some other registry keys are used for defining or inferring search paths under +certain conditions. A third-party installation is permitted to define these keys +under their Company-Tag key, however, the interpreter must be modified and +rebuilt in order to read these values. + +Copyright +========= + +This document has been placed in the public domain. \ No newline at end of file -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Sat Feb 6 21:40:38 2016 From: python-checkins at python.org (martin.panter) Date: Sun, 07 Feb 2016 02:40:38 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1MTc5?= =?utf-8?q?=3A_Preparatory_cleanup_of_existing_docs_on_string_formatting?= Message-ID: <20160207024038.11231.31494@psf.io> https://hg.python.org/cpython/rev/f25d8cbd074a changeset: 100172:f25d8cbd074a branch: 3.5 parent: 100169:aca6b47a260c user: Martin Panter date: Mon Feb 08 01:34:09 2016 +0000 summary: Issue #25179: Preparatory cleanup of existing docs on string formatting * Various sections were pointing to the section on the string.Formatter class, when the section on the common format string syntax is probably more appropriate * Fix references to various format() functions and methods * Nested replacement fields may contain conversions and format specifiers, and this is tested; see Issue #19729 for instance files: Doc/faq/programming.rst | 2 +- Doc/library/datetime.rst | 6 ++-- Doc/library/enum.rst | 12 +++++----- Doc/library/pprint.rst | 2 +- Doc/library/stdtypes.rst | 2 +- Doc/library/string.rst | 27 ++++++++++++---------- Doc/library/tracemalloc.rst | 2 +- Doc/tools/susp-ignored.csv | 2 +- Doc/tutorial/introduction.rst | 5 +-- 9 files changed, 31 insertions(+), 29 deletions(-) diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -839,7 +839,7 @@ To convert, e.g., the number 144 to the string '144', use the built-in type constructor :func:`str`. If you want a hexadecimal or octal representation, use the built-in functions :func:`hex` or :func:`oct`. For fancy formatting, see -the :ref:`string-formatting` section, e.g. ``"{:04d}".format(144)`` yields +the :ref:`formatstrings` section, e.g. ``"{:04d}".format(144)`` yields ``'0144'`` and ``"{:.3f}".format(1.0/3.0)`` yields ``'0.333'``. diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -604,7 +604,7 @@ .. method:: date.__format__(format) - Same as :meth:`.date.strftime`. This makes it possible to specify format + Same as :meth:`.date.strftime`. This makes it possible to specify a format string for a :class:`.date` object when using :meth:`str.format`. For a complete list of formatting directives, see :ref:`strftime-strptime-behavior`. @@ -1179,7 +1179,7 @@ .. method:: datetime.__format__(format) - Same as :meth:`.datetime.strftime`. This makes it possible to specify format + Same as :meth:`.datetime.strftime`. This makes it possible to specify a format string for a :class:`.datetime` object when using :meth:`str.format`. For a complete list of formatting directives, see :ref:`strftime-strptime-behavior`. @@ -1424,7 +1424,7 @@ .. method:: time.__format__(format) - Same as :meth:`.time.strftime`. This makes it possible to specify format string + Same as :meth:`.time.strftime`. This makes it possible to specify a format string for a :class:`.time` object when using :meth:`str.format`. For a complete list of formatting directives, see :ref:`strftime-strptime-behavior`. diff --git a/Doc/library/enum.rst b/Doc/library/enum.rst --- a/Doc/library/enum.rst +++ b/Doc/library/enum.rst @@ -555,12 +555,12 @@ 3. When another data type is mixed in, the :attr:`value` attribute is *not the same* as the enum member itself, although it is equivalent and will compare equal. -4. %-style formatting: `%s` and `%r` call :class:`Enum`'s :meth:`__str__` and - :meth:`__repr__` respectively; other codes (such as `%i` or `%h` for - IntEnum) treat the enum member as its mixed-in type. -5. :meth:`str.__format__` (or :func:`format`) will use the mixed-in - type's :meth:`__format__`. If the :class:`Enum`'s :func:`str` or - :func:`repr` is desired use the `!s` or `!r` :class:`str` format codes. +4. %-style formatting: `%s` and `%r` call the :class:`Enum` class's + :meth:`__str__` and :meth:`__repr__` respectively; other codes (such as + `%i` or `%h` for IntEnum) treat the enum member as its mixed-in type. +5. :meth:`str.format` (or :func:`format`) will use the mixed-in + type's :meth:`__format__`. If the :class:`Enum` class's :func:`str` or + :func:`repr` is desired, use the `!s` or `!r` format codes. Interesting examples diff --git a/Doc/library/pprint.rst b/Doc/library/pprint.rst --- a/Doc/library/pprint.rst +++ b/Doc/library/pprint.rst @@ -197,7 +197,7 @@ the current presentation context (direct and indirect containers for *object* that are affecting the presentation) as the keys; if an object needs to be presented which is already represented in *context*, the third return value - should be ``True``. Recursive calls to the :meth:`format` method should add + should be ``True``. Recursive calls to the :meth:`.format` method should add additional entries for containers to this dictionary. The third argument, *maxlevels*, gives the requested limit to recursion; this will be ``0`` if there is no requested limit. This argument should be passed unmodified to recursive diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1450,7 +1450,7 @@ For more information on the ``str`` class and its methods, see :ref:`textseq` and the :ref:`string-methods` section below. To output - formatted strings, see the :ref:`string-formatting` section. In addition, + formatted strings, see the :ref:`formatstrings` section. In addition, see the :ref:`stringservices` section. diff --git a/Doc/library/string.rst b/Doc/library/string.rst --- a/Doc/library/string.rst +++ b/Doc/library/string.rst @@ -75,14 +75,14 @@ .. _string-formatting: -String Formatting ------------------ +Custom String Formatting +------------------------ The built-in string class provides the ability to do complex variable -substitutions and value formatting via the :func:`format` method described in +substitutions and value formatting via the :meth:`~str.format` method described in :pep:`3101`. The :class:`Formatter` class in the :mod:`string` module allows you to create and customize your own string formatting behaviors using the same -implementation as the built-in :meth:`format` method. +implementation as the built-in :meth:`~str.format` method. .. class:: Formatter @@ -91,9 +91,9 @@ .. method:: format(format_string, *args, **kwargs) - :meth:`format` is the primary API method. It takes a format string and + The primary API method. It takes a format string and an arbitrary set of positional and keyword arguments. - :meth:`format` is just a wrapper that calls :meth:`vformat`. + It is just a wrapper that calls :meth:`vformat`. .. deprecated:: 3.5 Passing a format string as keyword argument *format_string* has been @@ -267,8 +267,9 @@ described in the next section. A *format_spec* field can also include nested replacement fields within it. -These nested replacement fields can contain only a field name; conversion flags -and format specifications are not allowed. The replacement fields within the +These nested replacement fields may contain a field name, conversion flag +and format specification, but deeper nesting is +not allowed. The replacement fields within the format_spec are substituted before the *format_spec* string is interpreted. This allows the formatting of a value to be dynamically specified. @@ -306,8 +307,10 @@ If a valid *align* value is specified, it can be preceded by a *fill* character that can be any character and defaults to a space if omitted. -Note that it is not possible to use ``{`` and ``}`` as *fill* char while -using the :meth:`str.format` method; this limitation however doesn't +It is not possible to use a literal curly brace ("``{``" or "``}``") as +the *fill* character when using the :meth:`str.format` +method. However, it is possible to insert a curly brace +with a nested replacement field. This limitation doesn't affect the :func:`format` function. The meaning of the various alignment options is as follows: @@ -496,8 +499,8 @@ Format examples ^^^^^^^^^^^^^^^ -This section contains examples of the new format syntax and comparison with -the old ``%``-formatting. +This section contains examples of the :meth:`str.format` syntax and +comparison with the old ``%``-formatting. In most of the cases the syntax is similar to the old ``%``-formatting, with the addition of the ``{}`` and with ``:`` used instead of ``%``. diff --git a/Doc/library/tracemalloc.rst b/Doc/library/tracemalloc.rst --- a/Doc/library/tracemalloc.rst +++ b/Doc/library/tracemalloc.rst @@ -620,7 +620,7 @@ *limit* is set, only format the *limit* most recent frames. Similar to the :func:`traceback.format_tb` function, except that - :meth:`format` does not include newlines. + :meth:`.format` does not include newlines. Example:: diff --git a/Doc/tools/susp-ignored.csv b/Doc/tools/susp-ignored.csv --- a/Doc/tools/susp-ignored.csv +++ b/Doc/tools/susp-ignored.csv @@ -82,7 +82,7 @@ howto/pyporting,,::,Programming Language :: Python :: 3 howto/regex,,::, howto/regex,,:foo,(?:foo) -howto/urllib2,,:example,"for example ""joe at password:example.com""" +howto/urllib2,,:password,"for example ""joe:password at example.com""" library/audioop,,:ipos,"# factor = audioop.findfactor(in_test[ipos*2:ipos*2+len(out_test)]," library/bisect,32,:hi,all(val >= x for val in a[i:hi]) library/bisect,42,:hi,all(val > x for val in a[i:hi]) diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -352,9 +352,8 @@ Strings support a large number of methods for basic transformations and searching. - :ref:`string-formatting` - Information about string formatting with :meth:`str.format` is described - here. + :ref:`formatstrings` + Information about string formatting with :meth:`str.format`. :ref:`old-string-formatting` The old formatting operations invoked when strings and Unicode strings are -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Feb 6 21:40:38 2016 From: python-checkins at python.org (martin.panter) Date: Sun, 07 Feb 2016 02:40:38 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI1MTc5?= =?utf-8?q?=3A_Preparatory_cleanup_of_existing_docs_on_string_formatting?= Message-ID: <20160207024038.19991.61366@psf.io> https://hg.python.org/cpython/rev/fe692ee6d19a changeset: 100174:fe692ee6d19a branch: 2.7 parent: 100168:a2a9ff290cb2 user: Martin Panter date: Mon Feb 08 01:34:09 2016 +0000 summary: Issue #25179: Preparatory cleanup of existing docs on string formatting * There was a link pointing to the section on the string.Formatter class (and multiple links in Python 3), when the section on the common format string syntax is probably more appropriate * Fix references to various format() functions and methods * Nested replacement fields may contain conversions and format specifiers, and this is tested in Python 3; see Issue #19729 for instance files: Doc/library/datetime.rst | 6 ++-- Doc/library/pprint.rst | 2 +- Doc/library/string.rst | 25 ++++++++++++---------- Doc/tools/susp-ignored.csv | 2 +- Doc/tutorial/introduction.rst | 5 +-- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -558,7 +558,7 @@ .. method:: date.__format__(format) - Same as :meth:`.date.strftime`. This makes it possible to specify format + Same as :meth:`.date.strftime`. This makes it possible to specify a format string for a :class:`.date` object when using :meth:`str.format`. See section :ref:`strftime-strptime-behavior`. @@ -1058,7 +1058,7 @@ .. method:: datetime.__format__(format) - Same as :meth:`.datetime.strftime`. This makes it possible to specify format + Same as :meth:`.datetime.strftime`. This makes it possible to specify a format string for a :class:`.datetime` object when using :meth:`str.format`. See section :ref:`strftime-strptime-behavior`. @@ -1292,7 +1292,7 @@ .. method:: time.__format__(format) - Same as :meth:`.time.strftime`. This makes it possible to specify format string + Same as :meth:`.time.strftime`. This makes it possible to specify a format string for a :class:`.time` object when using :meth:`str.format`. See section :ref:`strftime-strptime-behavior`. diff --git a/Doc/library/pprint.rst b/Doc/library/pprint.rst --- a/Doc/library/pprint.rst +++ b/Doc/library/pprint.rst @@ -190,7 +190,7 @@ the current presentation context (direct and indirect containers for *object* that are affecting the presentation) as the keys; if an object needs to be presented which is already represented in *context*, the third return value - should be ``True``. Recursive calls to the :meth:`format` method should add + should be ``True``. Recursive calls to the :meth:`.format` method should add additional entries for containers to this dictionary. The third argument, *maxlevels*, gives the requested limit to recursion; this will be ``0`` if there is no requested limit. This argument should be passed unmodified to recursive diff --git a/Doc/library/string.rst b/Doc/library/string.rst --- a/Doc/library/string.rst +++ b/Doc/library/string.rst @@ -105,8 +105,8 @@ .. _new-string-formatting: -String Formatting ------------------ +Custom String Formatting +------------------------ .. versionadded:: 2.6 @@ -115,7 +115,7 @@ :meth:`str.format` method described in :pep:`3101`. The :class:`Formatter` class in the :mod:`string` module allows you to create and customize your own string formatting behaviors using the same implementation as the built-in -:meth:`format` method. +:meth:`~str.format` method. .. class:: Formatter @@ -123,9 +123,9 @@ .. method:: format(format_string, *args, **kwargs) - :meth:`format` is the primary API method. It takes a format string and + The primary API method. It takes a format string and an arbitrary set of positional and keyword arguments. - :meth:`format` is just a wrapper that calls :meth:`vformat`. + It is just a wrapper that calls :meth:`vformat`. .. method:: vformat(format_string, args, kwargs) @@ -293,8 +293,9 @@ described in the next section. A *format_spec* field can also include nested replacement fields within it. -These nested replacement fields can contain only a field name; conversion flags -and format specifications are not allowed. The replacement fields within the +These nested replacement fields may contain a field name, conversion flag +and format specification, but deeper nesting is +not allowed. The replacement fields within the format_spec are substituted before the *format_spec* string is interpreted. This allows the formatting of a value to be dynamically specified. @@ -332,8 +333,10 @@ If a valid *align* value is specified, it can be preceded by a *fill* character that can be any character and defaults to a space if omitted. -Note that it is not possible to use ``{`` and ``}`` as *fill* char while -using the :meth:`str.format` method; this limitation however doesn't +It is not possible to use a literal curly brace ("``{``" or "``}``") as +the *fill* character when using the :meth:`str.format` +method. However, it is possible to insert a curly brace +with a nested replacement field. This limitation doesn't affect the :func:`format` function. The meaning of the various alignment options is as follows: @@ -508,8 +511,8 @@ Format examples ^^^^^^^^^^^^^^^ -This section contains examples of the new format syntax and comparison with -the old ``%``-formatting. +This section contains examples of the :meth:`str.format` syntax and +comparison with the old ``%``-formatting. In most of the cases the syntax is similar to the old ``%``-formatting, with the addition of the ``{}`` and with ``:`` used instead of ``%``. diff --git a/Doc/tools/susp-ignored.csv b/Doc/tools/susp-ignored.csv --- a/Doc/tools/susp-ignored.csv +++ b/Doc/tools/susp-ignored.csv @@ -46,7 +46,7 @@ howto/pyporting,,::,Programming Language :: Python :: 3 howto/regex,,::, howto/regex,,:foo,(?:foo) -howto/urllib2,,:example,"for example ""joe at password:example.com""" +howto/urllib2,,:password,"for example ""joe:password at example.com""" library/audioop,,:ipos,"# factor = audioop.findfactor(in_test[ipos*2:ipos*2+len(out_test)]," library/bisect,,:hi,all(val >= x for val in a[i:hi]) library/bisect,,:hi,all(val > x for val in a[i:hi]) diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -357,9 +357,8 @@ Both strings and Unicode strings support a large number of methods for basic transformations and searching. - :ref:`new-string-formatting` - Information about string formatting with :meth:`str.format` is described - here. + :ref:`formatstrings` + Information about string formatting with :meth:`str.format`. :ref:`string-formatting` The old formatting operations invoked when strings and Unicode strings are -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Feb 6 21:40:38 2016 From: python-checkins at python.org (martin.panter) Date: Sun, 07 Feb 2016 02:40:38 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Merge_string_formatting_doc_fixes_from_3=2E5?= Message-ID: <20160207024038.1543.52397@psf.io> https://hg.python.org/cpython/rev/4cf08147a52e changeset: 100173:4cf08147a52e parent: 100171:cfb77ccdc23a parent: 100172:f25d8cbd074a user: Martin Panter date: Mon Feb 08 01:49:35 2016 +0000 summary: Merge string formatting doc fixes from 3.5 files: Doc/faq/programming.rst | 2 +- Doc/library/datetime.rst | 6 ++-- Doc/library/enum.rst | 12 +++++----- Doc/library/pprint.rst | 2 +- Doc/library/stdtypes.rst | 2 +- Doc/library/string.rst | 27 ++++++++++++---------- Doc/library/tracemalloc.rst | 2 +- Doc/tools/susp-ignored.csv | 2 +- Doc/tutorial/introduction.rst | 5 +-- 9 files changed, 31 insertions(+), 29 deletions(-) diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -839,7 +839,7 @@ To convert, e.g., the number 144 to the string '144', use the built-in type constructor :func:`str`. If you want a hexadecimal or octal representation, use the built-in functions :func:`hex` or :func:`oct`. For fancy formatting, see -the :ref:`string-formatting` section, e.g. ``"{:04d}".format(144)`` yields +the :ref:`formatstrings` section, e.g. ``"{:04d}".format(144)`` yields ``'0144'`` and ``"{:.3f}".format(1.0/3.0)`` yields ``'0.333'``. diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -604,7 +604,7 @@ .. method:: date.__format__(format) - Same as :meth:`.date.strftime`. This makes it possible to specify format + Same as :meth:`.date.strftime`. This makes it possible to specify a format string for a :class:`.date` object when using :meth:`str.format`. For a complete list of formatting directives, see :ref:`strftime-strptime-behavior`. @@ -1179,7 +1179,7 @@ .. method:: datetime.__format__(format) - Same as :meth:`.datetime.strftime`. This makes it possible to specify format + Same as :meth:`.datetime.strftime`. This makes it possible to specify a format string for a :class:`.datetime` object when using :meth:`str.format`. For a complete list of formatting directives, see :ref:`strftime-strptime-behavior`. @@ -1424,7 +1424,7 @@ .. method:: time.__format__(format) - Same as :meth:`.time.strftime`. This makes it possible to specify format string + Same as :meth:`.time.strftime`. This makes it possible to specify a format string for a :class:`.time` object when using :meth:`str.format`. For a complete list of formatting directives, see :ref:`strftime-strptime-behavior`. diff --git a/Doc/library/enum.rst b/Doc/library/enum.rst --- a/Doc/library/enum.rst +++ b/Doc/library/enum.rst @@ -555,12 +555,12 @@ 3. When another data type is mixed in, the :attr:`value` attribute is *not the same* as the enum member itself, although it is equivalent and will compare equal. -4. %-style formatting: `%s` and `%r` call :class:`Enum`'s :meth:`__str__` and - :meth:`__repr__` respectively; other codes (such as `%i` or `%h` for - IntEnum) treat the enum member as its mixed-in type. -5. :meth:`str.__format__` (or :func:`format`) will use the mixed-in - type's :meth:`__format__`. If the :class:`Enum`'s :func:`str` or - :func:`repr` is desired use the `!s` or `!r` :class:`str` format codes. +4. %-style formatting: `%s` and `%r` call the :class:`Enum` class's + :meth:`__str__` and :meth:`__repr__` respectively; other codes (such as + `%i` or `%h` for IntEnum) treat the enum member as its mixed-in type. +5. :meth:`str.format` (or :func:`format`) will use the mixed-in + type's :meth:`__format__`. If the :class:`Enum` class's :func:`str` or + :func:`repr` is desired, use the `!s` or `!r` format codes. Interesting examples diff --git a/Doc/library/pprint.rst b/Doc/library/pprint.rst --- a/Doc/library/pprint.rst +++ b/Doc/library/pprint.rst @@ -197,7 +197,7 @@ the current presentation context (direct and indirect containers for *object* that are affecting the presentation) as the keys; if an object needs to be presented which is already represented in *context*, the third return value - should be ``True``. Recursive calls to the :meth:`format` method should add + should be ``True``. Recursive calls to the :meth:`.format` method should add additional entries for containers to this dictionary. The third argument, *maxlevels*, gives the requested limit to recursion; this will be ``0`` if there is no requested limit. This argument should be passed unmodified to recursive diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1450,7 +1450,7 @@ For more information on the ``str`` class and its methods, see :ref:`textseq` and the :ref:`string-methods` section below. To output - formatted strings, see the :ref:`string-formatting` section. In addition, + formatted strings, see the :ref:`formatstrings` section. In addition, see the :ref:`stringservices` section. diff --git a/Doc/library/string.rst b/Doc/library/string.rst --- a/Doc/library/string.rst +++ b/Doc/library/string.rst @@ -75,14 +75,14 @@ .. _string-formatting: -String Formatting ------------------ +Custom String Formatting +------------------------ The built-in string class provides the ability to do complex variable -substitutions and value formatting via the :func:`format` method described in +substitutions and value formatting via the :meth:`~str.format` method described in :pep:`3101`. The :class:`Formatter` class in the :mod:`string` module allows you to create and customize your own string formatting behaviors using the same -implementation as the built-in :meth:`format` method. +implementation as the built-in :meth:`~str.format` method. .. class:: Formatter @@ -91,9 +91,9 @@ .. method:: format(format_string, *args, **kwargs) - :meth:`format` is the primary API method. It takes a format string and + The primary API method. It takes a format string and an arbitrary set of positional and keyword arguments. - :meth:`format` is just a wrapper that calls :meth:`vformat`. + It is just a wrapper that calls :meth:`vformat`. .. deprecated:: 3.5 Passing a format string as keyword argument *format_string* has been @@ -267,8 +267,9 @@ described in the next section. A *format_spec* field can also include nested replacement fields within it. -These nested replacement fields can contain only a field name; conversion flags -and format specifications are not allowed. The replacement fields within the +These nested replacement fields may contain a field name, conversion flag +and format specification, but deeper nesting is +not allowed. The replacement fields within the format_spec are substituted before the *format_spec* string is interpreted. This allows the formatting of a value to be dynamically specified. @@ -306,8 +307,10 @@ If a valid *align* value is specified, it can be preceded by a *fill* character that can be any character and defaults to a space if omitted. -Note that it is not possible to use ``{`` and ``}`` as *fill* char while -using the :meth:`str.format` method; this limitation however doesn't +It is not possible to use a literal curly brace ("``{``" or "``}``") as +the *fill* character when using the :meth:`str.format` +method. However, it is possible to insert a curly brace +with a nested replacement field. This limitation doesn't affect the :func:`format` function. The meaning of the various alignment options is as follows: @@ -496,8 +499,8 @@ Format examples ^^^^^^^^^^^^^^^ -This section contains examples of the new format syntax and comparison with -the old ``%``-formatting. +This section contains examples of the :meth:`str.format` syntax and +comparison with the old ``%``-formatting. In most of the cases the syntax is similar to the old ``%``-formatting, with the addition of the ``{}`` and with ``:`` used instead of ``%``. diff --git a/Doc/library/tracemalloc.rst b/Doc/library/tracemalloc.rst --- a/Doc/library/tracemalloc.rst +++ b/Doc/library/tracemalloc.rst @@ -620,7 +620,7 @@ *limit* is set, only format the *limit* most recent frames. Similar to the :func:`traceback.format_tb` function, except that - :meth:`format` does not include newlines. + :meth:`.format` does not include newlines. Example:: diff --git a/Doc/tools/susp-ignored.csv b/Doc/tools/susp-ignored.csv --- a/Doc/tools/susp-ignored.csv +++ b/Doc/tools/susp-ignored.csv @@ -82,7 +82,7 @@ howto/pyporting,,::,Programming Language :: Python :: 3 howto/regex,,::, howto/regex,,:foo,(?:foo) -howto/urllib2,,:example,"for example ""joe at password:example.com""" +howto/urllib2,,:password,"for example ""joe:password at example.com""" library/audioop,,:ipos,"# factor = audioop.findfactor(in_test[ipos*2:ipos*2+len(out_test)]," library/bisect,32,:hi,all(val >= x for val in a[i:hi]) library/bisect,42,:hi,all(val > x for val in a[i:hi]) diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -352,9 +352,8 @@ Strings support a large number of methods for basic transformations and searching. - :ref:`string-formatting` - Information about string formatting with :meth:`str.format` is described - here. + :ref:`formatstrings` + Information about string formatting with :meth:`str.format`. :ref:`old-string-formatting` The old formatting operations invoked when strings and Unicode strings are -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Feb 7 01:36:11 2016 From: python-checkins at python.org (benjamin.peterson) Date: Sun, 07 Feb 2016 06:36:11 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_fix_hash_membe?= =?utf-8?q?r_name_=28closes_=2322847=29?= Message-ID: <20160207063611.40080.50319@psf.io> https://hg.python.org/cpython/rev/04424651f76c changeset: 100175:04424651f76c branch: 2.7 user: Benjamin Peterson date: Sat Feb 06 22:36:06 2016 -0800 summary: fix hash member name (closes #22847) files: Objects/typeobject.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Objects/typeobject.c b/Objects/typeobject.c --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -2565,7 +2565,7 @@ method_cache[h].version = type->tp_version_tag; method_cache[h].value = res; /* borrowed */ Py_INCREF(name); - assert(((PyStringObject *)(name))->hash != -1); + assert(((PyStringObject *)(name))->ob_shash != -1); #if MCACHE_STATS if (method_cache[h].name != Py_None && method_cache[h].name != name) method_cache_collisions++; -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Sun Feb 7 04:44:55 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Sun, 07 Feb 2016 09:44:55 +0000 Subject: [Python-checkins] Daily reference leaks (4cf08147a52e): sum=4 Message-ID: <20160207094455.1551.92545@psf.io> results for 4cf08147a52e on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflognuHTtI', '--timeout', '7200'] From python-checkins at python.org Sun Feb 7 17:05:31 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 07 Feb 2016 22:05:31 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2326039=3A_Added_zi?= =?utf-8?q?pfile=2EZipInfo=2Efrom=5Ffile=28=29_and_zipinfo=2EZipInfo=2Eis?= =?utf-8?b?X2RpcigpLg==?= Message-ID: <20160207220530.6679.64173@psf.io> https://hg.python.org/cpython/rev/7fea2cebc604 changeset: 100176:7fea2cebc604 parent: 100173:4cf08147a52e user: Serhiy Storchaka date: Mon Feb 08 00:02:25 2016 +0200 summary: Issue #26039: Added zipfile.ZipInfo.from_file() and zipinfo.ZipInfo.is_dir(). Patch by Thomas Kluyver. files: Doc/library/zipfile.rst | 24 ++++++++ Doc/whatsnew/3.6.rst | 10 +++ Lib/test/test_zipfile.py | 15 +++++ Lib/zipfile.py | 75 +++++++++++++++++---------- Misc/NEWS | 3 + 5 files changed, 99 insertions(+), 28 deletions(-) diff --git a/Doc/library/zipfile.rst b/Doc/library/zipfile.rst --- a/Doc/library/zipfile.rst +++ b/Doc/library/zipfile.rst @@ -465,6 +465,22 @@ :meth:`.infolist` methods of :class:`ZipFile` objects. Each object stores information about a single member of the ZIP archive. +There is one classmethod to make a :class:`ZipInfo` instance for a filesystem +file: + +.. classmethod:: ZipInfo.from_file(filename, arcname=None) + + Construct a :class:`ZipInfo` instance for a file on the filesystem, in + preparation for adding it to a zip file. + + *filename* should be the path to a file or directory on the filesystem. + + If *arcname* is specified, it is used as the name within the archive. + If *arcname* is not specified, the name will be the same as *filename*, but + with any drive letter and leading path separators removed. + + .. versionadded:: 3.6 + Instances have the following attributes: @@ -574,3 +590,11 @@ .. attribute:: ZipInfo.file_size Size of the uncompressed file. + +There is one method: + +.. method:: ZipInfo.is_dir() + + Return ``True`` if the ZipInfo represents a directory. + + .. versionadded:: 3.6 diff --git a/Doc/whatsnew/3.6.rst b/Doc/whatsnew/3.6.rst --- a/Doc/whatsnew/3.6.rst +++ b/Doc/whatsnew/3.6.rst @@ -140,6 +140,16 @@ (Contributed by Nikolay Bogoychev in :issue:`16099`.) +zipfile +------- + +A new :meth:`ZipInfo.from_file() ` class method +allow to make :class:`~zipfile.ZipInfo` instance from a filesystem file. +A new :meth:`ZipInfo.is_dir() ` method can be used +to check if the :class:`~zipfile.ZipInfo` instance represents a directory. +(Contributed by Thomas Kluyver in :issue:`26039`.) + + Optimizations ============= diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -3,6 +3,7 @@ import os import sys import importlib.util +import posixpath import time import struct import zipfile @@ -2071,5 +2072,19 @@ unittest.TestCase): compression = zipfile.ZIP_LZMA +class ZipInfoTests(unittest.TestCase): + def test_from_file(self): + zi = zipfile.ZipInfo.from_file(__file__) + self.assertEqual(posixpath.basename(zi.filename), 'test_zipfile.py') + self.assertFalse(zi.is_dir()) + + def test_from_dir(self): + dirpath = os.path.dirname(os.path.abspath(__file__)) + zi = zipfile.ZipInfo.from_file(dirpath, 'stdlib_tests') + self.assertEqual(zi.filename, 'stdlib_tests/') + self.assertTrue(zi.is_dir()) + self.assertEqual(zi.compress_type, zipfile.ZIP_STORED) + self.assertEqual(zi.file_size, 0) + if __name__ == "__main__": unittest.main() diff --git a/Lib/zipfile.py b/Lib/zipfile.py --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -371,7 +371,7 @@ result.append(' filemode=%r' % stat.filemode(hi)) if lo: result.append(' external_attr=%#x' % lo) - isdir = self.filename[-1:] == '/' + isdir = self.is_dir() if not isdir or self.file_size: result.append(' file_size=%r' % self.file_size) if ((not isdir or self.compress_size) and @@ -469,6 +469,41 @@ extra = extra[ln+4:] + @classmethod + def from_file(cls, filename, arcname=None): + """Construct an appropriate ZipInfo for a file on the filesystem. + + filename should be the path to a file or directory on the filesystem. + + arcname is the name which it will have within the archive (by default, + this will be the same as filename, but without a drive letter and with + leading path separators removed). + """ + st = os.stat(filename) + isdir = stat.S_ISDIR(st.st_mode) + mtime = time.localtime(st.st_mtime) + date_time = mtime[0:6] + # Create ZipInfo instance to store file information + if arcname is None: + arcname = filename + arcname = os.path.normpath(os.path.splitdrive(arcname)[1]) + while arcname[0] in (os.sep, os.altsep): + arcname = arcname[1:] + if isdir: + arcname += '/' + zinfo = cls(arcname, date_time) + zinfo.external_attr = (st.st_mode & 0xFFFF) << 16 # Unix attributes + if isdir: + zinfo.file_size = 0 + zinfo.external_attr |= 0x10 # MS-DOS directory flag + else: + zinfo.file_size = st.st_size + + return zinfo + + def is_dir(self): + return self.filename[-1] == '/' + class _ZipDecrypter: """Class to handle decryption of files stored within a ZIP archive. @@ -1389,7 +1424,7 @@ if upperdirs and not os.path.exists(upperdirs): os.makedirs(upperdirs) - if member.filename[-1] == '/': + if member.is_dir(): if not os.path.isdir(targetpath): os.mkdir(targetpath) return targetpath @@ -1430,29 +1465,17 @@ raise RuntimeError( "Attempt to write to ZIP archive that was already closed") - st = os.stat(filename) - isdir = stat.S_ISDIR(st.st_mode) - mtime = time.localtime(st.st_mtime) - date_time = mtime[0:6] - # Create ZipInfo instance to store file information - if arcname is None: - arcname = filename - arcname = os.path.normpath(os.path.splitdrive(arcname)[1]) - while arcname[0] in (os.sep, os.altsep): - arcname = arcname[1:] - if isdir: - arcname += '/' - zinfo = ZipInfo(arcname, date_time) - zinfo.external_attr = (st[0] & 0xFFFF) << 16 # Unix attributes - if isdir: - zinfo.compress_type = ZIP_STORED - elif compress_type is None: - zinfo.compress_type = self.compression + zinfo = ZipInfo.from_file(filename, arcname) + + if zinfo.is_dir(): + zinfo.compress_size = 0 + zinfo.CRC = 0 else: - zinfo.compress_type = compress_type + if compress_type is not None: + zinfo.compress_type = compress_type + else: + zinfo.compress_type = self.compression - zinfo.file_size = st.st_size - zinfo.flag_bits = 0x00 with self._lock: if self._seekable: self.fp.seek(self.start_dir) @@ -1464,11 +1487,7 @@ self._writecheck(zinfo) self._didModify = True - if isdir: - zinfo.file_size = 0 - zinfo.compress_size = 0 - zinfo.CRC = 0 - zinfo.external_attr |= 0x10 # MS-DOS directory flag + if zinfo.is_dir(): self.filelist.append(zinfo) self.NameToInfo[zinfo.filename] = zinfo self.fp.write(zinfo.FileHeader(False)) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -170,6 +170,9 @@ Library ------- +- Issue #26039: Added zipfile.ZipInfo.from_file() and zipinfo.ZipInfo.is_dir(). + Patch by Thomas Kluyver. + - Issue #12923: Reset FancyURLopener's redirect counter even if there is an exception. Based on patches by Brian Brazil and Daniel Rocco. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Feb 7 18:23:14 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 07 Feb 2016 23:23:14 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI2MTk4?= =?utf-8?q?=3A_Fixed_error_messages_for_some_argument_parsing_errors=2E?= Message-ID: <20160207232313.20009.14924@psf.io> https://hg.python.org/cpython/rev/ab25ce400abd changeset: 100177:ab25ce400abd branch: 2.7 parent: 100175:04424651f76c user: Serhiy Storchaka date: Mon Feb 08 01:05:48 2016 +0200 summary: Issue #26198: Fixed error messages for some argument parsing errors. Fixed the documented about buffer overflow error for "es#" and "et#" format units. files: Doc/c-api/arg.rst | 3 ++- Python/getargs.c | 33 +++++++++++++++++++++------------ 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/Doc/c-api/arg.rst b/Doc/c-api/arg.rst --- a/Doc/c-api/arg.rst +++ b/Doc/c-api/arg.rst @@ -136,7 +136,8 @@ :c:func:`PyArg_ParseTuple` will use this location as the buffer and interpret the initial value of *\*buffer_length* as the buffer size. It will then copy the encoded data into the buffer and NUL-terminate it. If - the buffer is not large enough, a :exc:`ValueError` will be set. + the buffer is not large enough, a :exc:`TypeError` will be set. + Note: starting from Python 3.6 a :exc:`ValueError` will be set. In both cases, *\*buffer_length* is set to the length of the encoded data without the trailing NUL byte. diff --git a/Python/getargs.c b/Python/getargs.c --- a/Python/getargs.c +++ b/Python/getargs.c @@ -346,7 +346,7 @@ flags, levels, msgbuf, sizeof(msgbuf), &freelist); if (msg) { - seterror(i+1, msg, levels, fname, msg); + seterror(i+1, msg, levels, fname, message); return cleanreturn(0, freelist); } } @@ -533,9 +533,17 @@ { assert(expected != NULL); assert(arg != NULL); - PyOS_snprintf(msgbuf, bufsize, - "must be %.50s, not %.50s", expected, - arg == Py_None ? "None" : arg->ob_type->tp_name); + if (expected[0] == '(') { + PyOS_snprintf(msgbuf, bufsize, + "%.100s", expected); + strncpy(msgbuf, expected, bufsize); + msgbuf[bufsize-1] = '\0'; + } + else { + PyOS_snprintf(msgbuf, bufsize, + "must be %.50s, not %.50s", expected, + arg == Py_None ? "None" : arg->ob_type->tp_name); + } return msgbuf; } @@ -753,7 +761,7 @@ else if (PyLong_Check(arg)) ival = PyLong_AsUnsignedLongMask(arg); else - return converterr("integer", arg, msgbuf, bufsize); + return converterr("an integer", arg, msgbuf, bufsize); *p = ival; break; } @@ -781,7 +789,7 @@ else if (PyLong_Check(arg)) ival = PyLong_AsUnsignedLongLongMask(arg); else - return converterr("integer", arg, msgbuf, bufsize); + return converterr("an integer", arg, msgbuf, bufsize); *p = ival; break; } @@ -1127,9 +1135,11 @@ } else { if (size + 1 > BUFFER_LEN) { Py_DECREF(s); - return converterr( - "(buffer overflow)", - arg, msgbuf, bufsize); + PyErr_Format(PyExc_TypeError, + "encoded string too long " + "(%zd, maximum length %zd)", + (Py_ssize_t)size, (Py_ssize_t)(BUFFER_LEN-1)); + return ""; } } memcpy(*buffer, @@ -1154,7 +1164,7 @@ != size) { Py_DECREF(s); return converterr( - "encoded string without NULL bytes", + "encoded string without null bytes", arg, msgbuf, bufsize); } *buffer = PyMem_NEW(char, size + 1); @@ -1261,7 +1271,6 @@ break; } - case 'w': { /* memory buffer, read-write access */ void **p = va_arg(*p_va, void **); void *res; @@ -1353,7 +1362,7 @@ } default: - return converterr("impossible", arg, msgbuf, bufsize); + return converterr("(impossible)", arg, msgbuf, bufsize); } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Feb 7 18:23:14 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 07 Feb 2016 23:23:14 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2MTk4?= =?utf-8?q?=3A_Fixed_error_messages_for_some_argument_parsing_errors=2E?= Message-ID: <20160207232314.61980.32236@psf.io> https://hg.python.org/cpython/rev/9f998e24d8d8 changeset: 100178:9f998e24d8d8 branch: 3.5 parent: 100172:f25d8cbd074a user: Serhiy Storchaka date: Mon Feb 08 01:06:11 2016 +0200 summary: Issue #26198: Fixed error messages for some argument parsing errors. Fixed the documented about buffer overflow error for "es#" and "et#" format units. files: Doc/c-api/arg.rst | 3 +- Lib/test/test_capi.py | 2 +- Python/getargs.c | 32 +++++++++++++++++++----------- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/Doc/c-api/arg.rst b/Doc/c-api/arg.rst --- a/Doc/c-api/arg.rst +++ b/Doc/c-api/arg.rst @@ -206,7 +206,8 @@ :c:func:`PyArg_ParseTuple` will use this location as the buffer and interpret the initial value of *\*buffer_length* as the buffer size. It will then copy the encoded data into the buffer and NUL-terminate it. If the buffer is not large - enough, a :exc:`ValueError` will be set. + enough, a :exc:`TypeError` will be set. + Note: starting from Python 3.6 a :exc:`ValueError` will be set. In both cases, *\*buffer_length* is set to the length of the encoded data without the trailing NUL byte. diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py --- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -489,7 +489,7 @@ format.encode("ascii"), keywords) when_not_skipped = False except TypeError as e: - s = "argument 1 must be impossible, not int" + s = "argument 1 (impossible)" when_not_skipped = (str(e) == s) except RuntimeError as e: when_not_skipped = False diff --git a/Python/getargs.c b/Python/getargs.c --- a/Python/getargs.c +++ b/Python/getargs.c @@ -342,7 +342,7 @@ flags, levels, msgbuf, sizeof(msgbuf), &freelist); if (msg) { - seterror(i+1, msg, levels, fname, msg); + seterror(i+1, msg, levels, fname, message); return cleanreturn(0, &freelist); } } @@ -535,9 +535,15 @@ { assert(expected != NULL); assert(arg != NULL); - PyOS_snprintf(msgbuf, bufsize, - "must be %.50s, not %.50s", expected, - arg == Py_None ? "None" : arg->ob_type->tp_name); + if (expected[0] == '(') { + PyOS_snprintf(msgbuf, bufsize, + "%.100s", expected); + } + else { + PyOS_snprintf(msgbuf, bufsize, + "must be %.50s, not %.50s", expected, + arg == Py_None ? "None" : arg->ob_type->tp_name); + } return msgbuf; } @@ -741,7 +747,7 @@ if (PyLong_Check(arg)) ival = PyLong_AsUnsignedLongMask(arg); else - return converterr("integer", arg, msgbuf, bufsize); + return converterr("int", arg, msgbuf, bufsize); *p = ival; break; } @@ -766,7 +772,7 @@ if (PyLong_Check(arg)) ival = PyLong_AsUnsignedLongLongMask(arg); else - return converterr("integer", arg, msgbuf, bufsize); + return converterr("int", arg, msgbuf, bufsize); *p = ival; break; } @@ -1123,9 +1129,11 @@ } else { if (size + 1 > BUFFER_LEN) { Py_DECREF(s); - return converterr( - "(buffer overflow)", - arg, msgbuf, bufsize); + PyErr_Format(PyExc_TypeError, + "encoded string too long " + "(%zd, maximum length %zd)", + (Py_ssize_t)size, (Py_ssize_t)(BUFFER_LEN-1)); + RETURN_ERR_OCCURRED; } } memcpy(*buffer, ptr, size+1); @@ -1147,7 +1155,7 @@ if ((Py_ssize_t)strlen(ptr) != size) { Py_DECREF(s); return converterr( - "encoded string without NULL bytes", + "encoded string without null bytes", arg, msgbuf, bufsize); } *buffer = PyMem_NEW(char, size + 1); @@ -1237,7 +1245,7 @@ if (*format != '*') return converterr( - "invalid use of 'w' format character", + "(invalid use of 'w' format character)", arg, msgbuf, bufsize); format++; @@ -1261,7 +1269,7 @@ } default: - return converterr("impossible", arg, msgbuf, bufsize); + return converterr("(impossible)", arg, msgbuf, bufsize); } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Feb 7 18:23:19 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 07 Feb 2016 23:23:19 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326198=3A_Fixed_error_messages_for_some_argument?= =?utf-8?q?_parsing_errors=2E?= Message-ID: <20160207232319.11235.62543@psf.io> https://hg.python.org/cpython/rev/f8bdc0ea3bcf changeset: 100179:f8bdc0ea3bcf parent: 100176:7fea2cebc604 parent: 100178:9f998e24d8d8 user: Serhiy Storchaka date: Mon Feb 08 01:20:21 2016 +0200 summary: Issue #26198: Fixed error messages for some argument parsing errors. files: Lib/test/test_capi.py | 2 +- Python/getargs.c | 32 +++++++++++++++++++----------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py --- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -489,7 +489,7 @@ format.encode("ascii"), keywords) when_not_skipped = False except TypeError as e: - s = "argument 1 must be impossible, not int" + s = "argument 1 (impossible)" when_not_skipped = (str(e) == s) except RuntimeError as e: when_not_skipped = False diff --git a/Python/getargs.c b/Python/getargs.c --- a/Python/getargs.c +++ b/Python/getargs.c @@ -342,7 +342,7 @@ flags, levels, msgbuf, sizeof(msgbuf), &freelist); if (msg) { - seterror(i+1, msg, levels, fname, msg); + seterror(i+1, msg, levels, fname, message); return cleanreturn(0, &freelist); } } @@ -535,9 +535,15 @@ { assert(expected != NULL); assert(arg != NULL); - PyOS_snprintf(msgbuf, bufsize, - "must be %.50s, not %.50s", expected, - arg == Py_None ? "None" : arg->ob_type->tp_name); + if (expected[0] == '(') { + PyOS_snprintf(msgbuf, bufsize, + "%.100s", expected); + } + else { + PyOS_snprintf(msgbuf, bufsize, + "must be %.50s, not %.50s", expected, + arg == Py_None ? "None" : arg->ob_type->tp_name); + } return msgbuf; } @@ -741,7 +747,7 @@ if (PyLong_Check(arg)) ival = PyLong_AsUnsignedLongMask(arg); else - return converterr("integer", arg, msgbuf, bufsize); + return converterr("int", arg, msgbuf, bufsize); *p = ival; break; } @@ -766,7 +772,7 @@ if (PyLong_Check(arg)) ival = PyLong_AsUnsignedLongLongMask(arg); else - return converterr("integer", arg, msgbuf, bufsize); + return converterr("int", arg, msgbuf, bufsize); *p = ival; break; } @@ -1123,9 +1129,11 @@ } else { if (size + 1 > BUFFER_LEN) { Py_DECREF(s); - return converterr( - "(buffer overflow)", - arg, msgbuf, bufsize); + PyErr_Format(PyExc_TypeError, + "encoded string too long " + "(%zd, maximum length %zd)", + (Py_ssize_t)size, (Py_ssize_t)(BUFFER_LEN-1)); + RETURN_ERR_OCCURRED; } } memcpy(*buffer, ptr, size+1); @@ -1147,7 +1155,7 @@ if ((Py_ssize_t)strlen(ptr) != size) { Py_DECREF(s); return converterr( - "encoded string without NULL bytes", + "encoded string without null bytes", arg, msgbuf, bufsize); } *buffer = PyMem_NEW(char, size + 1); @@ -1237,7 +1245,7 @@ if (*format != '*') return converterr( - "invalid use of 'w' format character", + "(invalid use of 'w' format character)", arg, msgbuf, bufsize); format++; @@ -1261,7 +1269,7 @@ } default: - return converterr("impossible", arg, msgbuf, bufsize); + return converterr("(impossible)", arg, msgbuf, bufsize); } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Feb 7 18:23:19 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 07 Feb 2016 23:23:19 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2326198=3A_ValueErr?= =?utf-8?q?or_is_now_raised_instead_of_TypeError_on_buffer?= Message-ID: <20160207232319.15923.11639@psf.io> https://hg.python.org/cpython/rev/53d66a554beb changeset: 100180:53d66a554beb user: Serhiy Storchaka date: Mon Feb 08 01:22:47 2016 +0200 summary: Issue #26198: ValueError is now raised instead of TypeError on buffer overflow in parsing "es#" and "et#" format units. SystemError is now raised instead of TypeError on programmical error in parsing format string. files: Lib/test/test_capi.py | 4 ++-- Lib/test/test_getargs2.py | 8 ++++---- Misc/NEWS | 7 +++++++ Python/getargs.c | 9 +++++++-- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py --- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -488,10 +488,10 @@ _testcapi.parse_tuple_and_keywords(tuple_1, dict_b, format.encode("ascii"), keywords) when_not_skipped = False - except TypeError as e: + except SystemError as e: s = "argument 1 (impossible)" when_not_skipped = (str(e) == s) - except RuntimeError as e: + except (TypeError, RuntimeError): when_not_skipped = False # test the format unit when skipped diff --git a/Lib/test/test_getargs2.py b/Lib/test/test_getargs2.py --- a/Lib/test/test_getargs2.py +++ b/Lib/test/test_getargs2.py @@ -636,10 +636,10 @@ self.assertEqual(getargs_es_hash('abc\xe9', 'latin1', buf), b'abc\xe9') self.assertEqual(buf, bytearray(b'abc\xe9\x00')) buf = bytearray(b'x'*4) - self.assertRaises(TypeError, getargs_es_hash, 'abc\xe9', 'latin1', buf) + self.assertRaises(ValueError, getargs_es_hash, 'abc\xe9', 'latin1', buf) self.assertEqual(buf, bytearray(b'x'*4)) buf = bytearray() - self.assertRaises(TypeError, getargs_es_hash, 'abc\xe9', 'latin1', buf) + self.assertRaises(ValueError, getargs_es_hash, 'abc\xe9', 'latin1', buf) def test_et_hash(self): from _testcapi import getargs_et_hash @@ -662,10 +662,10 @@ self.assertEqual(getargs_et_hash('abc\xe9', 'latin1', buf), b'abc\xe9') self.assertEqual(buf, bytearray(b'abc\xe9\x00')) buf = bytearray(b'x'*4) - self.assertRaises(TypeError, getargs_et_hash, 'abc\xe9', 'latin1', buf) + self.assertRaises(ValueError, getargs_et_hash, 'abc\xe9', 'latin1', buf) self.assertEqual(buf, bytearray(b'x'*4)) buf = bytearray() - self.assertRaises(TypeError, getargs_et_hash, 'abc\xe9', 'latin1', buf) + self.assertRaises(ValueError, getargs_et_hash, 'abc\xe9', 'latin1', buf) def test_u(self): from _testcapi import getargs_u diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -713,6 +713,13 @@ - Issue #25154: The pyvenv script has been deprecated in favour of `python3 -m venv`. +C API +----- + +- Issue #26198: ValueError is now raised instead of TypeError on buffer + overflow in parsing "es#" and "et#" format units. SystemError is now raised + instead of TypeError on programmical error in parsing format string. + What's New in Python 3.5.1 final? ================================= diff --git a/Python/getargs.c b/Python/getargs.c --- a/Python/getargs.c +++ b/Python/getargs.c @@ -394,7 +394,12 @@ PyOS_snprintf(p, sizeof(buf) - (p - buf), " %.256s", msg); message = buf; } - PyErr_SetString(PyExc_TypeError, message); + if (msg[0] == '(') { + PyErr_SetString(PyExc_SystemError, message); + } + else { + PyErr_SetString(PyExc_TypeError, message); + } } @@ -1129,7 +1134,7 @@ } else { if (size + 1 > BUFFER_LEN) { Py_DECREF(s); - PyErr_Format(PyExc_TypeError, + PyErr_Format(PyExc_ValueError, "encoded string too long " "(%zd, maximum length %zd)", (Py_ssize_t)size, (Py_ssize_t)(BUFFER_LEN-1)); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 8 02:27:47 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 08 Feb 2016 07:27:47 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326198=3A_Make_datetime_error_tests_more_lenient?= =?utf-8?q?=2E?= Message-ID: <20160208072747.68404.69365@psf.io> https://hg.python.org/cpython/rev/a9c9e4054f3f changeset: 100182:a9c9e4054f3f parent: 100180:53d66a554beb parent: 100181:22b0a63808f8 user: Serhiy Storchaka date: Mon Feb 08 09:26:57 2016 +0200 summary: Issue #26198: Make datetime error tests more lenient. files: Lib/test/datetimetester.py | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py --- a/Lib/test/datetimetester.py +++ b/Lib/test/datetimetester.py @@ -1240,7 +1240,7 @@ dt = self.theclass(2007, 9, 10) self.assertEqual(dt.__format__(''), str(dt)) - with self.assertRaisesRegex(TypeError, '^must be str, not int$'): + with self.assertRaisesRegex(TypeError, 'must be str, not int'): dt.__format__(123) # check that a derived class's __str__() gets called @@ -1575,7 +1575,7 @@ dt = self.theclass(2007, 9, 10, 4, 5, 1, 123) self.assertEqual(dt.__format__(''), str(dt)) - with self.assertRaisesRegex(TypeError, '^must be str, not int$'): + with self.assertRaisesRegex(TypeError, 'must be str, not int'): dt.__format__(123) # check that a derived class's __str__() gets called @@ -2337,7 +2337,7 @@ t = self.theclass(1, 2, 3, 4) self.assertEqual(t.__format__(''), str(t)) - with self.assertRaisesRegex(TypeError, '^must be str, not int$'): + with self.assertRaisesRegex(TypeError, 'must be str, not int'): t.__format__(123) # check that a derived class's __str__() gets called -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 8 02:27:47 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 08 Feb 2016 07:27:47 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2MTk4?= =?utf-8?q?=3A_Make_datetime_error_tests_more_lenient=2E?= Message-ID: <20160208072747.61974.72158@psf.io> https://hg.python.org/cpython/rev/22b0a63808f8 changeset: 100181:22b0a63808f8 branch: 3.5 parent: 100178:9f998e24d8d8 user: Serhiy Storchaka date: Mon Feb 08 09:25:53 2016 +0200 summary: Issue #26198: Make datetime error tests more lenient. files: Lib/test/datetimetester.py | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py --- a/Lib/test/datetimetester.py +++ b/Lib/test/datetimetester.py @@ -1239,7 +1239,7 @@ dt = self.theclass(2007, 9, 10) self.assertEqual(dt.__format__(''), str(dt)) - with self.assertRaisesRegex(TypeError, '^must be str, not int$'): + with self.assertRaisesRegex(TypeError, 'must be str, not int'): dt.__format__(123) # check that a derived class's __str__() gets called @@ -1574,7 +1574,7 @@ dt = self.theclass(2007, 9, 10, 4, 5, 1, 123) self.assertEqual(dt.__format__(''), str(dt)) - with self.assertRaisesRegex(TypeError, '^must be str, not int$'): + with self.assertRaisesRegex(TypeError, 'must be str, not int'): dt.__format__(123) # check that a derived class's __str__() gets called @@ -2336,7 +2336,7 @@ t = self.theclass(1, 2, 3, 4) self.assertEqual(t.__format__(''), str(t)) - with self.assertRaisesRegex(TypeError, '^must be str, not int$'): + with self.assertRaisesRegex(TypeError, 'must be str, not int'): t.__format__(123) # check that a derived class's __str__() gets called -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Mon Feb 8 04:45:01 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Mon, 08 Feb 2016 09:45:01 +0000 Subject: [Python-checkins] Daily reference leaks (53d66a554beb): sum=4 Message-ID: <20160208094500.61962.76386@psf.io> results for 53d66a554beb on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflog3S2Dfb', '--timeout', '7200'] From python-checkins at python.org Mon Feb 8 06:57:17 2016 From: python-checkins at python.org (martin.panter) Date: Mon, 08 Feb 2016 11:57:17 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2MDQ1?= =?utf-8?q?=3A_Add_UTF-8_suggestion_to_error_in_http=2Eclient?= Message-ID: <20160208115716.40076.50979@psf.io> https://hg.python.org/cpython/rev/966bd147ccb5 changeset: 100183:966bd147ccb5 branch: 3.5 parent: 100181:22b0a63808f8 user: Martin Panter date: Tue Feb 09 10:20:52 2016 +0000 summary: Issue #26045: Add UTF-8 suggestion to error in http.client Based on patch by Guido van Rossum. files: Lib/http/client.py | 17 ++++++++++++++++- Lib/test/test_httplib.py | 2 +- Misc/NEWS | 3 +++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Lib/http/client.py b/Lib/http/client.py --- a/Lib/http/client.py +++ b/Lib/http/client.py @@ -146,6 +146,21 @@ _METHODS_EXPECTING_BODY = {'PATCH', 'POST', 'PUT'} +def _encode(data, name='data'): + """Call data.encode("latin-1") but show a better error message.""" + try: + return data.encode("latin-1") + except UnicodeEncodeError as err: + raise UnicodeEncodeError( + err.encoding, + err.object, + err.start, + err.end, + "%s (%.20r) is not valid Latin-1. Use %s.encode('utf-8') " + "if you want to send it encoded in UTF-8." % + (name.title(), data[err.start:err.end], name)) from None + + class HTTPMessage(email.message.Message): # XXX The only usage of this method is in # http.server.CGIHTTPRequestHandler. Maybe move the code there so @@ -1124,7 +1139,7 @@ if isinstance(body, str): # RFC 2616 Section 3.7.1 says that text default has a # default charset of iso-8859-1. - body = body.encode('iso-8859-1') + body = _encode(body, 'body') self.endheaders(body) def getresponse(self): diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -1042,7 +1042,7 @@ # intentionally omitted for simplicity blacklist = {"HTTPMessage", "parse_headers"} for name in dir(client): - if name in blacklist: + if name.startswith("_") or name in blacklist: continue module_object = getattr(client, name) if getattr(module_object, "__module__", None) == "http.client": diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -73,6 +73,9 @@ Library ------- +- Issue #26045: Add UTF-8 suggestion to error message when posting a + non-Latin-1 string with http.client. + - Issue #12923: Reset FancyURLopener's redirect counter even if there is an exception. Based on patches by Brian Brazil and Daniel Rocco. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 8 06:57:17 2016 From: python-checkins at python.org (martin.panter) Date: Mon, 08 Feb 2016 11:57:17 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326045=3A_Merge_http=2Eclient_error_addition_fro?= =?utf-8?q?m_3=2E5?= Message-ID: <20160208115716.6671.91331@psf.io> https://hg.python.org/cpython/rev/9896ead3cc1d changeset: 100184:9896ead3cc1d parent: 100182:a9c9e4054f3f parent: 100183:966bd147ccb5 user: Martin Panter date: Tue Feb 09 11:57:11 2016 +0000 summary: Issue #26045: Merge http.client error addition from 3.5 files: Lib/http/client.py | 17 ++++++++++++++++- Lib/test/test_httplib.py | 2 +- Misc/NEWS | 3 +++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Lib/http/client.py b/Lib/http/client.py --- a/Lib/http/client.py +++ b/Lib/http/client.py @@ -146,6 +146,21 @@ _METHODS_EXPECTING_BODY = {'PATCH', 'POST', 'PUT'} +def _encode(data, name='data'): + """Call data.encode("latin-1") but show a better error message.""" + try: + return data.encode("latin-1") + except UnicodeEncodeError as err: + raise UnicodeEncodeError( + err.encoding, + err.object, + err.start, + err.end, + "%s (%.20r) is not valid Latin-1. Use %s.encode('utf-8') " + "if you want to send it encoded in UTF-8." % + (name.title(), data[err.start:err.end], name)) from None + + class HTTPMessage(email.message.Message): # XXX The only usage of this method is in # http.server.CGIHTTPRequestHandler. Maybe move the code there so @@ -1173,7 +1188,7 @@ if isinstance(body, str): # RFC 2616 Section 3.7.1 says that text default has a # default charset of iso-8859-1. - body = body.encode('iso-8859-1') + body = _encode(body, 'body') self.endheaders(body) def getresponse(self): diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -1042,7 +1042,7 @@ # intentionally omitted for simplicity blacklist = {"HTTPMessage", "parse_headers"} for name in dir(client): - if name in blacklist: + if name.startswith("_") or name in blacklist: continue module_object = getattr(client, name) if getattr(module_object, "__module__", None) == "http.client": diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -170,6 +170,9 @@ Library ------- +- Issue #26045: Add UTF-8 suggestion to error message when posting a + non-Latin-1 string with http.client. + - Issue #26039: Added zipfile.ZipInfo.from_file() and zipinfo.ZipInfo.is_dir(). Patch by Thomas Kluyver. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 8 09:24:37 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 08 Feb 2016 14:24:37 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325911=3A_Restored_support_of_bytes_paths_in_os?= =?utf-8?q?=2Ewalk=28=29_on_Windows=2E?= Message-ID: <20160208142437.19999.1500@psf.io> https://hg.python.org/cpython/rev/b060af2a58b6 changeset: 100186:b060af2a58b6 parent: 100184:9896ead3cc1d parent: 100185:5310f94772f4 user: Serhiy Storchaka date: Mon Feb 08 16:24:15 2016 +0200 summary: Issue #25911: Restored support of bytes paths in os.walk() on Windows. files: Lib/os.py | 27 ++++++++++++++++++++++----- Lib/test/test_os.py | 22 +++++++++++++++++----- Misc/NEWS | 2 ++ 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/Lib/os.py b/Lib/os.py --- a/Lib/os.py +++ b/Lib/os.py @@ -363,9 +363,12 @@ # minor reason when (say) a thousand readable directories are still # left to visit. That logic is copied here. try: - # Note that scandir is global in this module due - # to earlier import-*. - scandir_it = scandir(top) + if name == 'nt' and isinstance(top, bytes): + scandir_it = _dummy_scandir(top) + else: + # Note that scandir is global in this module due + # to earlier import-*. + scandir_it = scandir(top) except OSError as error: if onerror is not None: onerror(error) @@ -418,8 +421,8 @@ # Recurse into sub-directories islink, join = path.islink, path.join - for name in dirs: - new_path = join(top, name) + for dirname in dirs: + new_path = join(top, dirname) # Issue #23605: os.path.islink() is used instead of caching # entry.is_symlink() result during the loop on os.scandir() because # the caller can replace the directory entry during the "yield" @@ -430,6 +433,20 @@ # Yield after recursion if going bottom up yield top, dirs, nondirs +class _DummyDirEntry: + def __init__(self, dir, name): + self.name = name + self.path = path.join(dir, name) + def is_dir(self): + return path.isdir(self.path) + def is_symlink(self): + return path.islink(self.path) + +def _dummy_scandir(dir): + # listdir-based implementation for bytes patches on Windows + for name in listdir(dir): + yield _DummyDirEntry(dir, name) + __all__.append("walk") if {open, stat} <= supports_dir_fd and {listdir, stat} <= supports_fd: diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -790,10 +790,10 @@ # Wrapper to hide minor differences between os.walk and os.fwalk # to tests both functions with the same code base - def walk(self, directory, **kwargs): + def walk(self, top, **kwargs): if 'follow_symlinks' in kwargs: kwargs['followlinks'] = kwargs.pop('follow_symlinks') - return os.walk(directory, **kwargs) + return os.walk(top, **kwargs) def setUp(self): join = os.path.join @@ -944,11 +944,10 @@ class FwalkTests(WalkTests): """Tests for os.fwalk().""" - def walk(self, directory, **kwargs): - for root, dirs, files, root_fd in os.fwalk(directory, **kwargs): + def walk(self, top, **kwargs): + for root, dirs, files, root_fd in os.fwalk(top, **kwargs): yield (root, dirs, files) - def _compare_to_walk(self, walk_kwargs, fwalk_kwargs): """ compare with walk() results. @@ -1019,6 +1018,19 @@ os.unlink(name, dir_fd=rootfd) os.rmdir(support.TESTFN) +class BytesWalkTests(WalkTests): + """Tests for os.walk() with bytes.""" + def walk(self, top, **kwargs): + if 'follow_symlinks' in kwargs: + kwargs['followlinks'] = kwargs.pop('follow_symlinks') + for broot, bdirs, bfiles in os.walk(os.fsencode(top), **kwargs): + root = os.fsdecode(broot) + dirs = list(map(os.fsdecode, bdirs)) + files = list(map(os.fsdecode, bfiles)) + yield (root, dirs, files) + bdirs[:] = list(map(os.fsencode, dirs)) + bfiles[:] = list(map(os.fsencode, files)) + class MakedirTests(unittest.TestCase): def setUp(self): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -170,6 +170,8 @@ Library ------- +- Issue #25911: Restored support of bytes paths in os.walk() on Windows. + - Issue #26045: Add UTF-8 suggestion to error message when posting a non-Latin-1 string with http.client. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 8 09:24:38 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 08 Feb 2016 14:24:38 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1OTEx?= =?utf-8?q?=3A_Restored_support_of_bytes_paths_in_os=2Ewalk=28=29_on_Windo?= =?utf-8?b?d3Mu?= Message-ID: <20160208142437.68410.55@psf.io> https://hg.python.org/cpython/rev/5310f94772f4 changeset: 100185:5310f94772f4 branch: 3.5 parent: 100183:966bd147ccb5 user: Serhiy Storchaka date: Mon Feb 08 16:23:28 2016 +0200 summary: Issue #25911: Restored support of bytes paths in os.walk() on Windows. files: Lib/os.py | 27 ++++++++++++++++++++++----- Lib/test/test_os.py | 22 +++++++++++++++++----- Misc/NEWS | 2 ++ 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/Lib/os.py b/Lib/os.py --- a/Lib/os.py +++ b/Lib/os.py @@ -363,9 +363,12 @@ # minor reason when (say) a thousand readable directories are still # left to visit. That logic is copied here. try: - # Note that scandir is global in this module due - # to earlier import-*. - scandir_it = scandir(top) + if name == 'nt' and isinstance(top, bytes): + scandir_it = _dummy_scandir(top) + else: + # Note that scandir is global in this module due + # to earlier import-*. + scandir_it = scandir(top) except OSError as error: if onerror is not None: onerror(error) @@ -418,8 +421,8 @@ # Recurse into sub-directories islink, join = path.islink, path.join - for name in dirs: - new_path = join(top, name) + for dirname in dirs: + new_path = join(top, dirname) # Issue #23605: os.path.islink() is used instead of caching # entry.is_symlink() result during the loop on os.scandir() because # the caller can replace the directory entry during the "yield" @@ -430,6 +433,20 @@ # Yield after recursion if going bottom up yield top, dirs, nondirs +class _DummyDirEntry: + def __init__(self, dir, name): + self.name = name + self.path = path.join(dir, name) + def is_dir(self): + return path.isdir(self.path) + def is_symlink(self): + return path.islink(self.path) + +def _dummy_scandir(dir): + # listdir-based implementation for bytes patches on Windows + for name in listdir(dir): + yield _DummyDirEntry(dir, name) + __all__.append("walk") if {open, stat} <= supports_dir_fd and {listdir, stat} <= supports_fd: diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -791,10 +791,10 @@ # Wrapper to hide minor differences between os.walk and os.fwalk # to tests both functions with the same code base - def walk(self, directory, **kwargs): + def walk(self, top, **kwargs): if 'follow_symlinks' in kwargs: kwargs['followlinks'] = kwargs.pop('follow_symlinks') - return os.walk(directory, **kwargs) + return os.walk(top, **kwargs) def setUp(self): join = os.path.join @@ -945,11 +945,10 @@ class FwalkTests(WalkTests): """Tests for os.fwalk().""" - def walk(self, directory, **kwargs): - for root, dirs, files, root_fd in os.fwalk(directory, **kwargs): + def walk(self, top, **kwargs): + for root, dirs, files, root_fd in os.fwalk(top, **kwargs): yield (root, dirs, files) - def _compare_to_walk(self, walk_kwargs, fwalk_kwargs): """ compare with walk() results. @@ -1020,6 +1019,19 @@ os.unlink(name, dir_fd=rootfd) os.rmdir(support.TESTFN) +class BytesWalkTests(WalkTests): + """Tests for os.walk() with bytes.""" + def walk(self, top, **kwargs): + if 'follow_symlinks' in kwargs: + kwargs['followlinks'] = kwargs.pop('follow_symlinks') + for broot, bdirs, bfiles in os.walk(os.fsencode(top), **kwargs): + root = os.fsdecode(broot) + dirs = list(map(os.fsdecode, bdirs)) + files = list(map(os.fsdecode, bfiles)) + yield (root, dirs, files) + bdirs[:] = list(map(os.fsencode, dirs)) + bfiles[:] = list(map(os.fsencode, files)) + class MakedirTests(unittest.TestCase): def setUp(self): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -73,6 +73,8 @@ Library ------- +- Issue #25911: Restored support of bytes paths in os.walk() on Windows. + - Issue #26045: Add UTF-8 suggestion to error message when posting a non-Latin-1 string with http.client. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 8 09:39:26 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 08 Feb 2016 14:39:26 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbjogSXNzdWUgIzI1OTQ5OiBfX2Rp?= =?utf-8?q?ct=5F=5F_for_an_OrderedDict_instance_is_now_created_only_when?= Message-ID: <20160208143925.16556.74319@psf.io> https://hg.python.org/cpython/rev/caab6b356a9e changeset: 100187:caab6b356a9e user: Serhiy Storchaka date: Mon Feb 08 16:39:05 2016 +0200 summary: Issue #25949: __dict__ for an OrderedDict instance is now created only when needed. files: Lib/test/test_ordered_dict.py | 4 ++- Misc/NEWS | 3 ++ Objects/odictobject.c | 25 +++++++--------------- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/Lib/test/test_ordered_dict.py b/Lib/test/test_ordered_dict.py --- a/Lib/test/test_ordered_dict.py +++ b/Lib/test/test_ordered_dict.py @@ -298,9 +298,11 @@ # do not save instance dictionary if not needed pairs = [('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)] od = OrderedDict(pairs) + self.assertIsInstance(od.__dict__, dict) self.assertIsNone(od.__reduce__()[2]) od.x = 10 - self.assertIsNotNone(od.__reduce__()[2]) + self.assertEqual(od.__dict__['x'], 10) + self.assertEqual(od.__reduce__()[2], {'x': 10}) def test_pickle_recursive(self): OrderedDict = self.OrderedDict diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -170,6 +170,9 @@ Library ------- +- Issue #25949: __dict__ for an OrderedDict instance is now created only when + needed. + - Issue #25911: Restored support of bytes paths in os.walk() on Windows. - Issue #26045: Add UTF-8 suggestion to error message when posting a diff --git a/Objects/odictobject.c b/Objects/odictobject.c --- a/Objects/odictobject.c +++ b/Objects/odictobject.c @@ -1424,14 +1424,13 @@ * OrderedDict members */ -/* tp_members */ +/* tp_getset */ -static PyMemberDef odict_members[] = { - {"__dict__", T_OBJECT, offsetof(PyODictObject, od_inst_dict), READONLY}, - {0} +static PyGetSetDef odict_getset[] = { + {"__dict__", PyObject_GenericGetDict, PyObject_GenericSetDict}, + {NULL} }; - /* ---------------------------------------------- * OrderedDict type slot methods */ @@ -1653,20 +1652,12 @@ static PyObject * odict_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { - PyObject *dict; PyODictObject *od; - dict = PyDict_New(); - if (dict == NULL) + od = (PyODictObject *)PyDict_Type.tp_new(type, args, kwds); + if (od == NULL) return NULL; - od = (PyODictObject *)PyDict_Type.tp_new(type, args, kwds); - if (od == NULL) { - Py_DECREF(dict); - return NULL; - } - - od->od_inst_dict = dict; /* type constructor fills the memory with zeros (see PyType_GenericAlloc()), there is no need to set them to zero again */ if (_odict_resize(od) < 0) { @@ -1708,8 +1699,8 @@ (getiterfunc)odict_iter, /* tp_iter */ 0, /* tp_iternext */ odict_methods, /* tp_methods */ - odict_members, /* tp_members */ - 0, /* tp_getset */ + 0, /* tp_members */ + odict_getset, /* tp_getset */ &PyDict_Type, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 8 10:57:53 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 08 Feb 2016 15:57:53 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326117=3A_The_os=2Escandir=28=29_iterator_now_cl?= =?utf-8?q?oses_file_descriptor_not_only?= Message-ID: <20160208155752.6655.21878@psf.io> https://hg.python.org/cpython/rev/ec12fbf449a5 changeset: 100189:ec12fbf449a5 parent: 100187:caab6b356a9e parent: 100188:8ec721bb3027 user: Serhiy Storchaka date: Mon Feb 08 17:57:22 2016 +0200 summary: Issue #26117: The os.scandir() iterator now closes file descriptor not only when the iteration is finished, but when it was failed with error. files: Misc/NEWS | 3 ++ Modules/posixmodule.c | 41 ++++++++++++++++-------------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -170,6 +170,9 @@ Library ------- +- Issue #26117: The os.scandir() iterator now closes file descriptor not only + when the iteration is finished, but when it was failed with error. + - Issue #25949: __dict__ for an OrderedDict instance is now created only when needed. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -11954,12 +11954,11 @@ { WIN32_FIND_DATAW *file_data = &iterator->file_data; BOOL success; + PyObject *entry; /* Happens if the iterator is iterated twice */ - if (iterator->handle == INVALID_HANDLE_VALUE) { - PyErr_SetNone(PyExc_StopIteration); - return NULL; - } + if (iterator->handle == INVALID_HANDLE_VALUE) + return NULL; while (1) { if (!iterator->first_time) { @@ -11967,9 +11966,9 @@ success = FindNextFileW(iterator->handle, file_data); Py_END_ALLOW_THREADS if (!success) { + /* Error or no more files */ if (GetLastError() != ERROR_NO_MORE_FILES) - return path_error(&iterator->path); - /* No more files found in directory, stop iterating */ + path_error(&iterator->path); break; } } @@ -11977,15 +11976,18 @@ /* Skip over . and .. */ if (wcscmp(file_data->cFileName, L".") != 0 && - wcscmp(file_data->cFileName, L"..") != 0) - return DirEntry_from_find_data(&iterator->path, file_data); + wcscmp(file_data->cFileName, L"..") != 0) { + entry = DirEntry_from_find_data(&iterator->path, file_data); + if (!entry) + break; + return entry; + } /* Loop till we get a non-dot directory or finish iterating */ } + /* Error or no more files */ ScandirIterator_close(iterator); - - PyErr_SetNone(PyExc_StopIteration); return NULL; } @@ -12010,12 +12012,11 @@ struct dirent *direntp; Py_ssize_t name_len; int is_dot; + PyObject *entry; /* Happens if the iterator is iterated twice */ - if (!iterator->dirp) { - PyErr_SetNone(PyExc_StopIteration); - return NULL; - } + if (!iterator->dirp) + return NULL; while (1) { errno = 0; @@ -12024,9 +12025,9 @@ Py_END_ALLOW_THREADS if (!direntp) { + /* Error or no more files */ if (errno != 0) - return path_error(&iterator->path); - /* No more files found in directory, stop iterating */ + path_error(&iterator->path); break; } @@ -12035,20 +12036,22 @@ is_dot = direntp->d_name[0] == '.' && (name_len == 1 || (direntp->d_name[1] == '.' && name_len == 2)); if (!is_dot) { - return DirEntry_from_posix_info(&iterator->path, direntp->d_name, + entry = DirEntry_from_posix_info(&iterator->path, direntp->d_name, name_len, direntp->d_ino #ifdef HAVE_DIRENT_D_TYPE , direntp->d_type #endif ); + if (!entry) + break; + return entry; } /* Loop till we get a non-dot directory or finish iterating */ } + /* Error or no more files */ ScandirIterator_close(iterator); - - PyErr_SetNone(PyExc_StopIteration); return NULL; } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 8 10:57:52 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 08 Feb 2016 15:57:52 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2MTE3?= =?utf-8?q?=3A_The_os=2Escandir=28=29_iterator_now_closes_file_descriptor_?= =?utf-8?q?not_only?= Message-ID: <20160208155752.11229.6944@psf.io> https://hg.python.org/cpython/rev/8ec721bb3027 changeset: 100188:8ec721bb3027 branch: 3.5 parent: 100185:5310f94772f4 user: Serhiy Storchaka date: Mon Feb 08 17:56:36 2016 +0200 summary: Issue #26117: The os.scandir() iterator now closes file descriptor not only when the iteration is finished, but when it was failed with error. files: Misc/NEWS | 3 ++ Modules/posixmodule.c | 41 ++++++++++++++++-------------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -73,6 +73,9 @@ Library ------- +- Issue #26117: The os.scandir() iterator now closes file descriptor not only + when the iteration is finished, but when it was failed with error. + - Issue #25911: Restored support of bytes paths in os.walk() on Windows. - Issue #26045: Add UTF-8 suggestion to error message when posting a diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -11942,12 +11942,11 @@ { WIN32_FIND_DATAW *file_data = &iterator->file_data; BOOL success; + PyObject *entry; /* Happens if the iterator is iterated twice */ - if (iterator->handle == INVALID_HANDLE_VALUE) { - PyErr_SetNone(PyExc_StopIteration); - return NULL; - } + if (iterator->handle == INVALID_HANDLE_VALUE) + return NULL; while (1) { if (!iterator->first_time) { @@ -11955,9 +11954,9 @@ success = FindNextFileW(iterator->handle, file_data); Py_END_ALLOW_THREADS if (!success) { + /* Error or no more files */ if (GetLastError() != ERROR_NO_MORE_FILES) - return path_error(&iterator->path); - /* No more files found in directory, stop iterating */ + path_error(&iterator->path); break; } } @@ -11965,15 +11964,18 @@ /* Skip over . and .. */ if (wcscmp(file_data->cFileName, L".") != 0 && - wcscmp(file_data->cFileName, L"..") != 0) - return DirEntry_from_find_data(&iterator->path, file_data); + wcscmp(file_data->cFileName, L"..") != 0) { + entry = DirEntry_from_find_data(&iterator->path, file_data); + if (!entry) + break; + return entry; + } /* Loop till we get a non-dot directory or finish iterating */ } + /* Error or no more files */ ScandirIterator_close(iterator); - - PyErr_SetNone(PyExc_StopIteration); return NULL; } @@ -11998,12 +12000,11 @@ struct dirent *direntp; Py_ssize_t name_len; int is_dot; + PyObject *entry; /* Happens if the iterator is iterated twice */ - if (!iterator->dirp) { - PyErr_SetNone(PyExc_StopIteration); - return NULL; - } + if (!iterator->dirp) + return NULL; while (1) { errno = 0; @@ -12012,9 +12013,9 @@ Py_END_ALLOW_THREADS if (!direntp) { + /* Error or no more files */ if (errno != 0) - return path_error(&iterator->path); - /* No more files found in directory, stop iterating */ + path_error(&iterator->path); break; } @@ -12023,20 +12024,22 @@ is_dot = direntp->d_name[0] == '.' && (name_len == 1 || (direntp->d_name[1] == '.' && name_len == 2)); if (!is_dot) { - return DirEntry_from_posix_info(&iterator->path, direntp->d_name, + entry = DirEntry_from_posix_info(&iterator->path, direntp->d_name, name_len, direntp->d_ino #ifdef HAVE_DIRENT_D_TYPE , direntp->d_type #endif ); + if (!entry) + break; + return entry; } /* Loop till we get a non-dot directory or finish iterating */ } + /* Error or no more files */ ScandirIterator_close(iterator); - - PyErr_SetNone(PyExc_StopIteration); return NULL; } -- Repository URL: https://hg.python.org/cpython From lp_benchmark_robot at intel.com Mon Feb 8 12:11:40 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Mon, 8 Feb 2016 17:11:40 +0000 Subject: [Python-checkins] UGLY Benchmark Results for Python Default 2016-02-08 Message-ID: Results for project Python default, build date 2016-02-08 03:07:24 +0000 commit: 53d66a554beb previous commit: d3be5c4507b4 revision date: 2016-02-07 23:22:47 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.19% 1.44% 10.57% 12.81% :-| pybench 0.13% 1.82% 0.79% 5.83% :-( regex_v8 2.68% -0.27% -5.14% 5.63% :-| nbody 0.16% -1.91% -1.84% 9.17% :-| json_dump_v2 0.22% 0.63% -1.42% 10.26% :-| normal_startup 0.76% 0.27% 0.82% 5.21% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/ugly-benchmark-results-for-python-default-2016-02-08/ Note: Benchmark results are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Mon Feb 8 12:12:02 2016 From: python-checkins at python.org (victor.stinner) Date: Mon, 08 Feb 2016 17:12:02 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Simplify_main=28=29_of_tes?= =?utf-8?q?t=5Fast?= Message-ID: <20160208171202.15931.44079@psf.io> https://hg.python.org/cpython/rev/a0d053899ff8 changeset: 100190:a0d053899ff8 user: Victor Stinner date: Mon Feb 08 17:15:21 2016 +0100 summary: Simplify main() of test_ast * Use ast.parse() to get the AST for a statement * Use str%args syntax for format a line Issue #26204. files: Lib/test/test_ast.py | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py --- a/Lib/test/test_ast.py +++ b/Lib/test/test_ast.py @@ -1064,8 +1064,9 @@ for statements, kind in ((exec_tests, "exec"), (single_tests, "single"), (eval_tests, "eval")): print(kind+"_results = [") - for s in statements: - print(repr(to_tuple(compile(s, "?", kind, 0x400)))+",") + for statement in statements: + tree = ast.parse(statement, "?", kind) + print("%r," % (to_tuple(tree),)) print("]") print("main()") raise SystemExit -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 8 12:12:02 2016 From: python-checkins at python.org (victor.stinner) Date: Mon, 08 Feb 2016 17:12:02 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Replace_noop_constant_stat?= =?utf-8?q?ement_with_expression?= Message-ID: <20160208171202.15929.24576@psf.io> https://hg.python.org/cpython/rev/bcf27fa55632 changeset: 100191:bcf27fa55632 user: Victor Stinner date: Mon Feb 08 17:57:02 2016 +0100 summary: Replace noop constant statement with expression * Constant statements will be ignored and the compiler will emit a SyntaxWarning. * Replace constant statement (ex: "1") with an expression statement (ex: "x=1"). * test_traceback: use context manager on the file. Issue #26204. files: Lib/test/test_inspect.py | 2 +- Lib/test/test_peepholer.py | 20 +++++++++++--------- Lib/test/test_support.py | 3 ++- Lib/test/test_sys_settrace.py | 4 ++-- Lib/test/test_traceback.py | 14 +++++++------- 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py --- a/Lib/test/test_inspect.py +++ b/Lib/test/test_inspect.py @@ -401,7 +401,7 @@ self.assertEqual(normcase(inspect.getsourcefile(mod.spam)), modfile) self.assertEqual(normcase(inspect.getsourcefile(git.abuse)), modfile) fn = "_non_existing_filename_used_for_sourcefile_test.py" - co = compile("None", fn, "exec") + co = compile("x=1", fn, "exec") self.assertEqual(inspect.getsourcefile(co), None) linecache.cache[co.co_filename] = (1, None, "None", co.co_filename) try: 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 @@ -1,9 +1,8 @@ import dis import re import sys -from io import StringIO +import textwrap import unittest -from math import copysign from test.bytecode_helper import BytecodeTestCase @@ -30,22 +29,25 @@ def test_global_as_constant(self): # LOAD_GLOBAL None/True/False --> LOAD_CONST None/True/False - def f(x): - None - None + def f(): + x = None + x = None return x - def g(x): - True + def g(): + x = True return x - def h(x): - False + def h(): + x = False return x + for func, elem in ((f, None), (g, True), (h, False)): self.assertNotInBytecode(func, 'LOAD_GLOBAL') self.assertInBytecode(func, 'LOAD_CONST', elem) + def f(): 'Adding a docstring made this test fail in Py2.5.0' return None + self.assertNotInBytecode(f, 'LOAD_GLOBAL') self.assertInBytecode(f, 'LOAD_CONST', None) diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py --- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -230,7 +230,8 @@ def test_check_syntax_error(self): support.check_syntax_error(self, "def class") - self.assertRaises(AssertionError, support.check_syntax_error, self, "1") + with self.assertRaises(AssertionError): + support.check_syntax_error(self, "x=1") def test_CleanImport(self): import importlib diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py --- a/Lib/test/test_sys_settrace.py +++ b/Lib/test/test_sys_settrace.py @@ -338,8 +338,8 @@ def test_14_onliner_if(self): def onliners(): - if True: False - else: True + if True: x=False + else: x=True return 0 self.run_and_compare( onliners, diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py --- a/Lib/test/test_traceback.py +++ b/Lib/test/test_traceback.py @@ -129,12 +129,12 @@ def do_test(firstlines, message, charset, lineno): # Raise the message in a subprocess, and catch the output try: - output = open(TESTFN, "w", encoding=charset) - output.write("""{0}if 1: - import traceback; - raise RuntimeError('{1}') - """.format(firstlines, message)) - output.close() + with open(TESTFN, "w", encoding=charset) as output: + output.write("""{0}if 1: + import traceback; + raise RuntimeError('{1}') + """.format(firstlines, message)) + process = subprocess.Popen([sys.executable, TESTFN], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) stdout, stderr = process.communicate() @@ -176,7 +176,7 @@ do_test(" \t\f\n# coding: {0}\n".format(charset), text, charset, 5) # Issue #18960: coding spec should has no effect - do_test("0\n# coding: GBK\n", "h\xe9 ho", 'utf-8', 5) + do_test("x=0\n# coding: GBK\n", "h\xe9 ho", 'utf-8', 5) def test_print_traceback_at_exit(self): # Issue #22599: Ensure that it is possible to use the traceback module -- Repository URL: https://hg.python.org/cpython From lp_benchmark_robot at intel.com Mon Feb 8 12:12:53 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Mon, 8 Feb 2016 17:12:53 +0000 Subject: [Python-checkins] UGLY Benchmark Results for Python 2.7 2016-02-08 Message-ID: <4a4c2ede-ca07-41fe-93c6-eff34507bbec@irsmsx105.ger.corp.intel.com> Results for project Python 2.7, build date 2016-02-08 03:58:27 +0000 commit: ab25ce400abd previous commit: c8e43e55f2ce revision date: 2016-02-07 23:05:48 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dc from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.19% 1.19% 4.15% 6.75% :-) pybench 0.20% -0.15% 6.06% 4.29% :-( regex_v8 0.64% 0.35% -2.09% 10.80% :-) nbody 0.33% -1.91% 6.39% 5.02% :-) json_dump_v2 0.29% 1.66% 5.03% 8.33% :-( normal_startup 1.91% 0.09% -5.69% 2.75% :-| ssbench 0.14% -0.48% 0.39% 3.08% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/ugly-benchmark-results-for-python-2-7-2016-02-08/ Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Mon Feb 8 12:22:29 2016 From: python-checkins at python.org (victor.stinner) Date: Mon, 08 Feb 2016 17:22:29 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_compiler_now_ignores_const?= =?utf-8?q?ant_statements?= Message-ID: <20160208172228.20013.61741@psf.io> https://hg.python.org/cpython/rev/4bdb21380743 changeset: 100192:4bdb21380743 user: Victor Stinner date: Mon Feb 08 18:17:58 2016 +0100 summary: compiler now ignores constant statements The compile ignores constant statements and emit a SyntaxWarning warning. Don't emit the warning for string statement because triple quoted string is a common syntax for multiline comments. Don't emit the warning on ellipis neither: 'def f(): ...' is a legit syntax for abstract functions. Changes: * test_ast: ignore SyntaxWarning when compiling test statements. Modify test_load_const() to use assignment expressions rather than constant expression. * test_code: add more kinds of constant statements, ignore SyntaxWarning when testing that the compiler removes constant statements. * test_grammar: ignore SyntaxWarning on the statement "1" files: Lib/test/test_ast.py | 33 +++++++-------- Lib/test/test_code.py | 58 +++++++++++++++++++-------- Lib/test/test_grammar.py | 6 ++- Misc/NEWS | 4 + Python/compile.c | 41 ++++++++++++++----- 5 files changed, 95 insertions(+), 47 deletions(-) diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py --- a/Lib/test/test_ast.py +++ b/Lib/test/test_ast.py @@ -3,6 +3,7 @@ import os import sys import unittest +import warnings import weakref from test import support @@ -239,8 +240,10 @@ ast_tree = compile(i, "?", kind, ast.PyCF_ONLY_AST) self.assertEqual(to_tuple(ast_tree), o) self._assertTrueorder(ast_tree, (0, 0)) - with self.subTest(action="compiling", input=i): - compile(ast_tree, "?", kind) + with warnings.catch_warnings(): + warnings.filterwarnings('ignore', category=SyntaxWarning) + with self.subTest(action="compiling", input=i, kind=kind): + compile(ast_tree, "?", kind) def test_slice(self): slc = ast.parse("x[::]").body[0].value.slice @@ -1020,27 +1023,23 @@ b'bytes', (1, 2, 3)] - code = '\n'.join(map(repr, consts)) - code += '\n...' - - code_consts = [const for const in consts - if (not isinstance(const, (str, int, float, complex)) - or isinstance(const, bool))] - code_consts.append(Ellipsis) - # the compiler adds a final "LOAD_CONST None" - code_consts.append(None) + code = '\n'.join(['x={!r}'.format(const) for const in consts]) + code += '\nx = ...' + consts.extend((Ellipsis, None)) tree = ast.parse(code) - self.assertEqual(self.get_load_const(tree), code_consts) + self.assertEqual(self.get_load_const(tree), + consts) # Replace expression nodes with constants - for expr_node, const in zip(tree.body, consts): - assert isinstance(expr_node, ast.Expr) + for assign, const in zip(tree.body, consts): + assert isinstance(assign, ast.Assign), ast.dump(assign) new_node = ast.Constant(value=const) - ast.copy_location(new_node, expr_node.value) - expr_node.value = new_node + ast.copy_location(new_node, assign.value) + assign.value = new_node - self.assertEqual(self.get_load_const(tree), code_consts) + self.assertEqual(self.get_load_const(tree), + consts) def test_literal_eval(self): tree = ast.parse("1 + 2") diff --git a/Lib/test/test_code.py b/Lib/test/test_code.py --- a/Lib/test/test_code.py +++ b/Lib/test/test_code.py @@ -66,24 +66,6 @@ flags: 67 consts: ('None',) ->>> def optimize_away(): -... 'doc string' -... 'not a docstring' -... 53 -... 0x53 - ->>> dump(optimize_away.__code__) -name: optimize_away -argcount: 0 -kwonlyargcount: 0 -names: () -varnames: () -cellvars: () -freevars: () -nlocals: 0 -flags: 67 -consts: ("'doc string'", 'None') - >>> def keywordonly_args(a,b,*,k1): ... return a,b,k1 ... @@ -102,8 +84,10 @@ """ +import textwrap import unittest import weakref +import warnings from test.support import run_doctest, run_unittest, cpython_only @@ -134,6 +118,44 @@ self.assertEqual(co.co_name, "funcname") self.assertEqual(co.co_firstlineno, 15) + def dump(self, co): + dump = {} + for attr in ["name", "argcount", "kwonlyargcount", "names", "varnames", + "cellvars", "freevars", "nlocals", "flags"]: + dump[attr] = getattr(co, "co_" + attr) + dump['consts'] = tuple(consts(co.co_consts)) + return dump + + def test_optimize_away(self): + ns = {} + with warnings.catch_warnings(): + warnings.filterwarnings('ignore', category=SyntaxWarning) + exec(textwrap.dedent(''' + def optimize_away(): + 'doc string' + 'not a docstring' + 53 + 0x53 + b'bytes' + 1.0 + True + False + None + ... + '''), ns) + + self.assertEqual(self.dump(ns['optimize_away'].__code__), + {'name': 'optimize_away', + 'argcount': 0, + 'kwonlyargcount': 0, + 'names': (), + 'varnames': (), + 'cellvars': (), + 'freevars': (), + 'nlocals': 0, + 'flags': 67, + 'consts': ("'doc string'", 'None')}) + class CodeWeakRefTest(unittest.TestCase): diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py --- a/Lib/test/test_grammar.py +++ b/Lib/test/test_grammar.py @@ -7,6 +7,7 @@ import sys # testing import * from sys import * +from test import support class TokenTests(unittest.TestCase): @@ -424,8 +425,11 @@ # Tested below def test_expr_stmt(self): + msg = 'ignore constant statement' + with support.check_warnings((msg, SyntaxWarning)): + exec("1") + # (exprlist '=')* exprlist - 1 1, 2, 3 x = 1 x = 1, 2, 3 diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,10 @@ Core and Builtins ----------------- +- Issue #26204: The compiler now ignores constant statements (ex: "def f(): 1") + and emit a SyntaxWarning warning. The warning is not emitted for string and + ellipsis (...) statements. + - Issue #4806: Avoid masking the original TypeError exception when using star (*) unpacking in function calls. Based on patch by Hagen F?rstenau and Daniel Urban. diff --git a/Python/compile.c b/Python/compile.c --- a/Python/compile.c +++ b/Python/compile.c @@ -2616,20 +2616,39 @@ return 1; } - if (value->kind == Str_kind || value->kind == Num_kind) { - /* ignore strings and numbers */ + switch (value->kind) + { + case Str_kind: + case Ellipsis_kind: + /* Issue #26204: ignore string statement, but don't emit a + * SyntaxWarning. Triple quoted strings is a common syntax for + * multiline comments. + * + * Don't emit warning on "def f(): ..." neither. It's a legit syntax + * for abstract function. */ + return 1; + + case Bytes_kind: + case Num_kind: + case NameConstant_kind: + case Constant_kind: + { + PyObject *msg = PyUnicode_FromString("ignore constant statement"); + if (msg == NULL) + return 0; + if (PyErr_WarnExplicitObject(PyExc_SyntaxWarning, + msg, + c->c_filename, c->u->u_lineno, + NULL, NULL) == -1) { + Py_DECREF(msg); + return 0; + } + Py_DECREF(msg); return 1; } - if (value->kind == Constant_kind) { - PyObject *cst = value->v.Constant.value; - if (PyUnicode_CheckExact(cst) - || PyLong_CheckExact(cst) - || PyFloat_CheckExact(cst) - || PyComplex_CheckExact(cst)) { - /* ignore strings and numbers */ - return 1; - } + default: + break; } VISIT(c, expr, value); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 8 12:26:46 2016 From: python-checkins at python.org (steve.dower) Date: Mon, 08 Feb 2016 17:26:46 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Updates_build_?= =?utf-8?q?to_use_SHA256_hash_when_signing_files?= Message-ID: <20160208172644.6669.83852@psf.io> https://hg.python.org/cpython/rev/f45571c32e0d changeset: 100193:f45571c32e0d branch: 2.7 parent: 100177:ab25ce400abd user: Steve Dower date: Mon Feb 08 09:26:25 2016 -0800 summary: Updates build to use SHA256 hash when signing files files: Tools/msi/msi.py | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/Tools/msi/msi.py b/Tools/msi/msi.py --- a/Tools/msi/msi.py +++ b/Tools/msi/msi.py @@ -1436,6 +1436,7 @@ if certname: os.system('signtool sign /n "%s" ' '/t http://timestamp.verisign.com/scripts/timestamp.dll ' + '/fd SHA256 ' '/d "Python %s" ' '%s' % (certname, full_current_version, msiname)) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 8 12:28:00 2016 From: python-checkins at python.org (steve.dower) Date: Mon, 08 Feb 2016 17:28:00 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Updates_build_?= =?utf-8?q?to_use_SHA256_hash_when_signing_files=2E?= Message-ID: <20160208172759.2663.75031@psf.io> https://hg.python.org/cpython/rev/940908d3e439 changeset: 100194:940908d3e439 branch: 3.5 parent: 100188:8ec721bb3027 user: Steve Dower date: Mon Feb 08 09:24:46 2016 -0800 summary: Updates build to use SHA256 hash when signing files. files: PCbuild/pyproject.props | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/PCbuild/pyproject.props b/PCbuild/pyproject.props --- a/PCbuild/pyproject.props +++ b/PCbuild/pyproject.props @@ -154,7 +154,7 @@ $(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots at KitsRoot81)\bin\x86\signtool.exe $(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots at KitsRoot)\bin\x86\signtool.exe $(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A at InstallationFolder)\Bin\signtool.exe - <_SignCommand Condition="Exists($(SignToolPath))">"$(SignToolPath)" sign /q /n "$(SigningCertificate)" /t http://timestamp.verisign.com/scripts/timestamp.dll /d "Python $(PythonVersion)" + <_SignCommand Condition="Exists($(SignToolPath))">"$(SignToolPath)" sign /q /n "$(SigningCertificate)" /fd sha256 /t http://timestamp.verisign.com/scripts/timestamp.dll /d "Python $(PythonVersion)" -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 8 12:28:07 2016 From: python-checkins at python.org (steve.dower) Date: Mon, 08 Feb 2016 17:28:07 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Updates_build_to_use_SHA256_hash_when_signing_files?= Message-ID: <20160208172759.1566.65281@psf.io> https://hg.python.org/cpython/rev/7fa70b7cd16f changeset: 100195:7fa70b7cd16f parent: 100192:4bdb21380743 parent: 100194:940908d3e439 user: Steve Dower date: Mon Feb 08 09:27:44 2016 -0800 summary: Updates build to use SHA256 hash when signing files files: PCbuild/pyproject.props | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/PCbuild/pyproject.props b/PCbuild/pyproject.props --- a/PCbuild/pyproject.props +++ b/PCbuild/pyproject.props @@ -154,7 +154,7 @@ $(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots at KitsRoot81)\bin\x86\signtool.exe $(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots at KitsRoot)\bin\x86\signtool.exe $(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A at InstallationFolder)\Bin\signtool.exe - <_SignCommand Condition="Exists($(SignToolPath))">"$(SignToolPath)" sign /q /n "$(SigningCertificate)" /t http://timestamp.verisign.com/scripts/timestamp.dll /d "Python $(PythonVersion)" + <_SignCommand Condition="Exists($(SignToolPath))">"$(SignToolPath)" sign /q /n "$(SigningCertificate)" /fd sha256 /t http://timestamp.verisign.com/scripts/timestamp.dll /d "Python $(PythonVersion)" -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 8 12:59:28 2016 From: python-checkins at python.org (gregory.p.smith) Date: Mon, 08 Feb 2016 17:59:28 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Clarify_=22cardinality_of=22_as_=22number_of_elements_in?= =?utf-8?q?=22_as_many_readers_do?= Message-ID: <20160208175927.16562.70179@psf.io> https://hg.python.org/cpython/rev/a67fda8e33b0 changeset: 100197:a67fda8e33b0 parent: 100195:7fa70b7cd16f parent: 100196:81cb7af9ce10 user: Gregory P. Smith date: Mon Feb 08 09:59:00 2016 -0800 summary: Clarify "cardinality of" as "number of elements in" as many readers do not have a math vocabulary. files: Doc/library/stdtypes.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -3828,7 +3828,7 @@ .. describe:: len(s) - Return the cardinality of set *s*. + Return the number of elements in set *s* (cardinality of *s*). .. describe:: x in s -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 8 12:59:30 2016 From: python-checkins at python.org (gregory.p.smith) Date: Mon, 08 Feb 2016 17:59:30 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogQ2xhcmlmeSAiY2Fy?= =?utf-8?q?dinality_of=22_as_=22number_of_elements_in=22_as_many_readers_d?= =?utf-8?q?o?= Message-ID: <20160208175927.68404.94071@psf.io> https://hg.python.org/cpython/rev/81cb7af9ce10 changeset: 100196:81cb7af9ce10 branch: 3.5 parent: 100194:940908d3e439 user: Gregory P. Smith date: Mon Feb 08 09:58:40 2016 -0800 summary: Clarify "cardinality of" as "number of elements in" as many readers do not have a math vocabulary. files: Doc/library/stdtypes.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -3828,7 +3828,7 @@ .. describe:: len(s) - Return the cardinality of set *s*. + Return the number of elements in set *s* (cardinality of *s*). .. describe:: x in s -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 8 12:59:30 2016 From: python-checkins at python.org (gregory.p.smith) Date: Mon, 08 Feb 2016 17:59:30 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogQ2xhcmlmeSAiY2Fy?= =?utf-8?q?dinality_of=22_as_=22number_of_elements_in=22_as_many_readers_d?= =?utf-8?q?o?= Message-ID: <20160208175927.40066.45740@psf.io> https://hg.python.org/cpython/rev/11c6bfbab9ce changeset: 100198:11c6bfbab9ce branch: 2.7 parent: 100193:f45571c32e0d user: Gregory P. Smith date: Mon Feb 08 09:59:14 2016 -0800 summary: Clarify "cardinality of" as "number of elements in" as many readers do not have a math vocabulary. files: Doc/library/sets.rst | 3 ++- Doc/library/stdtypes.rst | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Doc/library/sets.rst b/Doc/library/sets.rst --- a/Doc/library/sets.rst +++ b/Doc/library/sets.rst @@ -76,7 +76,8 @@ +-------------------------------+------------+---------------------------------+ | Operation | Equivalent | Result | +===============================+============+=================================+ -| ``len(s)`` | | cardinality of set *s* | +| ``len(s)`` | | number of elements in set *s* +| | | (cardinality) | +-------------------------------+------------+---------------------------------+ | ``x in s`` | | test *x* for membership in *s* | +-------------------------------+------------+---------------------------------+ diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1779,7 +1779,7 @@ .. describe:: len(s) - Return the cardinality of set *s*. + Return the number of elements in set *s* (cardinality of *s*). .. describe:: x in s -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 8 13:28:46 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 08 Feb 2016 18:28:46 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI1OTgz?= =?utf-8?q?=3A_Added_tests_for_multi-argument_type=28=29=2E?= Message-ID: <20160208182845.40078.8953@psf.io> https://hg.python.org/cpython/rev/f9bd6ddb6ba4 changeset: 100199:f9bd6ddb6ba4 branch: 2.7 user: Serhiy Storchaka date: Mon Feb 08 20:27:52 2016 +0200 summary: Issue #25983: Added tests for multi-argument type(). files: Lib/test/test_builtin.py | 130 ++++++++++++++++++++++++++- 1 files changed, 129 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -1682,6 +1682,134 @@ data = 'The quick Brown fox Jumped over The lazy Dog'.split() self.assertRaises(TypeError, sorted, data, None, lambda x,y: 0) + +class TestType(unittest.TestCase): + def test_new_type(self): + A = type('A', (), {}) + self.assertEqual(A.__name__, 'A') + self.assertEqual(A.__module__, __name__) + self.assertEqual(A.__bases__, (object,)) + self.assertIs(A.__base__, object) + x = A() + self.assertIs(type(x), A) + self.assertIs(x.__class__, A) + + class B: + def ham(self): + return 'ham%d' % self + C = type('C', (B, int), {'spam': lambda self: 'spam%s' % self}) + self.assertEqual(C.__name__, 'C') + self.assertEqual(C.__module__, __name__) + self.assertEqual(C.__bases__, (B, int)) + self.assertIs(C.__base__, int) + self.assertIn('spam', C.__dict__) + self.assertNotIn('ham', C.__dict__) + x = C(42) + self.assertEqual(x, 42) + self.assertIs(type(x), C) + self.assertIs(x.__class__, C) + self.assertEqual(x.ham(), 'ham42') + self.assertEqual(x.spam(), 'spam42') + self.assertEqual(x.bit_length(), 6) + + def test_type_new_keywords(self): + class B: + def ham(self): + return 'ham%d' % self + C = type.__new__(type, + name='C', + bases=(B, int), + dict={'spam': lambda self: 'spam%s' % self}) + self.assertEqual(C.__name__, 'C') + self.assertEqual(C.__module__, __name__) + self.assertEqual(C.__bases__, (B, int)) + self.assertIs(C.__base__, int) + self.assertIn('spam', C.__dict__) + self.assertNotIn('ham', C.__dict__) + + def test_type_name(self): + for name in 'A', '\xc4', 'B.A', '42', '': + A = type(name, (), {}) + self.assertEqual(A.__name__, name) + self.assertEqual(A.__module__, __name__) + with self.assertRaises(ValueError): + type('A\x00B', (), {}) + with self.assertRaises(TypeError): + type(u'A', (), {}) + + C = type('C', (), {}) + for name in 'A', '\xc4', 'B.A', '42', '': + C.__name__ = name + self.assertEqual(C.__name__, name) + self.assertEqual(C.__module__, __name__) + + A = type('C', (), {}) + with self.assertRaises(ValueError): + A.__name__ = 'A\x00B' + self.assertEqual(A.__name__, 'C') + with self.assertRaises(TypeError): + A.__name__ = u'A' + self.assertEqual(A.__name__, 'C') + + def test_type_doc(self): + tests = ('x', '\xc4', 'x\x00y', 42, None) + if have_unicode: + tests += (u'\xc4', u'x\x00y') + for doc in tests: + A = type('A', (), {'__doc__': doc}) + self.assertEqual(A.__doc__, doc) + + A = type('A', (), {}) + self.assertEqual(A.__doc__, None) + with self.assertRaises(AttributeError): + A.__doc__ = 'x' + + def test_bad_args(self): + with self.assertRaises(TypeError): + type() + with self.assertRaises(TypeError): + type('A', ()) + with self.assertRaises(TypeError): + type('A', (), {}, ()) + with self.assertRaises(TypeError): + type('A', (), dict={}) + with self.assertRaises(TypeError): + type('A', [], {}) + with self.assertRaises(TypeError): + type('A', (), UserDict.UserDict()) + with self.assertRaises(TypeError): + type('A', (None,), {}) + with self.assertRaises(TypeError): + type('A', (bool,), {}) + with self.assertRaises(TypeError): + type('A', (int, str), {}) + class B: + pass + with self.assertRaises(TypeError): + type('A', (B,), {}) + + def test_bad_slots(self): + with self.assertRaises(TypeError): + type('A', (long,), {'__slots__': 'x'}) + with self.assertRaises(TypeError): + type('A', (), {'__slots__': ''}) + with self.assertRaises(TypeError): + type('A', (), {'__slots__': '42'}) + with self.assertRaises(TypeError): + type('A', (), {'__slots__': 'x\x00y'}) + with self.assertRaises(TypeError): + type('A', (), {'__slots__': ('__dict__', '__dict__')}) + with self.assertRaises(TypeError): + type('A', (), {'__slots__': ('__weakref__', '__weakref__')}) + + class B(object): + pass + with self.assertRaises(TypeError): + type('A', (B,), {'__slots__': '__dict__'}) + with self.assertRaises(TypeError): + type('A', (B,), {'__slots__': '__weakref__'}) + + def _run_unittest(*args): with check_py3k_warnings( (".+ not supported in 3.x", DeprecationWarning), @@ -1696,7 +1824,7 @@ (".+ not supported in 3.x", DeprecationWarning)): run_unittest(TestExecFile) numruns += 1 - test_classes = (BuiltinTest, TestSorted) + test_classes = (BuiltinTest, TestSorted, TestType) _run_unittest(*test_classes) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 8 13:28:46 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 08 Feb 2016 18:28:46 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1OTgz?= =?utf-8?q?=3A_Added_tests_for_multi-argument_type=28=29=2E?= Message-ID: <20160208182846.40084.43404@psf.io> https://hg.python.org/cpython/rev/0e7aabe76159 changeset: 100200:0e7aabe76159 branch: 3.5 parent: 100196:81cb7af9ce10 user: Serhiy Storchaka date: Mon Feb 08 20:28:03 2016 +0200 summary: Issue #25983: Added tests for multi-argument type(). files: Lib/test/test_builtin.py | 155 +++++++++++++++++++++++++++ 1 files changed, 155 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -1668,6 +1668,161 @@ self.assertEqual(["before", "after"], out.decode().splitlines()) +class TestType(unittest.TestCase): + def test_new_type(self): + A = type('A', (), {}) + self.assertEqual(A.__name__, 'A') + self.assertEqual(A.__qualname__, 'A') + self.assertEqual(A.__module__, __name__) + self.assertEqual(A.__bases__, (object,)) + self.assertIs(A.__base__, object) + x = A() + self.assertIs(type(x), A) + self.assertIs(x.__class__, A) + + class B: + def ham(self): + return 'ham%d' % self + C = type('C', (B, int), {'spam': lambda self: 'spam%s' % self}) + self.assertEqual(C.__name__, 'C') + self.assertEqual(C.__qualname__, 'C') + self.assertEqual(C.__module__, __name__) + self.assertEqual(C.__bases__, (B, int)) + self.assertIs(C.__base__, int) + self.assertIn('spam', C.__dict__) + self.assertNotIn('ham', C.__dict__) + x = C(42) + self.assertEqual(x, 42) + self.assertIs(type(x), C) + self.assertIs(x.__class__, C) + self.assertEqual(x.ham(), 'ham42') + self.assertEqual(x.spam(), 'spam42') + self.assertEqual(x.to_bytes(2, 'little'), b'\x2a\x00') + + def test_type_new_keywords(self): + class B: + def ham(self): + return 'ham%d' % self + C = type.__new__(type, + name='C', + bases=(B, int), + dict={'spam': lambda self: 'spam%s' % self}) + self.assertEqual(C.__name__, 'C') + self.assertEqual(C.__qualname__, 'C') + self.assertEqual(C.__module__, __name__) + self.assertEqual(C.__bases__, (B, int)) + self.assertIs(C.__base__, int) + self.assertIn('spam', C.__dict__) + self.assertNotIn('ham', C.__dict__) + + def test_type_name(self): + for name in 'A', '\xc4', '\U0001f40d', 'B.A', '42', '': + with self.subTest(name=name): + A = type(name, (), {}) + self.assertEqual(A.__name__, name) + self.assertEqual(A.__qualname__, name) + self.assertEqual(A.__module__, __name__) + with self.assertRaises(ValueError): + type('A\x00B', (), {}) + with self.assertRaises(ValueError): + type('A\udcdcB', (), {}) + with self.assertRaises(TypeError): + type(b'A', (), {}) + + C = type('C', (), {}) + for name in 'A', '\xc4', '\U0001f40d', 'B.A', '42', '': + with self.subTest(name=name): + C.__name__ = name + self.assertEqual(C.__name__, name) + self.assertEqual(C.__qualname__, 'C') + self.assertEqual(C.__module__, __name__) + + A = type('C', (), {}) + with self.assertRaises(ValueError): + A.__name__ = 'A\x00B' + self.assertEqual(A.__name__, 'C') + with self.assertRaises(ValueError): + A.__name__ = 'A\udcdcB' + self.assertEqual(A.__name__, 'C') + with self.assertRaises(TypeError): + A.__name__ = b'A' + self.assertEqual(A.__name__, 'C') + + def test_type_qualname(self): + A = type('A', (), {'__qualname__': 'B.C'}) + self.assertEqual(A.__name__, 'A') + self.assertEqual(A.__qualname__, 'B.C') + self.assertEqual(A.__module__, __name__) + with self.assertRaises(TypeError): + type('A', (), {'__qualname__': b'B'}) + self.assertEqual(A.__qualname__, 'B.C') + + A.__qualname__ = 'D.E' + self.assertEqual(A.__name__, 'A') + self.assertEqual(A.__qualname__, 'D.E') + with self.assertRaises(TypeError): + A.__qualname__ = b'B' + self.assertEqual(A.__qualname__, 'D.E') + + def test_type_doc(self): + for doc in 'x', '\xc4', '\U0001f40d', 'x\x00y', b'x', 42, None: + A = type('A', (), {'__doc__': doc}) + self.assertEqual(A.__doc__, doc) + with self.assertRaises(UnicodeEncodeError): + type('A', (), {'__doc__': 'x\udcdcy'}) + + A = type('A', (), {}) + self.assertEqual(A.__doc__, None) + for doc in 'x', '\xc4', '\U0001f40d', 'x\x00y', 'x\udcdcy', b'x', 42, None: + A.__doc__ = doc + self.assertEqual(A.__doc__, doc) + + def test_bad_args(self): + with self.assertRaises(TypeError): + type() + with self.assertRaises(TypeError): + type('A', ()) + with self.assertRaises(TypeError): + type('A', (), {}, ()) + with self.assertRaises(TypeError): + type('A', (), dict={}) + with self.assertRaises(TypeError): + type('A', [], {}) + with self.assertRaises(TypeError): + type('A', (), types.MappingProxyType({})) + with self.assertRaises(TypeError): + type('A', (None,), {}) + with self.assertRaises(TypeError): + type('A', (bool,), {}) + with self.assertRaises(TypeError): + type('A', (int, str), {}) + + def test_bad_slots(self): + with self.assertRaises(TypeError): + type('A', (), {'__slots__': b'x'}) + with self.assertRaises(TypeError): + type('A', (int,), {'__slots__': 'x'}) + with self.assertRaises(TypeError): + type('A', (), {'__slots__': ''}) + with self.assertRaises(TypeError): + type('A', (), {'__slots__': '42'}) + with self.assertRaises(TypeError): + type('A', (), {'__slots__': 'x\x00y'}) + with self.assertRaises(ValueError): + type('A', (), {'__slots__': 'x', 'x': 0}) + with self.assertRaises(TypeError): + type('A', (), {'__slots__': ('__dict__', '__dict__')}) + with self.assertRaises(TypeError): + type('A', (), {'__slots__': ('__weakref__', '__weakref__')}) + + class B: + pass + with self.assertRaises(TypeError): + type('A', (B,), {'__slots__': '__dict__'}) + with self.assertRaises(TypeError): + type('A', (B,), {'__slots__': '__weakref__'}) + + def load_tests(loader, tests, pattern): from doctest import DocTestSuite tests.addTest(DocTestSuite(builtins)) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 8 13:28:51 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 08 Feb 2016 18:28:51 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325983=3A_Added_tests_for_multi-argument_type=28?= =?utf-8?b?KS4=?= Message-ID: <20160208182851.19989.69111@psf.io> https://hg.python.org/cpython/rev/f494052eb476 changeset: 100201:f494052eb476 parent: 100197:a67fda8e33b0 parent: 100200:0e7aabe76159 user: Serhiy Storchaka date: Mon Feb 08 20:28:22 2016 +0200 summary: Issue #25983: Added tests for multi-argument type(). files: Lib/test/test_builtin.py | 155 +++++++++++++++++++++++++++ 1 files changed, 155 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -1668,6 +1668,161 @@ self.assertEqual(["before", "after"], out.decode().splitlines()) +class TestType(unittest.TestCase): + def test_new_type(self): + A = type('A', (), {}) + self.assertEqual(A.__name__, 'A') + self.assertEqual(A.__qualname__, 'A') + self.assertEqual(A.__module__, __name__) + self.assertEqual(A.__bases__, (object,)) + self.assertIs(A.__base__, object) + x = A() + self.assertIs(type(x), A) + self.assertIs(x.__class__, A) + + class B: + def ham(self): + return 'ham%d' % self + C = type('C', (B, int), {'spam': lambda self: 'spam%s' % self}) + self.assertEqual(C.__name__, 'C') + self.assertEqual(C.__qualname__, 'C') + self.assertEqual(C.__module__, __name__) + self.assertEqual(C.__bases__, (B, int)) + self.assertIs(C.__base__, int) + self.assertIn('spam', C.__dict__) + self.assertNotIn('ham', C.__dict__) + x = C(42) + self.assertEqual(x, 42) + self.assertIs(type(x), C) + self.assertIs(x.__class__, C) + self.assertEqual(x.ham(), 'ham42') + self.assertEqual(x.spam(), 'spam42') + self.assertEqual(x.to_bytes(2, 'little'), b'\x2a\x00') + + def test_type_new_keywords(self): + class B: + def ham(self): + return 'ham%d' % self + C = type.__new__(type, + name='C', + bases=(B, int), + dict={'spam': lambda self: 'spam%s' % self}) + self.assertEqual(C.__name__, 'C') + self.assertEqual(C.__qualname__, 'C') + self.assertEqual(C.__module__, __name__) + self.assertEqual(C.__bases__, (B, int)) + self.assertIs(C.__base__, int) + self.assertIn('spam', C.__dict__) + self.assertNotIn('ham', C.__dict__) + + def test_type_name(self): + for name in 'A', '\xc4', '\U0001f40d', 'B.A', '42', '': + with self.subTest(name=name): + A = type(name, (), {}) + self.assertEqual(A.__name__, name) + self.assertEqual(A.__qualname__, name) + self.assertEqual(A.__module__, __name__) + with self.assertRaises(ValueError): + type('A\x00B', (), {}) + with self.assertRaises(ValueError): + type('A\udcdcB', (), {}) + with self.assertRaises(TypeError): + type(b'A', (), {}) + + C = type('C', (), {}) + for name in 'A', '\xc4', '\U0001f40d', 'B.A', '42', '': + with self.subTest(name=name): + C.__name__ = name + self.assertEqual(C.__name__, name) + self.assertEqual(C.__qualname__, 'C') + self.assertEqual(C.__module__, __name__) + + A = type('C', (), {}) + with self.assertRaises(ValueError): + A.__name__ = 'A\x00B' + self.assertEqual(A.__name__, 'C') + with self.assertRaises(ValueError): + A.__name__ = 'A\udcdcB' + self.assertEqual(A.__name__, 'C') + with self.assertRaises(TypeError): + A.__name__ = b'A' + self.assertEqual(A.__name__, 'C') + + def test_type_qualname(self): + A = type('A', (), {'__qualname__': 'B.C'}) + self.assertEqual(A.__name__, 'A') + self.assertEqual(A.__qualname__, 'B.C') + self.assertEqual(A.__module__, __name__) + with self.assertRaises(TypeError): + type('A', (), {'__qualname__': b'B'}) + self.assertEqual(A.__qualname__, 'B.C') + + A.__qualname__ = 'D.E' + self.assertEqual(A.__name__, 'A') + self.assertEqual(A.__qualname__, 'D.E') + with self.assertRaises(TypeError): + A.__qualname__ = b'B' + self.assertEqual(A.__qualname__, 'D.E') + + def test_type_doc(self): + for doc in 'x', '\xc4', '\U0001f40d', 'x\x00y', b'x', 42, None: + A = type('A', (), {'__doc__': doc}) + self.assertEqual(A.__doc__, doc) + with self.assertRaises(UnicodeEncodeError): + type('A', (), {'__doc__': 'x\udcdcy'}) + + A = type('A', (), {}) + self.assertEqual(A.__doc__, None) + for doc in 'x', '\xc4', '\U0001f40d', 'x\x00y', 'x\udcdcy', b'x', 42, None: + A.__doc__ = doc + self.assertEqual(A.__doc__, doc) + + def test_bad_args(self): + with self.assertRaises(TypeError): + type() + with self.assertRaises(TypeError): + type('A', ()) + with self.assertRaises(TypeError): + type('A', (), {}, ()) + with self.assertRaises(TypeError): + type('A', (), dict={}) + with self.assertRaises(TypeError): + type('A', [], {}) + with self.assertRaises(TypeError): + type('A', (), types.MappingProxyType({})) + with self.assertRaises(TypeError): + type('A', (None,), {}) + with self.assertRaises(TypeError): + type('A', (bool,), {}) + with self.assertRaises(TypeError): + type('A', (int, str), {}) + + def test_bad_slots(self): + with self.assertRaises(TypeError): + type('A', (), {'__slots__': b'x'}) + with self.assertRaises(TypeError): + type('A', (int,), {'__slots__': 'x'}) + with self.assertRaises(TypeError): + type('A', (), {'__slots__': ''}) + with self.assertRaises(TypeError): + type('A', (), {'__slots__': '42'}) + with self.assertRaises(TypeError): + type('A', (), {'__slots__': 'x\x00y'}) + with self.assertRaises(ValueError): + type('A', (), {'__slots__': 'x', 'x': 0}) + with self.assertRaises(TypeError): + type('A', (), {'__slots__': ('__dict__', '__dict__')}) + with self.assertRaises(TypeError): + type('A', (), {'__slots__': ('__weakref__', '__weakref__')}) + + class B: + pass + with self.assertRaises(TypeError): + type('A', (B,), {'__slots__': '__dict__'}) + with self.assertRaises(TypeError): + type('A', (B,), {'__slots__': '__weakref__'}) + + def load_tests(loader, tests, pattern): from doctest import DocTestSuite tests.addTest(DocTestSuite(builtins)) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 8 16:47:49 2016 From: python-checkins at python.org (victor.stinner) Date: Mon, 08 Feb 2016 21:47:49 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_compiler=3A_don=27t_emit_S?= =?utf-8?q?yntaxWarning_on_const_stmt?= Message-ID: <20160208214748.20013.32383@psf.io> https://hg.python.org/cpython/rev/15531b10976c changeset: 100202:15531b10976c user: Victor Stinner date: Mon Feb 08 22:45:06 2016 +0100 summary: compiler: don't emit SyntaxWarning on const stmt Issue #26204: the compiler doesn't emit SyntaxWarning warnings anymore when constant statements are ignored. files: Lib/test/test_ast.py | 7 +-- Lib/test/test_code.py | 58 ++++++++------------------- Lib/test/test_grammar.py | 6 +-- Misc/NEWS | 7 +- Python/compile.c | 24 +---------- 5 files changed, 27 insertions(+), 75 deletions(-) diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py --- a/Lib/test/test_ast.py +++ b/Lib/test/test_ast.py @@ -3,7 +3,6 @@ import os import sys import unittest -import warnings import weakref from test import support @@ -240,10 +239,8 @@ ast_tree = compile(i, "?", kind, ast.PyCF_ONLY_AST) self.assertEqual(to_tuple(ast_tree), o) self._assertTrueorder(ast_tree, (0, 0)) - with warnings.catch_warnings(): - warnings.filterwarnings('ignore', category=SyntaxWarning) - with self.subTest(action="compiling", input=i, kind=kind): - compile(ast_tree, "?", kind) + with self.subTest(action="compiling", input=i, kind=kind): + compile(ast_tree, "?", kind) def test_slice(self): slc = ast.parse("x[::]").body[0].value.slice diff --git a/Lib/test/test_code.py b/Lib/test/test_code.py --- a/Lib/test/test_code.py +++ b/Lib/test/test_code.py @@ -66,6 +66,24 @@ flags: 67 consts: ('None',) +>>> def optimize_away(): +... 'doc string' +... 'not a docstring' +... 53 +... 0x53 + +>>> dump(optimize_away.__code__) +name: optimize_away +argcount: 0 +kwonlyargcount: 0 +names: () +varnames: () +cellvars: () +freevars: () +nlocals: 0 +flags: 67 +consts: ("'doc string'", 'None') + >>> def keywordonly_args(a,b,*,k1): ... return a,b,k1 ... @@ -84,10 +102,8 @@ """ -import textwrap import unittest import weakref -import warnings from test.support import run_doctest, run_unittest, cpython_only @@ -118,44 +134,6 @@ self.assertEqual(co.co_name, "funcname") self.assertEqual(co.co_firstlineno, 15) - def dump(self, co): - dump = {} - for attr in ["name", "argcount", "kwonlyargcount", "names", "varnames", - "cellvars", "freevars", "nlocals", "flags"]: - dump[attr] = getattr(co, "co_" + attr) - dump['consts'] = tuple(consts(co.co_consts)) - return dump - - def test_optimize_away(self): - ns = {} - with warnings.catch_warnings(): - warnings.filterwarnings('ignore', category=SyntaxWarning) - exec(textwrap.dedent(''' - def optimize_away(): - 'doc string' - 'not a docstring' - 53 - 0x53 - b'bytes' - 1.0 - True - False - None - ... - '''), ns) - - self.assertEqual(self.dump(ns['optimize_away'].__code__), - {'name': 'optimize_away', - 'argcount': 0, - 'kwonlyargcount': 0, - 'names': (), - 'varnames': (), - 'cellvars': (), - 'freevars': (), - 'nlocals': 0, - 'flags': 67, - 'consts': ("'doc string'", 'None')}) - class CodeWeakRefTest(unittest.TestCase): diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py --- a/Lib/test/test_grammar.py +++ b/Lib/test/test_grammar.py @@ -7,7 +7,6 @@ import sys # testing import * from sys import * -from test import support class TokenTests(unittest.TestCase): @@ -425,11 +424,8 @@ # Tested below def test_expr_stmt(self): - msg = 'ignore constant statement' - with support.check_warnings((msg, SyntaxWarning)): - exec("1") - # (exprlist '=')* exprlist + 1 1, 2, 3 x = 1 x = 1, 2, 3 diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,9 +10,10 @@ Core and Builtins ----------------- -- Issue #26204: The compiler now ignores constant statements (ex: "def f(): 1") - and emit a SyntaxWarning warning. The warning is not emitted for string and - ellipsis (...) statements. +- Issue #26204: The compiler now ignores all constant statements: bytes, str, + int, float, complex, name constants (None, False, True), Ellipsis + and ast.Constant; not only str and int. For example, ``1.0`` is now ignored + in ``def f(): 1.0``. - Issue #4806: Avoid masking the original TypeError exception when using star (*) unpacking in function calls. Based on patch by Hagen F?rstenau and diff --git a/Python/compile.c b/Python/compile.c --- a/Python/compile.c +++ b/Python/compile.c @@ -2619,33 +2619,13 @@ switch (value->kind) { case Str_kind: + case Num_kind: case Ellipsis_kind: - /* Issue #26204: ignore string statement, but don't emit a - * SyntaxWarning. Triple quoted strings is a common syntax for - * multiline comments. - * - * Don't emit warning on "def f(): ..." neither. It's a legit syntax - * for abstract function. */ - return 1; - case Bytes_kind: - case Num_kind: case NameConstant_kind: case Constant_kind: - { - PyObject *msg = PyUnicode_FromString("ignore constant statement"); - if (msg == NULL) - return 0; - if (PyErr_WarnExplicitObject(PyExc_SyntaxWarning, - msg, - c->c_filename, c->u->u_lineno, - NULL, NULL) == -1) { - Py_DECREF(msg); - return 0; - } - Py_DECREF(msg); + /* ignore constant statement */ return 1; - } default: break; -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 8 20:38:39 2016 From: python-checkins at python.org (martin.panter) Date: Tue, 09 Feb 2016 01:38:39 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWVzICMyNjMx?= =?utf-8?q?0=2C_=2326311=3A_Fix_typos_in_the_documentation?= Message-ID: <20160209013839.2661.40319@psf.io> https://hg.python.org/cpython/rev/8c7a8c7a02b9 changeset: 100205:8c7a8c7a02b9 branch: 2.7 parent: 100199:f9bd6ddb6ba4 user: Martin Panter date: Wed Feb 10 01:17:51 2016 +0000 summary: Issues #26310, #26311: Fix typos in the documentation files: Doc/library/pyexpat.rst | 4 ++-- Doc/library/ttk.rst | 2 +- Lib/SocketServer.py | 2 +- Lib/idlelib/NEWS.txt | 2 +- Lib/idlelib/help.py | 2 +- Misc/NEWS | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Doc/library/pyexpat.rst b/Doc/library/pyexpat.rst --- a/Doc/library/pyexpat.rst +++ b/Doc/library/pyexpat.rst @@ -595,9 +595,9 @@ .. sectionauthor:: Fred L. Drake, Jr. -Content modules are described using nested tuples. Each tuple contains four +Content models are described using nested tuples. Each tuple contains four values: the type, the quantifier, the name, and a tuple of children. Children -are simply additional content module descriptions. +are simply additional content model descriptions. The values of the first two fields are constants defined in the ``model`` object of the :mod:`xml.parsers.expat` module. These constants can be collected in two diff --git a/Doc/library/ttk.rst b/Doc/library/ttk.rst --- a/Doc/library/ttk.rst +++ b/Doc/library/ttk.rst @@ -293,7 +293,7 @@ :meth:`Widget.configure`, :meth:`Widget.identify`, :meth:`Widget.instate` and :meth:`Widget.state`) and those inherited from :class:`Entry` (:meth:`Entry.bbox`, :meth:`Entry.delete`, :meth:`Entry.icursor`, -:meth:`Entry.index`, :meth:`Entry.inset`, :meth:`Entry.selection`, +:meth:`Entry.index`, :meth:`Entry.insert`, :meth:`Entry.selection`, :meth:`Entry.xview`), this class has some other methods, described at :class:`ttk.Combobox`. diff --git a/Lib/SocketServer.py b/Lib/SocketServer.py --- a/Lib/SocketServer.py +++ b/Lib/SocketServer.py @@ -642,7 +642,7 @@ client address as self.client_address, and the server (in case it needs access to per-server information) as self.server. Since a separate instance is created for each request, the handle() method - can define arbitrary other instance variariables. + can define other arbitrary instance variables. """ diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt --- a/Lib/idlelib/NEWS.txt +++ b/Lib/idlelib/NEWS.txt @@ -162,7 +162,7 @@ move version to end. - Issue #14105: Idle debugger breakpoints no longer disappear - when inseting or deleting lines. + when inserting or deleting lines. What's New in IDLE 2.7.8? diff --git a/Lib/idlelib/help.py b/Lib/idlelib/help.py --- a/Lib/idlelib/help.py +++ b/Lib/idlelib/help.py @@ -11,7 +11,7 @@ Doc/library/idle.rst (Sphinx)=> Doc/build/html/library/idle.html (help.copy_strip)=> Lib/idlelib/help.html -HelpParser - Parse help.html and and render to tk Text. +HelpParser - Parse help.html and render to tk Text. HelpText - Display formatted help.html. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -1159,7 +1159,7 @@ move version to end. - Issue #14105: Idle debugger breakpoints no longer disappear - when inseting or deleting lines. + when inserting or deleting lines. Extension Modules ----------------- -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 8 20:38:39 2016 From: python-checkins at python.org (martin.panter) Date: Tue, 09 Feb 2016 01:38:39 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWVzICMyNjMx?= =?utf-8?q?0=2C_=2326311=3A_Fix_typos_in_the_documentation_and_code_commen?= =?utf-8?q?ts?= Message-ID: <20160209013838.68422.48526@psf.io> https://hg.python.org/cpython/rev/1383a260b66d changeset: 100203:1383a260b66d branch: 3.5 parent: 100200:0e7aabe76159 user: Martin Panter date: Wed Feb 10 01:17:51 2016 +0000 summary: Issues #26310, #26311: Fix typos in the documentation and code comments files: Doc/library/pyexpat.rst | 4 ++-- Doc/library/tkinter.ttk.rst | 2 +- Doc/whatsnew/3.5.rst | 2 +- Lib/email/headerregistry.py | 2 +- Lib/idlelib/NEWS.txt | 2 +- Lib/idlelib/help.py | 2 +- Lib/socketserver.py | 2 +- Misc/NEWS | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Doc/library/pyexpat.rst b/Doc/library/pyexpat.rst --- a/Doc/library/pyexpat.rst +++ b/Doc/library/pyexpat.rst @@ -570,9 +570,9 @@ .. sectionauthor:: Fred L. Drake, Jr. -Content modules are described using nested tuples. Each tuple contains four +Content models are described using nested tuples. Each tuple contains four values: the type, the quantifier, the name, and a tuple of children. Children -are simply additional content module descriptions. +are simply additional content model descriptions. The values of the first two fields are constants defined in the :mod:`xml.parsers.expat.model` module. These constants can be collected in two diff --git a/Doc/library/tkinter.ttk.rst b/Doc/library/tkinter.ttk.rst --- a/Doc/library/tkinter.ttk.rst +++ b/Doc/library/tkinter.ttk.rst @@ -299,7 +299,7 @@ :meth:`Widget.configure`, :meth:`Widget.identify`, :meth:`Widget.instate` and :meth:`Widget.state`, and the following inherited from :class:`Entry`: :meth:`Entry.bbox`, :meth:`Entry.delete`, :meth:`Entry.icursor`, -:meth:`Entry.index`, :meth:`Entry.inset`, :meth:`Entry.selection`, +:meth:`Entry.index`, :meth:`Entry.insert`, :meth:`Entry.selection`, :meth:`Entry.xview`, it has some other methods, described at :class:`ttk.Combobox`. diff --git a/Doc/whatsnew/3.5.rst b/Doc/whatsnew/3.5.rst --- a/Doc/whatsnew/3.5.rst +++ b/Doc/whatsnew/3.5.rst @@ -914,7 +914,7 @@ ---------- A new :mod:`compileall` option, :samp:`-j {N}`, allows to run *N* workers -sumultaneously to perform parallel bytecode compilation. +simultaneously to perform parallel bytecode compilation. The :func:`~compileall.compile_dir` function has a corresponding ``workers`` parameter. (Contributed by Claudiu Popa in :issue:`16104`.) diff --git a/Lib/email/headerregistry.py b/Lib/email/headerregistry.py --- a/Lib/email/headerregistry.py +++ b/Lib/email/headerregistry.py @@ -16,7 +16,7 @@ class Address: def __init__(self, display_name='', username='', domain='', addr_spec=None): - """Create an object represeting a full email address. + """Create an object representing a full email address. An address can have a 'display_name', a 'username', and a 'domain'. In addition to specifying the username and domain separately, they may be diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt --- a/Lib/idlelib/NEWS.txt +++ b/Lib/idlelib/NEWS.txt @@ -149,7 +149,7 @@ move version to end. - Issue #14105: Idle debugger breakpoints no longer disappear - when inseting or deleting lines. + when inserting or deleting lines. - Issue #17172: Turtledemo can now be run from Idle. Currently, the entry is on the Help menu, but it may move to Run. diff --git a/Lib/idlelib/help.py b/Lib/idlelib/help.py --- a/Lib/idlelib/help.py +++ b/Lib/idlelib/help.py @@ -11,7 +11,7 @@ Doc/library/idle.rst (Sphinx)=> Doc/build/html/library/idle.html (help.copy_strip)=> Lib/idlelib/help.html -HelpParser - Parse help.html and and render to tk Text. +HelpParser - Parse help.html and render to tk Text. HelpText - Display formatted help.html. diff --git a/Lib/socketserver.py b/Lib/socketserver.py --- a/Lib/socketserver.py +++ b/Lib/socketserver.py @@ -671,7 +671,7 @@ client address as self.client_address, and the server (in case it needs access to per-server information) as self.server. Since a separate instance is created for each request, the handle() method - can define arbitrary other instance variariables. + can define other arbitrary instance variables. """ diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -3448,7 +3448,7 @@ move version to end. - Issue #14105: Idle debugger breakpoints no longer disappear - when inseting or deleting lines. + when inserting or deleting lines. - Issue #17172: Turtledemo can now be run from Idle. Currently, the entry is on the Help menu, but it may move to Run. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 8 20:38:39 2016 From: python-checkins at python.org (martin.panter) Date: Tue, 09 Feb 2016 01:38:39 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issues_=2326310=2C_26311=3A_Merge_typo_fixes_from_3=2E5?= Message-ID: <20160209013838.1560.53671@psf.io> https://hg.python.org/cpython/rev/e2d3c93d8763 changeset: 100204:e2d3c93d8763 parent: 100202:15531b10976c parent: 100203:1383a260b66d user: Martin Panter date: Wed Feb 10 01:18:36 2016 +0000 summary: Issues #26310, 26311: Merge typo fixes from 3.5 files: Doc/library/pyexpat.rst | 4 ++-- Doc/library/tkinter.ttk.rst | 2 +- Doc/whatsnew/3.5.rst | 2 +- Lib/email/headerregistry.py | 2 +- Lib/idlelib/NEWS.txt | 2 +- Lib/idlelib/help.py | 2 +- Lib/socketserver.py | 2 +- Misc/NEWS | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Doc/library/pyexpat.rst b/Doc/library/pyexpat.rst --- a/Doc/library/pyexpat.rst +++ b/Doc/library/pyexpat.rst @@ -570,9 +570,9 @@ .. sectionauthor:: Fred L. Drake, Jr. -Content modules are described using nested tuples. Each tuple contains four +Content models are described using nested tuples. Each tuple contains four values: the type, the quantifier, the name, and a tuple of children. Children -are simply additional content module descriptions. +are simply additional content model descriptions. The values of the first two fields are constants defined in the :mod:`xml.parsers.expat.model` module. These constants can be collected in two diff --git a/Doc/library/tkinter.ttk.rst b/Doc/library/tkinter.ttk.rst --- a/Doc/library/tkinter.ttk.rst +++ b/Doc/library/tkinter.ttk.rst @@ -299,7 +299,7 @@ :meth:`Widget.configure`, :meth:`Widget.identify`, :meth:`Widget.instate` and :meth:`Widget.state`, and the following inherited from :class:`Entry`: :meth:`Entry.bbox`, :meth:`Entry.delete`, :meth:`Entry.icursor`, -:meth:`Entry.index`, :meth:`Entry.inset`, :meth:`Entry.selection`, +:meth:`Entry.index`, :meth:`Entry.insert`, :meth:`Entry.selection`, :meth:`Entry.xview`, it has some other methods, described at :class:`ttk.Combobox`. diff --git a/Doc/whatsnew/3.5.rst b/Doc/whatsnew/3.5.rst --- a/Doc/whatsnew/3.5.rst +++ b/Doc/whatsnew/3.5.rst @@ -914,7 +914,7 @@ ---------- A new :mod:`compileall` option, :samp:`-j {N}`, allows to run *N* workers -sumultaneously to perform parallel bytecode compilation. +simultaneously to perform parallel bytecode compilation. The :func:`~compileall.compile_dir` function has a corresponding ``workers`` parameter. (Contributed by Claudiu Popa in :issue:`16104`.) diff --git a/Lib/email/headerregistry.py b/Lib/email/headerregistry.py --- a/Lib/email/headerregistry.py +++ b/Lib/email/headerregistry.py @@ -16,7 +16,7 @@ class Address: def __init__(self, display_name='', username='', domain='', addr_spec=None): - """Create an object represeting a full email address. + """Create an object representing a full email address. An address can have a 'display_name', a 'username', and a 'domain'. In addition to specifying the username and domain separately, they may be diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt --- a/Lib/idlelib/NEWS.txt +++ b/Lib/idlelib/NEWS.txt @@ -149,7 +149,7 @@ move version to end. - Issue #14105: Idle debugger breakpoints no longer disappear - when inseting or deleting lines. + when inserting or deleting lines. - Issue #17172: Turtledemo can now be run from Idle. Currently, the entry is on the Help menu, but it may move to Run. diff --git a/Lib/idlelib/help.py b/Lib/idlelib/help.py --- a/Lib/idlelib/help.py +++ b/Lib/idlelib/help.py @@ -11,7 +11,7 @@ Doc/library/idle.rst (Sphinx)=> Doc/build/html/library/idle.html (help.copy_strip)=> Lib/idlelib/help.html -HelpParser - Parse help.html and and render to tk Text. +HelpParser - Parse help.html and render to tk Text. HelpText - Display formatted help.html. diff --git a/Lib/socketserver.py b/Lib/socketserver.py --- a/Lib/socketserver.py +++ b/Lib/socketserver.py @@ -671,7 +671,7 @@ client address as self.client_address, and the server (in case it needs access to per-server information) as self.server. Since a separate instance is created for each request, the handle() method - can define arbitrary other instance variariables. + can define other arbitrary instance variables. """ diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -3936,7 +3936,7 @@ move version to end. - Issue #14105: Idle debugger breakpoints no longer disappear - when inseting or deleting lines. + when inserting or deleting lines. - Issue #17172: Turtledemo can now be run from Idle. Currently, the entry is on the Help menu, but it may move to Run. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 8 23:35:01 2016 From: python-checkins at python.org (raymond.hettinger) Date: Tue, 09 Feb 2016 04:35:01 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2326200=3A__The_SET?= =?utf-8?q?REF_macro_adds_unnecessary_work_in_some_cases=2E?= Message-ID: <20160209043501.19985.57751@psf.io> https://hg.python.org/cpython/rev/3084914245d2 changeset: 100206:3084914245d2 parent: 100204:e2d3c93d8763 user: Raymond Hettinger date: Mon Feb 08 20:34:49 2016 -0800 summary: Issue #26200: The SETREF macro adds unnecessary work in some cases. files: Modules/_collectionsmodule.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -1218,6 +1218,7 @@ static int deque_ass_item(dequeobject *deque, Py_ssize_t i, PyObject *v) { + PyObject *old_value; block *b; Py_ssize_t n, len=Py_SIZE(deque), halflen=(len+1)>>1, index=i; @@ -1246,7 +1247,9 @@ b = b->leftlink; } Py_INCREF(v); - Py_SETREF(b->data[i], v); + old_value = b->data[i]; + b->data[i] = v; + Py_DECREF(old_value); return 0; } -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Tue Feb 9 04:43:33 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Tue, 09 Feb 2016 09:43:33 +0000 Subject: [Python-checkins] Daily reference leaks (3084914245d2): sum=4 Message-ID: <20160209094333.61958.96397@psf.io> results for 3084914245d2 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogYiUbpH', '--timeout', '7200'] From python-checkins at python.org Tue Feb 9 05:24:17 2016 From: python-checkins at python.org (martin.panter) Date: Tue, 09 Feb 2016 10:24:17 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2326243=3A_zlib=2Ec?= =?utf-8?q?ompress=28=29_keyword_argument_support_by_Aviv_Palivoda?= Message-ID: <20160209102417.15917.7533@psf.io> https://hg.python.org/cpython/rev/592db8704d38 changeset: 100207:592db8704d38 user: Martin Panter date: Wed Feb 10 10:06:36 2016 +0000 summary: Issue #26243: zlib.compress() keyword argument support by Aviv Palivoda files: Doc/library/zlib.rst | 11 ++++++-- Doc/whatsnew/3.6.rst | 7 +++++ Lib/test/test_zlib.py | 4 +++ Misc/NEWS | 3 ++ Modules/clinic/zlibmodule.c.h | 27 +++++++++++----------- Modules/zlibmodule.c | 17 ++++++------- 6 files changed, 44 insertions(+), 25 deletions(-) diff --git a/Doc/library/zlib.rst b/Doc/library/zlib.rst --- a/Doc/library/zlib.rst +++ b/Doc/library/zlib.rst @@ -46,14 +46,19 @@ platforms, use ``adler32(data) & 0xffffffff``. -.. function:: compress(data[, level]) +.. function:: compress(data, level=-1) Compresses the bytes in *data*, returning a bytes object containing compressed data. - *level* is an integer from ``0`` to ``9`` controlling the level of compression; + *level* is an integer from ``0`` to ``9`` or ``-1`` controlling the level of compression; ``1`` is fastest and produces the least compression, ``9`` is slowest and - produces the most. ``0`` is no compression. The default value is ``6``. + produces the most. ``0`` is no compression. The default value is ``-1`` + (Z_DEFAULT_COMPRESSION). Z_DEFAULT_COMPRESSION represents a default + compromise between speed and compression (currently equivalent to level 6). Raises the :exc:`error` exception if any error occurs. + .. versionchanged:: 3.6 + Keyword arguments are now supported. + .. function:: compressobj(level=-1, method=DEFLATED, wbits=15, memLevel=8, strategy=Z_DEFAULT_STRATEGY[, zdict]) diff --git a/Doc/whatsnew/3.6.rst b/Doc/whatsnew/3.6.rst --- a/Doc/whatsnew/3.6.rst +++ b/Doc/whatsnew/3.6.rst @@ -150,6 +150,13 @@ (Contributed by Thomas Kluyver in :issue:`26039`.) +zlib +---- + +The :func:`~zlib.compress` function now accepts keyword arguments. +(Contributed by Aviv Palivoda in :issue:`26243`.) + + Optimizations ============= diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py --- a/Lib/test/test_zlib.py +++ b/Lib/test/test_zlib.py @@ -162,6 +162,10 @@ x = zlib.compress(HAMLET_SCENE) self.assertEqual(zlib.decompress(x), HAMLET_SCENE) + def test_keywords(self): + x = zlib.compress(data=HAMLET_SCENE, level=3) + self.assertEqual(zlib.decompress(x), HAMLET_SCENE) + def test_speech128(self): # compress more data data = HAMLET_SCENE * 128 diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -175,6 +175,9 @@ Library ------- +- Issue #26243: Support keyword arguments to zlib.compress(). Patch by Aviv + Palivoda. + - Issue #26117: The os.scandir() iterator now closes file descriptor not only when the iteration is finished, but when it was failed with error. diff --git a/Modules/clinic/zlibmodule.c.h b/Modules/clinic/zlibmodule.c.h --- a/Modules/clinic/zlibmodule.c.h +++ b/Modules/clinic/zlibmodule.c.h @@ -3,38 +3,39 @@ [clinic start generated code]*/ PyDoc_STRVAR(zlib_compress__doc__, -"compress($module, bytes, level=Z_DEFAULT_COMPRESSION, /)\n" +"compress($module, /, data, level=Z_DEFAULT_COMPRESSION)\n" "--\n" "\n" "Returns a bytes object containing compressed data.\n" "\n" -" bytes\n" +" data\n" " Binary data to be compressed.\n" " level\n" " Compression level, in 0-9."); #define ZLIB_COMPRESS_METHODDEF \ - {"compress", (PyCFunction)zlib_compress, METH_VARARGS, zlib_compress__doc__}, + {"compress", (PyCFunction)zlib_compress, METH_VARARGS|METH_KEYWORDS, zlib_compress__doc__}, static PyObject * -zlib_compress_impl(PyModuleDef *module, Py_buffer *bytes, int level); +zlib_compress_impl(PyModuleDef *module, Py_buffer *data, int level); static PyObject * -zlib_compress(PyModuleDef *module, PyObject *args) +zlib_compress(PyModuleDef *module, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; - Py_buffer bytes = {NULL, NULL}; + static char *_keywords[] = {"data", "level", NULL}; + Py_buffer data = {NULL, NULL}; int level = Z_DEFAULT_COMPRESSION; - if (!PyArg_ParseTuple(args, "y*|i:compress", - &bytes, &level)) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "y*|i:compress", _keywords, + &data, &level)) goto exit; - return_value = zlib_compress_impl(module, &bytes, level); + return_value = zlib_compress_impl(module, &data, level); exit: - /* Cleanup for bytes */ - if (bytes.obj) - PyBuffer_Release(&bytes); + /* Cleanup for data */ + if (data.obj) + PyBuffer_Release(&data); return return_value; } @@ -439,4 +440,4 @@ #ifndef ZLIB_COMPRESS_COPY_METHODDEF #define ZLIB_COMPRESS_COPY_METHODDEF #endif /* !defined(ZLIB_COMPRESS_COPY_METHODDEF) */ -/*[clinic end generated code: output=cf81e1deae3af0ce input=a9049054013a1b77]*/ +/*[clinic end generated code: output=3c96b58b923c1273 input=a9049054013a1b77]*/ diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c --- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -137,18 +137,17 @@ /*[clinic input] zlib.compress - bytes: Py_buffer + data: Py_buffer Binary data to be compressed. level: int(c_default="Z_DEFAULT_COMPRESSION") = Z_DEFAULT_COMPRESSION - Compression level, in 0-9. - / + Compression level, in 0-9 or -1. Returns a bytes object containing compressed data. [clinic start generated code]*/ static PyObject * -zlib_compress_impl(PyModuleDef *module, Py_buffer *bytes, int level) -/*[clinic end generated code: output=5d7dd4588788efd3 input=be3abe9934bda4b3]*/ +zlib_compress_impl(PyModuleDef *module, Py_buffer *data, int level) +/*[clinic end generated code: output=1b97589132b203b4 input=671c615a4b2267da]*/ { PyObject *ReturnVal = NULL; Byte *input, *output = NULL; @@ -156,13 +155,13 @@ int err; z_stream zst; - if ((size_t)bytes->len > UINT_MAX) { + if ((size_t)data->len > UINT_MAX) { PyErr_SetString(PyExc_OverflowError, "Size does not fit in an unsigned int"); goto error; } - input = bytes->buf; - length = (unsigned int)bytes->len; + input = data->buf; + length = (unsigned int)data->len; zst.avail_out = length + length/1000 + 12 + 1; @@ -1323,7 +1322,7 @@ "zlib library, which is based on GNU zip.\n" "\n" "adler32(string[, start]) -- Compute an Adler-32 checksum.\n" -"compress(string[, level]) -- Compress string, with compression level in 0-9.\n" +"compress(data[, level]) -- Compress data, with compression level 0-9 or -1.\n" "compressobj([level[, ...]]) -- Return a compressor object.\n" "crc32(string[, start]) -- Compute a CRC-32 checksum.\n" "decompress(string,[wbits],[bufsize]) -- Decompresses a compressed string.\n" -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Feb 9 05:46:16 2016 From: python-checkins at python.org (martin.panter) Date: Tue, 09 Feb 2016 10:46:16 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_26243=3A_Forgot_to_u?= =?utf-8?q?pdate_zlib_doc_strings_in_Argument_Clinic?= Message-ID: <20160209104614.61964.85065@psf.io> https://hg.python.org/cpython/rev/dc758f51b8f5 changeset: 100208:dc758f51b8f5 user: Martin Panter date: Wed Feb 10 10:45:54 2016 +0000 summary: Issue 26243: Forgot to update zlib doc strings in Argument Clinic files: Modules/clinic/zlibmodule.c.h | 4 ++-- Modules/zlibmodule.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/clinic/zlibmodule.c.h b/Modules/clinic/zlibmodule.c.h --- a/Modules/clinic/zlibmodule.c.h +++ b/Modules/clinic/zlibmodule.c.h @@ -11,7 +11,7 @@ " data\n" " Binary data to be compressed.\n" " level\n" -" Compression level, in 0-9."); +" Compression level, in 0-9 or -1."); #define ZLIB_COMPRESS_METHODDEF \ {"compress", (PyCFunction)zlib_compress, METH_VARARGS|METH_KEYWORDS, zlib_compress__doc__}, @@ -440,4 +440,4 @@ #ifndef ZLIB_COMPRESS_COPY_METHODDEF #define ZLIB_COMPRESS_COPY_METHODDEF #endif /* !defined(ZLIB_COMPRESS_COPY_METHODDEF) */ -/*[clinic end generated code: output=3c96b58b923c1273 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=e6f3b79e051ecc35 input=a9049054013a1b77]*/ diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c --- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -147,7 +147,7 @@ static PyObject * zlib_compress_impl(PyModuleDef *module, Py_buffer *data, int level) -/*[clinic end generated code: output=1b97589132b203b4 input=671c615a4b2267da]*/ +/*[clinic end generated code: output=1b97589132b203b4 input=abed30f4fa14e213]*/ { PyObject *ReturnVal = NULL; Byte *input, *output = NULL; -- Repository URL: https://hg.python.org/cpython From lp_benchmark_robot at intel.com Tue Feb 9 11:36:39 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Tue, 9 Feb 2016 16:36:39 +0000 Subject: [Python-checkins] UGLY Benchmark Results for Python 2.7 2016-02-09 Message-ID: <4505d3e8-2d3e-4ce6-81dc-7462d7c0b9ae@irsmsx103.ger.corp.intel.com> Results for project Python 2.7, build date 2016-02-09 03:58:57 +0000 commit: 8c7a8c7a02b9 previous commit: ab25ce400abd revision date: 2016-02-10 01:17:51 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dc from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.16% -1.38% 2.83% 8.72% :-) pybench 0.15% -0.12% 5.95% 4.83% :-( regex_v8 0.64% -0.22% -2.31% 11.18% :-) nbody 0.10% 0.64% 6.98% 5.08% :-) json_dump_v2 0.30% 0.24% 5.26% 11.12% :-( normal_startup 1.84% -0.19% -5.89% 2.92% :-) ssbench 0.17% 1.81% 2.20% 1.07% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/ugly-benchmark-results-for-python-2-7-2016-02-09/ Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Tue Feb 9 11:36:02 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Tue, 9 Feb 2016 16:36:02 +0000 Subject: [Python-checkins] UGLY Benchmark Results for Python Default 2016-02-09 Message-ID: Results for project Python default, build date 2016-02-09 03:07:36 +0000 commit: e2d3c93d8763 previous commit: 53d66a554beb revision date: 2016-02-10 01:18:36 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.24% -2.17% 8.64% 15.48% :-| pybench 0.21% -0.14% 0.65% 5.14% :-( regex_v8 3.54% -0.83% -6.02% 5.96% :-| nbody 0.22% 1.52% -0.29% 8.50% :-| json_dump_v2 0.21% 0.74% -0.67% 9.76% :-| normal_startup 0.82% -0.07% 0.62% 4.97% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/ugly-benchmark-results-for-python-default-2016-02-09/ Note: Benchmark results are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Tue Feb 9 11:42:47 2016 From: python-checkins at python.org (zach.ware) Date: Tue, 09 Feb 2016 16:42:47 +0000 Subject: [Python-checkins] =?utf-8?q?devguide=3A_Tools/buildbot/test-amd64?= =?utf-8?q?=2Ebat_no_longer_exists?= Message-ID: <20160209164246.11223.29203@psf.io> https://hg.python.org/devguide/rev/2b858ea7c02b changeset: 791:2b858ea7c02b user: Zachary Ware date: Tue Feb 09 10:16:10 2016 -0600 summary: Tools/buildbot/test-amd64.bat no longer exists files: buildbots.rst | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/buildbots.rst b/buildbots.rst --- a/buildbots.rst +++ b/buildbots.rst @@ -217,8 +217,7 @@ If you are interested in the results of a specific test file only, we recommend you change (temporarily, of course) the contents of the ``buildbottest`` clause in ``Makefile.pre.in``; or, for Windows builders, -the ``Tools/buildbot/test.bat`` and ``Tools/buildbot/test-amd64.bat`` -scripts. +the ``Tools/buildbot/test.bat`` script. .. note:: For security reasons, it is impossible to build repositories from outside -- Repository URL: https://hg.python.org/devguide From python-checkins at python.org Tue Feb 9 11:42:48 2016 From: python-checkins at python.org (zach.ware) Date: Tue, 09 Feb 2016 16:42:48 +0000 Subject: [Python-checkins] =?utf-8?q?devguide=3A_Issue_=2325848=3A_Add_sec?= =?utf-8?q?tion_on_running_a_build_on_all_custom_builders?= Message-ID: <20160209164246.19989.58462@psf.io> https://hg.python.org/devguide/rev/5430f4fd4ca7 changeset: 792:5430f4fd4ca7 user: Zachary Ware date: Tue Feb 09 10:42:07 2016 -0600 summary: Issue #25848: Add section on running a build on all custom builders files: buildbots.rst | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/buildbots.rst b/buildbots.rst --- a/buildbots.rst +++ b/buildbots.rst @@ -219,9 +219,22 @@ ``buildbottest`` clause in ``Makefile.pre.in``; or, for Windows builders, the ``Tools/buildbot/test.bat`` script. +It is also possible to run a build on all of the custom builders at the same +time. Navigate to the bottom of the +`builders page `_, then find[#]_ +and fill out the set of fields that includes a *Repo path:* field. Click the +associated *Force Build* button to start the build on all available custom +builders. + .. note:: For security reasons, it is impossible to build repositories from outside the http://hg.python.org realm. .. seealso:: :ref:`buildslave` + +.. rubric:: Footnotes + +.. [#] Yes, find. Unfortunately, it moves around every time the buildbot + master is restarted; this ought to be fixed some day. + -- Repository URL: https://hg.python.org/devguide From python-checkins at python.org Wed Feb 10 00:22:29 2016 From: python-checkins at python.org (martin.panter) Date: Wed, 10 Feb 2016 05:22:29 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2326136=3A_Upgrade_?= =?utf-8?q?the_generator=5Fstop_warning_to_DeprecationWarning?= Message-ID: <20160210052228.1566.97374@psf.io> https://hg.python.org/cpython/rev/73f89182bb4d changeset: 100209:73f89182bb4d user: Martin Panter date: Wed Feb 10 04:40:48 2016 +0000 summary: Issue #26136: Upgrade the generator_stop warning to DeprecationWarning Patch by Anish Shah. files: Doc/whatsnew/3.6.rst | 8 ++++++++ Lib/test/test_contextlib.py | 2 +- Lib/test/test_generators.py | 6 +++--- Lib/test/test_with.py | 4 ++-- Misc/NEWS | 4 ++++ Objects/genobject.c | 2 +- 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Doc/whatsnew/3.6.rst b/Doc/whatsnew/3.6.rst --- a/Doc/whatsnew/3.6.rst +++ b/Doc/whatsnew/3.6.rst @@ -234,6 +234,14 @@ (Contributed by Rose Ames in :issue:`25791`.) +Deprecated Python behavior +-------------------------- + +* Raising the :exc:`StopIteration` exception inside a generator will now generate a + :exc:`DeprecationWarning`, and will trigger a :exc:`RuntimeError` in Python 3.7. + See :ref:`whatsnew-pep-479` for details. + + Removed ======= diff --git a/Lib/test/test_contextlib.py b/Lib/test/test_contextlib.py --- a/Lib/test/test_contextlib.py +++ b/Lib/test/test_contextlib.py @@ -89,7 +89,7 @@ def woohoo(): yield try: - with self.assertWarnsRegex(PendingDeprecationWarning, + with self.assertWarnsRegex(DeprecationWarning, "StopIteration"): with woohoo(): raise stop_exc diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py --- a/Lib/test/test_generators.py +++ b/Lib/test/test_generators.py @@ -245,11 +245,11 @@ yield with self.assertRaises(StopIteration), \ - self.assertWarnsRegex(PendingDeprecationWarning, "StopIteration"): + self.assertWarnsRegex(DeprecationWarning, "StopIteration"): next(gen()) - with self.assertRaisesRegex(PendingDeprecationWarning, + with self.assertRaisesRegex(DeprecationWarning, "generator .* raised StopIteration"), \ warnings.catch_warnings(): @@ -268,7 +268,7 @@ g = f() self.assertEqual(next(g), 1) - with self.assertWarnsRegex(PendingDeprecationWarning, "StopIteration"): + with self.assertWarnsRegex(DeprecationWarning, "StopIteration"): with self.assertRaises(StopIteration): next(g) diff --git a/Lib/test/test_with.py b/Lib/test/test_with.py --- a/Lib/test/test_with.py +++ b/Lib/test/test_with.py @@ -454,7 +454,7 @@ with cm(): raise StopIteration("from with") - with self.assertWarnsRegex(PendingDeprecationWarning, "StopIteration"): + with self.assertWarnsRegex(DeprecationWarning, "StopIteration"): self.assertRaises(StopIteration, shouldThrow) def testRaisedStopIteration2(self): @@ -482,7 +482,7 @@ with cm(): raise next(iter([])) - with self.assertWarnsRegex(PendingDeprecationWarning, "StopIteration"): + with self.assertWarnsRegex(DeprecationWarning, "StopIteration"): self.assertRaises(StopIteration, shouldThrow) def testRaisedGeneratorExit1(self): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,10 @@ Core and Builtins ----------------- +- Issue #26136: Upgrade the warning when a generator raises StopIteration + from PendingDeprecationWarning to DeprecationWarning. Patch by Anish + Shah. + - Issue #26204: The compiler now ignores all constant statements: bytes, str, int, float, complex, name constants (None, False, True), Ellipsis and ast.Constant; not only str and int. For example, ``1.0`` is now ignored diff --git a/Objects/genobject.c b/Objects/genobject.c --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -178,7 +178,7 @@ /* Pop the exception before issuing a warning. */ PyErr_Fetch(&exc, &val, &tb); - if (PyErr_WarnFormat(PyExc_PendingDeprecationWarning, 1, + if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, "generator '%.50S' raised StopIteration", gen->gi_qualname)) { /* Warning was converted to an error. */ -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Feb 10 00:47:03 2016 From: python-checkins at python.org (martin.panter) Date: Wed, 10 Feb 2016 05:47:03 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2326304=3A_Addition?= =?utf-8?q?al_=E2=80=9Callows_to=E2=80=9D_fix_specific_to_3=2E6?= Message-ID: <20160210054702.6661.14055@psf.io> https://hg.python.org/cpython/rev/37f6f965023d changeset: 100212:37f6f965023d user: Martin Panter date: Wed Feb 10 05:45:55 2016 +0000 summary: Issue #26304: Additional ?allows to? fix specific to 3.6 files: Doc/whatsnew/3.6.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/whatsnew/3.6.rst b/Doc/whatsnew/3.6.rst --- a/Doc/whatsnew/3.6.rst +++ b/Doc/whatsnew/3.6.rst @@ -144,7 +144,7 @@ ------- A new :meth:`ZipInfo.from_file() ` class method -allow to make :class:`~zipfile.ZipInfo` instance from a filesystem file. +allows making a :class:`~zipfile.ZipInfo` instance from a filesystem file. A new :meth:`ZipInfo.is_dir() ` method can be used to check if the :class:`~zipfile.ZipInfo` instance represents a directory. (Contributed by Thomas Kluyver in :issue:`26039`.) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Feb 10 00:47:03 2016 From: python-checkins at python.org (martin.panter) Date: Wed, 10 Feb 2016 05:47:03 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326304=3A_Merge_doc_wording_from_3=2E5?= Message-ID: <20160210054701.68406.90832@psf.io> https://hg.python.org/cpython/rev/d01abc2d5197 changeset: 100211:d01abc2d5197 parent: 100209:73f89182bb4d parent: 100210:818e91105418 user: Martin Panter date: Wed Feb 10 05:44:56 2016 +0000 summary: Issue #26304: Merge doc wording from 3.5 files: Doc/c-api/arg.rst | 2 +- Doc/c-api/function.rst | 2 +- Doc/howto/pyporting.rst | 4 +- Doc/library/asyncio-eventloop.rst | 4 +- Doc/library/asyncio-task.rst | 2 +- Doc/library/ctypes.rst | 32 +++++++------- Doc/library/nis.rst | 6 +- Doc/library/signal.rst | 2 +- Doc/library/smtplib.rst | 4 +- Doc/library/tarfile.rst | 2 +- Doc/using/cmdline.rst | 2 +- Doc/whatsnew/3.3.rst | 6 +- Doc/whatsnew/3.5.rst | 14 +++--- Include/object.h | 2 +- Lib/asyncio/futures.py | 2 +- Lib/ctypes/__init__.py | 4 +- Lib/test/test_cmd_line_script.py | 2 +- Lib/test/test_doctest.py | 2 +- Lib/test/test_genericpath.py | 2 +- Lib/test/test_strptime.py | 2 +- Lib/tkinter/__init__.py | 4 +- Misc/HISTORY | 34 ++++++++-------- Misc/NEWS | 12 ++-- Modules/_ctypes/_ctypes.c | 2 +- Modules/_ctypes/libffi/m4/libtool.m4 | 2 +- 25 files changed, 76 insertions(+), 76 deletions(-) diff --git a/Doc/c-api/arg.rst b/Doc/c-api/arg.rst --- a/Doc/c-api/arg.rst +++ b/Doc/c-api/arg.rst @@ -30,7 +30,7 @@ Strings and buffers ------------------- -These formats allow to access an object as a contiguous chunk of memory. +These formats allow accessing an object as a contiguous chunk of memory. You don't have to provide raw storage for the returned unicode or bytes area. Also, you won't have to release any memory yourself, except with the ``es``, ``es#``, ``et`` and ``et#`` formats. diff --git a/Doc/c-api/function.rst b/Doc/c-api/function.rst --- a/Doc/c-api/function.rst +++ b/Doc/c-api/function.rst @@ -40,7 +40,7 @@ .. c:function:: PyObject* PyFunction_NewWithQualName(PyObject *code, PyObject *globals, PyObject *qualname) - As :c:func:`PyFunction_New`, but also allows to set the function object's + As :c:func:`PyFunction_New`, but also allows setting the function object's ``__qualname__`` attribute. *qualname* should be a unicode object or NULL; if NULL, the ``__qualname__`` attribute is set to the same value as its ``__name__`` attribute. diff --git a/Doc/howto/pyporting.rst b/Doc/howto/pyporting.rst --- a/Doc/howto/pyporting.rst +++ b/Doc/howto/pyporting.rst @@ -243,8 +243,8 @@ binary reading). Under Python 3, binary files and text files are clearly distinct and mutually incompatible; see the :mod:`io` module for details. Therefore, you **must** make a decision of whether a file will be used for -binary access (allowing to read and/or write binary data) or text access -(allowing to read and/or write text data). You should also use :func:`io.open` +binary access (allowing binary data to be read and/or written) or text access +(allowing text data to be read and/or written). You should also use :func:`io.open` for opening files instead of the built-in :func:`open` function as the :mod:`io` module is consistent from Python 2 to 3 while the built-in :func:`open` function is not (in Python 3 it's actually :func:`io.open`). diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst --- a/Doc/library/asyncio-eventloop.rst +++ b/Doc/library/asyncio-eventloop.rst @@ -253,7 +253,7 @@ a class. For example, if you want to use a pre-created protocol instance, you can pass ``lambda: my_protocol``. - Options allowing to change how the connection is created: + Options that change how the connection is created: * *ssl*: if given and not false, a SSL/TLS transport is created (by default a plain TCP transport is created). If *ssl* is @@ -654,7 +654,7 @@ Error Handling API ------------------ -Allows to customize how exceptions are handled in the event loop. +Allows customizing how exceptions are handled in the event loop. .. method:: BaseEventLoop.set_exception_handler(handler) diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst --- a/Doc/library/asyncio-task.rst +++ b/Doc/library/asyncio-task.rst @@ -510,7 +510,7 @@ .. note:: - In the functions below, the optional *loop* argument allows to explicitly set + In the functions below, the optional *loop* argument allows explicitly setting the event loop object used by the underlying task or coroutine. If it's not provided, the default event loop is used. diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst --- a/Doc/library/ctypes.rst +++ b/Doc/library/ctypes.rst @@ -942,7 +942,7 @@ Callback functions ^^^^^^^^^^^^^^^^^^ -:mod:`ctypes` allows to create C callable function pointers from Python callables. +:mod:`ctypes` allows creating C callable function pointers from Python callables. These are sometimes called *callback functions*. First, you must create a class for the callback function. The class knows the @@ -1350,7 +1350,7 @@ ignored. The *use_errno* parameter, when set to True, enables a ctypes mechanism that -allows to access the system :data:`errno` error number in a safe way. +allows accessing the system :data:`errno` error number in a safe way. :mod:`ctypes` maintains a thread-local copy of the systems :data:`errno` variable; if you call foreign functions created with ``use_errno=True`` then the :data:`errno` value before the function call is swapped with the ctypes private @@ -1421,7 +1421,7 @@ Class which loads shared libraries. *dlltype* should be one of the :class:`CDLL`, :class:`PyDLL`, :class:`WinDLL`, or :class:`OleDLL` types. - :meth:`__getattr__` has special behavior: It allows to load a shared library by + :meth:`__getattr__` has special behavior: It allows loading a shared library by accessing it as attribute of a library loader instance. The result is cached, so repeated attribute accesses return the same library each time. @@ -1498,7 +1498,7 @@ It is possible to assign a callable Python object that is not a ctypes type, in this case the function is assumed to return a C :c:type:`int`, and - the callable will be called with this integer, allowing to do further + the callable will be called with this integer, allowing further processing or error checking. Using this is deprecated, for more flexible post processing or error checking use a ctypes data type as :attr:`restype` and assign a callable to the :attr:`errcheck` attribute. @@ -1513,7 +1513,7 @@ When a foreign function is called, each actual argument is passed to the :meth:`from_param` class method of the items in the :attr:`argtypes` - tuple, this method allows to adapt the actual argument to an object that + tuple, this method allows adapting the actual argument to an object that the foreign function accepts. For example, a :class:`c_char_p` item in the :attr:`argtypes` tuple will convert a string passed as argument into a bytes object using ctypes conversion rules. @@ -1521,7 +1521,7 @@ New: It is now possible to put items in argtypes which are not ctypes types, but each item must have a :meth:`from_param` method which returns a value usable as argument (integer, string, ctypes instance). This allows - to define adapters that can adapt custom objects as function parameters. + defining adapters that can adapt custom objects as function parameters. .. attribute:: errcheck @@ -1535,12 +1535,12 @@ *result* is what the foreign function returns, as specified by the :attr:`restype` attribute. - *func* is the foreign function object itself, this allows to reuse the + *func* is the foreign function object itself, this allows reusing the same callable object to check or post process the results of several functions. *arguments* is a tuple containing the parameters originally passed to - the function call, this allows to specialize the behavior on the + the function call, this allows specializing the behavior on the arguments used. The object that this function returns will be returned from the @@ -1785,7 +1785,7 @@ If a bytes object is specified as first argument, the buffer is made one item larger than its length so that the last element in the array is a NUL termination character. An integer can be passed as second argument which allows - to specify the size of the array if the length of the bytes should not be used. + specifying the size of the array if the length of the bytes should not be used. @@ -1800,21 +1800,21 @@ If a string is specified as first argument, the buffer is made one item larger than the length of the string so that the last element in the array is a NUL termination character. An integer can be passed as second argument which - allows to specify the size of the array if the length of the string should not + allows specifying the size of the array if the length of the string should not be used. .. function:: DllCanUnloadNow() - Windows only: This function is a hook which allows to implement in-process + Windows only: This function is a hook which allows implementing in-process COM servers with ctypes. It is called from the DllCanUnloadNow function that the _ctypes extension dll exports. .. function:: DllGetClassObject() - Windows only: This function is a hook which allows to implement in-process + Windows only: This function is a hook which allows implementing in-process COM servers with ctypes. It is called from the DllGetClassObject function that the ``_ctypes`` extension dll exports. @@ -2321,7 +2321,7 @@ checked, only one field can be accessed when names are repeated. It is possible to define the :attr:`_fields_` class variable *after* the - class statement that defines the Structure subclass, this allows to create + class statement that defines the Structure subclass, this allows creating data types that directly or indirectly reference themselves:: class List(Structure): @@ -2342,7 +2342,7 @@ .. attribute:: _pack_ - An optional small integer that allows to override the alignment of + An optional small integer that allows overriding the alignment of structure fields in the instance. :attr:`_pack_` must already be defined when :attr:`_fields_` is assigned, otherwise it will have no effect. @@ -2354,8 +2354,8 @@ assigned, otherwise it will have no effect. The fields listed in this variable must be structure or union type fields. - :mod:`ctypes` will create descriptors in the structure type that allows to - access the nested fields directly, without the need to create the + :mod:`ctypes` will create descriptors in the structure type that allows + accessing the nested fields directly, without the need to create the structure or union field. Here is an example type (Windows):: diff --git a/Doc/library/nis.rst b/Doc/library/nis.rst --- a/Doc/library/nis.rst +++ b/Doc/library/nis.rst @@ -26,7 +26,7 @@ Note that *mapname* is first checked if it is an alias to another name. - The *domain* argument allows to override the NIS domain used for the lookup. If + The *domain* argument allows overriding the NIS domain used for the lookup. If unspecified, lookup is in the default NIS domain. @@ -38,7 +38,7 @@ Note that *mapname* is first checked if it is an alias to another name. - The *domain* argument allows to override the NIS domain used for the lookup. If + The *domain* argument allows overriding the NIS domain used for the lookup. If unspecified, lookup is in the default NIS domain. @@ -46,7 +46,7 @@ Return a list of all valid maps. - The *domain* argument allows to override the NIS domain used for the lookup. If + The *domain* argument allows overriding the NIS domain used for the lookup. If unspecified, lookup is in the default NIS domain. diff --git a/Doc/library/signal.rst b/Doc/library/signal.rst --- a/Doc/library/signal.rst +++ b/Doc/library/signal.rst @@ -11,7 +11,7 @@ General rules ------------- -The :func:`signal.signal` function allows to define custom handlers to be +The :func:`signal.signal` function allows defining custom handlers to be executed when a signal is received. A small number of default handlers are installed: :const:`SIGPIPE` is ignored (so write errors on pipes and sockets can be reported as ordinary Python exceptions) and :const:`SIGINT` is diff --git a/Doc/library/smtplib.rst b/Doc/library/smtplib.rst --- a/Doc/library/smtplib.rst +++ b/Doc/library/smtplib.rst @@ -33,7 +33,7 @@ *timeout* parameter specifies a timeout in seconds for blocking operations like the connection attempt (if not specified, the global default timeout setting will be used). If the timeout expires, :exc:`socket.timeout` is - raised. The optional source_address parameter allows to bind + raised. The optional source_address parameter allows binding to some specific source address in a machine with multiple network interfaces, and/or to some specific source TCP port. It takes a 2-tuple (host, port), for the socket to bind to as its source address before @@ -76,7 +76,7 @@ *port* is zero, the standard SMTP-over-SSL port (465) is used. The optional arguments *local_hostname*, *timeout* and *source_address* have the same meaning as they do in the :class:`SMTP` class. *context*, also optional, - can contain a :class:`~ssl.SSLContext` and allows to configure various + can contain a :class:`~ssl.SSLContext` and allows configuring various aspects of the secure connection. Please read :ref:`ssl-security` for best practices. diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst --- a/Doc/library/tarfile.rst +++ b/Doc/library/tarfile.rst @@ -111,7 +111,7 @@ specifies the blocksize and defaults to ``20 * 512`` bytes. Use this variant in combination with e.g. ``sys.stdin``, a socket :term:`file object` or a tape device. However, such a :class:`TarFile` object is limited in that it does - not allow to be accessed randomly, see :ref:`tar-examples`. The currently + not allow random access, see :ref:`tar-examples`. The currently possible modes: +-------------+--------------------------------------------+ diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst --- a/Doc/using/cmdline.rst +++ b/Doc/using/cmdline.rst @@ -398,7 +398,7 @@ tracing with a traceback limit of *NFRAME* frames. See the :func:`tracemalloc.start` for more information. - It also allows to pass arbitrary values and retrieve them through the + It also allows passing arbitrary values and retrieving them through the :data:`sys._xoptions` dictionary. .. versionchanged:: 3.2 diff --git a/Doc/whatsnew/3.3.rst b/Doc/whatsnew/3.3.rst --- a/Doc/whatsnew/3.3.rst +++ b/Doc/whatsnew/3.3.rst @@ -1528,7 +1528,7 @@ multiprocessing --------------- -The new :func:`multiprocessing.connection.wait` function allows to poll +The new :func:`multiprocessing.connection.wait` function allows polling multiple objects (such as connections, sockets and pipes) with a timeout. (Contributed by Richard Oudkerk in :issue:`12328`.) @@ -1715,8 +1715,8 @@ ------ :class:`pickle.Pickler` objects now have an optional -:attr:`~pickle.Pickler.dispatch_table` attribute allowing to set per-pickler -reduction functions. +:attr:`~pickle.Pickler.dispatch_table` attribute allowing per-pickler +reduction functions to be set. (Contributed by Richard Oudkerk in :issue:`14166`.) diff --git a/Doc/whatsnew/3.5.rst b/Doc/whatsnew/3.5.rst --- a/Doc/whatsnew/3.5.rst +++ b/Doc/whatsnew/3.5.rst @@ -748,7 +748,7 @@ argparse -------- -The :class:`~argparse.ArgumentParser` class now allows to disable +The :class:`~argparse.ArgumentParser` class now allows disabling :ref:`abbreviated usage ` of long options by setting :ref:`allow_abbrev` to ``False``. (Contributed by Jonathan Paugh, Steven Bethard, paul j3 and Daniel Eriksson in :issue:`14910`.) @@ -913,12 +913,12 @@ compileall ---------- -A new :mod:`compileall` option, :samp:`-j {N}`, allows to run *N* workers +A new :mod:`compileall` option, :samp:`-j {N}`, allows running *N* workers simultaneously to perform parallel bytecode compilation. The :func:`~compileall.compile_dir` function has a corresponding ``workers`` parameter. (Contributed by Claudiu Popa in :issue:`16104`.) -Another new option, ``-r``, allows to control the maximum recursion +Another new option, ``-r``, allows controlling the maximum recursion level for subdirectories. (Contributed by Claudiu Popa in :issue:`19628`.) The ``-q`` command line option can now be specified more than once, in @@ -1453,8 +1453,8 @@ use ``/dev/urandom`` and avoiding failures due to potential file descriptor exhaustion. (Contributed by Victor Stinner in :issue:`22181`.) -New :func:`~os.get_blocking` and :func:`~os.set_blocking` functions allow to -get and set a file descriptor's blocking mode (:data:`~os.O_NONBLOCK`.) +New :func:`~os.get_blocking` and :func:`~os.set_blocking` functions allow +getting and setting a file descriptor's blocking mode (:data:`~os.O_NONBLOCK`.) (Contributed by Victor Stinner in :issue:`22054`.) The :func:`~os.truncate` and :func:`~os.ftruncate` functions are now supported @@ -1681,8 +1681,8 @@ Functions with timeouts now use a monotonic clock, instead of a system clock. (Contributed by Victor Stinner in :issue:`22043`.) -A new :meth:`socket.sendfile() ` method allows to -send a file over a socket by using the high-performance :func:`os.sendfile` +A new :meth:`socket.sendfile() ` method allows +sending a file over a socket by using the high-performance :func:`os.sendfile` function on UNIX, resulting in uploads being from 2 to 3 times faster than when using plain :meth:`socket.send() `. (Contributed by Giampaolo Rodola' in :issue:`17552`.) diff --git a/Include/object.h b/Include/object.h --- a/Include/object.h +++ b/Include/object.h @@ -134,7 +134,7 @@ usage, the string "foo" is interned, and the structures are linked. On interpreter shutdown, all strings are released (through _PyUnicode_ClearStaticStrings). - Alternatively, _Py_static_string allows to choose the variable name. + Alternatively, _Py_static_string allows choosing the variable name. _PyUnicode_FromId returns a borrowed reference to the interned string. _PyObject_{Get,Set,Has}AttrId are __getattr__ versions using _Py_Identifier*. */ diff --git a/Lib/asyncio/futures.py b/Lib/asyncio/futures.py --- a/Lib/asyncio/futures.py +++ b/Lib/asyncio/futures.py @@ -142,7 +142,7 @@ def __init__(self, *, loop=None): """Initialize the future. - The optional event_loop argument allows to explicitly set the event + The optional event_loop argument allows explicitly setting the event loop object used by the future. If it's not provided, the future uses the default event loop. """ diff --git a/Lib/ctypes/__init__.py b/Lib/ctypes/__init__.py --- a/Lib/ctypes/__init__.py +++ b/Lib/ctypes/__init__.py @@ -368,8 +368,8 @@ return func class PyDLL(CDLL): - """This class represents the Python library itself. It allows to - access Python API functions. The GIL is not released, and + """This class represents the Python library itself. It allows + accessing Python API functions. The GIL is not released, and Python exceptions are handled correctly. """ _func_flags_ = _FUNCFLAG_CDECL | _FUNCFLAG_PYTHONAPI diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py --- a/Lib/test/test_cmd_line_script.py +++ b/Lib/test/test_cmd_line_script.py @@ -498,7 +498,7 @@ def test_non_ascii(self): # Mac OS X denies the creation of a file with an invalid UTF-8 name. - # Windows allows to create a name with an arbitrary bytes name, but + # Windows allows creating a name with an arbitrary bytes name, but # Python cannot a undecodable bytes argument to a subprocess. if (support.TESTFN_UNDECODABLE and sys.platform not in ('win32', 'darwin')): diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py --- a/Lib/test/test_doctest.py +++ b/Lib/test/test_doctest.py @@ -2775,7 +2775,7 @@ with two tests, both of the files having "errors" in the tests that can be made non-errors by applying the appropriate doctest options to the run (ELLIPSIS in the first file, NORMALIZE_WHITESPACE in the second). This combination will -allow to thoroughly test the -f and -o flags, as well as the doctest command's +allow thoroughly testing the -f and -o flags, as well as the doctest command's ability to process more than one file on the command line and, since the second file ends in '.py', its handling of python module files (as opposed to straight text files). diff --git a/Lib/test/test_genericpath.py b/Lib/test/test_genericpath.py --- a/Lib/test/test_genericpath.py +++ b/Lib/test/test_genericpath.py @@ -419,7 +419,7 @@ def test_nonascii_abspath(self): if (support.TESTFN_UNDECODABLE # Mac OS X denies the creation of a directory with an invalid - # UTF-8 name. Windows allows to create a directory with an + # UTF-8 name. Windows allows creating a directory with an # arbitrary bytes name, but fails to enter this directory # (when the bytes name is used). and sys.platform not in ('win32', 'darwin')): diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py --- a/Lib/test/test_strptime.py +++ b/Lib/test/test_strptime.py @@ -190,7 +190,7 @@ def test_whitespace_substitution(self): # When pattern contains whitespace, make sure it is taken into account - # so as to not allow to subpatterns to end up next to each other and + # so as to not allow subpatterns to end up next to each other and # "steal" characters from each other. pattern = self.time_re.pattern('%j %H') self.assertFalse(re.match(pattern, "180")) diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -2499,7 +2499,7 @@ self.tk.call(self._w, 'toggle') class Entry(Widget, XView): - """Entry widget which allows to display simple text.""" + """Entry widget which allows displaying simple text.""" def __init__(self, master=None, cnf={}, **kw): """Construct an entry widget with the parent MASTER. @@ -2695,7 +2695,7 @@ itemconfig = itemconfigure class Menu(Widget): - """Menu widget which allows to display menu bars, pull-down menus and pop-up menus.""" + """Menu widget which allows displaying menu bars, pull-down menus and pop-up menus.""" def __init__(self, master=None, cnf={}, **kw): """Construct menu widget with the parent MASTER. diff --git a/Misc/HISTORY b/Misc/HISTORY --- a/Misc/HISTORY +++ b/Misc/HISTORY @@ -1095,7 +1095,7 @@ functions to support PEP 3115 compliant dynamic class creation. Patch by Daniel Urban and Nick Coghlan. -- Issue #13152: Allow to specify a custom tabsize for expanding tabs in +- Issue #13152: Allow specifying a custom tabsize for expanding tabs in textwrap. Patch by John Feuerstein. - Issue #14721: Send the correct 'Content-length: 0' header when the body is an @@ -2234,7 +2234,7 @@ fixed. - Issue #14166: Pickler objects now have an optional ``dispatch_table`` - attribute which allows to set custom per-pickler reduction functions. + attribute which allows setting custom per-pickler reduction functions. Patch by sbt. - Issue #14177: marshal.loads() now raises TypeError when given an unicode @@ -3185,7 +3185,7 @@ binary mode, but ensure that the shebang is decodable from UTF-8 and from the encoding of the script. -- Issue #8498: In socket.accept(), allow to specify 0 as a backlog value in +- Issue #8498: In socket.accept(), allow specifying 0 as a backlog value in order to accept exactly one connection. Patch by Daniel Evers. - Issue #12011: signal.signal() and signal.siginterrupt() raise an OSError, @@ -3885,7 +3885,7 @@ - Issue #12331: The test suite for lib2to3 can now run from an installed Python. -- Issue #12626: In regrtest, allow to filter tests using a glob filter +- Issue #12626: In regrtest, allow filtering tests using a glob filter with the ``-m`` (or ``--match``) option. This works with all test cases using the unittest module. This is useful with long test suites such as test_io or test_subprocess. @@ -4221,7 +4221,7 @@ Core and Builtins ----------------- -- Issue #10451: memoryview objects could allow to mutate a readable buffer. +- Issue #10451: memoryview objects could allow mutating a readable buffer. Initial patch by Ross Lagerwall. Library @@ -4765,7 +4765,7 @@ - Add the "display" and "undisplay" pdb commands. -- Issue #7245: Add a SIGINT handler in pdb that allows to break a program again +- Issue #7245: Add a SIGINT handler in pdb that allows breaking a program again after a "continue" command. - Add the "interact" pdb command. @@ -6916,7 +6916,7 @@ correct encoding. - Issue #4870: Add an `options` attribute to SSL contexts, as well as several - ``OP_*`` constants to the `ssl` module. This allows to selectively disable + ``OP_*`` constants to the `ssl` module. This allows selectively disabling protocol versions, when used in combination with `PROTOCOL_SSLv23`. - Issue #8759: Fixed user paths in sysconfig for posix and os2 schemes. @@ -9497,8 +9497,8 @@ - Issue #4051: Prevent conflict of UNICODE macros in cPickle. -- Issue #4738: Each zlib object now has a separate lock, allowing to compress - or decompress several streams at once on multi-CPU systems. Also, the GIL +- Issue #4738: Each zlib object now has a separate lock, allowing several streams + to be compressed or decompressed at once on multi-CPU systems. Also, the GIL is now released when computing the CRC of a large buffer. Patch by ebfe. - Issue #4228: Pack negative values the same way as 2.4 in struct's L format. @@ -9996,7 +9996,7 @@ as bytes string, please use PyUnicode_AsUTF8String() instead. - Issue #3460: PyUnicode_Join() implementation is 10% to 80% faster thanks - to Python 3.0's stricter semantics which allow to avoid successive + to Python 3.0's stricter semantics which allow avoiding successive reallocations of the result string (this also affects str.join()). @@ -12762,7 +12762,7 @@ - Patch #1110248: SYNC_FLUSH the zlib buffer for GZipFile.flush. -- Patch #1107973: Allow to iterate over the lines of a tarfile.ExFileObject. +- Patch #1107973: Allow iterating over the lines of a tarfile.ExFileObject. - Patch #1104111: Alter setup.py --help and --help-commands. @@ -13739,7 +13739,7 @@ same as when the argument is omitted). [SF bug 658254, patch 663482] -- nntplib does now allow to ignore a .netrc file. +- nntplib does now allow ignoring a .netrc file. - urllib2 now recognizes Basic authentication even if other authentication schemes are offered. @@ -14157,7 +14157,7 @@ - fcntl.ioctl now warns if the mutate flag is not specified. -- nt now properly allows to refer to UNC roots, e.g. in nt.stat(). +- nt now properly allows referring to UNC roots, e.g. in nt.stat(). - the weakref module now supports additional objects: array.array, sre.pattern_objects, file objects, and sockets. @@ -16715,7 +16715,7 @@ - New functions PyErr_SetExcFromWindowsErr() and PyErr_SetExcFromWindowsErrWithFilename(). Similar to PyErr_SetFromWindowsErrWithFilename() and - PyErr_SetFromWindowsErr(), but they allow to specify + PyErr_SetFromWindowsErr(), but they allow specifying the exception type to raise. Available on Windows. - Py_FatalError() is now declared as taking a const char* argument. It @@ -17590,8 +17590,8 @@ - property() now takes 4 keyword arguments: fget, fset, fdel and doc. These map to read-only attributes 'fget', 'fset', 'fdel', and '__doc__' in the constructed property object. fget, fset and fdel weren't - discoverable from Python in 2.2a3. __doc__ is new, and allows to - associate a docstring with a property. + discoverable from Python in 2.2a3. __doc__ is new, and allows + associating a docstring with a property. - Comparison overloading is now more completely implemented. For example, a str subclass instance can properly be compared to a str @@ -18006,7 +18006,7 @@ ----- - regrtest.py now knows which tests are expected to be skipped on some - platforms, allowing to give clearer test result output. regrtest + platforms, allowing clearer test result output to be given. regrtest also has optional --use/-u switch to run normally disabled tests which require network access or consume significant disk resources. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -2224,8 +2224,8 @@ and ASCII letter now raise a deprecation warning and will be forbidden in Python 3.6. -- Issue #23671: string.Template now allows to specify the "self" parameter as - keyword argument. string.Formatter now allows to specify the "self" and +- Issue #23671: string.Template now allows specifying the "self" parameter as + a keyword argument. string.Formatter now allows specifying the "self" and the "format_string" parameters as keyword arguments. - Issue #23502: The pprint module now supports mapping proxies. @@ -3354,7 +3354,7 @@ - Issue #22085: Dropped support of Tk 8.3 in Tkinter. - Issue #21580: Now Tkinter correctly handles bytes arguments passed to Tk. - In particular this allows to initialize images from binary data. + In particular this allows initializing images from binary data. - Issue #22003: When initialized from a bytes object, io.BytesIO() now defers making a copy until it is mutated, improving performance and @@ -3499,7 +3499,7 @@ - Issue #21711: support for "site-python" directories has now been removed from the site module (it was deprecated in 3.4). -- Issue #17552: new socket.sendfile() method allowing to send a file over a +- Issue #17552: new socket.sendfile() method allowing a file to be sent over a socket by using high-performance os.sendfile() on UNIX. Patch by Giampaolo Rodola'. @@ -7462,7 +7462,7 @@ symlinks on POSIX platforms. - Issue #13773: sqlite3.connect() gets a new `uri` parameter to pass the - filename as a URI, allowing to pass custom options. + filename as a URI, allowing custom options to be passed. - Issue #16564: Fixed regression relative to Python2 in the operation of email.encoders.encode_noop when used with binary data. @@ -7723,7 +7723,7 @@ - Issue #7719: Make distutils ignore ``.nfs*`` files instead of choking later on. Initial patch by SilentGhost and Jeff Ramnani. -- Issue #13120: Allow to call pdb.set_trace() from thread. +- Issue #13120: Allow calling pdb.set_trace() from thread. Patch by Ilya Sandler. - Issue #16585: Make CJK encoders support error handlers that return bytes per diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -3402,7 +3402,7 @@ return NULL; } - /* XXX XXX This would allow to pass additional options. For COM + /* XXX XXX This would allow passing additional options. For COM method *implementations*, we would probably want different behaviour than in 'normal' callback functions: return a HRESULT if an exception occurs in the callback, and print the traceback not diff --git a/Modules/_ctypes/libffi/m4/libtool.m4 b/Modules/_ctypes/libffi/m4/libtool.m4 --- a/Modules/_ctypes/libffi/m4/libtool.m4 +++ b/Modules/_ctypes/libffi/m4/libtool.m4 @@ -1121,7 +1121,7 @@ # If we don't find anything, use the default library path according # to the aix ld manual. # Store the results from the different compilers for each TAGNAME. -# Allow to override them for all tags through lt_cv_aix_libpath. +# Allow overriding them for all tags through lt_cv_aix_libpath. m4_defun([_LT_SYS_MODULE_PATH_AIX], [m4_require([_LT_DECL_SED])dnl if test set = "${lt_cv_aix_libpath+set}"; then -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Feb 10 00:47:04 2016 From: python-checkins at python.org (martin.panter) Date: Wed, 10 Feb 2016 05:47:04 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2MzA0?= =?utf-8?q?=3A_Change_=22allows_to_=3Cverb=3E=22_to_=22allows_=3Cverb=3Ein?= =?utf-8?q?g=22_or_similar?= Message-ID: <20160210054701.6655.96021@psf.io> https://hg.python.org/cpython/rev/818e91105418 changeset: 100210:818e91105418 branch: 3.5 parent: 100203:1383a260b66d user: Martin Panter date: Wed Feb 10 05:44:01 2016 +0000 summary: Issue #26304: Change "allows to " to "allows ing" or similar The original form is incorrect grammar and feels awkward, even though the meaning is clear. files: Doc/c-api/arg.rst | 2 +- Doc/c-api/function.rst | 2 +- Doc/howto/pyporting.rst | 4 +- Doc/library/asyncio-eventloop.rst | 4 +- Doc/library/asyncio-task.rst | 2 +- Doc/library/ctypes.rst | 32 +++++++------- Doc/library/nis.rst | 6 +- Doc/library/signal.rst | 2 +- Doc/library/smtplib.rst | 4 +- Doc/library/tarfile.rst | 2 +- Doc/using/cmdline.rst | 2 +- Doc/whatsnew/3.3.rst | 6 +- Doc/whatsnew/3.5.rst | 14 +++--- Include/object.h | 2 +- Lib/asyncio/futures.py | 2 +- Lib/ctypes/__init__.py | 4 +- Lib/test/test_cmd_line_script.py | 2 +- Lib/test/test_doctest.py | 2 +- Lib/test/test_genericpath.py | 2 +- Lib/test/test_strptime.py | 2 +- Lib/tkinter/__init__.py | 4 +- Misc/HISTORY | 34 ++++++++-------- Misc/NEWS | 12 ++-- Modules/_ctypes/_ctypes.c | 2 +- Modules/_ctypes/libffi/m4/libtool.m4 | 2 +- 25 files changed, 76 insertions(+), 76 deletions(-) diff --git a/Doc/c-api/arg.rst b/Doc/c-api/arg.rst --- a/Doc/c-api/arg.rst +++ b/Doc/c-api/arg.rst @@ -30,7 +30,7 @@ Strings and buffers ------------------- -These formats allow to access an object as a contiguous chunk of memory. +These formats allow accessing an object as a contiguous chunk of memory. You don't have to provide raw storage for the returned unicode or bytes area. Also, you won't have to release any memory yourself, except with the ``es``, ``es#``, ``et`` and ``et#`` formats. diff --git a/Doc/c-api/function.rst b/Doc/c-api/function.rst --- a/Doc/c-api/function.rst +++ b/Doc/c-api/function.rst @@ -40,7 +40,7 @@ .. c:function:: PyObject* PyFunction_NewWithQualName(PyObject *code, PyObject *globals, PyObject *qualname) - As :c:func:`PyFunction_New`, but also allows to set the function object's + As :c:func:`PyFunction_New`, but also allows setting the function object's ``__qualname__`` attribute. *qualname* should be a unicode object or NULL; if NULL, the ``__qualname__`` attribute is set to the same value as its ``__name__`` attribute. diff --git a/Doc/howto/pyporting.rst b/Doc/howto/pyporting.rst --- a/Doc/howto/pyporting.rst +++ b/Doc/howto/pyporting.rst @@ -243,8 +243,8 @@ binary reading). Under Python 3, binary files and text files are clearly distinct and mutually incompatible; see the :mod:`io` module for details. Therefore, you **must** make a decision of whether a file will be used for -binary access (allowing to read and/or write binary data) or text access -(allowing to read and/or write text data). You should also use :func:`io.open` +binary access (allowing binary data to be read and/or written) or text access +(allowing text data to be read and/or written). You should also use :func:`io.open` for opening files instead of the built-in :func:`open` function as the :mod:`io` module is consistent from Python 2 to 3 while the built-in :func:`open` function is not (in Python 3 it's actually :func:`io.open`). diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst --- a/Doc/library/asyncio-eventloop.rst +++ b/Doc/library/asyncio-eventloop.rst @@ -253,7 +253,7 @@ a class. For example, if you want to use a pre-created protocol instance, you can pass ``lambda: my_protocol``. - Options allowing to change how the connection is created: + Options that change how the connection is created: * *ssl*: if given and not false, a SSL/TLS transport is created (by default a plain TCP transport is created). If *ssl* is @@ -654,7 +654,7 @@ Error Handling API ------------------ -Allows to customize how exceptions are handled in the event loop. +Allows customizing how exceptions are handled in the event loop. .. method:: BaseEventLoop.set_exception_handler(handler) diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst --- a/Doc/library/asyncio-task.rst +++ b/Doc/library/asyncio-task.rst @@ -510,7 +510,7 @@ .. note:: - In the functions below, the optional *loop* argument allows to explicitly set + In the functions below, the optional *loop* argument allows explicitly setting the event loop object used by the underlying task or coroutine. If it's not provided, the default event loop is used. diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst --- a/Doc/library/ctypes.rst +++ b/Doc/library/ctypes.rst @@ -942,7 +942,7 @@ Callback functions ^^^^^^^^^^^^^^^^^^ -:mod:`ctypes` allows to create C callable function pointers from Python callables. +:mod:`ctypes` allows creating C callable function pointers from Python callables. These are sometimes called *callback functions*. First, you must create a class for the callback function. The class knows the @@ -1350,7 +1350,7 @@ ignored. The *use_errno* parameter, when set to True, enables a ctypes mechanism that -allows to access the system :data:`errno` error number in a safe way. +allows accessing the system :data:`errno` error number in a safe way. :mod:`ctypes` maintains a thread-local copy of the systems :data:`errno` variable; if you call foreign functions created with ``use_errno=True`` then the :data:`errno` value before the function call is swapped with the ctypes private @@ -1421,7 +1421,7 @@ Class which loads shared libraries. *dlltype* should be one of the :class:`CDLL`, :class:`PyDLL`, :class:`WinDLL`, or :class:`OleDLL` types. - :meth:`__getattr__` has special behavior: It allows to load a shared library by + :meth:`__getattr__` has special behavior: It allows loading a shared library by accessing it as attribute of a library loader instance. The result is cached, so repeated attribute accesses return the same library each time. @@ -1498,7 +1498,7 @@ It is possible to assign a callable Python object that is not a ctypes type, in this case the function is assumed to return a C :c:type:`int`, and - the callable will be called with this integer, allowing to do further + the callable will be called with this integer, allowing further processing or error checking. Using this is deprecated, for more flexible post processing or error checking use a ctypes data type as :attr:`restype` and assign a callable to the :attr:`errcheck` attribute. @@ -1513,7 +1513,7 @@ When a foreign function is called, each actual argument is passed to the :meth:`from_param` class method of the items in the :attr:`argtypes` - tuple, this method allows to adapt the actual argument to an object that + tuple, this method allows adapting the actual argument to an object that the foreign function accepts. For example, a :class:`c_char_p` item in the :attr:`argtypes` tuple will convert a string passed as argument into a bytes object using ctypes conversion rules. @@ -1521,7 +1521,7 @@ New: It is now possible to put items in argtypes which are not ctypes types, but each item must have a :meth:`from_param` method which returns a value usable as argument (integer, string, ctypes instance). This allows - to define adapters that can adapt custom objects as function parameters. + defining adapters that can adapt custom objects as function parameters. .. attribute:: errcheck @@ -1535,12 +1535,12 @@ *result* is what the foreign function returns, as specified by the :attr:`restype` attribute. - *func* is the foreign function object itself, this allows to reuse the + *func* is the foreign function object itself, this allows reusing the same callable object to check or post process the results of several functions. *arguments* is a tuple containing the parameters originally passed to - the function call, this allows to specialize the behavior on the + the function call, this allows specializing the behavior on the arguments used. The object that this function returns will be returned from the @@ -1785,7 +1785,7 @@ If a bytes object is specified as first argument, the buffer is made one item larger than its length so that the last element in the array is a NUL termination character. An integer can be passed as second argument which allows - to specify the size of the array if the length of the bytes should not be used. + specifying the size of the array if the length of the bytes should not be used. @@ -1800,21 +1800,21 @@ If a string is specified as first argument, the buffer is made one item larger than the length of the string so that the last element in the array is a NUL termination character. An integer can be passed as second argument which - allows to specify the size of the array if the length of the string should not + allows specifying the size of the array if the length of the string should not be used. .. function:: DllCanUnloadNow() - Windows only: This function is a hook which allows to implement in-process + Windows only: This function is a hook which allows implementing in-process COM servers with ctypes. It is called from the DllCanUnloadNow function that the _ctypes extension dll exports. .. function:: DllGetClassObject() - Windows only: This function is a hook which allows to implement in-process + Windows only: This function is a hook which allows implementing in-process COM servers with ctypes. It is called from the DllGetClassObject function that the ``_ctypes`` extension dll exports. @@ -2321,7 +2321,7 @@ checked, only one field can be accessed when names are repeated. It is possible to define the :attr:`_fields_` class variable *after* the - class statement that defines the Structure subclass, this allows to create + class statement that defines the Structure subclass, this allows creating data types that directly or indirectly reference themselves:: class List(Structure): @@ -2342,7 +2342,7 @@ .. attribute:: _pack_ - An optional small integer that allows to override the alignment of + An optional small integer that allows overriding the alignment of structure fields in the instance. :attr:`_pack_` must already be defined when :attr:`_fields_` is assigned, otherwise it will have no effect. @@ -2354,8 +2354,8 @@ assigned, otherwise it will have no effect. The fields listed in this variable must be structure or union type fields. - :mod:`ctypes` will create descriptors in the structure type that allows to - access the nested fields directly, without the need to create the + :mod:`ctypes` will create descriptors in the structure type that allows + accessing the nested fields directly, without the need to create the structure or union field. Here is an example type (Windows):: diff --git a/Doc/library/nis.rst b/Doc/library/nis.rst --- a/Doc/library/nis.rst +++ b/Doc/library/nis.rst @@ -26,7 +26,7 @@ Note that *mapname* is first checked if it is an alias to another name. - The *domain* argument allows to override the NIS domain used for the lookup. If + The *domain* argument allows overriding the NIS domain used for the lookup. If unspecified, lookup is in the default NIS domain. @@ -38,7 +38,7 @@ Note that *mapname* is first checked if it is an alias to another name. - The *domain* argument allows to override the NIS domain used for the lookup. If + The *domain* argument allows overriding the NIS domain used for the lookup. If unspecified, lookup is in the default NIS domain. @@ -46,7 +46,7 @@ Return a list of all valid maps. - The *domain* argument allows to override the NIS domain used for the lookup. If + The *domain* argument allows overriding the NIS domain used for the lookup. If unspecified, lookup is in the default NIS domain. diff --git a/Doc/library/signal.rst b/Doc/library/signal.rst --- a/Doc/library/signal.rst +++ b/Doc/library/signal.rst @@ -11,7 +11,7 @@ General rules ------------- -The :func:`signal.signal` function allows to define custom handlers to be +The :func:`signal.signal` function allows defining custom handlers to be executed when a signal is received. A small number of default handlers are installed: :const:`SIGPIPE` is ignored (so write errors on pipes and sockets can be reported as ordinary Python exceptions) and :const:`SIGINT` is diff --git a/Doc/library/smtplib.rst b/Doc/library/smtplib.rst --- a/Doc/library/smtplib.rst +++ b/Doc/library/smtplib.rst @@ -33,7 +33,7 @@ *timeout* parameter specifies a timeout in seconds for blocking operations like the connection attempt (if not specified, the global default timeout setting will be used). If the timeout expires, :exc:`socket.timeout` is - raised. The optional source_address parameter allows to bind + raised. The optional source_address parameter allows binding to some specific source address in a machine with multiple network interfaces, and/or to some specific source TCP port. It takes a 2-tuple (host, port), for the socket to bind to as its source address before @@ -76,7 +76,7 @@ *port* is zero, the standard SMTP-over-SSL port (465) is used. The optional arguments *local_hostname*, *timeout* and *source_address* have the same meaning as they do in the :class:`SMTP` class. *context*, also optional, - can contain a :class:`~ssl.SSLContext` and allows to configure various + can contain a :class:`~ssl.SSLContext` and allows configuring various aspects of the secure connection. Please read :ref:`ssl-security` for best practices. diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst --- a/Doc/library/tarfile.rst +++ b/Doc/library/tarfile.rst @@ -111,7 +111,7 @@ specifies the blocksize and defaults to ``20 * 512`` bytes. Use this variant in combination with e.g. ``sys.stdin``, a socket :term:`file object` or a tape device. However, such a :class:`TarFile` object is limited in that it does - not allow to be accessed randomly, see :ref:`tar-examples`. The currently + not allow random access, see :ref:`tar-examples`. The currently possible modes: +-------------+--------------------------------------------+ diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst --- a/Doc/using/cmdline.rst +++ b/Doc/using/cmdline.rst @@ -398,7 +398,7 @@ tracing with a traceback limit of *NFRAME* frames. See the :func:`tracemalloc.start` for more information. - It also allows to pass arbitrary values and retrieve them through the + It also allows passing arbitrary values and retrieving them through the :data:`sys._xoptions` dictionary. .. versionchanged:: 3.2 diff --git a/Doc/whatsnew/3.3.rst b/Doc/whatsnew/3.3.rst --- a/Doc/whatsnew/3.3.rst +++ b/Doc/whatsnew/3.3.rst @@ -1528,7 +1528,7 @@ multiprocessing --------------- -The new :func:`multiprocessing.connection.wait` function allows to poll +The new :func:`multiprocessing.connection.wait` function allows polling multiple objects (such as connections, sockets and pipes) with a timeout. (Contributed by Richard Oudkerk in :issue:`12328`.) @@ -1715,8 +1715,8 @@ ------ :class:`pickle.Pickler` objects now have an optional -:attr:`~pickle.Pickler.dispatch_table` attribute allowing to set per-pickler -reduction functions. +:attr:`~pickle.Pickler.dispatch_table` attribute allowing per-pickler +reduction functions to be set. (Contributed by Richard Oudkerk in :issue:`14166`.) diff --git a/Doc/whatsnew/3.5.rst b/Doc/whatsnew/3.5.rst --- a/Doc/whatsnew/3.5.rst +++ b/Doc/whatsnew/3.5.rst @@ -748,7 +748,7 @@ argparse -------- -The :class:`~argparse.ArgumentParser` class now allows to disable +The :class:`~argparse.ArgumentParser` class now allows disabling :ref:`abbreviated usage ` of long options by setting :ref:`allow_abbrev` to ``False``. (Contributed by Jonathan Paugh, Steven Bethard, paul j3 and Daniel Eriksson in :issue:`14910`.) @@ -913,12 +913,12 @@ compileall ---------- -A new :mod:`compileall` option, :samp:`-j {N}`, allows to run *N* workers +A new :mod:`compileall` option, :samp:`-j {N}`, allows running *N* workers simultaneously to perform parallel bytecode compilation. The :func:`~compileall.compile_dir` function has a corresponding ``workers`` parameter. (Contributed by Claudiu Popa in :issue:`16104`.) -Another new option, ``-r``, allows to control the maximum recursion +Another new option, ``-r``, allows controlling the maximum recursion level for subdirectories. (Contributed by Claudiu Popa in :issue:`19628`.) The ``-q`` command line option can now be specified more than once, in @@ -1453,8 +1453,8 @@ use ``/dev/urandom`` and avoiding failures due to potential file descriptor exhaustion. (Contributed by Victor Stinner in :issue:`22181`.) -New :func:`~os.get_blocking` and :func:`~os.set_blocking` functions allow to -get and set a file descriptor's blocking mode (:data:`~os.O_NONBLOCK`.) +New :func:`~os.get_blocking` and :func:`~os.set_blocking` functions allow +getting and setting a file descriptor's blocking mode (:data:`~os.O_NONBLOCK`.) (Contributed by Victor Stinner in :issue:`22054`.) The :func:`~os.truncate` and :func:`~os.ftruncate` functions are now supported @@ -1681,8 +1681,8 @@ Functions with timeouts now use a monotonic clock, instead of a system clock. (Contributed by Victor Stinner in :issue:`22043`.) -A new :meth:`socket.sendfile() ` method allows to -send a file over a socket by using the high-performance :func:`os.sendfile` +A new :meth:`socket.sendfile() ` method allows +sending a file over a socket by using the high-performance :func:`os.sendfile` function on UNIX, resulting in uploads being from 2 to 3 times faster than when using plain :meth:`socket.send() `. (Contributed by Giampaolo Rodola' in :issue:`17552`.) diff --git a/Include/object.h b/Include/object.h --- a/Include/object.h +++ b/Include/object.h @@ -134,7 +134,7 @@ usage, the string "foo" is interned, and the structures are linked. On interpreter shutdown, all strings are released (through _PyUnicode_ClearStaticStrings). - Alternatively, _Py_static_string allows to choose the variable name. + Alternatively, _Py_static_string allows choosing the variable name. _PyUnicode_FromId returns a borrowed reference to the interned string. _PyObject_{Get,Set,Has}AttrId are __getattr__ versions using _Py_Identifier*. */ diff --git a/Lib/asyncio/futures.py b/Lib/asyncio/futures.py --- a/Lib/asyncio/futures.py +++ b/Lib/asyncio/futures.py @@ -142,7 +142,7 @@ def __init__(self, *, loop=None): """Initialize the future. - The optional event_loop argument allows to explicitly set the event + The optional event_loop argument allows explicitly setting the event loop object used by the future. If it's not provided, the future uses the default event loop. """ diff --git a/Lib/ctypes/__init__.py b/Lib/ctypes/__init__.py --- a/Lib/ctypes/__init__.py +++ b/Lib/ctypes/__init__.py @@ -368,8 +368,8 @@ return func class PyDLL(CDLL): - """This class represents the Python library itself. It allows to - access Python API functions. The GIL is not released, and + """This class represents the Python library itself. It allows + accessing Python API functions. The GIL is not released, and Python exceptions are handled correctly. """ _func_flags_ = _FUNCFLAG_CDECL | _FUNCFLAG_PYTHONAPI diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py --- a/Lib/test/test_cmd_line_script.py +++ b/Lib/test/test_cmd_line_script.py @@ -499,7 +499,7 @@ def test_non_ascii(self): # Mac OS X denies the creation of a file with an invalid UTF-8 name. - # Windows allows to create a name with an arbitrary bytes name, but + # Windows allows creating a name with an arbitrary bytes name, but # Python cannot a undecodable bytes argument to a subprocess. if (support.TESTFN_UNDECODABLE and sys.platform not in ('win32', 'darwin')): diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py --- a/Lib/test/test_doctest.py +++ b/Lib/test/test_doctest.py @@ -2775,7 +2775,7 @@ with two tests, both of the files having "errors" in the tests that can be made non-errors by applying the appropriate doctest options to the run (ELLIPSIS in the first file, NORMALIZE_WHITESPACE in the second). This combination will -allow to thoroughly test the -f and -o flags, as well as the doctest command's +allow thoroughly testing the -f and -o flags, as well as the doctest command's ability to process more than one file on the command line and, since the second file ends in '.py', its handling of python module files (as opposed to straight text files). diff --git a/Lib/test/test_genericpath.py b/Lib/test/test_genericpath.py --- a/Lib/test/test_genericpath.py +++ b/Lib/test/test_genericpath.py @@ -419,7 +419,7 @@ def test_nonascii_abspath(self): if (support.TESTFN_UNDECODABLE # Mac OS X denies the creation of a directory with an invalid - # UTF-8 name. Windows allows to create a directory with an + # UTF-8 name. Windows allows creating a directory with an # arbitrary bytes name, but fails to enter this directory # (when the bytes name is used). and sys.platform not in ('win32', 'darwin')): diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py --- a/Lib/test/test_strptime.py +++ b/Lib/test/test_strptime.py @@ -190,7 +190,7 @@ def test_whitespace_substitution(self): # When pattern contains whitespace, make sure it is taken into account - # so as to not allow to subpatterns to end up next to each other and + # so as to not allow subpatterns to end up next to each other and # "steal" characters from each other. pattern = self.time_re.pattern('%j %H') self.assertFalse(re.match(pattern, "180")) diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -2500,7 +2500,7 @@ self.tk.call(self._w, 'toggle') class Entry(Widget, XView): - """Entry widget which allows to display simple text.""" + """Entry widget which allows displaying simple text.""" def __init__(self, master=None, cnf={}, **kw): """Construct an entry widget with the parent MASTER. @@ -2696,7 +2696,7 @@ itemconfig = itemconfigure class Menu(Widget): - """Menu widget which allows to display menu bars, pull-down menus and pop-up menus.""" + """Menu widget which allows displaying menu bars, pull-down menus and pop-up menus.""" def __init__(self, master=None, cnf={}, **kw): """Construct menu widget with the parent MASTER. diff --git a/Misc/HISTORY b/Misc/HISTORY --- a/Misc/HISTORY +++ b/Misc/HISTORY @@ -1095,7 +1095,7 @@ functions to support PEP 3115 compliant dynamic class creation. Patch by Daniel Urban and Nick Coghlan. -- Issue #13152: Allow to specify a custom tabsize for expanding tabs in +- Issue #13152: Allow specifying a custom tabsize for expanding tabs in textwrap. Patch by John Feuerstein. - Issue #14721: Send the correct 'Content-length: 0' header when the body is an @@ -2234,7 +2234,7 @@ fixed. - Issue #14166: Pickler objects now have an optional ``dispatch_table`` - attribute which allows to set custom per-pickler reduction functions. + attribute which allows setting custom per-pickler reduction functions. Patch by sbt. - Issue #14177: marshal.loads() now raises TypeError when given an unicode @@ -3185,7 +3185,7 @@ binary mode, but ensure that the shebang is decodable from UTF-8 and from the encoding of the script. -- Issue #8498: In socket.accept(), allow to specify 0 as a backlog value in +- Issue #8498: In socket.accept(), allow specifying 0 as a backlog value in order to accept exactly one connection. Patch by Daniel Evers. - Issue #12011: signal.signal() and signal.siginterrupt() raise an OSError, @@ -3885,7 +3885,7 @@ - Issue #12331: The test suite for lib2to3 can now run from an installed Python. -- Issue #12626: In regrtest, allow to filter tests using a glob filter +- Issue #12626: In regrtest, allow filtering tests using a glob filter with the ``-m`` (or ``--match``) option. This works with all test cases using the unittest module. This is useful with long test suites such as test_io or test_subprocess. @@ -4221,7 +4221,7 @@ Core and Builtins ----------------- -- Issue #10451: memoryview objects could allow to mutate a readable buffer. +- Issue #10451: memoryview objects could allow mutating a readable buffer. Initial patch by Ross Lagerwall. Library @@ -4765,7 +4765,7 @@ - Add the "display" and "undisplay" pdb commands. -- Issue #7245: Add a SIGINT handler in pdb that allows to break a program again +- Issue #7245: Add a SIGINT handler in pdb that allows breaking a program again after a "continue" command. - Add the "interact" pdb command. @@ -6916,7 +6916,7 @@ correct encoding. - Issue #4870: Add an `options` attribute to SSL contexts, as well as several - ``OP_*`` constants to the `ssl` module. This allows to selectively disable + ``OP_*`` constants to the `ssl` module. This allows selectively disabling protocol versions, when used in combination with `PROTOCOL_SSLv23`. - Issue #8759: Fixed user paths in sysconfig for posix and os2 schemes. @@ -9497,8 +9497,8 @@ - Issue #4051: Prevent conflict of UNICODE macros in cPickle. -- Issue #4738: Each zlib object now has a separate lock, allowing to compress - or decompress several streams at once on multi-CPU systems. Also, the GIL +- Issue #4738: Each zlib object now has a separate lock, allowing several streams + to be compressed or decompressed at once on multi-CPU systems. Also, the GIL is now released when computing the CRC of a large buffer. Patch by ebfe. - Issue #4228: Pack negative values the same way as 2.4 in struct's L format. @@ -9996,7 +9996,7 @@ as bytes string, please use PyUnicode_AsUTF8String() instead. - Issue #3460: PyUnicode_Join() implementation is 10% to 80% faster thanks - to Python 3.0's stricter semantics which allow to avoid successive + to Python 3.0's stricter semantics which allow avoiding successive reallocations of the result string (this also affects str.join()). @@ -12762,7 +12762,7 @@ - Patch #1110248: SYNC_FLUSH the zlib buffer for GZipFile.flush. -- Patch #1107973: Allow to iterate over the lines of a tarfile.ExFileObject. +- Patch #1107973: Allow iterating over the lines of a tarfile.ExFileObject. - Patch #1104111: Alter setup.py --help and --help-commands. @@ -13739,7 +13739,7 @@ same as when the argument is omitted). [SF bug 658254, patch 663482] -- nntplib does now allow to ignore a .netrc file. +- nntplib does now allow ignoring a .netrc file. - urllib2 now recognizes Basic authentication even if other authentication schemes are offered. @@ -14157,7 +14157,7 @@ - fcntl.ioctl now warns if the mutate flag is not specified. -- nt now properly allows to refer to UNC roots, e.g. in nt.stat(). +- nt now properly allows referring to UNC roots, e.g. in nt.stat(). - the weakref module now supports additional objects: array.array, sre.pattern_objects, file objects, and sockets. @@ -16715,7 +16715,7 @@ - New functions PyErr_SetExcFromWindowsErr() and PyErr_SetExcFromWindowsErrWithFilename(). Similar to PyErr_SetFromWindowsErrWithFilename() and - PyErr_SetFromWindowsErr(), but they allow to specify + PyErr_SetFromWindowsErr(), but they allow specifying the exception type to raise. Available on Windows. - Py_FatalError() is now declared as taking a const char* argument. It @@ -17590,8 +17590,8 @@ - property() now takes 4 keyword arguments: fget, fset, fdel and doc. These map to read-only attributes 'fget', 'fset', 'fdel', and '__doc__' in the constructed property object. fget, fset and fdel weren't - discoverable from Python in 2.2a3. __doc__ is new, and allows to - associate a docstring with a property. + discoverable from Python in 2.2a3. __doc__ is new, and allows + associating a docstring with a property. - Comparison overloading is now more completely implemented. For example, a str subclass instance can properly be compared to a str @@ -18006,7 +18006,7 @@ ----- - regrtest.py now knows which tests are expected to be skipped on some - platforms, allowing to give clearer test result output. regrtest + platforms, allowing clearer test result output to be given. regrtest also has optional --use/-u switch to run normally disabled tests which require network access or consume significant disk resources. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -1729,8 +1729,8 @@ and ASCII letter now raise a deprecation warning and will be forbidden in Python 3.6. -- Issue #23671: string.Template now allows to specify the "self" parameter as - keyword argument. string.Formatter now allows to specify the "self" and +- Issue #23671: string.Template now allows specifying the "self" parameter as + a keyword argument. string.Formatter now allows specifying the "self" and the "format_string" parameters as keyword arguments. - Issue #23502: The pprint module now supports mapping proxies. @@ -2859,7 +2859,7 @@ - Issue #22085: Dropped support of Tk 8.3 in Tkinter. - Issue #21580: Now Tkinter correctly handles bytes arguments passed to Tk. - In particular this allows to initialize images from binary data. + In particular this allows initializing images from binary data. - Issue #22003: When initialized from a bytes object, io.BytesIO() now defers making a copy until it is mutated, improving performance and @@ -3004,7 +3004,7 @@ - Issue #21711: support for "site-python" directories has now been removed from the site module (it was deprecated in 3.4). -- Issue #17552: new socket.sendfile() method allowing to send a file over a +- Issue #17552: new socket.sendfile() method allowing a file to be sent over a socket by using high-performance os.sendfile() on UNIX. Patch by Giampaolo Rodola'. @@ -6967,7 +6967,7 @@ symlinks on POSIX platforms. - Issue #13773: sqlite3.connect() gets a new `uri` parameter to pass the - filename as a URI, allowing to pass custom options. + filename as a URI, allowing custom options to be passed. - Issue #16564: Fixed regression relative to Python2 in the operation of email.encoders.encode_noop when used with binary data. @@ -7228,7 +7228,7 @@ - Issue #7719: Make distutils ignore ``.nfs*`` files instead of choking later on. Initial patch by SilentGhost and Jeff Ramnani. -- Issue #13120: Allow to call pdb.set_trace() from thread. +- Issue #13120: Allow calling pdb.set_trace() from thread. Patch by Ilya Sandler. - Issue #16585: Make CJK encoders support error handlers that return bytes per diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -3402,7 +3402,7 @@ return NULL; } - /* XXX XXX This would allow to pass additional options. For COM + /* XXX XXX This would allow passing additional options. For COM method *implementations*, we would probably want different behaviour than in 'normal' callback functions: return a HRESULT if an exception occurs in the callback, and print the traceback not diff --git a/Modules/_ctypes/libffi/m4/libtool.m4 b/Modules/_ctypes/libffi/m4/libtool.m4 --- a/Modules/_ctypes/libffi/m4/libtool.m4 +++ b/Modules/_ctypes/libffi/m4/libtool.m4 @@ -1121,7 +1121,7 @@ # If we don't find anything, use the default library path according # to the aix ld manual. # Store the results from the different compilers for each TAGNAME. -# Allow to override them for all tags through lt_cv_aix_libpath. +# Allow overriding them for all tags through lt_cv_aix_libpath. m4_defun([_LT_SYS_MODULE_PATH_AIX], [m4_require([_LT_DECL_SED])dnl if test set = "${lt_cv_aix_libpath+set}"; then -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Feb 10 00:55:12 2016 From: python-checkins at python.org (chris.angelico) Date: Wed, 10 Feb 2016 05:55:12 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Apply_Nathaniel=27s_changes_t?= =?utf-8?q?o_PEP_513?= Message-ID: <20160210055455.6679.31241@psf.io> https://hg.python.org/peps/rev/161a5afedcdc changeset: 6221:161a5afedcdc user: Chris Angelico date: Wed Feb 10 16:54:46 2016 +1100 summary: Apply Nathaniel's changes to PEP 513 files: pep-0513.txt | 118 +++++++++++++++++++++++++++++++------- 1 files changed, 94 insertions(+), 24 deletions(-) diff --git a/pep-0513.txt b/pep-0513.txt --- a/pep-0513.txt +++ b/pep-0513.txt @@ -126,8 +126,7 @@ To be eligible for the ``manylinux1`` platform tag, a Python wheel must therefore both (a) contain binary executables and compiled code that links -*only* to libraries (other than the appropriate ``libpython`` library, which is -always a permitted dependency consistent with the PEP 425 ABI tag) with SONAMEs +*only* to libraries with SONAMEs included in the following list: :: libpanelw.so.5 @@ -153,11 +152,7 @@ libglib-2.0.so.0 and, (b) work on a stock CentOS 5.11 [6]_ system that contains the system -package manager's provided versions of these libraries. In addition, -for wheels targeting CPython 3.2 and earlier (including all 2.x -versions), there is an extra requirement that (c) the wheel be -built against a version of CPython compiled with 4-byte unicode -support (i.e. one where ``sys.maxunicode > 0xFFFF``). +package manager's provided versions of these libraries. Because CentOS 5 is only available for x86_64 and i686 architectures, these are the only architectures currently supported by the ``manylinux1`` @@ -216,6 +211,81 @@ problematic or add libraries that have turned out to be safe. +libpythonX.Y.so.1 +----------------- + +Note that ``libpythonX.Y.so.1`` is *not* on the list of libraries that +a ``manylinux1`` extension is allowed to link to. Explicitly linking +to ``libpythonX.Y.so.1`` is unnecessary in almost all cases: the way +ELF linking works, extension modules that are loaded into the +interpreter automatically get access to all of the interpreter's +symbols, regardless of whether or not the extension itself is +explicitly linked against libpython. Furthermore, explicit linking to +libpython creates problems in the common configuration where Python is +not built with ``--enable-shared``. In particular, on Debian and +Ubuntu systems, ``apt install pythonX.Y`` does not even install +``libpythonX.Y.so.1``, meaning that any wheel that *did* depend on +``libpythonX.Y.so.1`` could fail to import. + +There is one situation where extensions that are linked in this way +can fail to work: if a host program (e.g., ``apache2``) uses +``dlopen()`` to load a module (e.g., ``mod_wsgi``) that embeds the +CPython interpreter, and the host program does *not* pass the +``RTLD_GLOBAL`` flag to ``dlopen()``, then the embedded CPython will +be unable to load any extension modules that do not themselves link +explicitly to ``libpythonX.Y.so.1``. Fortunately, ``apache2`` *does* +set the ``RTLD_GLOBAL`` flag, as do all the other programs that +embed-CPython-via-a-dlopened-plugin that we could locate, so this does +not seem to be a serious problem in practice. The incompatibility with +Debian/Ubuntu is more of an issue than the theoretical incompatibility +with a rather obscure corner case. + +This is a rather complex and subtle issue that extends beyond +the scope of ``manylinux1``; for more discussion see: [9]_, [10]_, +[11]_. + +UCS-2 vs UCS-4 builds +--------------------- + +All versions of CPython 2.x, plus CPython 3.0-3.2 inclusive, can be +built in two ABI-incompatible modes: builds using the +``--enable-unicode=ucs2`` configure flag store Unicode data in UCS-2 +(or really UTF-16) format, while builds using the +``--enable-unicode=ucs4`` configure flag store Unicode data in +UCS-4. (CPython 3.3 and greater use a different storage method that +always supports UCS-4.) If we want to make sure ``ucs2`` wheels don't +get installed into ``ucs4`` CPythons and vice-versa, then something +must be done. + +An earlier version of this PEP included a requirement that +``manylinux1`` wheels targeting these older CPython versions should +always use the ``ucs4`` ABI. But then, in between the PEP's initial +acceptance and its implementation, ``pip`` and ``wheel`` gained +first-class support for tracking and checking this aspect of ABI +compatibility for the relevant CPython versions, which is a better +solution. So we now allow the ``manylinux1`` platform tags to be used +in combination with any ABI tag. However, to maintain compatibility it +is crucial to ensure that all ``manylinux1`` wheels include a +non-trivial abi tag. For example, a wheel built against a ``ucs4`` +CPython might have a name like:: + + PKG-VERSION-cp27-cp27mu-manylinux1_x86_64.whl + ^^^^^^ Good! + +While a wheel built against the ``ucs2`` ABI might have a name like:: + + PKG-VERSION-cp27-cp27m-manylinux1_x86_64.whl + ^^^^^ Okay! + +But you should never have a wheel with a name like:: + + PKG-VERSION-cp27-none-manylinux1_x86_64.whl + ^^^^ BAD! Don't do this! + +We note for information that the ``ucs4`` ABI appears to be much more +widespread among Linux CPython distributors. + + Compilation of Compliant Wheels =============================== @@ -237,7 +307,7 @@ The first tool is a Docker image based on CentOS 5.11, which is recommended as an easy to use self-contained build box for compiling ``manylinux1`` wheels -[9]_. Compiling on a more recently-released linux distribution will generally +[12]_. Compiling on a more recently-released linux distribution will generally introduce dependencies on too-new versioned symbols. The image comes with a full compiler suite installed (``gcc``, ``g++``, and ``gfortran`` 4.8.2) as well as the latest releases of Python and ``pip``. @@ -245,7 +315,7 @@ Auditwheel ---------- -The second tool is a command line executable called ``auditwheel`` [10]_ that +The second tool is a command line executable called ``auditwheel`` [13]_ that may aid in package maintainers in dealing with third-party external dependencies. @@ -285,7 +355,7 @@ dependencies within ``manylinux1`` wheels, we recognize that the ``manylinux1`` policy encourages bundling external dependencies, a practice which runs counter to the package management policies of many linux -distributions' system package managers [11]_, [12]_. The primary purpose of +distributions' system package managers [14]_, [15]_. The primary purpose of this is cross-distro compatibility. Furthermore, ``manylinux1`` wheels on PyPI occupy a different niche than the Python packages available through the system package manager. @@ -352,8 +422,6 @@ We know of four main sources of potential incompatibility that are likely to arise in practice: -* "Narrow" unicode builds of Python 3.2 and earlier (including all - versions of Python 2) * Eventually, in the future, there may exist distributions that break compatibility with this profile (e.g., if one of the libraries in the profile changes its ABI in a backwards-incompatible way) @@ -361,8 +429,7 @@ * A linux distribution that does not use ``glibc`` (e.g. Alpine Linux, which is based on musl ``libc``, or Android) -Checking for unicode configuration compatibility is straightforward, -but the other cases are more subtle. We propose a two-pronged +To address these we propose a two-pronged approach. To handle potential future incompatibilities, we standardize a mechanism for a Python distributor to signal that a particular Python install definitely is or is not compatible with ``manylinux1``: @@ -389,11 +456,6 @@ if get_platform() not in ["linux-x86_64", "linux-i686"]: return False - # "wide" Unicode mode is mandatory (always true on CPython 3.3+) - import sys - if sys.maxunicode <= 0xFFFF: - return False - # Check for presence of _manylinux module try: import _manylinux @@ -522,13 +584,21 @@ (https://groups.google.com/forum/#!topic/manylinux-discuss/-4l3rrjfr9U) .. [8] distutils-sig discussion (https://mail.python.org/pipermail/distutils-sig/2016-January/027997.html) -.. [9] manylinux1 docker image - (https://quay.io/repository/manylinux/manylinux) -.. [10] auditwheel tool +.. [9] distutils-sig discussion + (https://mail.python.org/pipermail/distutils-sig/2016-February/028275.html) +.. [10] github issue discussion + (https://github.com/pypa/manylinux/issues/30) +.. [11] python bug tracker discussion + (https://bugs.python.org/issue21536) +.. [12] manylinux1 docker images + (Source: https://github.com/pypa/manylinux; + x86-64: https://quay.io/repository/pypa/manylinux1_x86_64; + x86-32: https://quay.io/repository/pypa/manylinux1_i686) +.. [13] auditwheel tool (https://pypi.python.org/pypi/auditwheel) -.. [11] Fedora Bundled Software Policy +.. [14] Fedora Bundled Software Policy (https://fedoraproject.org/wiki/Bundled_Software_policy) -.. [12] Debian Policy Manual -- 4.13: Convenience copies of code +.. [15] Debian Policy Manual -- 4.13: Convenience copies of code (https://www.debian.org/doc/debian-policy/ch-source.html#s-embeddedfiles) -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Wed Feb 10 01:32:02 2016 From: python-checkins at python.org (martin.panter) Date: Wed, 10 Feb 2016 06:32:02 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI2MzA0?= =?utf-8?q?=3A_Change_=22allows_to_=3Cverb=3E=22_to_=22allows_=3Cverb=3Ein?= =?utf-8?q?g=22_or_similar?= Message-ID: <20160210063123.6671.81539@psf.io> https://hg.python.org/cpython/rev/4cfc19f667aa changeset: 100213:4cfc19f667aa branch: 2.7 parent: 100205:8c7a8c7a02b9 user: Martin Panter date: Wed Feb 10 05:44:01 2016 +0000 summary: Issue #26304: Change "allows to " to "allows ing" or similar The original form is incorrect grammar and feels awkward, even though the meaning is clear. files: Doc/c-api/arg.rst | 2 +- Doc/howto/pyporting.rst | 4 +- Doc/library/ctypes.rst | 32 ++++++++-------- Doc/library/nis.rst | 6 +- Doc/library/tarfile.rst | 2 +- Lib/ctypes/__init__.py | 4 +- Lib/lib-tk/Tkinter.py | 4 +- Lib/test/test_strptime.py | 2 +- Misc/HISTORY | 14 +++--- Misc/NEWS | 4 +- Modules/_ctypes/_ctypes.c | 2 +- Modules/_ctypes/libffi/m4/libtool.m4 | 2 +- 12 files changed, 39 insertions(+), 39 deletions(-) diff --git a/Doc/c-api/arg.rst b/Doc/c-api/arg.rst --- a/Doc/c-api/arg.rst +++ b/Doc/c-api/arg.rst @@ -24,7 +24,7 @@ that matches the format unit; and the entry in [square] brackets is the type of the C variable(s) whose address should be passed. -These formats allow to access an object as a contiguous chunk of memory. +These formats allow accessing an object as a contiguous chunk of memory. You don't have to provide raw storage for the returned unicode or bytes area. Also, you won't have to release any memory yourself, except with the ``es``, ``es#``, ``et`` and ``et#`` formats. diff --git a/Doc/howto/pyporting.rst b/Doc/howto/pyporting.rst --- a/Doc/howto/pyporting.rst +++ b/Doc/howto/pyporting.rst @@ -243,8 +243,8 @@ binary reading). Under Python 3, binary files and text files are clearly distinct and mutually incompatible; see the :mod:`io` module for details. Therefore, you **must** make a decision of whether a file will be used for -binary access (allowing to read and/or write binary data) or text access -(allowing to read and/or write text data). You should also use :func:`io.open` +binary access (allowing binary data to be read and/or written) or text access +(allowing text data to be read and/or written). You should also use :func:`io.open` for opening files instead of the built-in :func:`open` function as the :mod:`io` module is consistent from Python 2 to 3 while the built-in :func:`open` function is not (in Python 3 it's actually :func:`io.open`). diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst --- a/Doc/library/ctypes.rst +++ b/Doc/library/ctypes.rst @@ -934,7 +934,7 @@ Callback functions ^^^^^^^^^^^^^^^^^^ -:mod:`ctypes` allows to create C callable function pointers from Python callables. +:mod:`ctypes` allows creating C callable function pointers from Python callables. These are sometimes called *callback functions*. First, you must create a class for the callback function, the class knows the @@ -1404,7 +1404,7 @@ ignored. The *use_errno* parameter, when set to True, enables a ctypes mechanism that -allows to access the system :data:`errno` error number in a safe way. +allows accessing the system :data:`errno` error number in a safe way. :mod:`ctypes` maintains a thread-local copy of the systems :data:`errno` variable; if you call foreign functions created with ``use_errno=True`` then the :data:`errno` value before the function call is swapped with the ctypes private @@ -1478,7 +1478,7 @@ Class which loads shared libraries. *dlltype* should be one of the :class:`CDLL`, :class:`PyDLL`, :class:`WinDLL`, or :class:`OleDLL` types. - :meth:`__getattr__` has special behavior: It allows to load a shared library by + :meth:`__getattr__` has special behavior: It allows loading a shared library by accessing it as attribute of a library loader instance. The result is cached, so repeated attribute accesses return the same library each time. @@ -1557,7 +1557,7 @@ It is possible to assign a callable Python object that is not a ctypes type, in this case the function is assumed to return a C :c:type:`int`, and - the callable will be called with this integer, allowing to do further + the callable will be called with this integer, allowing further processing or error checking. Using this is deprecated, for more flexible post processing or error checking use a ctypes data type as :attr:`restype` and assign a callable to the :attr:`errcheck` attribute. @@ -1573,7 +1573,7 @@ When a foreign function is called, each actual argument is passed to the :meth:`from_param` class method of the items in the :attr:`argtypes` - tuple, this method allows to adapt the actual argument to an object that + tuple, this method allows adapting the actual argument to an object that the foreign function accepts. For example, a :class:`c_char_p` item in the :attr:`argtypes` tuple will convert a unicode string passed as argument into an byte string using ctypes conversion rules. @@ -1581,7 +1581,7 @@ New: It is now possible to put items in argtypes which are not ctypes types, but each item must have a :meth:`from_param` method which returns a value usable as argument (integer, string, ctypes instance). This allows - to define adapters that can adapt custom objects as function parameters. + defining adapters that can adapt custom objects as function parameters. .. attribute:: errcheck @@ -1595,12 +1595,12 @@ *result* is what the foreign function returns, as specified by the :attr:`restype` attribute. - *func* is the foreign function object itself, this allows to reuse the + *func* is the foreign function object itself, this allows reusing the same callable object to check or post process the results of several functions. *arguments* is a tuple containing the parameters originally passed to - the function call, this allows to specialize the behavior on the + the function call, this allows specializing the behavior on the arguments used. The object that this function returns will be returned from the @@ -1853,7 +1853,7 @@ If a string is specified as first argument, the buffer is made one item larger than the length of the string so that the last element in the array is a NUL termination character. An integer can be passed as second argument which allows - to specify the size of the array if the length of the string should not be used. + specifying the size of the array if the length of the string should not be used. If the first parameter is a unicode string, it is converted into an 8-bit string according to ctypes conversion rules. @@ -1870,7 +1870,7 @@ If a unicode string is specified as first argument, the buffer is made one item larger than the length of the string so that the last element in the array is a NUL termination character. An integer can be passed as second argument which - allows to specify the size of the array if the length of the string should not + allows specifying the size of the array if the length of the string should not be used. If the first parameter is a 8-bit string, it is converted into an unicode string @@ -1879,14 +1879,14 @@ .. function:: DllCanUnloadNow() - Windows only: This function is a hook which allows to implement in-process + Windows only: This function is a hook which allows implementing in-process COM servers with ctypes. It is called from the DllCanUnloadNow function that the _ctypes extension dll exports. .. function:: DllGetClassObject() - Windows only: This function is a hook which allows to implement in-process + Windows only: This function is a hook which allows implementing in-process COM servers with ctypes. It is called from the DllGetClassObject function that the ``_ctypes`` extension dll exports. @@ -2432,7 +2432,7 @@ checked, only one field can be accessed when names are repeated. It is possible to define the :attr:`_fields_` class variable *after* the - class statement that defines the Structure subclass, this allows to create + class statement that defines the Structure subclass, this allows creating data types that directly or indirectly reference themselves:: class List(Structure): @@ -2453,7 +2453,7 @@ .. attribute:: _pack_ - An optional small integer that allows to override the alignment of + An optional small integer that allows overriding the alignment of structure fields in the instance. :attr:`_pack_` must already be defined when :attr:`_fields_` is assigned, otherwise it will have no effect. @@ -2465,8 +2465,8 @@ assigned, otherwise it will have no effect. The fields listed in this variable must be structure or union type fields. - :mod:`ctypes` will create descriptors in the structure type that allows to - access the nested fields directly, without the need to create the + :mod:`ctypes` will create descriptors in the structure type that allow + accessing the nested fields directly, without the need to create the structure or union field. Here is an example type (Windows):: diff --git a/Doc/library/nis.rst b/Doc/library/nis.rst --- a/Doc/library/nis.rst +++ b/Doc/library/nis.rst @@ -27,7 +27,7 @@ Note that *mapname* is first checked if it is an alias to another name. .. versionchanged:: 2.5 - The *domain* argument allows to override the NIS domain used for the lookup. If + The *domain* argument allows overriding the NIS domain used for the lookup. If unspecified, lookup is in the default NIS domain. @@ -40,7 +40,7 @@ Note that *mapname* is first checked if it is an alias to another name. .. versionchanged:: 2.5 - The *domain* argument allows to override the NIS domain used for the lookup. If + The *domain* argument allows overriding the NIS domain used for the lookup. If unspecified, lookup is in the default NIS domain. @@ -49,7 +49,7 @@ Return a list of all valid maps. .. versionchanged:: 2.5 - The *domain* argument allows to override the NIS domain used for the lookup. If + The *domain* argument allows overriding the NIS domain used for the lookup. If unspecified, lookup is in the default NIS domain. diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst --- a/Doc/library/tarfile.rst +++ b/Doc/library/tarfile.rst @@ -90,7 +90,7 @@ specifies the blocksize and defaults to ``20 * 512`` bytes. Use this variant in combination with e.g. ``sys.stdin``, a socket file object or a tape device. However, such a :class:`TarFile` object is limited in that it does - not allow to be accessed randomly, see :ref:`tar-examples`. The currently + not allow random access, see :ref:`tar-examples`. The currently possible modes: +-------------+--------------------------------------------+ diff --git a/Lib/ctypes/__init__.py b/Lib/ctypes/__init__.py --- a/Lib/ctypes/__init__.py +++ b/Lib/ctypes/__init__.py @@ -386,8 +386,8 @@ return func class PyDLL(CDLL): - """This class represents the Python library itself. It allows to - access Python API functions. The GIL is not released, and + """This class represents the Python library itself. It allows + accessing Python API functions. The GIL is not released, and Python exceptions are handled correctly. """ _func_flags_ = _FUNCFLAG_CDECL | _FUNCFLAG_PYTHONAPI diff --git a/Lib/lib-tk/Tkinter.py b/Lib/lib-tk/Tkinter.py --- a/Lib/lib-tk/Tkinter.py +++ b/Lib/lib-tk/Tkinter.py @@ -2486,7 +2486,7 @@ self.tk.call(self._w, 'toggle') class Entry(Widget, XView): - """Entry widget which allows to display simple text.""" + """Entry widget which allows displaying simple text.""" def __init__(self, master=None, cnf={}, **kw): """Construct an entry widget with the parent MASTER. @@ -2682,7 +2682,7 @@ itemconfig = itemconfigure class Menu(Widget): - """Menu widget which allows to display menu bars, pull-down menus and pop-up menus.""" + """Menu widget which allows displaying menu bars, pull-down menus and pop-up menus.""" def __init__(self, master=None, cnf={}, **kw): """Construct menu widget with the parent MASTER. diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py --- a/Lib/test/test_strptime.py +++ b/Lib/test/test_strptime.py @@ -190,7 +190,7 @@ def test_whitespace_substitution(self): # When pattern contains whitespace, make sure it is taken into account - # so as to not allow to subpatterns to end up next to each other and + # so as to not allow subpatterns to end up next to each other and # "steal" characters from each other. pattern = self.time_re.pattern('%j %H') self.assertFalse(re.match(pattern, "180")) diff --git a/Misc/HISTORY b/Misc/HISTORY --- a/Misc/HISTORY +++ b/Misc/HISTORY @@ -1845,7 +1845,7 @@ - Patch #1110248: SYNC_FLUSH the zlib buffer for GZipFile.flush. -- Patch #1107973: Allow to iterate over the lines of a tarfile.ExFileObject. +- Patch #1107973: Allow iterating over the lines of a tarfile.ExFileObject. - Patch #1104111: Alter setup.py --help and --help-commands. @@ -2822,7 +2822,7 @@ same as when the argument is omitted). [SF bug 658254, patch 663482] -- nntplib does now allow to ignore a .netrc file. +- nntplib does now allow ignoring a .netrc file. - urllib2 now recognizes Basic authentication even if other authentication schemes are offered. @@ -3240,7 +3240,7 @@ - fcntl.ioctl now warns if the mutate flag is not specified. -- nt now properly allows to refer to UNC roots, e.g. in nt.stat(). +- nt now properly allows referring to UNC roots, e.g. in nt.stat(). - the weakref module now supports additional objects: array.array, sre.pattern_objects, file objects, and sockets. @@ -5798,7 +5798,7 @@ - New functions PyErr_SetExcFromWindowsErr() and PyErr_SetExcFromWindowsErrWithFilename(). Similar to PyErr_SetFromWindowsErrWithFilename() and - PyErr_SetFromWindowsErr(), but they allow to specify + PyErr_SetFromWindowsErr(), but they allow specifying the exception type to raise. Available on Windows. - Py_FatalError() is now declared as taking a const char* argument. It @@ -6678,8 +6678,8 @@ - property() now takes 4 keyword arguments: fget, fset, fdel and doc. These map to read-only attributes 'fget', 'fset', 'fdel', and '__doc__' in the constructed property object. fget, fset and fdel weren't - discoverable from Python in 2.2a3. __doc__ is new, and allows to - associate a docstring with a property. + discoverable from Python in 2.2a3. __doc__ is new, and allows + associating a docstring with a property. - Comparison overloading is now more completely implemented. For example, a str subclass instance can properly be compared to a str @@ -7094,7 +7094,7 @@ ----- - regrtest.py now knows which tests are expected to be skipped on some - platforms, allowing to give clearer test result output. regrtest + platforms, allowing clearer test result output to be given. regrtest also has optional --use/-u switch to run normally disabled tests which require network access or consume significant disk resources. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -623,8 +623,8 @@ - Issue #21802: The reader in BufferedRWPair now is closed even when closing writer failed in BufferedRWPair.close(). -- Issue #23671: string.Template now allows to specify the "self" parameter as - keyword argument. string.Formatter now allows to specify the "self" and +- Issue #23671: string.Template now allows specifying the "self" parameter as + a keyword argument. string.Formatter now allows specifying the "self" and the "format_string" parameters as keyword arguments. - Issue #21560: An attempt to write a data of wrong type no longer cause diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -3497,7 +3497,7 @@ return NULL; } - /* XXX XXX This would allow to pass additional options. For COM + /* XXX XXX This would allow passing additional options. For COM method *implementations*, we would probably want different behaviour than in 'normal' callback functions: return a HRESULT if an exception occurs in the callback, and print the traceback not diff --git a/Modules/_ctypes/libffi/m4/libtool.m4 b/Modules/_ctypes/libffi/m4/libtool.m4 --- a/Modules/_ctypes/libffi/m4/libtool.m4 +++ b/Modules/_ctypes/libffi/m4/libtool.m4 @@ -1121,7 +1121,7 @@ # If we don't find anything, use the default library path according # to the aix ld manual. # Store the results from the different compilers for each TAGNAME. -# Allow to override them for all tags through lt_cv_aix_libpath. +# Allow overriding them for all tags through lt_cv_aix_libpath. m4_defun([_LT_SYS_MODULE_PATH_AIX], [m4_require([_LT_DECL_SED])dnl if test set = "${lt_cv_aix_libpath+set}"; then -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Feb 10 03:33:31 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 10 Feb 2016 08:33:31 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325698=3A_Prevent_possible_replacing_imported_mo?= =?utf-8?q?dule_with_the_empty_one?= Message-ID: <20160210083330.16562.45630@psf.io> https://hg.python.org/cpython/rev/c711c36cf988 changeset: 100216:c711c36cf988 parent: 100212:37f6f965023d parent: 100215:1c2de3b0a474 user: Serhiy Storchaka date: Wed Feb 10 10:31:43 2016 +0200 summary: Issue #25698: Prevent possible replacing imported module with the empty one if the stack is too deep. files: Python/import.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Python/import.c b/Python/import.c --- a/Python/import.c +++ b/Python/import.c @@ -671,9 +671,13 @@ PyObject *modules = PyImport_GetModuleDict(); PyObject *m; - if ((m = PyDict_GetItem(modules, name)) != NULL && - PyModule_Check(m)) + if ((m = PyDict_GetItemWithError(modules, name)) != NULL && + PyModule_Check(m)) { return m; + } + if (PyErr_Occurred()) { + return NULL; + } m = PyModule_NewObject(name); if (m == NULL) return NULL; -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Feb 10 03:33:35 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 10 Feb 2016 08:33:35 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1Njk4?= =?utf-8?q?=3A_Prevent_possible_replacing_imported_module_with_the_empty_o?= =?utf-8?q?ne?= Message-ID: <20160210083330.68406.92077@psf.io> https://hg.python.org/cpython/rev/1c2de3b0a474 changeset: 100215:1c2de3b0a474 branch: 3.5 parent: 100210:818e91105418 user: Serhiy Storchaka date: Wed Feb 10 10:31:20 2016 +0200 summary: Issue #25698: Prevent possible replacing imported module with the empty one if the stack is too deep. files: Python/import.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Python/import.c b/Python/import.c --- a/Python/import.c +++ b/Python/import.c @@ -671,9 +671,13 @@ PyObject *modules = PyImport_GetModuleDict(); PyObject *m; - if ((m = PyDict_GetItem(modules, name)) != NULL && - PyModule_Check(m)) + if ((m = PyDict_GetItemWithError(modules, name)) != NULL && + PyModule_Check(m)) { return m; + } + if (PyErr_Occurred()) { + return NULL; + } m = PyModule_NewObject(name); if (m == NULL) return NULL; -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Feb 10 03:33:36 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 10 Feb 2016 08:33:36 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI1Njk4?= =?utf-8?q?=3A_Importing_module_if_the_stack_is_too_deep_no_longer_replace?= =?utf-8?q?s?= Message-ID: <20160210083330.1539.5400@psf.io> https://hg.python.org/cpython/rev/81dba6e392c3 changeset: 100214:81dba6e392c3 branch: 2.7 user: Serhiy Storchaka date: Wed Feb 10 10:28:06 2016 +0200 summary: Issue #25698: Importing module if the stack is too deep no longer replaces imported module with the empty one. files: Include/dictobject.h | 1 + Misc/NEWS | 3 ++ Objects/dictobject.c | 30 ++++++++++++++++++++ Python/import.c | 48 ++++++++++++++++++++++---------- 4 files changed, 67 insertions(+), 15 deletions(-) diff --git a/Include/dictobject.h b/Include/dictobject.h --- a/Include/dictobject.h +++ b/Include/dictobject.h @@ -108,6 +108,7 @@ PyAPI_FUNC(PyObject *) PyDict_New(void); PyAPI_FUNC(PyObject *) PyDict_GetItem(PyObject *mp, PyObject *key); +PyAPI_FUNC(PyObject *) _PyDict_GetItemWithError(PyObject *mp, PyObject *key); PyAPI_FUNC(int) PyDict_SetItem(PyObject *mp, PyObject *key, PyObject *item); PyAPI_FUNC(int) PyDict_DelItem(PyObject *mp, PyObject *key); PyAPI_FUNC(void) PyDict_Clear(PyObject *mp); diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -50,6 +50,9 @@ Library ------- +- Issue #25698: Importing module if the stack is too deep no longer replaces + imported module with the empty one. + - Issue #12923: Reset FancyURLopener's redirect counter even if there is an exception. Based on patches by Brian Brazil and Daniel Rocco. diff --git a/Objects/dictobject.c b/Objects/dictobject.c --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -749,6 +749,36 @@ return ep->me_value; } +/* Variant of PyDict_GetItem() that doesn't suppress exceptions. + This returns NULL *with* an exception set if an exception occurred. + It returns NULL *without* an exception set if the key wasn't present. +*/ +PyObject * +_PyDict_GetItemWithError(PyObject *op, PyObject *key) +{ + long hash; + PyDictObject *mp = (PyDictObject *)op; + PyDictEntry *ep; + if (!PyDict_Check(op)) { + PyErr_BadInternalCall(); + return NULL; + } + if (!PyString_CheckExact(key) || + (hash = ((PyStringObject *) key)->ob_shash) == -1) + { + hash = PyObject_Hash(key); + if (hash == -1) { + return NULL; + } + } + + ep = (mp->ma_lookup)(mp, key, hash); + if (ep == NULL) { + return NULL; + } + return ep->me_value; +} + static int dict_set_item_by_hash_or_entry(register PyObject *op, PyObject *key, long hash, PyDictEntry *ep, PyObject *value) diff --git a/Python/import.c b/Python/import.c --- a/Python/import.c +++ b/Python/import.c @@ -632,25 +632,43 @@ Because the former action is most common, THIS DOES NOT RETURN A 'NEW' REFERENCE! */ +static PyObject * +_PyImport_AddModuleObject(PyObject *name) +{ + PyObject *modules = PyImport_GetModuleDict(); + PyObject *m; + + if ((m = _PyDict_GetItemWithError(modules, name)) != NULL && + PyModule_Check(m)) { + return m; + } + if (PyErr_Occurred()) { + return NULL; + } + m = PyModule_New(PyString_AS_STRING(name)); + if (m == NULL) { + return NULL; + } + if (PyDict_SetItem(modules, name, m) != 0) { + Py_DECREF(m); + return NULL; + } + assert(Py_REFCNT(m) > 1); + Py_DECREF(m); /* Yes, it still exists, in modules! */ + + return m; +} + PyObject * PyImport_AddModule(const char *name) { - PyObject *modules = PyImport_GetModuleDict(); - PyObject *m; - - if ((m = PyDict_GetItemString(modules, name)) != NULL && - PyModule_Check(m)) - return m; - m = PyModule_New(name); - if (m == NULL) + PyObject *nameobj, *module; + nameobj = PyString_FromString(name); + if (nameobj == NULL) return NULL; - if (PyDict_SetItemString(modules, name, m) != 0) { - Py_DECREF(m); - return NULL; - } - Py_DECREF(m); /* Yes, it still exists, in modules! */ - - return m; + module = _PyImport_AddModuleObject(nameobj); + Py_DECREF(nameobj); + return module; } /* Remove name from sys.modules, if it's there. */ -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Wed Feb 10 04:44:28 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Wed, 10 Feb 2016 09:44:28 +0000 Subject: [Python-checkins] Daily reference leaks (73f89182bb4d): sum=62 Message-ID: <20160210094427.61968.12829@psf.io> results for 73f89182bb4d on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 test_multiprocessing_fork leaked [0, 38, 0] references, sum=38 test_multiprocessing_fork leaked [0, 18, 0] memory blocks, sum=18 test_multiprocessing_fork leaked [0, 2, 0] file descriptors, sum=2 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflog3NtAma', '--timeout', '7200'] From python-checkins at python.org Wed Feb 10 07:45:08 2016 From: python-checkins at python.org (georg.brandl) Date: Wed, 10 Feb 2016 12:45:08 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogQ2xvc2VzICMyNjMy?= =?utf-8?q?0=3A_fix_stylesheet_after_Sphinx_update=2E?= Message-ID: <20160210124503.1556.57414@psf.io> https://hg.python.org/cpython/rev/5715a6d9ff12 changeset: 100217:5715a6d9ff12 branch: 2.7 parent: 100214:81dba6e392c3 user: Georg Brandl date: Wed Feb 10 13:44:29 2016 +0100 summary: Closes #26320: fix stylesheet after Sphinx update. files: Doc/tools/static/basic.css | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/tools/static/basic.css b/Doc/tools/static/basic.css --- a/Doc/tools/static/basic.css +++ b/Doc/tools/static/basic.css @@ -393,22 +393,22 @@ padding: 0 0.5em 0 0.5em; } -tt.descname { +code.descname { background-color: transparent; font-weight: bold; font-size: 1.2em; } -tt.descclassname { +code.descclassname { background-color: transparent; } -tt.xref, a tt { +code.xref, a code { background-color: transparent; font-weight: bold; } -h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt { +h1 code, h2 code, h3 code, h4 code, h5 code, h6 code { background-color: transparent; } -- Repository URL: https://hg.python.org/cpython From lp_benchmark_robot at intel.com Wed Feb 10 09:09:43 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Wed, 10 Feb 2016 14:09:43 +0000 Subject: [Python-checkins] NEUTRAL Benchmark Results for Python Default 2016-02-10 Message-ID: Results for project Python default, build date 2016-02-10 03:04:58 +0000 commit: dc758f51b8f5 previous commit: e2d3c93d8763 revision date: 2016-02-10 10:45:54 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.19% 0.52% 9.11% 15.34% :-| pybench 0.16% 0.01% 0.65% 4.73% :-( regex_v8 3.58% -0.02% -6.04% 4.87% :-| nbody 0.24% -0.02% -0.30% 8.39% :-| json_dump_v2 0.23% -0.11% -0.78% 10.57% :-| normal_startup 0.83% 0.26% 0.79% 4.95% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/neutral-benchmark-results-for-python-default-2016-02-10/ Note: Benchmark results are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Wed Feb 10 09:11:07 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Wed, 10 Feb 2016 14:11:07 +0000 Subject: [Python-checkins] UGLY Benchmark Results for Python 2.7 2016-02-10 Message-ID: <87ea67d4-d45c-45f9-9b6e-9a8b67cfca9e@irsmsx101.ger.corp.intel.com> No new revisions. Here are the previous results: Results for project Python 2.7, build date 2016-02-10 03:56:11 +0000 commit: 8c7a8c7a02b9 previous commit: ab25ce400abd revision date: 2016-02-10 01:17:51 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dc from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.16% -1.38% 2.83% 8.72% :-) pybench 0.15% -0.12% 5.95% 4.83% :-( regex_v8 0.64% -0.22% -2.31% 11.18% :-) nbody 0.10% 0.64% 6.98% 5.08% :-) json_dump_v2 0.30% 0.24% 5.26% 11.12% :-( normal_startup 1.84% -0.19% -5.89% 2.92% :-) ssbench 0.17% 1.81% 2.20% 1.07% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/ugly-benchmark-results-for-python-2-7-2016-02-10/ Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Wed Feb 10 12:47:30 2016 From: python-checkins at python.org (guido.van.rossum) Date: Wed, 10 Feb 2016 17:47:30 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Hopefully_clarify_the_diff?= =?utf-8?q?erence_between_Optional=5Bt=5D_and_an_optional_argument=2E?= Message-ID: <20160210174705.1537.66724@psf.io> https://hg.python.org/cpython/rev/d9f922d57501 changeset: 100218:d9f922d57501 parent: 100216:c711c36cf988 user: Guido van Rossum date: Wed Feb 10 09:46:56 2016 -0800 summary: Hopefully clarify the difference between Optional[t] and an optional argument. files: Doc/library/typing.rst | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -286,6 +286,13 @@ ``Optional[X]`` is equivalent to ``Union[X, type(None)]``. + Note that this is not the same concept as an optional argument, + which is one that has a default. An optional argument with a + default needn't use the ``Optional`` qualifier on its type + annotation (although it is inferred if the default is ``None``). + A mandatory argument may still have an ``Optional`` type if an + explicit value of ``None`` is allowed. + .. class:: Tuple Tuple type; ``Tuple[X, Y]`` is the is the type of a tuple of two items -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Feb 10 12:50:13 2016 From: python-checkins at python.org (guido.van.rossum) Date: Wed, 10 Feb 2016 17:50:13 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Null_merge_of_typing=2Erst_change?= Message-ID: <20160210175013.11221.62398@psf.io> https://hg.python.org/cpython/rev/eae2bb1930c1 changeset: 100220:eae2bb1930c1 parent: 100218:d9f922d57501 parent: 100219:3940f38b0593 user: Guido van Rossum date: Wed Feb 10 09:49:36 2016 -0800 summary: Null merge of typing.rst change files: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Feb 10 12:50:13 2016 From: python-checkins at python.org (guido.van.rossum) Date: Wed, 10 Feb 2016 17:50:13 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Hopefully_clar?= =?utf-8?q?ify_the_difference_between_Optional=5Bt=5D_and_an_optional_argu?= =?utf-8?q?ment=2E?= Message-ID: <20160210175012.11217.22219@psf.io> https://hg.python.org/cpython/rev/3940f38b0593 changeset: 100219:3940f38b0593 branch: 3.5 parent: 100215:1c2de3b0a474 user: Guido van Rossum date: Wed Feb 10 09:48:58 2016 -0800 summary: Hopefully clarify the difference between Optional[t] and an optional argument. files: Doc/library/typing.rst | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -286,6 +286,13 @@ ``Optional[X]`` is equivalent to ``Union[X, type(None)]``. + Note that this is not the same concept as an optional argument, + which is one that has a default. An optional argument with a + default needn't use the ``Optional`` qualifier on its type + annotation (although it is inferred if the default is ``None``). + A mandatory argument may still have an ``Optional`` type if an + explicit value of ``None`` is allowed. + .. class:: Tuple Tuple type; ``Tuple[X, Y]`` is the is the type of a tuple of two items -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Feb 10 17:16:33 2016 From: python-checkins at python.org (georg.brandl) Date: Wed, 10 Feb 2016 22:16:33 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_515=3A_underscores_in_num?= =?utf-8?q?eric_literals=2E?= Message-ID: <20160210221633.16548.85599@psf.io> https://hg.python.org/peps/rev/d42c0678191d changeset: 6222:d42c0678191d user: Georg Brandl date: Wed Feb 10 23:16:04 2016 +0100 summary: PEP 515: underscores in numeric literals. files: pep-0515.txt | 178 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 178 insertions(+), 0 deletions(-) diff --git a/pep-0515.txt b/pep-0515.txt new file mode 100644 --- /dev/null +++ b/pep-0515.txt @@ -0,0 +1,178 @@ +PEP: 515 +Title: Underscores in Numeric Literals +Version: $Revision$ +Last-Modified: $Date$ +Author: Georg Brandl +Status: Draft +Type: Standards Track +Content-Type: text/x-rst +Created: 10-Feb-2016 +Python-Version: 3.6 + +Abstract and Rationale +====================== + +This PEP proposes to extend Python's syntax so that underscores can be used in +integral and floating-point number literals. + +This is a common feature of other modern languages, and can aid readability of +long literals, or literals whose value should clearly separate into parts, such +as bytes or words in hexadecimal notation. + +Examples:: + + # grouping decimal numbers by thousands + amount = 10_000_000.0 + + # grouping hexadecimal addresses by words + addr = 0xDEAD_BEEF + + # grouping bits into bytes in a binary literal + flags = 0b_0011_1111_0100_1110 + + +Specification +============= + +The current proposal is to allow underscores anywhere in numeric literals, with +these exceptions: + +* Leading underscores cannot be allowed, since they already introduce + identifiers. +* Trailing underscores are not allowed, because they look confusing and don't + contribute much to readability. +* The number base prefixes ``0x``, ``0o``, and ``0b`` cannot be split up, + because they are fixed strings and not logically part of the number. +* No underscore allowed after a sign in an exponent (``1e-_5``), because + underscores can also not be used after the signs in front of the number + (``-1e5``). +* No underscore allowed after a decimal point, because this leads to ambiguity + with attribute access (the lexer cannot know that there is no number literal + in ``foo._5``). + +There appears to be no reason to restrict the use of underscores otherwise. + +The production list for integer literals would therefore look like this:: + + integer: decimalinteger | octinteger | hexinteger | bininteger + decimalinteger: nonzerodigit [decimalrest] | "0" [("0" | "_")* "0"] + nonzerodigit: "1"..."9" + decimalrest: (digit | "_")* digit + digit: "0"..."9" + octinteger: "0" ("o" | "O") (octdigit | "_")* octdigit + hexinteger: "0" ("x" | "X") (hexdigit | "_")* hexdigit + bininteger: "0" ("b" | "B") (bindigit | "_")* bindigit + octdigit: "0"..."7" + hexdigit: digit | "a"..."f" | "A"..."F" + bindigit: "0" | "1" + +For floating-point literals:: + + floatnumber: pointfloat | exponentfloat + pointfloat: [intpart] fraction | intpart "." + exponentfloat: (intpart | pointfloat) exponent + intpart: digit (digit | "_")* + fraction: "." intpart + exponent: ("e" | "E") "_"* ["+" | "-"] digit [decimalrest] + + +Alternative Syntax +================== + +Underscore Placement Rules +-------------------------- + +Instead of the liberal rule specified above, the use of underscores could be +limited. Common rules are (see the "other languages" section): + +* Only one consecutive underscore allowed, and only between digits. +* Multiple consecutive underscore allowed, but only between digits. + +Different Separators +-------------------- + +A proposed alternate syntax was to use whitespace for grouping. Although +strings are a precedent for combining adjoining literals, the behavior can lead +to unexpected effects which are not possible with underscores. Also, no other +language is known to use this rule, except for languages that generally +disregard any whitespace. + +C++14 introduces apostrophes for grouping, which is not considered due to the +conflict with Python's string literals. [1]_ + + +Behavior in Other Languages +=========================== + +Those languages that do allow underscore grouping implement a large variety of +rules for allowed placement of underscores. This is a listing placing the known +rules into three major groups. In cases where the language spec contradicts the +actual behavior, the actual behavior is listed. + +**Group 1: liberal (like this PEP)** + +* D [2]_ +* Perl 5 (although docs say it's more restricted) [3]_ +* Rust [4]_ +* Swift (although textual description says "between digits") [5]_ + +**Group 2: only between digits, multiple consecutive underscores** + +* C# (open proposal for 7.0) [6]_ +* Java [7]_ + +**Group 3: only between digits, only one underscore** + +* Ada [8]_ +* Julia (but not in the exponent part of floats) [9]_ +* Ruby (docs say "anywhere", in reality only between digits) [10]_ + + +Implementation +============== + +A preliminary patch that implements the specification given above has been +posted to the issue tracker. [11]_ + + +References +========== + +.. [1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3499.html + +.. [2] http://dlang.org/spec/lex.html#integerliteral + +.. [3] http://perldoc.perl.org/perldata.html#Scalar-value-constructors + +.. [4] http://doc.rust-lang.org/reference.html#number-literals + +.. [5] https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/LexicalStructure.html + +.. [6] https://github.com/dotnet/roslyn/issues/216 + +.. [7] https://docs.oracle.com/javase/7/docs/technotes/guides/language/underscores-literals.html + +.. [8] http://archive.adaic.com/standards/83lrm/html/lrm-02-04.html#2.4 + +.. [9] http://docs.julialang.org/en/release-0.4/manual/integers-and-floating-point-numbers/ + +.. [10] http://ruby-doc.org/core-2.3.0/doc/syntax/literals_rdoc.html#label-Numbers + +.. [11] http://bugs.python.org/issue26331 + + +Copyright +========= + +This document has been placed in the public domain. + + + +.. + Local Variables: + mode: indented-text + indent-tabs-mode: nil + sentence-end-double-space: t + fill-column: 70 + coding: utf-8 + End: -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Wed Feb 10 17:58:47 2016 From: python-checkins at python.org (charles-francois.natali) Date: Wed, 10 Feb 2016 22:58:47 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2323992=3A_multipro?= =?utf-8?q?cessing=3A_make_MapResult_not_fail-fast_upon_exception=2E?= Message-ID: <20160210225840.6673.38449@psf.io> https://hg.python.org/cpython/rev/1ba0deb52223 changeset: 100221:1ba0deb52223 user: Charles-Fran?ois Natali date: Wed Feb 10 22:58:18 2016 +0000 summary: Issue #23992: multiprocessing: make MapResult not fail-fast upon exception. files: Lib/multiprocessing/pool.py | 20 +++++++++------ Lib/test/_test_multiprocessing.py | 24 +++++++++++++++++++ Misc/NEWS | 2 + 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/Lib/multiprocessing/pool.py b/Lib/multiprocessing/pool.py --- a/Lib/multiprocessing/pool.py +++ b/Lib/multiprocessing/pool.py @@ -638,22 +638,26 @@ self._number_left = length//chunksize + bool(length % chunksize) def _set(self, i, success_result): + self._number_left -= 1 success, result = success_result - if success: + if success and self._success: self._value[i*self._chunksize:(i+1)*self._chunksize] = result - self._number_left -= 1 if self._number_left == 0: if self._callback: self._callback(self._value) del self._cache[self._job] self._event.set() else: - self._success = False - self._value = result - if self._error_callback: - self._error_callback(self._value) - del self._cache[self._job] - self._event.set() + if not success and self._success: + # only store first exception + self._success = False + self._value = result + if self._number_left == 0: + # only consider the result ready once all jobs are done + if self._error_callback: + self._error_callback(self._value) + del self._cache[self._job] + self._event.set() # # Class whose instances are returned by `Pool.imap()` diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py --- a/Lib/test/_test_multiprocessing.py +++ b/Lib/test/_test_multiprocessing.py @@ -1660,6 +1660,10 @@ def mul(x, y): return x*y +def raise_large_valuerror(wait): + time.sleep(wait) + raise ValueError("x" * 1024**2) + class SayWhenError(ValueError): pass def exception_throwing_generator(total, when): @@ -1895,6 +1899,26 @@ with self.assertRaises(RuntimeError): p.apply(self._test_wrapped_exception) + def test_map_no_failfast(self): + # Issue #23992: the fail-fast behaviour when an exception is raised + # during map() would make Pool.join() deadlock, because a worker + # process would fill the result queue (after the result handler thread + # terminated, hence not draining it anymore). + + t_start = time.time() + + with self.assertRaises(ValueError): + with self.Pool(2) as p: + try: + p.map(raise_large_valuerror, [0, 1]) + finally: + time.sleep(0.5) + p.close() + p.join() + + # check that we indeed waited for all jobs + self.assertGreater(time.time() - t_start, 0.9) + def raising(): raise KeyError("key") diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -179,6 +179,8 @@ Library ------- +- Issue #23992: multiprocessing: make MapResult not fail-fast upon exception. + - Issue #26243: Support keyword arguments to zlib.compress(). Patch by Aviv Palivoda. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 11 02:57:21 2016 From: python-checkins at python.org (georg.brandl) Date: Thu, 11 Feb 2016 07:57:21 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Update_PEP_515=3A_new=2C_much?= =?utf-8?q?_simpler_rule=2E?= Message-ID: <20160211075719.6677.40982@psf.io> https://hg.python.org/peps/rev/39a195d1ee9c changeset: 6224:39a195d1ee9c user: Georg Brandl date: Thu Feb 11 08:57:12 2016 +0100 summary: Update PEP 515: new, much simpler rule. files: pep-0515.txt | 50 ++++++++++++++++------------------------ 1 files changed, 20 insertions(+), 30 deletions(-) diff --git a/pep-0515.txt b/pep-0515.txt --- a/pep-0515.txt +++ b/pep-0515.txt @@ -37,34 +37,18 @@ Specification ============= -The current proposal is to allow underscores anywhere in numeric literals, with -these exceptions: - -* Leading underscores cannot be allowed, since they already introduce - identifiers. -* Trailing underscores are not allowed, because they look confusing and don't - contribute much to readability. -* The number base prefixes ``0x``, ``0o``, and ``0b`` cannot be split up, - because they are fixed strings and not logically part of the number. -* No underscore allowed immediately after a sign in an exponent (``1e-_5``), - because underscores can also not be used after the signs in front of the - number (``-1e5``). -* No underscore allowed immediately after a decimal point, because this leads to - ambiguity with attribute access (the lexer cannot know that there is no number - literal in ``foo._5``). - -There appears to be no reason to restrict the use of underscores otherwise. +The current proposal is to allow one or more consecutive underscores following +digits and base specifiers in numeric literals. The production list for integer literals would therefore look like this:: integer: decimalinteger | octinteger | hexinteger | bininteger - decimalinteger: nonzerodigit [decimalrest] | "0" [("0" | "_")* "0"] + decimalinteger: nonzerodigit (digit | "_")* | "0" ("0" | "_")* nonzerodigit: "1"..."9" - decimalrest: (digit | "_")* digit digit: "0"..."9" - octinteger: "0" ("o" | "O") (octdigit | "_")* octdigit - hexinteger: "0" ("x" | "X") (hexdigit | "_")* hexdigit - bininteger: "0" ("b" | "B") (bindigit | "_")* bindigit + octinteger: "0" ("o" | "O") (octdigit | "_")* + hexinteger: "0" ("x" | "X") (hexdigit | "_")* + bininteger: "0" ("b" | "B") (bindigit | "_")* octdigit: "0"..."7" hexdigit: digit | "a"..."f" | "A"..."F" bindigit: "0" | "1" @@ -72,11 +56,12 @@ For floating-point and complex literals:: floatnumber: pointfloat | exponentfloat - pointfloat: [intpart] "_"* "." intpart | intpart "_"* "." - exponentfloat: (intpart | pointfloat) "_"* exponent - intpart: digit [(digit | "_")* digit] - exponent: ("e" | "E") "_"* ["+" | "-"] digit [decimalrest] - imagnumber: (floatnumber | intpart) "_"* ("j" | "J") + pointfloat: [intpart] fraction | intpart "." + exponentfloat: (intpart | pointfloat) exponent + intpart: digit (digit | "_")* + fraction: "." intpart + exponent: ("e" | "E") ["+" | "-"] intpart + imagnumber: (floatnumber | intpart) ("j" | "J") Further Considerations @@ -131,11 +116,16 @@ rules into three major groups. In cases where the language spec contradicts the actual behavior, the actual behavior is listed. -**Group 1: liberal (like this PEP)** +**Group 1: liberal** + +This group is the least homogeneous: the rules vary slightly between languages. +All of them allow trailing underscores. Some allow underscores after non-digits +like the ``e`` or the sign in exponents. * D [2]_ -* Perl 5 (although docs say it's more restricted) [3]_ -* Rust [4]_ +* Perl 5 (underscores basically allowed anywhere, although docs say it's more + restricted) [3]_ +* Rust (allows between exponent sign and digits) [4]_ * Swift (although textual description says "between digits") [5]_ **Group 2: only between digits, multiple consecutive underscores** -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Thu Feb 11 02:57:23 2016 From: python-checkins at python.org (georg.brandl) Date: Thu, 11 Feb 2016 07:57:23 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Update_PEP_515_with_correctio?= =?utf-8?b?bnMu?= Message-ID: <20160211075718.68402.89219@psf.io> https://hg.python.org/peps/rev/292a4c58bfed changeset: 6223:292a4c58bfed user: Georg Brandl date: Thu Feb 11 08:45:52 2016 +0100 summary: Update PEP 515 with corrections. files: pep-0515.txt | 46 +++++++++++++++++++++++++++++---------- 1 files changed, 34 insertions(+), 12 deletions(-) diff --git a/pep-0515.txt b/pep-0515.txt --- a/pep-0515.txt +++ b/pep-0515.txt @@ -13,7 +13,7 @@ ====================== This PEP proposes to extend Python's syntax so that underscores can be used in -integral and floating-point number literals. +integral, floating-point and complex number literals. This is a common feature of other modern languages, and can aid readability of long literals, or literals whose value should clearly separate into parts, such @@ -30,6 +30,9 @@ # grouping bits into bytes in a binary literal flags = 0b_0011_1111_0100_1110 + # making the literal suffix stand out more + imag = 1.247812376e-15_j + Specification ============= @@ -43,12 +46,12 @@ contribute much to readability. * The number base prefixes ``0x``, ``0o``, and ``0b`` cannot be split up, because they are fixed strings and not logically part of the number. -* No underscore allowed after a sign in an exponent (``1e-_5``), because - underscores can also not be used after the signs in front of the number - (``-1e5``). -* No underscore allowed after a decimal point, because this leads to ambiguity - with attribute access (the lexer cannot know that there is no number literal - in ``foo._5``). +* No underscore allowed immediately after a sign in an exponent (``1e-_5``), + because underscores can also not be used after the signs in front of the + number (``-1e5``). +* No underscore allowed immediately after a decimal point, because this leads to + ambiguity with attribute access (the lexer cannot know that there is no number + literal in ``foo._5``). There appears to be no reason to restrict the use of underscores otherwise. @@ -66,14 +69,28 @@ hexdigit: digit | "a"..."f" | "A"..."F" bindigit: "0" | "1" -For floating-point literals:: +For floating-point and complex literals:: floatnumber: pointfloat | exponentfloat - pointfloat: [intpart] fraction | intpart "." - exponentfloat: (intpart | pointfloat) exponent - intpart: digit (digit | "_")* - fraction: "." intpart + pointfloat: [intpart] "_"* "." intpart | intpart "_"* "." + exponentfloat: (intpart | pointfloat) "_"* exponent + intpart: digit [(digit | "_")* digit] exponent: ("e" | "E") "_"* ["+" | "-"] digit [decimalrest] + imagnumber: (floatnumber | intpart) "_"* ("j" | "J") + + +Further Considerations +====================== + +This PEP currently only proposes changing the literal syntax. The following +extensions are open for discussion: + +* Allowing underscores in string arguments to the ``Decimal`` constructor. It + could be argued that these are akin to literals, since there is no Decimal + literal available (yet). + +* Allowing underscores in string arguments to ``int()``, ``float()`` and + ``complex()``. Alternative Syntax @@ -88,6 +105,11 @@ * Only one consecutive underscore allowed, and only between digits. * Multiple consecutive underscore allowed, but only between digits. +A less common rule would be to allow underscores only every N digits (where N +could be 3 for decimal literals, or 4 for hexadecimal ones). This is +unnecessarily restrictive, especially considering the separator placement is +different in different cultures. + Different Separators -------------------- -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Thu Feb 11 03:11:25 2016 From: python-checkins at python.org (georg.brandl) Date: Thu, 11 Feb 2016 08:11:25 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Minor_update_to_PEP_515=2E?= Message-ID: <20160211081124.2639.3662@psf.io> https://hg.python.org/peps/rev/93cdd746f34d changeset: 6225:93cdd746f34d user: Georg Brandl date: Thu Feb 11 09:11:20 2016 +0100 summary: Minor update to PEP 515. files: pep-0515.txt | 28 ++++++++++++++-------------- 1 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pep-0515.txt b/pep-0515.txt --- a/pep-0515.txt +++ b/pep-0515.txt @@ -64,20 +64,6 @@ imagnumber: (floatnumber | intpart) ("j" | "J") -Further Considerations -====================== - -This PEP currently only proposes changing the literal syntax. The following -extensions are open for discussion: - -* Allowing underscores in string arguments to the ``Decimal`` constructor. It - could be argued that these are akin to literals, since there is no Decimal - literal available (yet). - -* Allowing underscores in string arguments to ``int()``, ``float()`` and - ``complex()``. - - Alternative Syntax ================== @@ -147,6 +133,20 @@ posted to the issue tracker. [11]_ +Open Questions +============== + +This PEP currently only proposes changing the literal syntax. The following +extensions are open for discussion: + +* Allowing underscores in string arguments to the ``Decimal`` constructor. It + could be argued that these are akin to literals, since there is no Decimal + literal available (yet). + +* Allowing underscores in string arguments to ``int()`` with base argument 0, + ``float()`` and ``complex()``. + + References ========== -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Thu Feb 11 03:18:51 2016 From: python-checkins at python.org (georg.brandl) Date: Thu, 11 Feb 2016 08:18:51 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Add_Post-History=2E?= Message-ID: <20160211081848.40086.706@psf.io> https://hg.python.org/peps/rev/0a61cb13245b changeset: 6226:0a61cb13245b user: Georg Brandl date: Thu Feb 11 09:18:45 2016 +0100 summary: Add Post-History. files: pep-0515.txt | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/pep-0515.txt b/pep-0515.txt --- a/pep-0515.txt +++ b/pep-0515.txt @@ -8,6 +8,7 @@ Content-Type: text/x-rst Created: 10-Feb-2016 Python-Version: 3.6 +Post-History: 10-Feb-2016, 11-Feb-2016 Abstract and Rationale ====================== -- Repository URL: https://hg.python.org/peps From solipsis at pitrou.net Thu Feb 11 04:45:27 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Thu, 11 Feb 2016 09:45:27 +0000 Subject: [Python-checkins] Daily reference leaks (1ba0deb52223): sum=-19 Message-ID: <20160211094523.1543.83186@psf.io> results for 1ba0deb52223 on branch "default" -------------------------------------------- test_asyncio leaked [0, 0, -17] references, sum=-17 test_asyncio leaked [0, 0, -6] memory blocks, sum=-6 test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogG7DE68', '--timeout', '7200'] From python-checkins at python.org Thu Feb 11 05:42:17 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 11 Feb 2016 10:42:17 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2326312=3A_SystemEr?= =?utf-8?q?ror_is_now_raised_in_all_programming_bugs_with_using?= Message-ID: <20160211104216.6649.65576@psf.io> https://hg.python.org/cpython/rev/c7eff18f3840 changeset: 100222:c7eff18f3840 user: Serhiy Storchaka date: Thu Feb 11 12:41:40 2016 +0200 summary: Issue #26312: SystemError is now raised in all programming bugs with using PyArg_ParseTupleAndKeywords(). RuntimeError did raised before in some programming bugs. files: Lib/test/test_capi.py | 4 ++-- Misc/NEWS | 4 ++++ Python/getargs.c | 12 ++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py --- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -491,7 +491,7 @@ except SystemError as e: s = "argument 1 (impossible)" when_not_skipped = (str(e) == s) - except (TypeError, RuntimeError): + except TypeError: when_not_skipped = False # test the format unit when skipped @@ -500,7 +500,7 @@ _testcapi.parse_tuple_and_keywords(empty_tuple, dict_b, optional_format.encode("ascii"), keywords) when_skipped = False - except RuntimeError as e: + except SystemError as e: s = "impossible: '{}'".format(format) when_skipped = (str(e) == s) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -741,6 +741,10 @@ C API ----- +- Issue #26312: SystemError is now raised in all programming bugs with using + PyArg_ParseTupleAndKeywords(). RuntimeError did raised before in some + programming bugs. + - Issue #26198: ValueError is now raised instead of TypeError on buffer overflow in parsing "es#" and "et#" format units. SystemError is now raised instead of TypeError on programmical error in parsing format string. diff --git a/Python/getargs.c b/Python/getargs.c --- a/Python/getargs.c +++ b/Python/getargs.c @@ -1512,7 +1512,7 @@ keyword = kwlist[i]; if (*format == '|') { if (min != INT_MAX) { - PyErr_SetString(PyExc_RuntimeError, + PyErr_SetString(PyExc_SystemError, "Invalid format string (| specified twice)"); return cleanreturn(0, &freelist); } @@ -1521,14 +1521,14 @@ format++; if (max != INT_MAX) { - PyErr_SetString(PyExc_RuntimeError, + PyErr_SetString(PyExc_SystemError, "Invalid format string ($ before |)"); return cleanreturn(0, &freelist); } } if (*format == '$') { if (max != INT_MAX) { - PyErr_SetString(PyExc_RuntimeError, + PyErr_SetString(PyExc_SystemError, "Invalid format string ($ specified twice)"); return cleanreturn(0, &freelist); } @@ -1546,7 +1546,7 @@ } } if (IS_END_OF_FORMAT(*format)) { - PyErr_Format(PyExc_RuntimeError, + PyErr_Format(PyExc_SystemError, "More keyword list entries (%d) than " "format specifiers (%d)", len, i); return cleanreturn(0, &freelist); @@ -1598,14 +1598,14 @@ * keyword args */ msg = skipitem(&format, p_va, flags); if (msg) { - PyErr_Format(PyExc_RuntimeError, "%s: '%s'", msg, + PyErr_Format(PyExc_SystemError, "%s: '%s'", msg, format); return cleanreturn(0, &freelist); } } if (!IS_END_OF_FORMAT(*format) && (*format != '|') && (*format != '$')) { - PyErr_Format(PyExc_RuntimeError, + PyErr_Format(PyExc_SystemError, "more argument specifiers than keyword list entries " "(remaining format:'%s')", format); return cleanreturn(0, &freelist); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 11 06:11:01 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 11 Feb 2016 11:11:01 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325985=3A_sys=2Eve?= =?utf-8?q?rsion=5Finfo_is_now_used_instead_of_sys=2Eversion?= Message-ID: <20160211111100.6659.43772@psf.io> https://hg.python.org/cpython/rev/935d7804d1be changeset: 100223:935d7804d1be user: Serhiy Storchaka date: Thu Feb 11 13:10:36 2016 +0200 summary: Issue #25985: sys.version_info is now used instead of sys.version to format short Python version. files: Doc/c-api/intro.rst | 7 +- Doc/includes/test.py | 2 +- Doc/library/sysconfig.rst | 2 +- Lib/distutils/command/bdist_msi.py | 2 +- Lib/distutils/command/bdist_wininst.py | 2 +- Lib/distutils/command/build.py | 4 +- Lib/distutils/command/install.py | 4 +- Lib/distutils/command/install_egg_info.py | 4 +- Lib/distutils/sysconfig.py | 2 +- Lib/distutils/tests/test_build.py | 5 +- Lib/importlib/_bootstrap_external.py | 2 +- Lib/pydoc.py | 6 +- Lib/site.py | 4 +- Lib/sysconfig.py | 8 +- Lib/test/test_importlib/test_windows.py | 2 +- Lib/test/test_site.py | 5 +- Lib/test/test_venv.py | 2 +- Lib/urllib/request.py | 2 +- Lib/xmlrpc/client.py | 2 +- Makefile.pre.in | 2 +- Python/importlib_external.h | 31 +++++----- Tools/freeze/freeze.py | 2 +- Tools/scripts/nm2def.py | 4 +- setup.py | 2 +- 24 files changed, 56 insertions(+), 52 deletions(-) diff --git a/Doc/c-api/intro.rst b/Doc/c-api/intro.rst --- a/Doc/c-api/intro.rst +++ b/Doc/c-api/intro.rst @@ -64,9 +64,10 @@ located in the directories :file:`{prefix}/include/pythonversion/` and :file:`{exec_prefix}/include/pythonversion/`, where :envvar:`prefix` and :envvar:`exec_prefix` are defined by the corresponding parameters to Python's -:program:`configure` script and *version* is ``sys.version[:3]``. On Windows, -the headers are installed in :file:`{prefix}/include`, where :envvar:`prefix` is -the installation directory specified to the installer. +:program:`configure` script and *version* is +``'%d.%d' % sys.version_info[:2]``. On Windows, the headers are installed +in :file:`{prefix}/include`, where :envvar:`prefix` is the installation +directory specified to the installer. To include the headers, place both directories (if different) on your compiler's search path for includes. Do *not* place the parent directories on the search diff --git a/Doc/includes/test.py b/Doc/includes/test.py --- a/Doc/includes/test.py +++ b/Doc/includes/test.py @@ -204,7 +204,7 @@ import os import sys from distutils.util import get_platform -PLAT_SPEC = "%s-%s" % (get_platform(), sys.version[0:3]) +PLAT_SPEC = "%s-%d.%d" % (get_platform(), *sys.version_info[:2]) src = os.path.join("build", "lib.%s" % PLAT_SPEC) sys.path.append(src) diff --git a/Doc/library/sysconfig.rst b/Doc/library/sysconfig.rst --- a/Doc/library/sysconfig.rst +++ b/Doc/library/sysconfig.rst @@ -163,7 +163,7 @@ .. function:: get_python_version() Return the ``MAJOR.MINOR`` Python version number as a string. Similar to - ``sys.version[:3]``. + ``'%d.%d' % sys.version_info[:2]``. .. function:: get_platform() diff --git a/Lib/distutils/command/bdist_msi.py b/Lib/distutils/command/bdist_msi.py --- a/Lib/distutils/command/bdist_msi.py +++ b/Lib/distutils/command/bdist_msi.py @@ -199,7 +199,7 @@ target_version = self.target_version if not target_version: assert self.skip_build, "Should have already checked this" - target_version = sys.version[0:3] + target_version = '%d.%d' % sys.version_info[:2] plat_specifier = ".%s-%s" % (self.plat_name, target_version) build = self.get_finalized_command('build') build.build_lib = os.path.join(build.build_base, diff --git a/Lib/distutils/command/bdist_wininst.py b/Lib/distutils/command/bdist_wininst.py --- a/Lib/distutils/command/bdist_wininst.py +++ b/Lib/distutils/command/bdist_wininst.py @@ -141,7 +141,7 @@ target_version = self.target_version if not target_version: assert self.skip_build, "Should have already checked this" - target_version = sys.version[0:3] + target_version = '%d.%d' % sys.version_info[:2] plat_specifier = ".%s-%s" % (self.plat_name, target_version) build = self.get_finalized_command('build') build.build_lib = os.path.join(build.build_base, diff --git a/Lib/distutils/command/build.py b/Lib/distutils/command/build.py --- a/Lib/distutils/command/build.py +++ b/Lib/distutils/command/build.py @@ -81,7 +81,7 @@ "--plat-name only supported on Windows (try " "using './configure --help' on your platform)") - plat_specifier = ".%s-%s" % (self.plat_name, sys.version[0:3]) + plat_specifier = ".%s-%d.%d" % (self.plat_name, *sys.version_info[:2]) # Make it so Python 2.x and Python 2.x with --with-pydebug don't # share the same build directories. Doing so confuses the build @@ -114,7 +114,7 @@ 'temp' + plat_specifier) if self.build_scripts is None: self.build_scripts = os.path.join(self.build_base, - 'scripts-' + sys.version[0:3]) + 'scripts-%d.%d' % sys.version_info[:2]) if self.executable is None: self.executable = os.path.normpath(sys.executable) diff --git a/Lib/distutils/command/install.py b/Lib/distutils/command/install.py --- a/Lib/distutils/command/install.py +++ b/Lib/distutils/command/install.py @@ -290,8 +290,8 @@ 'dist_version': self.distribution.get_version(), 'dist_fullname': self.distribution.get_fullname(), 'py_version': py_version, - 'py_version_short': py_version[0:3], - 'py_version_nodot': py_version[0] + py_version[2], + 'py_version_short': '%d.%d' % sys.version_info[:2], + 'py_version_nodot': '%d%d' % sys.version_info[:2], 'sys_prefix': prefix, 'prefix': prefix, 'sys_exec_prefix': exec_prefix, diff --git a/Lib/distutils/command/install_egg_info.py b/Lib/distutils/command/install_egg_info.py --- a/Lib/distutils/command/install_egg_info.py +++ b/Lib/distutils/command/install_egg_info.py @@ -21,10 +21,10 @@ def finalize_options(self): self.set_undefined_options('install_lib',('install_dir','install_dir')) - basename = "%s-%s-py%s.egg-info" % ( + basename = "%s-%s-py%d.%d.egg-info" % ( to_filename(safe_name(self.distribution.get_name())), to_filename(safe_version(self.distribution.get_version())), - sys.version[:3] + *sys.version_info[:2] ) self.target = os.path.join(self.install_dir, basename) self.outputs = [self.target] diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py --- a/Lib/distutils/sysconfig.py +++ b/Lib/distutils/sysconfig.py @@ -70,7 +70,7 @@ leaving off the patchlevel. Sample return values could be '1.5' or '2.2'. """ - return sys.version[:3] + return '%d.%d' % sys.version_info[:2] def get_python_inc(plat_specific=0, prefix=None): diff --git a/Lib/distutils/tests/test_build.py b/Lib/distutils/tests/test_build.py --- a/Lib/distutils/tests/test_build.py +++ b/Lib/distutils/tests/test_build.py @@ -27,7 +27,7 @@ # build_platlib is 'build/lib.platform-x.x[-pydebug]' # examples: # build/lib.macosx-10.3-i386-2.7 - plat_spec = '.%s-%s' % (cmd.plat_name, sys.version[0:3]) + plat_spec = '.%s-%d.%d' % (cmd.plat_name, *sys.version_info[:2]) if hasattr(sys, 'gettotalrefcount'): self.assertTrue(cmd.build_platlib.endswith('-pydebug')) plat_spec += '-pydebug' @@ -42,7 +42,8 @@ self.assertEqual(cmd.build_temp, wanted) # build_scripts is build/scripts-x.x - wanted = os.path.join(cmd.build_base, 'scripts-' + sys.version[0:3]) + wanted = os.path.join(cmd.build_base, + 'scripts-%d.%d' % sys.version_info[:2]) self.assertEqual(cmd.build_scripts, wanted) # executable is os.path.normpath(sys.executable) diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -593,7 +593,7 @@ else: registry_key = cls.REGISTRY_KEY key = registry_key.format(fullname=fullname, - sys_version=sys.version[:3]) + sys_version='%d.%d' % sys.version_info[:2]) try: with cls._open_registry(key) as hkey: filepath = _winreg.QueryValue(hkey, '') diff --git a/Lib/pydoc.py b/Lib/pydoc.py --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -1911,10 +1911,10 @@ def intro(self): self.output.write(''' -Welcome to Python %s's help utility! +Welcome to Python {0}'s help utility! If this is your first time using Python, you should definitely check out -the tutorial on the Internet at http://docs.python.org/%s/tutorial/. +the tutorial on the Internet at http://docs.python.org/{0}/tutorial/. Enter the name of any module, keyword, or topic to get help on writing Python programs and using Python modules. To quit this help utility and @@ -1924,7 +1924,7 @@ "modules", "keywords", "symbols", or "topics". Each module also comes with a one-line summary of what it does; to list the modules whose name or summary contain a given string such as "spam", type "modules spam". -''' % tuple([sys.version[:3]]*2)) +'''.format('%d.%d' % sys.version_info[:2])) def list(self, items, columns=4, width=80): items = list(sorted(items)) diff --git a/Lib/site.py b/Lib/site.py --- a/Lib/site.py +++ b/Lib/site.py @@ -304,7 +304,7 @@ if os.sep == '/': sitepackages.append(os.path.join(prefix, "lib", - "python" + sys.version[:3], + "python%d.%d" % sys.version_info[:2], "site-packages")) else: sitepackages.append(prefix) @@ -317,7 +317,7 @@ if framework: sitepackages.append( os.path.join("/Library", framework, - sys.version[:3], "site-packages")) + '%d.%d' % sys.version_info[:2], "site-packages")) return sitepackages def addsitepackages(known_paths, prefixes=None): diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py --- a/Lib/sysconfig.py +++ b/Lib/sysconfig.py @@ -86,8 +86,8 @@ # FIXME don't rely on sys.version here, its format is an implementation detail # of CPython, use sys.version_info or sys.hexversion _PY_VERSION = sys.version.split()[0] -_PY_VERSION_SHORT = sys.version[:3] -_PY_VERSION_SHORT_NO_DOT = _PY_VERSION[0] + _PY_VERSION[2] +_PY_VERSION_SHORT = '%d.%d' % sys.version_info[:2] +_PY_VERSION_SHORT_NO_DOT = '%d%d' % sys.version_info[:2] _PREFIX = os.path.normpath(sys.prefix) _BASE_PREFIX = os.path.normpath(sys.base_prefix) _EXEC_PREFIX = os.path.normpath(sys.exec_prefix) @@ -386,7 +386,7 @@ module.build_time_vars = vars sys.modules[name] = module - pybuilddir = 'build/lib.%s-%s' % (get_platform(), sys.version[:3]) + pybuilddir = 'build/lib.%s-%s' % (get_platform(), _PY_VERSION_SHORT) if hasattr(sys, "gettotalrefcount"): pybuilddir += '-pydebug' os.makedirs(pybuilddir, exist_ok=True) @@ -518,7 +518,7 @@ _CONFIG_VARS['exec_prefix'] = _EXEC_PREFIX _CONFIG_VARS['py_version'] = _PY_VERSION _CONFIG_VARS['py_version_short'] = _PY_VERSION_SHORT - _CONFIG_VARS['py_version_nodot'] = _PY_VERSION[0] + _PY_VERSION[2] + _CONFIG_VARS['py_version_nodot'] = _PY_VERSION_SHORT_NO_DOT _CONFIG_VARS['installed_base'] = _BASE_PREFIX _CONFIG_VARS['base'] = _PREFIX _CONFIG_VARS['installed_platbase'] = _BASE_EXEC_PREFIX diff --git a/Lib/test/test_importlib/test_windows.py b/Lib/test/test_importlib/test_windows.py --- a/Lib/test/test_importlib/test_windows.py +++ b/Lib/test/test_importlib/test_windows.py @@ -40,7 +40,7 @@ else: root = machinery.WindowsRegistryFinder.REGISTRY_KEY key = root.format(fullname=name, - sys_version=sys.version[:3]) + sys_version='%d.%d' % sys.version_info[:2]) try: with temp_module(name, "a = 1") as location: subkey = CreateKey(HKEY_CURRENT_USER, key) diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py --- a/Lib/test/test_site.py +++ b/Lib/test/test_site.py @@ -238,13 +238,14 @@ self.assertEqual(len(dirs), 2) wanted = os.path.join('/Library', sysconfig.get_config_var("PYTHONFRAMEWORK"), - sys.version[:3], + '%d.%d' % sys.version_info[:2], 'site-packages') self.assertEqual(dirs[1], wanted) elif os.sep == '/': # OS X non-framwework builds, Linux, FreeBSD, etc self.assertEqual(len(dirs), 1) - wanted = os.path.join('xoxo', 'lib', 'python' + sys.version[:3], + wanted = os.path.join('xoxo', 'lib', + 'python%d.%d' % sys.version_info[:2], 'site-packages') self.assertEqual(dirs[0], wanted) else: diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py --- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -51,7 +51,7 @@ self.include = 'Include' else: self.bindir = 'bin' - self.lib = ('lib', 'python%s' % sys.version[:3]) + self.lib = ('lib', 'python%d.%d' % sys.version_info[:2]) self.include = 'include' if sys.platform == 'darwin' and '__PYVENV_LAUNCHER__' in os.environ: executable = os.environ['__PYVENV_LAUNCHER__'] diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -133,7 +133,7 @@ ] # used in User-Agent header sent -__version__ = sys.version[:3] +__version__ = '%d.%d' % sys.version_info[:2] _opener = None def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, diff --git a/Lib/xmlrpc/client.py b/Lib/xmlrpc/client.py --- a/Lib/xmlrpc/client.py +++ b/Lib/xmlrpc/client.py @@ -151,7 +151,7 @@ return s.replace(">", ">",) # used in User-Agent header sent -__version__ = sys.version[:3] +__version__ = '%d.%d' % sys.version_info[:2] # xmlrpc integer limits MAXINT = 2**31-1 diff --git a/Makefile.pre.in b/Makefile.pre.in --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -568,7 +568,7 @@ $(LINKCC) $(PY_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST) platform: $(BUILDPYTHON) pybuilddir.txt - $(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print(get_platform()+"-"+sys.version[0:3])' >platform + $(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print("%s-%d.%d" % (get_platform(), *sys.version_info[:2]))' >platform # Create build directory and generate the sysconfig build-time data there. # pybuilddir.txt contains the name of the build dir and is used for diff --git a/Python/importlib_external.h b/Python/importlib_external.h --- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -888,22 +888,23 @@ 87,105,110,100,111,119,115,82,101,103,105,115,116,114,121,70, 105,110,100,101,114,46,95,111,112,101,110,95,114,101,103,105, 115,116,114,121,99,2,0,0,0,0,0,0,0,6,0,0, - 0,16,0,0,0,67,0,0,0,115,143,0,0,0,124,0, + 0,16,0,0,0,67,0,0,0,115,147,0,0,0,124,0, 0,106,0,0,114,21,0,124,0,0,106,1,0,125,2,0, 110,9,0,124,0,0,106,2,0,125,2,0,124,2,0,106, - 3,0,100,1,0,124,1,0,100,2,0,116,4,0,106,5, - 0,100,0,0,100,3,0,133,2,0,25,131,0,2,125,3, - 0,121,47,0,124,0,0,106,6,0,124,3,0,131,1,0, - 143,25,0,125,4,0,116,7,0,106,8,0,124,4,0,100, - 4,0,131,2,0,125,5,0,87,100,0,0,81,82,88,87, - 110,22,0,4,116,9,0,107,10,0,114,138,0,1,1,1, - 100,0,0,83,89,110,1,0,88,124,5,0,83,41,5,78, - 114,119,0,0,0,90,11,115,121,115,95,118,101,114,115,105, - 111,110,114,80,0,0,0,114,30,0,0,0,41,10,218,11, - 68,69,66,85,71,95,66,85,73,76,68,218,18,82,69,71, - 73,83,84,82,89,95,75,69,89,95,68,69,66,85,71,218, - 12,82,69,71,73,83,84,82,89,95,75,69,89,114,47,0, - 0,0,114,7,0,0,0,218,7,118,101,114,115,105,111,110, + 3,0,100,1,0,124,1,0,100,2,0,100,3,0,116,4, + 0,106,5,0,100,0,0,100,4,0,133,2,0,25,22,131, + 0,2,125,3,0,121,47,0,124,0,0,106,6,0,124,3, + 0,131,1,0,143,25,0,125,4,0,116,7,0,106,8,0, + 124,4,0,100,5,0,131,2,0,125,5,0,87,100,0,0, + 81,82,88,87,110,22,0,4,116,9,0,107,10,0,114,142, + 0,1,1,1,100,0,0,83,89,110,1,0,88,124,5,0, + 83,41,6,78,114,119,0,0,0,90,11,115,121,115,95,118, + 101,114,115,105,111,110,122,5,37,100,46,37,100,114,56,0, + 0,0,114,30,0,0,0,41,10,218,11,68,69,66,85,71, + 95,66,85,73,76,68,218,18,82,69,71,73,83,84,82,89, + 95,75,69,89,95,68,69,66,85,71,218,12,82,69,71,73, + 83,84,82,89,95,75,69,89,114,47,0,0,0,114,7,0, + 0,0,218,12,118,101,114,115,105,111,110,95,105,110,102,111, 114,166,0,0,0,114,163,0,0,0,90,10,81,117,101,114, 121,86,97,108,117,101,114,40,0,0,0,41,6,114,164,0, 0,0,114,119,0,0,0,90,12,114,101,103,105,115,116,114, @@ -911,7 +912,7 @@ 218,8,102,105,108,101,112,97,116,104,114,4,0,0,0,114, 4,0,0,0,114,5,0,0,0,218,16,95,115,101,97,114, 99,104,95,114,101,103,105,115,116,114,121,77,2,0,0,115, - 22,0,0,0,0,2,9,1,12,2,9,1,15,1,22,1, + 22,0,0,0,0,2,9,1,12,2,9,1,15,1,26,1, 3,1,18,1,29,1,13,1,9,1,122,38,87,105,110,100, 111,119,115,82,101,103,105,115,116,114,121,70,105,110,100,101, 114,46,95,115,101,97,114,99,104,95,114,101,103,105,115,116, diff --git a/Tools/freeze/freeze.py b/Tools/freeze/freeze.py --- a/Tools/freeze/freeze.py +++ b/Tools/freeze/freeze.py @@ -218,7 +218,7 @@ ishome = os.path.exists(os.path.join(prefix, 'Python', 'ceval.c')) # locations derived from options - version = sys.version[:3] + version = '%d.%d' % sys.version_info[:2] flagged_version = version + sys.abiflags if win: extensions_c = 'frozen_extensions.c' diff --git a/Tools/scripts/nm2def.py b/Tools/scripts/nm2def.py --- a/Tools/scripts/nm2def.py +++ b/Tools/scripts/nm2def.py @@ -36,8 +36,8 @@ """ import os, sys -PYTHONLIB = 'libpython'+sys.version[:3]+'.a' -PC_PYTHONLIB = 'Python'+sys.version[0]+sys.version[2]+'.dll' +PYTHONLIB = 'libpython%d.%d.a' % sys.version_info[:2] +PC_PYTHONLIB = 'Python%d%d.dll' % sys.version_info[:2] NM = 'nm -p -g %s' # For Linux, use "nm -g %s" def symbols(lib=PYTHONLIB,types=('T','C','D')): diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -2226,7 +2226,7 @@ setup(# PyPI Metadata (PEP 301) name = "Python", version = sys.version.split()[0], - url = "http://www.python.org/%s" % sys.version[:3], + url = "http://www.python.org/%d.%d" % sys.version_info[:2], maintainer = "Guido van Rossum and the Python community", maintainer_email = "python-dev at python.org", description = "A high-level object-oriented programming language", -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 11 06:12:44 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 11 Feb 2016 11:12:44 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326325=3A_Added_test=2Esupport=2Echeck=5Fno=5Fre?= =?utf-8?q?source=5Fwarning=28=29_to_check_that?= Message-ID: <20160211111244.1566.70360@psf.io> https://hg.python.org/cpython/rev/faf676d8c054 changeset: 100225:faf676d8c054 parent: 100223:935d7804d1be parent: 100224:e9a4b30e3e43 user: Serhiy Storchaka date: Thu Feb 11 13:12:19 2016 +0200 summary: Issue #26325: Added test.support.check_no_resource_warning() to check that no ResourceWarning is emitted. files: Lib/test/support/__init__.py | 24 +++++++++++- Lib/test/test_asyncio/test_subprocess.py | 3 +- Lib/test/test_io.py | 12 +---- Lib/test/test_xml_etree.py | 10 +---- Misc/NEWS | 3 + 5 files changed, 32 insertions(+), 20 deletions(-) diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -102,7 +102,8 @@ # threads "threading_setup", "threading_cleanup", "reap_threads", "start_threads", # miscellaneous - "check_warnings", "EnvironmentVarGuard", "run_with_locale", "swap_item", + "check_warnings", "check_no_resource_warning", "EnvironmentVarGuard", + "run_with_locale", "swap_item", "swap_attr", "Matcher", "set_memlimit", "SuppressCrashReport", "sortdict", "run_with_tz", ] @@ -1149,6 +1150,27 @@ return _filterwarnings(filters, quiet) + at contextlib.contextmanager +def check_no_resource_warning(testcase): + """Context manager to check that no ResourceWarning is emitted. + + Usage: + + with check_no_resource_warning(self): + f = open(...) + ... + del f + + You must remove the object which may emit ResourceWarning before + the end of the context manager. + """ + with warnings.catch_warnings(record=True) as warns: + warnings.filterwarnings('always', category=ResourceWarning) + yield + gc_collect() + testcase.assertEqual(warns, []) + + class CleanImport(object): """Context manager to force import to return a new module reference. diff --git a/Lib/test/test_asyncio/test_subprocess.py b/Lib/test/test_asyncio/test_subprocess.py --- a/Lib/test/test_asyncio/test_subprocess.py +++ b/Lib/test/test_asyncio/test_subprocess.py @@ -427,10 +427,9 @@ create = asyncio.create_subprocess_exec(sys.executable, '-c', 'pass', loop=self.loop) - with warnings.catch_warnings(record=True) as warns: + with support.check_no_resource_warning(self): with self.assertRaises(exc): self.loop.run_until_complete(create) - self.assertEqual(warns, []) if sys.platform != 'win32': diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -681,18 +681,14 @@ f2.readline() def test_nonbuffered_textio(self): - with warnings.catch_warnings(record=True) as recorded: + with support.check_no_resource_warning(self): with self.assertRaises(ValueError): self.open(support.TESTFN, 'w', buffering=0) - support.gc_collect() - self.assertEqual(recorded, []) def test_invalid_newline(self): - with warnings.catch_warnings(record=True) as recorded: + with support.check_no_resource_warning(self): with self.assertRaises(ValueError): self.open(support.TESTFN, 'w', newline='invalid') - support.gc_collect() - self.assertEqual(recorded, []) class CIOTest(IOTest): @@ -3366,10 +3362,8 @@ # When using closefd=False, there's no warning r, w = os.pipe() fds += r, w - with warnings.catch_warnings(record=True) as recorded: + with support.check_no_resource_warning(self): open(r, *args, closefd=False, **kwargs) - support.gc_collect() - self.assertEqual(recorded, []) def test_warn_on_dealloc_fd(self): self._check_warn_on_dealloc_fd("rb", buffering=0) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -569,14 +569,11 @@ self.assertFalse(f.closed) self.assertEqual(str(cm.exception), "unknown event 'bogus'") - with warnings.catch_warnings(record=True) as w: - warnings.filterwarnings("always", category=ResourceWarning) + with support.check_no_resource_warning(self): with self.assertRaises(ValueError) as cm: iterparse(SIMPLE_XMLFILE, events) self.assertEqual(str(cm.exception), "unknown event 'bogus'") del cm - support.gc_collect() - self.assertEqual(w, []) source = io.BytesIO( b"\n" @@ -603,15 +600,12 @@ it = iterparse(TESTFN) action, elem = next(it) self.assertEqual((action, elem.tag), ('end', 'document')) - with warnings.catch_warnings(record=True) as w: - warnings.filterwarnings("always", category=ResourceWarning) + with support.check_no_resource_warning(self): with self.assertRaises(ET.ParseError) as cm: next(it) self.assertEqual(str(cm.exception), 'junk after document element: line 1, column 12') del cm, it - support.gc_collect() - self.assertEqual(w, []) def test_writefile(self): elem = ET.Element("tag") diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -673,6 +673,9 @@ Tests ----- +- Issue #26325: Added test.support.check_no_resource_warning() to check that + no ResourceWarning is emitted. + - Issue #25940: Changed test_ssl to use self-signed.pythontest.net. This avoids relying on svn.python.org, which recently changed root certificate. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 11 06:12:45 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 11 Feb 2016 11:12:45 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2MzI1?= =?utf-8?q?=3A_Added_test=2Esupport=2Echeck=5Fno=5Fresource=5Fwarning=28?= =?utf-8?q?=29_to_check_that?= Message-ID: <20160211111243.61976.6975@psf.io> https://hg.python.org/cpython/rev/e9a4b30e3e43 changeset: 100224:e9a4b30e3e43 branch: 3.5 parent: 100219:3940f38b0593 user: Serhiy Storchaka date: Thu Feb 11 13:11:44 2016 +0200 summary: Issue #26325: Added test.support.check_no_resource_warning() to check that no ResourceWarning is emitted. files: Lib/test/support/__init__.py | 24 +++++++++++- Lib/test/test_asyncio/test_subprocess.py | 3 +- Lib/test/test_io.py | 12 +---- Lib/test/test_xml_etree.py | 10 +---- Misc/NEWS | 3 + 5 files changed, 32 insertions(+), 20 deletions(-) diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -100,7 +100,8 @@ # threads "threading_setup", "threading_cleanup", "reap_threads", "start_threads", # miscellaneous - "check_warnings", "EnvironmentVarGuard", "run_with_locale", "swap_item", + "check_warnings", "check_no_resource_warning", "EnvironmentVarGuard", + "run_with_locale", "swap_item", "swap_attr", "Matcher", "set_memlimit", "SuppressCrashReport", "sortdict", "run_with_tz", ] @@ -1147,6 +1148,27 @@ return _filterwarnings(filters, quiet) + at contextlib.contextmanager +def check_no_resource_warning(testcase): + """Context manager to check that no ResourceWarning is emitted. + + Usage: + + with check_no_resource_warning(self): + f = open(...) + ... + del f + + You must remove the object which may emit ResourceWarning before + the end of the context manager. + """ + with warnings.catch_warnings(record=True) as warns: + warnings.filterwarnings('always', category=ResourceWarning) + yield + gc_collect() + testcase.assertEqual(warns, []) + + class CleanImport(object): """Context manager to force import to return a new module reference. diff --git a/Lib/test/test_asyncio/test_subprocess.py b/Lib/test/test_asyncio/test_subprocess.py --- a/Lib/test/test_asyncio/test_subprocess.py +++ b/Lib/test/test_asyncio/test_subprocess.py @@ -427,10 +427,9 @@ create = asyncio.create_subprocess_exec(sys.executable, '-c', 'pass', loop=self.loop) - with warnings.catch_warnings(record=True) as warns: + with support.check_no_resource_warning(self): with self.assertRaises(exc): self.loop.run_until_complete(create) - self.assertEqual(warns, []) if sys.platform != 'win32': diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -681,18 +681,14 @@ f2.readline() def test_nonbuffered_textio(self): - with warnings.catch_warnings(record=True) as recorded: + with support.check_no_resource_warning(self): with self.assertRaises(ValueError): self.open(support.TESTFN, 'w', buffering=0) - support.gc_collect() - self.assertEqual(recorded, []) def test_invalid_newline(self): - with warnings.catch_warnings(record=True) as recorded: + with support.check_no_resource_warning(self): with self.assertRaises(ValueError): self.open(support.TESTFN, 'w', newline='invalid') - support.gc_collect() - self.assertEqual(recorded, []) class CIOTest(IOTest): @@ -3366,10 +3362,8 @@ # When using closefd=False, there's no warning r, w = os.pipe() fds += r, w - with warnings.catch_warnings(record=True) as recorded: + with support.check_no_resource_warning(self): open(r, *args, closefd=False, **kwargs) - support.gc_collect() - self.assertEqual(recorded, []) def test_warn_on_dealloc_fd(self): self._check_warn_on_dealloc_fd("rb", buffering=0) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -567,14 +567,11 @@ self.assertFalse(f.closed) self.assertEqual(str(cm.exception), "unknown event 'bogus'") - with warnings.catch_warnings(record=True) as w: - warnings.filterwarnings("always", category=ResourceWarning) + with support.check_no_resource_warning(self): with self.assertRaises(ValueError) as cm: iterparse(SIMPLE_XMLFILE, events) self.assertEqual(str(cm.exception), "unknown event 'bogus'") del cm - support.gc_collect() - self.assertEqual(w, []) source = io.BytesIO( b"\n" @@ -601,15 +598,12 @@ it = iterparse(TESTFN) action, elem = next(it) self.assertEqual((action, elem.tag), ('end', 'document')) - with warnings.catch_warnings(record=True) as w: - warnings.filterwarnings("always", category=ResourceWarning) + with support.check_no_resource_warning(self): with self.assertRaises(ET.ParseError) as cm: next(it) self.assertEqual(str(cm.exception), 'junk after document element: line 1, column 12') del cm, it - support.gc_collect() - self.assertEqual(w, []) def test_writefile(self): elem = ET.Element("tag") diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -216,6 +216,9 @@ Tests ----- +- Issue #26325: Added test.support.check_no_resource_warning() to check that + no ResourceWarning is emitted. + - Issue #25940: Changed test_ssl to use self-signed.pythontest.net. This avoids relying on svn.python.org, which recently changed root certificate. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 11 06:21:51 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 11 Feb 2016 11:21:51 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325994=3A_Added_th?= =?utf-8?q?e_close=28=29_method_and_the_support_of_the_context_manager?= Message-ID: <20160211112150.68416.93021@psf.io> https://hg.python.org/cpython/rev/f98ed0616d07 changeset: 100226:f98ed0616d07 user: Serhiy Storchaka date: Thu Feb 11 13:21:30 2016 +0200 summary: Issue #25994: Added the close() method and the support of the context manager protocol for the os.scandir() iterator. files: Doc/library/os.rst | 27 ++++++++- Doc/whatsnew/3.6.rst | 11 +++ Lib/os.py | 92 ++++++++++++++++++------------ Lib/test/test_os.py | 52 +++++++++++++++++ Misc/NEWS | 3 + Modules/posixmodule.c | 73 ++++++++++++++++++++++-- 6 files changed, 210 insertions(+), 48 deletions(-) diff --git a/Doc/library/os.rst b/Doc/library/os.rst --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -1891,14 +1891,29 @@ :attr:`~DirEntry.path` attributes of each :class:`DirEntry` will be of the same type as *path*. + The :func:`scandir` iterator supports the :term:`context manager` protocol + and has the following method: + + .. method:: scandir.close() + + Close the iterator and free acquired resources. + + This is called automatically when the iterator is exhausted or garbage + collected, or when an error happens during iterating. However it + is advisable to call it explicitly or use the :keyword:`with` + statement. + + .. versionadded:: 3.6 + The following example shows a simple use of :func:`scandir` to display all the files (excluding directories) in the given *path* that don't start with ``'.'``. The ``entry.is_file()`` call will generally not make an additional system call:: - for entry in os.scandir(path): - if not entry.name.startswith('.') and entry.is_file(): - print(entry.name) + with os.scandir(path) as it: + for entry in it: + if not entry.name.startswith('.') and entry.is_file(): + print(entry.name) .. note:: @@ -1914,6 +1929,12 @@ .. versionadded:: 3.5 + .. versionadded:: 3.6 + Added support for the :term:`context manager` protocol and the + :func:`~scandir.close()` method. If a :func:`scandir` iterator is neither + exhausted nor explicitly closed a :exc:`ResourceWarning` will be emitted + in its destructor. + .. class:: DirEntry diff --git a/Doc/whatsnew/3.6.rst b/Doc/whatsnew/3.6.rst --- a/Doc/whatsnew/3.6.rst +++ b/Doc/whatsnew/3.6.rst @@ -104,6 +104,17 @@ (Contributed by Ashley Anderson in :issue:`12006`.) +os +-- + +A new :meth:`~os.scandir.close` method allows explicitly closing a +:func:`~os.scandir` iterator. The :func:`~os.scandir` iterator now +supports the :term:`context manager` protocol. If a :func:`scandir` +iterator is neither exhausted nor explicitly closed a :exc:`ResourceWarning` +will be emitted in its destructor. +(Contributed by Serhiy Storchaka in :issue:`25994`.) + + pickle ------ diff --git a/Lib/os.py b/Lib/os.py --- a/Lib/os.py +++ b/Lib/os.py @@ -374,46 +374,47 @@ onerror(error) return - while True: - try: + with scandir_it: + while True: try: - entry = next(scandir_it) - except StopIteration: - break - except OSError as error: - if onerror is not None: - onerror(error) - return + try: + entry = next(scandir_it) + except StopIteration: + break + except OSError as error: + if onerror is not None: + onerror(error) + return - try: - is_dir = entry.is_dir() - except OSError: - # If is_dir() raises an OSError, consider that the entry is not - # a directory, same behaviour than os.path.isdir(). - is_dir = False + try: + is_dir = entry.is_dir() + except OSError: + # If is_dir() raises an OSError, consider that the entry is not + # a directory, same behaviour than os.path.isdir(). + is_dir = False - if is_dir: - dirs.append(entry.name) - else: - nondirs.append(entry.name) + if is_dir: + dirs.append(entry.name) + else: + nondirs.append(entry.name) - if not topdown and is_dir: - # Bottom-up: recurse into sub-directory, but exclude symlinks to - # directories if followlinks is False - if followlinks: - walk_into = True - else: - try: - is_symlink = entry.is_symlink() - except OSError: - # If is_symlink() raises an OSError, consider that the - # entry is not a symbolic link, same behaviour than - # os.path.islink(). - is_symlink = False - walk_into = not is_symlink + if not topdown and is_dir: + # Bottom-up: recurse into sub-directory, but exclude symlinks to + # directories if followlinks is False + if followlinks: + walk_into = True + else: + try: + is_symlink = entry.is_symlink() + except OSError: + # If is_symlink() raises an OSError, consider that the + # entry is not a symbolic link, same behaviour than + # os.path.islink(). + is_symlink = False + walk_into = not is_symlink - if walk_into: - yield from walk(entry.path, topdown, onerror, followlinks) + if walk_into: + yield from walk(entry.path, topdown, onerror, followlinks) # Yield before recursion if going top down if topdown: @@ -437,15 +438,30 @@ def __init__(self, dir, name): self.name = name self.path = path.join(dir, name) + def is_dir(self): return path.isdir(self.path) + def is_symlink(self): return path.islink(self.path) -def _dummy_scandir(dir): +class _dummy_scandir: # listdir-based implementation for bytes patches on Windows - for name in listdir(dir): - yield _DummyDirEntry(dir, name) + def __init__(self, dir): + self.dir = dir + self.it = iter(listdir(dir)) + + def __iter__(self): + return self + + def __next__(self): + return _DummyDirEntry(self.dir, next(self.it)) + + def __enter__(self): + return self + + def __exit__(self, *args): + self.it = iter(()) __all__.append("walk") diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -2808,6 +2808,8 @@ class TestScandir(unittest.TestCase): + check_no_resource_warning = support.check_no_resource_warning + def setUp(self): self.path = os.path.realpath(support.TESTFN) self.addCleanup(support.rmtree, self.path) @@ -3030,6 +3032,56 @@ for obj in [1234, 1.234, {}, []]: self.assertRaises(TypeError, os.scandir, obj) + def test_close(self): + self.create_file("file.txt") + self.create_file("file2.txt") + iterator = os.scandir(self.path) + next(iterator) + iterator.close() + # multiple closes + iterator.close() + with self.check_no_resource_warning(): + del iterator + + def test_context_manager(self): + self.create_file("file.txt") + self.create_file("file2.txt") + with os.scandir(self.path) as iterator: + next(iterator) + with self.check_no_resource_warning(): + del iterator + + def test_context_manager_close(self): + self.create_file("file.txt") + self.create_file("file2.txt") + with os.scandir(self.path) as iterator: + next(iterator) + iterator.close() + + def test_context_manager_exception(self): + self.create_file("file.txt") + self.create_file("file2.txt") + with self.assertRaises(ZeroDivisionError): + with os.scandir(self.path) as iterator: + next(iterator) + 1/0 + with self.check_no_resource_warning(): + del iterator + + def test_resource_warning(self): + self.create_file("file.txt") + self.create_file("file2.txt") + iterator = os.scandir(self.path) + next(iterator) + with self.assertWarns(ResourceWarning): + del iterator + support.gc_collect() + # exhausted iterator + iterator = os.scandir(self.path) + list(iterator) + with self.check_no_resource_warning(): + del iterator + if __name__ == "__main__": unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -179,6 +179,9 @@ Library ------- +- Issue #25994: Added the close() method and the support of the context manager + protocol for the os.scandir() iterator. + - Issue #23992: multiprocessing: make MapResult not fail-fast upon exception. - Issue #26243: Support keyword arguments to zlib.compress(). Patch by Aviv diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -11937,8 +11937,14 @@ #ifdef MS_WINDOWS +static int +ScandirIterator_is_closed(ScandirIterator *iterator) +{ + return iterator->handle == INVALID_HANDLE_VALUE; +} + static void -ScandirIterator_close(ScandirIterator *iterator) +ScandirIterator_closedir(ScandirIterator *iterator) { if (iterator->handle == INVALID_HANDLE_VALUE) return; @@ -11956,7 +11962,7 @@ BOOL success; PyObject *entry; - /* Happens if the iterator is iterated twice */ + /* Happens if the iterator is iterated twice, or closed explicitly */ if (iterator->handle == INVALID_HANDLE_VALUE) return NULL; @@ -11987,14 +11993,20 @@ } /* Error or no more files */ - ScandirIterator_close(iterator); + ScandirIterator_closedir(iterator); return NULL; } #else /* POSIX */ +static int +ScandirIterator_is_closed(ScandirIterator *iterator) +{ + return !iterator->dirp; +} + static void -ScandirIterator_close(ScandirIterator *iterator) +ScandirIterator_closedir(ScandirIterator *iterator) { if (!iterator->dirp) return; @@ -12014,7 +12026,7 @@ int is_dot; PyObject *entry; - /* Happens if the iterator is iterated twice */ + /* Happens if the iterator is iterated twice, or closed explicitly */ if (!iterator->dirp) return NULL; @@ -12051,21 +12063,67 @@ } /* Error or no more files */ - ScandirIterator_close(iterator); + ScandirIterator_closedir(iterator); return NULL; } #endif +static PyObject * +ScandirIterator_close(ScandirIterator *self, PyObject *args) +{ + ScandirIterator_closedir(self); + Py_RETURN_NONE; +} + +static PyObject * +ScandirIterator_enter(PyObject *self, PyObject *args) +{ + Py_INCREF(self); + return self; +} + +static PyObject * +ScandirIterator_exit(ScandirIterator *self, PyObject *args) +{ + ScandirIterator_closedir(self); + Py_RETURN_NONE; +} + static void ScandirIterator_dealloc(ScandirIterator *iterator) { - ScandirIterator_close(iterator); + if (!ScandirIterator_is_closed(iterator)) { + PyObject *exc, *val, *tb; + Py_ssize_t old_refcount = Py_REFCNT(iterator); + /* Py_INCREF/Py_DECREF cannot be used, because the refcount is + * likely zero, Py_DECREF would call again the destructor. + */ + ++Py_REFCNT(iterator); + PyErr_Fetch(&exc, &val, &tb); + if (PyErr_WarnFormat(PyExc_ResourceWarning, 1, + "unclosed scandir iterator %R", iterator)) { + /* Spurious errors can appear at shutdown */ + if (PyErr_ExceptionMatches(PyExc_Warning)) + PyErr_WriteUnraisable((PyObject *) iterator); + } + PyErr_Restore(exc, val, tb); + Py_REFCNT(iterator) = old_refcount; + + ScandirIterator_closedir(iterator); + } Py_XDECREF(iterator->path.object); path_cleanup(&iterator->path); Py_TYPE(iterator)->tp_free((PyObject *)iterator); } +static PyMethodDef ScandirIterator_methods[] = { + {"__enter__", (PyCFunction)ScandirIterator_enter, METH_NOARGS}, + {"__exit__", (PyCFunction)ScandirIterator_exit, METH_VARARGS}, + {"close", (PyCFunction)ScandirIterator_close, METH_NOARGS}, + {NULL} +}; + static PyTypeObject ScandirIteratorType = { PyVarObject_HEAD_INIT(NULL, 0) MODNAME ".ScandirIterator", /* tp_name */ @@ -12095,6 +12153,7 @@ 0, /* tp_weaklistoffset */ PyObject_SelfIter, /* tp_iter */ (iternextfunc)ScandirIterator_iternext, /* tp_iternext */ + ScandirIterator_methods, /* tp_methods */ }; static PyObject * -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 11 06:32:16 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 11 Feb 2016 11:32:16 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1OTk1?= =?utf-8?q?=3A_os=2Ewalk=28=29_no_longer_uses_FDs_proportional_to_the_tree?= =?utf-8?q?_depth=2E?= Message-ID: <20160211113216.2635.15926@psf.io> https://hg.python.org/cpython/rev/e951d76f1945 changeset: 100227:e951d76f1945 branch: 3.5 parent: 100224:e9a4b30e3e43 user: Serhiy Storchaka date: Thu Feb 11 13:29:28 2016 +0200 summary: Issue #25995: os.walk() no longer uses FDs proportional to the tree depth. files: Lib/os.py | 13 ++----------- Misc/NEWS | 2 ++ 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/Lib/os.py b/Lib/os.py --- a/Lib/os.py +++ b/Lib/os.py @@ -369,22 +369,13 @@ # Note that scandir is global in this module due # to earlier import-*. scandir_it = scandir(top) + entries = list(scandir(top)) except OSError as error: if onerror is not None: onerror(error) return - while True: - try: - try: - entry = next(scandir_it) - except StopIteration: - break - except OSError as error: - if onerror is not None: - onerror(error) - return - + for entry in entries: try: is_dir = entry.is_dir() except OSError: diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -73,6 +73,8 @@ Library ------- +- Issue #25995: os.walk() no longer uses FDs proportional to the tree depth. + - Issue #26117: The os.scandir() iterator now closes file descriptor not only when the iteration is finished, but when it was failed with error. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 11 06:32:18 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 11 Feb 2016 11:32:18 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325995=3A_os=2Ewal?= =?utf-8?q?k=28=29_no_longer_uses_FDs_proportional_to_the_tree_depth=2E?= Message-ID: <20160211113216.40064.48477@psf.io> https://hg.python.org/cpython/rev/6197a09a56b1 changeset: 100228:6197a09a56b1 parent: 100226:f98ed0616d07 user: Serhiy Storchaka date: Thu Feb 11 13:31:00 2016 +0200 summary: Issue #25995: os.walk() no longer uses FDs proportional to the tree depth. Different solution from 3.5. files: Lib/os.py | 6 +++++- Misc/NEWS | 2 ++ 2 files changed, 7 insertions(+), 1 deletions(-) diff --git a/Lib/os.py b/Lib/os.py --- a/Lib/os.py +++ b/Lib/os.py @@ -356,6 +356,7 @@ dirs = [] nondirs = [] + walk_dirs = [] # We may not have read permission for top, in which case we can't # get a list of the files the directory contains. os.walk @@ -414,7 +415,7 @@ walk_into = not is_symlink if walk_into: - yield from walk(entry.path, topdown, onerror, followlinks) + walk_dirs.append(entry.path) # Yield before recursion if going top down if topdown: @@ -431,6 +432,9 @@ if followlinks or not islink(new_path): yield from walk(new_path, topdown, onerror, followlinks) else: + # Recurse into sub-directories + for new_path in walk_dirs: + yield from walk(new_path, topdown, onerror, followlinks) # Yield after recursion if going bottom up yield top, dirs, nondirs diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -179,6 +179,8 @@ Library ------- +- Issue #25995: os.walk() no longer uses FDs proportional to the tree depth. + - Issue #25994: Added the close() method and the support of the context manager protocol for the os.scandir() iterator. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 11 06:32:22 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 11 Feb 2016 11:32:22 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Null_merge?= Message-ID: <20160211113222.16560.14250@psf.io> https://hg.python.org/cpython/rev/733a902ac816 changeset: 100229:733a902ac816 parent: 100228:6197a09a56b1 parent: 100227:e951d76f1945 user: Serhiy Storchaka date: Thu Feb 11 13:31:56 2016 +0200 summary: Null merge files: -- Repository URL: https://hg.python.org/cpython From lp_benchmark_robot at intel.com Thu Feb 11 07:36:58 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Thu, 11 Feb 2016 12:36:58 +0000 Subject: [Python-checkins] UGLY Benchmark Results for Python Default 2016-02-11 Message-ID: Results for project Python default, build date 2016-02-11 03:07:28 +0000 commit: 1ba0deb52223 previous commit: dc758f51b8f5 revision date: 2016-02-10 22:58:18 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.31% -1.06% 8.14% 16.13% :-| pybench 0.15% -0.08% 0.57% 5.18% :-( regex_v8 2.67% 1.54% -4.40% 3.74% :-| nbody 0.19% -0.40% -0.70% 7.22% :-| json_dump_v2 0.21% -1.17% -1.96% 11.30% :-| normal_startup 0.78% -0.35% 0.40% 5.18% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/ugly-benchmark-results-for-python-default-2016-02-11/ Note: Benchmark results are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Thu Feb 11 07:37:47 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Thu, 11 Feb 2016 12:37:47 +0000 Subject: [Python-checkins] UGLY Benchmark Results for Python 2.7 2016-02-11 Message-ID: Results for project Python 2.7, build date 2016-02-11 03:59:02 +0000 commit: 5715a6d9ff12 previous commit: 8c7a8c7a02b9 revision date: 2016-02-10 12:44:29 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dc from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.12% 1.72% 4.51% 4.24% :-) pybench 0.11% 0.32% 6.25% 3.97% :-( regex_v8 0.78% -0.28% -2.60% 10.92% :-) nbody 0.26% -2.74% 4.43% 5.19% :-) json_dump_v2 0.18% -0.86% 4.44% 10.07% :-( normal_startup 1.87% 0.33% -5.55% 2.04% :-| ssbench 0.21% -0.64% 1.54% 2.41% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/ugly-benchmark-results-for-python-2-7-2016-02-11/ Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Thu Feb 11 10:26:39 2016 From: python-checkins at python.org (yury.selivanov) Date: Thu, 11 Feb 2016 15:26:39 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issues_=2326289_and_=23263?= =?utf-8?q?15=3A_Optimize_floor/modulo_div_for_single-digit_longs?= Message-ID: <20160211152630.1539.12769@psf.io> https://hg.python.org/cpython/rev/37bacf3fa1f5 changeset: 100230:37bacf3fa1f5 user: Yury Selivanov date: Thu Feb 11 10:26:27 2016 -0500 summary: Issues #26289 and #26315: Optimize floor/modulo div for single-digit longs Microbenchmarks show 2-2.5x improvement. Built-in 'divmod' function is now also ~10% faster. -m timeit -s "x=22331" "x//2;x//-3;x//4;x//5;x//-6;x//7;x//8;x//-99;x//100;" with patch: 0.321 without patch: 0.633 -m timeit -s "x=22331" "x%2;x%3;x%-4;x%5;x%6;x%-7;x%8;x%99;x%-100;" with patch: 0.224 without patch: 0.66 Big thanks to Serhiy Storchaka, Mark Dickinson and Victor Stinner for thorow code reviews and algorithms improvements. files: Lib/test/test_long.py | 33 ++++++++++++ Misc/NEWS | 4 + Objects/longobject.c | 79 +++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_long.py b/Lib/test/test_long.py --- a/Lib/test/test_long.py +++ b/Lib/test/test_long.py @@ -689,6 +689,20 @@ self.assertRaises(OverflowError, int, float('-inf')) self.assertRaises(ValueError, int, float('nan')) + def test_mod_division(self): + with self.assertRaises(ZeroDivisionError): + _ = 1 % 0 + + self.assertEqual(13 % 10, 3) + self.assertEqual(-13 % 10, 7) + self.assertEqual(13 % -10, -7) + self.assertEqual(-13 % -10, -3) + + self.assertEqual(12 % 4, 0) + self.assertEqual(-12 % 4, 0) + self.assertEqual(12 % -4, 0) + self.assertEqual(-12 % -4, 0) + def test_true_division(self): huge = 1 << 40000 mhuge = -huge @@ -723,6 +737,25 @@ for zero in ["huge / 0", "mhuge / 0"]: self.assertRaises(ZeroDivisionError, eval, zero, namespace) + def test_floordiv(self): + with self.assertRaises(ZeroDivisionError): + _ = 1 // 0 + + self.assertEqual(2 // 3, 0) + self.assertEqual(2 // -3, -1) + self.assertEqual(-2 // 3, -1) + self.assertEqual(-2 // -3, 0) + + self.assertEqual(-11 // -3, 3) + self.assertEqual(-11 // 3, -4) + self.assertEqual(11 // -3, -4) + self.assertEqual(11 // 3, 3) + + self.assertEqual(-12 // -3, 4) + self.assertEqual(-12 // 3, -4) + self.assertEqual(12 // -3, -4) + self.assertEqual(12 // 3, 4) + def check_truediv(self, a, b, skip_small=True): """Verify that the result of a/b is correctly rounded, by comparing it with a pure Python implementation of correctly diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -176,6 +176,10 @@ - Issue #26288: Optimize PyLong_AsDouble. +- Issues #26289 and #26315: Optimize floor and modulo division for + single-digit longs. Microbenchmarks show 2-2.5x improvement. Built-in + 'divmod' function is now also ~10% faster. + Library ------- diff --git a/Objects/longobject.c b/Objects/longobject.c --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -3502,6 +3502,52 @@ return (PyObject *)z; } +/* Fast modulo division for single-digit longs. */ +static PyObject * +fast_mod(PyLongObject *a, PyLongObject *b) +{ + sdigit left = a->ob_digit[0]; + sdigit right = b->ob_digit[0]; + sdigit mod; + + assert(Py_ABS(Py_SIZE(a)) == 1); + assert(Py_ABS(Py_SIZE(b)) == 1); + + if (Py_SIZE(a) == Py_SIZE(b)) { + /* 'a' and 'b' have the same sign. */ + mod = left % right; + } + else { + /* Either 'a' or 'b' is negative. */ + mod = right - 1 - (left - 1) % right; + } + + return PyLong_FromLong(mod * Py_SIZE(b)); +} + +/* Fast floor division for single-digit longs. */ +static PyObject * +fast_floor_div(PyLongObject *a, PyLongObject *b) +{ + sdigit left = a->ob_digit[0]; + sdigit right = b->ob_digit[0]; + sdigit div; + + assert(Py_ABS(Py_SIZE(a)) == 1); + assert(Py_ABS(Py_SIZE(b)) == 1); + + if (Py_SIZE(a) == Py_SIZE(b)) { + /* 'a' and 'b' have the same sign. */ + div = left / right; + } + else { + /* Either 'a' or 'b' is negative. */ + div = -1 - (left - 1) / right; + } + + return PyLong_FromLong(div); +} + /* The / and % operators are now defined in terms of divmod(). The expression a mod b has the value a - b*floor(a/b). The long_divrem function gives the remainder after division of @@ -3529,6 +3575,30 @@ { PyLongObject *div, *mod; + if (Py_ABS(Py_SIZE(v)) == 1 && Py_ABS(Py_SIZE(w)) == 1) { + /* Fast path for single-digit longs */ + div = NULL; + if (pdiv != NULL) { + div = (PyLongObject *)fast_floor_div(v, w); + if (div == NULL) { + return -1; + } + } + if (pmod != NULL) { + mod = (PyLongObject *)fast_mod(v, w); + if (mod == NULL) { + Py_XDECREF(div); + return -1; + } + *pmod = mod; + } + if (pdiv != NULL) { + /* We only want to set `*pdiv` when `*pmod` is + set successfully. */ + *pdiv = div; + } + return 0; + } if (long_divrem(v, w, &div, &mod) < 0) return -1; if ((Py_SIZE(mod) < 0 && Py_SIZE(w) > 0) || @@ -3573,6 +3643,11 @@ PyLongObject *div; CHECK_BINOP(a, b); + + if (Py_ABS(Py_SIZE(a)) == 1 && Py_ABS(Py_SIZE(b)) == 1) { + return fast_floor_div((PyLongObject*)a, (PyLongObject*)b); + } + if (l_divmod((PyLongObject*)a, (PyLongObject*)b, &div, NULL) < 0) div = NULL; return (PyObject *)div; @@ -3848,6 +3923,10 @@ CHECK_BINOP(a, b); + if (Py_ABS(Py_SIZE(a)) == 1 && Py_ABS(Py_SIZE(b)) == 1) { + return fast_mod((PyLongObject*)a, (PyLongObject*)b); + } + if (l_divmod((PyLongObject*)a, (PyLongObject*)b, NULL, &mod) < 0) mod = NULL; return (PyObject *)mod; -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 11 11:59:12 2016 From: python-checkins at python.org (georg.brandl) Date: Thu, 11 Feb 2016 16:59:12 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Clarify_what_the_underscores_?= =?utf-8?q?actually_mean=2E?= Message-ID: <20160211165813.61982.90419@psf.io> https://hg.python.org/peps/rev/0bc422eb7f5a changeset: 6227:0bc422eb7f5a user: Georg Brandl date: Thu Feb 11 17:58:09 2016 +0100 summary: Clarify what the underscores actually mean. files: pep-0515.txt | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pep-0515.txt b/pep-0515.txt --- a/pep-0515.txt +++ b/pep-0515.txt @@ -13,8 +13,9 @@ Abstract and Rationale ====================== -This PEP proposes to extend Python's syntax so that underscores can be used in -integral, floating-point and complex number literals. +This PEP proposes to extend Python's syntax so that underscores can be used as +visual separators for digit grouping purposes in integral, floating-point and +complex number literals. This is a common feature of other modern languages, and can aid readability of long literals, or literals whose value should clearly separate into parts, such @@ -39,7 +40,8 @@ ============= The current proposal is to allow one or more consecutive underscores following -digits and base specifiers in numeric literals. +digits and base specifiers in numeric literals. The underscores have no +semantic meaning, and literals are parsed as if the underscores were absent. The production list for integer literals would therefore look like this:: @@ -47,9 +49,9 @@ decimalinteger: nonzerodigit (digit | "_")* | "0" ("0" | "_")* nonzerodigit: "1"..."9" digit: "0"..."9" - octinteger: "0" ("o" | "O") (octdigit | "_")* - hexinteger: "0" ("x" | "X") (hexdigit | "_")* - bininteger: "0" ("b" | "B") (bindigit | "_")* + octinteger: "0" ("o" | "O") "_"* octdigit (octdigit | "_")* + hexinteger: "0" ("x" | "X") "_"* hexdigit (hexdigit | "_")* + bininteger: "0" ("b" | "B") "_"* bindigit (bindigit | "_")* octdigit: "0"..."7" hexdigit: digit | "a"..."f" | "A"..."F" bindigit: "0" | "1" -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Thu Feb 11 12:24:42 2016 From: python-checkins at python.org (georg.brandl) Date: Thu, 11 Feb 2016 17:24:42 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy4zKTogSXNzdWUgIzI1NzA5?= =?utf-8?q?=3A_Fixed_problem_with_in-place_string_concatenation_and_utf-8_?= =?utf-8?q?cache=2E?= Message-ID: <20160211172333.6671.37183@psf.io> https://hg.python.org/cpython/rev/b9c8f1c80f47 changeset: 100231:b9c8f1c80f47 branch: 3.3 parent: 99898:c5cae7366835 user: Serhiy Storchaka date: Thu Dec 03 01:02:03 2015 +0200 summary: Issue #25709: Fixed problem with in-place string concatenation and utf-8 cache. files: Lib/test/test_unicode.py | 17 +++++++++++++++++ Misc/NEWS | 5 +++++ Objects/unicodeobject.c | 5 +++++ 3 files changed, 27 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -2303,6 +2303,23 @@ self.assertNotEqual(abc, abcdef) self.assertEqual(abcdef.decode('unicode_internal'), text) + @support.cpython_only + def test_pep393_utf8_caching_bug(self): + # Issue #25709: Problem with string concatenation and utf-8 cache + from _testcapi import getargs_s_hash + for k in 0x24, 0xa4, 0x20ac, 0x1f40d: + s = '' + for i in range(5): + # Due to CPython specific optimization the 's' string can be + # resized in-place. + s += chr(k) + # Parsing with the "s#" format code calls indirectly + # PyUnicode_AsUTF8AndSize() which creates the UTF-8 + # encoded string cached in the Unicode object. + self.assertEqual(getargs_s_hash(s), chr(k).encode() * (i + 1)) + # Check that the second call returns the same result + self.assertEqual(getargs_s_hash(s), chr(k).encode() * (i + 1)) + class StringModuleTest(unittest.TestCase): def test_formatter_parser(self): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,8 +10,13 @@ Core and Builtins ----------------- +- Issue #25709: Fixed problem with in-place string concatenation and utf-8 cache. + - Issue #24407: Fix crash when dict is mutated while being updated. +- Issue #24097: Fixed crash in object.__reduce__() if slot name is freed inside + __getattr__. + - Issue #24096: Make warnings.warn_explicit more robust against mutation of the warnings.filters list. diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -679,6 +679,11 @@ } new_size = (struct_size + (length + 1) * char_size); + if (_PyUnicode_HAS_UTF8_MEMORY(unicode)) { + PyObject_DEL(_PyUnicode_UTF8(unicode)); + _PyUnicode_UTF8(unicode) = NULL; + _PyUnicode_UTF8_LENGTH(unicode) = 0; + } _Py_DEC_REFTOTAL; _Py_ForgetReference(unicode); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 11 12:34:10 2016 From: python-checkins at python.org (georg.brandl) Date: Thu, 11 Feb 2016 17:34:10 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Update_schedules=2E?= Message-ID: <20160211173409.19993.108@psf.io> https://hg.python.org/peps/rev/ffe96fb0abea changeset: 6228:ffe96fb0abea user: Georg Brandl date: Thu Feb 11 18:34:06 2016 +0100 summary: Update schedules. files: pep-0392.txt | 6 ++++++ pep-0398.txt | 6 ++++++ 2 files changed, 12 insertions(+), 0 deletions(-) diff --git a/pep-0392.txt b/pep-0392.txt --- a/pep-0392.txt +++ b/pep-0392.txt @@ -103,6 +103,12 @@ - 3.2.6 candidate 1 (source-only release): October 4, 2014 - 3.2.6 final (source-only release): October 11, 2014 +3.2.7 schedule +-------------- + +- 3.2.7 candidate 1 (source-only release): February 20, 2016 +- 3.2.7 final (source-only release): February 27, 2016 + Features for 3.2 ================ diff --git a/pep-0398.txt b/pep-0398.txt --- a/pep-0398.txt +++ b/pep-0398.txt @@ -107,6 +107,12 @@ - 3.3.6 candidate 1 (source-only release): October 4, 2014 - 3.3.6 final (source-only release): October 11, 2014 +3.3.7 schedule +-------------- + +- 3.3.7 candidate 1 (source-only release): February 20, 2016 +- 3.3.7 final (source-only release): February 27, 2016 + Features for 3.3 ================ -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Thu Feb 11 15:08:38 2016 From: python-checkins at python.org (georg.brandl) Date: Thu, 11 Feb 2016 20:08:38 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Minor_nit=2E?= Message-ID: <20160211200838.11219.90778@psf.io> https://hg.python.org/peps/rev/e8436e149402 changeset: 6229:e8436e149402 user: Georg Brandl date: Thu Feb 11 21:08:20 2016 +0100 summary: Minor nit. files: pep-0515.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/pep-0515.txt b/pep-0515.txt --- a/pep-0515.txt +++ b/pep-0515.txt @@ -29,7 +29,7 @@ # grouping hexadecimal addresses by words addr = 0xDEAD_BEEF - # grouping bits into bytes in a binary literal + # grouping bits into nibbles in a binary literal flags = 0b_0011_1111_0100_1110 # making the literal suffix stand out more -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Thu Feb 11 22:11:17 2016 From: python-checkins at python.org (brett.cannon) Date: Fri, 12 Feb 2016 03:11:17 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_List_Senthil_as_in_charge_of_?= =?utf-8?q?figuring_out_how_to_convert_repos?= Message-ID: <20160212031115.85136.5070@psf.io> https://hg.python.org/peps/rev/d5e8e3395a46 changeset: 6230:d5e8e3395a46 user: Brett Cannon date: Thu Feb 11 19:11:13 2016 -0800 summary: List Senthil as in charge of figuring out how to convert repos files: pep-0512.txt | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/pep-0512.txt b/pep-0512.txt --- a/pep-0512.txt +++ b/pep-0512.txt @@ -508,13 +508,16 @@ * Not started - `Create a 'python-dev' team`_ - - `Define commands to move a Mercurial repository to Git`_ + - `Adding GitHub username support to bugs.python.org`_ * In progress - `A bot to enforce CLA signing`_: https://github.com/brettcannon/knights-who-say-ni (Brett Cannon) + - `Define commands to move a Mercurial repository to Git`_: + https://github.com/orsenthil/cpython-hg-to-git (Senthil Kumaran) + * Completed - None -- Repository URL: https://hg.python.org/peps From solipsis at pitrou.net Fri Feb 12 04:45:12 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Fri, 12 Feb 2016 09:45:12 +0000 Subject: [Python-checkins] Daily reference leaks (37bacf3fa1f5): sum=4 Message-ID: <20160212094512.5764.46541@psf.io> results for 37bacf3fa1f5 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/refloge59CLW', '--timeout', '7200'] From lp_benchmark_robot at intel.com Fri Feb 12 07:27:31 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Fri, 12 Feb 2016 12:27:31 +0000 Subject: [Python-checkins] UGLY Benchmark Results for Python Default 2016-02-12 Message-ID: Results for project Python default, build date 2016-02-12 03:08:08 +0000 commit: 37bacf3fa1f5 previous commit: 1ba0deb52223 revision date: 2016-02-11 15:26:27 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.22% 0.77% 8.85% 15.87% :-| pybench 0.12% -0.00% 0.57% 4.97% :-( regex_v8 3.07% -0.86% -5.30% 4.83% :-( nbody 0.19% -1.36% -2.07% 9.80% :-| json_dump_v2 0.19% 1.08% -0.85% 10.70% :-| normal_startup 0.92% -0.34% 0.26% 5.39% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/ugly-benchmark-results-for-python-default-2016-02-12/ Note: Benchmark results are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Fri Feb 12 07:29:35 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Fri, 12 Feb 2016 12:29:35 +0000 Subject: [Python-checkins] UGLY Benchmark Results for Python 2.7 2016-02-12 Message-ID: No new revisions. Here are the previous results: Results for project Python 2.7, build date 2016-02-12 03:59:30 +0000 commit: 5715a6d9ff12 previous commit: 8c7a8c7a02b9 revision date: 2016-02-10 12:44:29 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dc from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.12% 1.72% 4.51% 4.24% :-) pybench 0.11% 0.32% 6.25% 3.97% :-( regex_v8 0.78% -0.28% -2.60% 10.92% :-) nbody 0.26% -2.74% 4.43% 5.19% :-) json_dump_v2 0.18% -0.86% 4.44% 10.07% :-( normal_startup 1.87% 0.33% -5.55% 2.04% :-| ssbench 0.21% -0.64% 1.54% 2.41% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/ugly-benchmark-results-for-python-2-7-2016-02-12/ Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Fri Feb 12 17:39:32 2016 From: python-checkins at python.org (charles-francois.natali) Date: Fri, 12 Feb 2016 22:39:32 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI0MzAz?= =?utf-8?q?=3A_Fix_random_EEXIST_upon_multiprocessing_semaphores_creation_?= =?utf-8?q?with?= Message-ID: <20160212223931.1680.18326@psf.io> https://hg.python.org/cpython/rev/d3662c088db8 changeset: 100232:d3662c088db8 branch: 2.7 parent: 100217:5715a6d9ff12 user: Charles-Fran?ois Natali date: Fri Feb 12 22:39:21 2016 +0000 summary: Issue #24303: Fix random EEXIST upon multiprocessing semaphores creation with Linux PID namespaces enabled. files: Misc/NEWS | 3 +++ Modules/_multiprocessing/semaphore.c | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -50,6 +50,9 @@ Library ------- +- Issue #24303: Fix random EEXIST upon multiprocessing semaphores creation with + Linux PID namespaces enabled. + - Issue #25698: Importing module if the stack is too deep no longer replaces imported module with the empty one. diff --git a/Modules/_multiprocessing/semaphore.c b/Modules/_multiprocessing/semaphore.c --- a/Modules/_multiprocessing/semaphore.c +++ b/Modules/_multiprocessing/semaphore.c @@ -429,7 +429,7 @@ int kind, maxvalue, value; PyObject *result; static char *kwlist[] = {"kind", "value", "maxvalue", NULL}; - static int counter = 0; + int try = 0; if (!PyArg_ParseTupleAndKeywords(args, kwds, "iii", kwlist, &kind, &value, &maxvalue)) @@ -440,10 +440,18 @@ return NULL; } - PyOS_snprintf(buffer, sizeof(buffer), "/mp%ld-%d", (long)getpid(), counter++); + /* Create a semaphore with a unique name. The bytes returned by + * _PyOS_URandom() are treated as unsigned long to ensure that the filename + * is valid (no special characters). */ + do { + unsigned long suffix; + _PyOS_URandom((char *)&suffix, sizeof(suffix)); + PyOS_snprintf(buffer, sizeof(buffer), "/mp%ld-%lu", (long)getpid(), + suffix); + SEM_CLEAR_ERROR(); + handle = SEM_CREATE(buffer, value, maxvalue); + } while ((handle == SEM_FAILED) && (errno == EEXIST) && (++try < 100)); - SEM_CLEAR_ERROR(); - handle = SEM_CREATE(buffer, value, maxvalue); /* On Windows we should fail if GetLastError()==ERROR_ALREADY_EXISTS */ if (handle == SEM_FAILED || SEM_GET_LAST_ERROR() != 0) goto failure; -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Feb 12 19:29:14 2016 From: python-checkins at python.org (victor.stinner) Date: Sat, 13 Feb 2016 00:29:14 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_511=3A_update_bytecode_ex?= =?utf-8?q?ample?= Message-ID: <20160213002909.31097.30326@psf.io> https://hg.python.org/peps/rev/2807dda1f92f changeset: 6231:2807dda1f92f user: Victor Stinner date: Sat Feb 13 01:29:05 2016 +0100 summary: PEP 511: update bytecode example files: pep-0511.txt | 21 ++++++++++++++++++--- 1 files changed, 18 insertions(+), 3 deletions(-) diff --git a/pep-0511.txt b/pep-0511.txt --- a/pep-0511.txt +++ b/pep-0511.txt @@ -443,14 +443,29 @@ ``"Ni! Ni! Ni!"``:: import sys + import types class BytecodeTransformer: name = "knights_who_say_ni" - def code_transformer(self, code, consts, names, lnotab, context): + def code_transformer(self, code, context): consts = ['Ni! Ni! Ni!' if isinstance(const, str) else const - for const in consts] - return (code, consts, names, lnotab) + for const in code.co_consts] + return types.CodeType(code.co_argcount, + code.co_kwonlyargcount, + code.co_nlocals, + code.co_stacksize, + code.co_flags, + code.co_code, + tuple(consts), + code.co_names, + code.co_varnames, + code.co_filename, + code.co_name, + code.co_firstlineno, + code.co_lnotab, + code.co_freevars, + code.co_cellvars) # replace existing code transformers with the new bytecode transformer sys.set_code_transformers([BytecodeTransformer()]) -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Fri Feb 12 19:47:01 2016 From: python-checkins at python.org (martin.panter) Date: Sat, 13 Feb 2016 00:47:01 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2325179=3A_Document?= =?utf-8?q?ation_for_formatted_string_literals_aka_f-strings?= Message-ID: <20160213004659.124180.10427@psf.io> https://hg.python.org/cpython/rev/f4d7de7d18c0 changeset: 100233:f4d7de7d18c0 parent: 100230:37bacf3fa1f5 user: Martin Panter date: Sat Feb 13 00:41:37 2016 +0000 summary: Issue #25179: Documentation for formatted string literals aka f-strings Some of the inspiration and wording is taken from the text of PEP 498 by Eric V. Smith, and the existing str.format() documentation. files: Doc/faq/programming.rst | 3 +- Doc/library/datetime.rst | 9 +- Doc/library/enum.rst | 3 +- Doc/library/stdtypes.rst | 15 +- Doc/library/string.rst | 10 +- Doc/reference/datamodel.rst | 5 +- Doc/reference/lexical_analysis.rst | 108 ++++++++++++++++- Doc/tutorial/inputoutput.rst | 3 +- Doc/tutorial/introduction.rst | 3 + Doc/whatsnew/3.6.rst | 20 ++- 10 files changed, 158 insertions(+), 21 deletions(-) diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -839,7 +839,8 @@ To convert, e.g., the number 144 to the string '144', use the built-in type constructor :func:`str`. If you want a hexadecimal or octal representation, use the built-in functions :func:`hex` or :func:`oct`. For fancy formatting, see -the :ref:`formatstrings` section, e.g. ``"{:04d}".format(144)`` yields +the :ref:`f-strings` and :ref:`formatstrings` sections, +e.g. ``"{:04d}".format(144)`` yields ``'0144'`` and ``"{:.3f}".format(1.0/3.0)`` yields ``'0.333'``. diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -605,7 +605,8 @@ .. method:: date.__format__(format) Same as :meth:`.date.strftime`. This makes it possible to specify a format - string for a :class:`.date` object when using :meth:`str.format`. For a + string for a :class:`.date` object in :ref:`formatted string + literals ` and when using :meth:`str.format`. For a complete list of formatting directives, see :ref:`strftime-strptime-behavior`. @@ -1180,7 +1181,8 @@ .. method:: datetime.__format__(format) Same as :meth:`.datetime.strftime`. This makes it possible to specify a format - string for a :class:`.datetime` object when using :meth:`str.format`. For a + string for a :class:`.datetime` object in :ref:`formatted string + literals ` and when using :meth:`str.format`. For a complete list of formatting directives, see :ref:`strftime-strptime-behavior`. @@ -1425,7 +1427,8 @@ .. method:: time.__format__(format) Same as :meth:`.time.strftime`. This makes it possible to specify a format string - for a :class:`.time` object when using :meth:`str.format`. For a + for a :class:`.time` object in :ref:`formatted string + literals ` and when using :meth:`str.format`. For a complete list of formatting directives, see :ref:`strftime-strptime-behavior`. diff --git a/Doc/library/enum.rst b/Doc/library/enum.rst --- a/Doc/library/enum.rst +++ b/Doc/library/enum.rst @@ -558,7 +558,8 @@ 4. %-style formatting: `%s` and `%r` call the :class:`Enum` class's :meth:`__str__` and :meth:`__repr__` respectively; other codes (such as `%i` or `%h` for IntEnum) treat the enum member as its mixed-in type. -5. :meth:`str.format` (or :func:`format`) will use the mixed-in +5. :ref:`Formatted string literals `, :meth:`str.format`, + and :func:`format` will use the mixed-in type's :meth:`__format__`. If the :class:`Enum` class's :func:`str` or :func:`repr` is desired, use the `!s` or `!r` format codes. diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1450,8 +1450,8 @@ For more information on the ``str`` class and its methods, see :ref:`textseq` and the :ref:`string-methods` section below. To output - formatted strings, see the :ref:`formatstrings` section. In addition, - see the :ref:`stringservices` section. + formatted strings, see the :ref:`f-strings` and :ref:`formatstrings` + sections. In addition, see the :ref:`stringservices` section. .. index:: @@ -2053,8 +2053,8 @@ .. index:: single: formatting, string (%) single: interpolation, string (%) - single: string; formatting - single: string; interpolation + single: string; formatting, printf + single: string; interpolation, printf single: printf-style formatting single: sprintf-style formatting single: % formatting @@ -2064,9 +2064,10 @@ The formatting operations described here exhibit a variety of quirks that lead to a number of common errors (such as failing to display tuples and - dictionaries correctly). Using the newer :meth:`str.format` interface - helps avoid these errors, and also provides a generally more powerful, - flexible and extensible approach to formatting text. + dictionaries correctly). Using the newer :ref:`formatted + string literals ` or the :meth:`str.format` interface + helps avoid these errors. These alternatives also provide more powerful, + flexible and extensible approaches to formatting text. String objects have one unique built-in operation: the ``%`` operator (modulo). This is also known as the string *formatting* or *interpolation* operator. diff --git a/Doc/library/string.rst b/Doc/library/string.rst --- a/Doc/library/string.rst +++ b/Doc/library/string.rst @@ -188,7 +188,9 @@ The :meth:`str.format` method and the :class:`Formatter` class share the same syntax for format strings (although in the case of :class:`Formatter`, -subclasses can define their own format string syntax). +subclasses can define their own format string syntax). The syntax is +related to that of :ref:`formatted string literals `, but +there are differences. Format strings contain "replacement fields" surrounded by curly braces ``{}``. Anything that is not contained in braces is considered literal text, which is @@ -283,7 +285,8 @@ "Format specifications" are used within replacement fields contained within a format string to define how individual values are presented (see -:ref:`formatstrings`). They can also be passed directly to the built-in +:ref:`formatstrings` and :ref:`f-strings`). +They can also be passed directly to the built-in :func:`format` function. Each formattable type may define how the format specification is to be interpreted. @@ -308,7 +311,8 @@ If a valid *align* value is specified, it can be preceded by a *fill* character that can be any character and defaults to a space if omitted. It is not possible to use a literal curly brace ("``{``" or "``}``") as -the *fill* character when using the :meth:`str.format` +the *fill* character in a :ref:`formatted string literal +` or when using the :meth:`str.format` method. However, it is possible to insert a curly brace with a nested replacement field. This limitation doesn't affect the :func:`format` function. diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -1234,8 +1234,9 @@ .. method:: object.__format__(self, format_spec) - Called by the :func:`format` built-in function (and by extension, the - :meth:`str.format` method of class :class:`str`) to produce a "formatted" + Called by the :func:`format` built-in function, + and by extension, evaluation of :ref:`formatted string literals + ` and the :meth:`str.format` method, to produce a "formatted" string representation of an object. The ``format_spec`` argument is a string that contains a description of the formatting options desired. The interpretation of the ``format_spec`` argument is up to the type diff --git a/Doc/reference/lexical_analysis.rst b/Doc/reference/lexical_analysis.rst --- a/Doc/reference/lexical_analysis.rst +++ b/Doc/reference/lexical_analysis.rst @@ -405,7 +405,8 @@ .. productionlist:: stringliteral: [`stringprefix`](`shortstring` | `longstring`) - stringprefix: "r" | "u" | "R" | "U" + stringprefix: "r" | "u" | "R" | "U" | "f" | "F" + : | "fr" | "Fr" | "fR" | "FR" | "rf" | "rF" | "Rf" | "RF" shortstring: "'" `shortstringitem`* "'" | '"' `shortstringitem`* '"' longstring: "'''" `longstringitem`* "'''" | '"""' `longstringitem`* '"""' shortstringitem: `shortstringchar` | `stringescapeseq` @@ -464,6 +465,11 @@ to simplify the maintenance of dual Python 2.x and 3.x codebases. See :pep:`414` for more information. +A string literal with ``'f'`` or ``'F'`` in its prefix is a +:dfn:`formatted string literal`; see :ref:`f-strings`. The ``'f'`` may be +combined with ``'r'``, but not with ``'b'`` or ``'u'``, therefore raw +formatted strings are possible, but formatted bytes literals are not. + In triple-quoted literals, unescaped newlines and quotes are allowed (and are retained), except that three unescaped quotes in a row terminate the literal. (A "quote" is the character used to open the literal, i.e. either ``'`` or ``"``.) @@ -584,7 +590,105 @@ Note that this feature is defined at the syntactical level, but implemented at compile time. The '+' operator must be used to concatenate string expressions at run time. Also note that literal concatenation can use different quoting -styles for each component (even mixing raw strings and triple quoted strings). +styles for each component (even mixing raw strings and triple quoted strings), +and formatted string literals may be concatenated with plain string literals. + + +.. index:: + single: formatted string literal + single: interpolated string literal + single: string; formatted literal + single: string; interpolated literal + single: f-string +.. _f-strings: + +Formatted string literals +------------------------- + +.. versionadded:: 3.6 + +A :dfn:`formatted string literal` or :dfn:`f-string` is a string literal +that is prefixed with ``'f'`` or ``'F'``. These strings may contain +replacement fields, which are expressions delimited by curly braces ``{}``. +While other string literals always have a constant value, formatted strings +are really expressions evaluated at run time. + +Escape sequences are decoded like in ordinary string literals (except when +a literal is also marked as a raw string). After decoding, the grammar +for the contents of the string is: + +.. productionlist:: + f_string: (`literal_char` | "{{" | "}}" | `replacement_field`)* + replacement_field: "{" `f_expression` ["!" `conversion`] [":" `format_spec`] "}" + f_expression: `conditional_expression` ("," `conditional_expression`)* [","] + : | `yield_expression` + conversion: "s" | "r" | "a" + format_spec: (`literal_char` | NULL | `replacement_field`)* + literal_char: + +The parts of the string outside curly braces are treated literally, +except that any doubled curly braces ``'{{'`` or ``'}}'`` are replaced +with the corresponding single curly brace. A single opening curly +bracket ``'{'`` marks a replacement field, which starts with a +Python expression. After the expression, there may be a conversion field, +introduced by an exclamation point ``'!'``. A format specifier may also +be appended, introduced by a colon ``':'``. A replacement field ends +with a closing curly bracket ``'}'``. + +Expressions in formatted string literals are treated like regular +Python expressions surrounded by parentheses, with a few exceptions. +An empty expression is not allowed, and a :keyword:`lambda` expression +must be surrounded by explicit parentheses. Replacement expressions +can contain line breaks (e.g. in triple-quoted strings), but they +cannot contain comments. Each expression is evaluated in the context +where the formatted string literal appears, in order from left to right. + +If a conversion is specified, the result of evaluating the expression +is converted before formatting. Conversion ``'!s'`` calls :func:`str` on +the result, ``'!r'`` calls :func:`repr`, and ``'!a'`` calls :func:`ascii`. + +The result is then formatted using the :func:`format` protocol. The +format specifier is passed to the :meth:`__format__` method of the +expression or conversion result. An empty string is passed when the +format specifier is omitted. The formatted result is then included in +the final value of the whole string. + +Top-level format specifiers may include nested replacement fields. +These nested fields may include their own conversion fields and +format specifiers, but may not include more deeply-nested replacement fields. + +Formatted string literals may be concatenated, but replacement fields +cannot be split across literals. + +Some examples of formatted string literals:: + + >>> name = "Fred" + >>> f"He said his name is {name!r}." + "He said his name is 'Fred'." + >>> f"He said his name is {repr(name)}." # repr() is equivalent to !r + "He said his name is 'Fred'." + >>> width = 10 + >>> precision = 4 + >>> value = decimal.Decimal("12.34567") + >>> f"result: {value:{width}.{precision}}" # nested fields + 'result: 12.35' + +A consequence of sharing the same syntax as regular string literals is +that characters in the replacement fields must not conflict with the +quoting used in the outer formatted string literal. Also, escape +sequences normally apply to the outer formatted string literal, +rather than inner string literals:: + + f"abc {a["x"]} def" # error: outer string literal ended prematurely + f"abc {a[\"x\"]} def" # workaround: escape the inner quotes + f"abc {a['x']} def" # workaround: use different quoting + + f"newline: {ord('\n')}" # error: literal line break in inner string + f"newline: {ord('\\n')}" # workaround: double escaping + fr"newline: {ord('\n')}" # workaround: raw outer string + +See also :pep:`498` for the proposal that added formatted string literals, +and :meth:`str.format`, which uses a related format string mechanism. .. _numbers: diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst --- a/Doc/tutorial/inputoutput.rst +++ b/Doc/tutorial/inputoutput.rst @@ -25,7 +25,8 @@ concatenation operations you can create any layout you can imagine. The string type has some methods that perform useful operations for padding strings to a given column width; these will be discussed shortly. The second -way is to use the :meth:`str.format` method. +way is to use :ref:`formatted string literals `, or the +:meth:`str.format` method. The :mod:`string` module contains a :class:`~string.Template` class which offers yet another way to substitute values into strings. diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -352,6 +352,9 @@ Strings support a large number of methods for basic transformations and searching. + :ref:`f-strings` + String literals that have embedded expressions. + :ref:`formatstrings` Information about string formatting with :meth:`str.format`. diff --git a/Doc/whatsnew/3.6.rst b/Doc/whatsnew/3.6.rst --- a/Doc/whatsnew/3.6.rst +++ b/Doc/whatsnew/3.6.rst @@ -62,7 +62,7 @@ .. This section singles out the most important changes in Python 3.6. Brevity is key. -* None yet. +* PEP 498: :ref:`Formatted string literals ` .. PEP-sized items next. @@ -80,6 +80,24 @@ PEP written by Carl Meyer +.. _whatsnew-fstrings: + +PEP 498: Formatted string literals +---------------------------------- + +Formatted string literals are a new kind of string literal, prefixed +with ``'f'``. They are similar to the format strings accepted by +:meth:`str.format`. They contain replacement fields surrounded by +curly braces. The replacement fields are expressions, which are +evaluated at run time, and then formatted using the :func:`format` protocol. + + >>> name = "Fred" + >>> f"He said his name is {name}." + 'He said his name is Fred.' + +See :pep:`498` and the main documentation at :ref:`f-strings`. + + Other Language Changes ====================== -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Feb 12 20:54:24 2016 From: python-checkins at python.org (victor.stinner) Date: Sat, 13 Feb 2016 01:54:24 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_511=3A_code_transformer_c?= =?utf-8?q?ontext?= Message-ID: <20160213015421.56700.8208@psf.io> https://hg.python.org/peps/rev/b9f4c54b17a8 changeset: 6232:b9f4c54b17a8 user: Victor Stinner date: Sat Feb 13 02:54:18 2016 +0100 summary: PEP 511: code transformer context files: pep-0511.txt | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/pep-0511.txt b/pep-0511.txt --- a/pep-0511.txt +++ b/pep-0511.txt @@ -277,6 +277,19 @@ Parameters: * *code*: code object +* *context*: an object with an *optimize* attribute (``int``), the optimization + level (0, 1 or 2). The value of the *optimize* attribute comes from the + *optimize* parameter of the ``compile()`` function, it is equal to + ``sys.flags.optimize`` by default. + +Each implementation of Python can add extra attributes to *context*. For +example, on CPython, *context* will also have the following attribute: + +* *interactive* (``bool``): true if in interactive mode + +XXX add more flags? + +XXX replace flags int with a sub-namespace, or with specific attributes? The method must return a code object. -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Sat Feb 13 03:43:46 2016 From: python-checkins at python.org (georg.brandl) Date: Sat, 13 Feb 2016 08:43:46 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_515=3A_major_revision=2E_?= =?utf-8?q?Use_rules_preferred_by_Guido=2E?= Message-ID: <20160213084346.1707.50335@psf.io> https://hg.python.org/peps/rev/c99bd3d7fd71 changeset: 6233:c99bd3d7fd71 user: Georg Brandl date: Sat Feb 13 09:43:02 2016 +0100 summary: PEP 515: major revision. Use rules preferred by Guido. files: pep-0515.txt | 187 +++++++++++++++++++++----------------- 1 files changed, 102 insertions(+), 85 deletions(-) diff --git a/pep-0515.txt b/pep-0515.txt --- a/pep-0515.txt +++ b/pep-0515.txt @@ -2,7 +2,7 @@ Title: Underscores in Numeric Literals Version: $Revision$ Last-Modified: $Date$ -Author: Georg Brandl +Author: Georg Brandl, Serhiy Storchaka Status: Draft Type: Standards Track Content-Type: text/x-rst @@ -13,13 +13,14 @@ Abstract and Rationale ====================== -This PEP proposes to extend Python's syntax so that underscores can be used as -visual separators for digit grouping purposes in integral, floating-point and -complex number literals. +This PEP proposes to extend Python's syntax and number-from-string +constructors so that underscores can be used as visual separators for +digit grouping purposes in integral, floating-point and complex number +literals. -This is a common feature of other modern languages, and can aid readability of -long literals, or literals whose value should clearly separate into parts, such -as bytes or words in hexadecimal notation. +This is a common feature of other modern languages, and can aid +readability of long literals, or literals whose value should clearly +separate into parts, such as bytes or words in hexadecimal notation. Examples:: @@ -32,39 +33,81 @@ # grouping bits into nibbles in a binary literal flags = 0b_0011_1111_0100_1110 - # making the literal suffix stand out more - imag = 1.247812376e-15_j + # same, for string conversions + flags = int('0b_1111_0000', 2) Specification ============= -The current proposal is to allow one or more consecutive underscores following -digits and base specifiers in numeric literals. The underscores have no -semantic meaning, and literals are parsed as if the underscores were absent. +The current proposal is to allow one underscore between digits, and +after base specifiers in numeric literals. The underscores have no +semantic meaning, and literals are parsed as if the underscores were +absent. -The production list for integer literals would therefore look like this:: +Literal Grammar +--------------- - integer: decimalinteger | octinteger | hexinteger | bininteger - decimalinteger: nonzerodigit (digit | "_")* | "0" ("0" | "_")* +The production list for integer literals would therefore look like +this:: + + integer: decinteger | bininteger | octinteger | hexinteger + decinteger: nonzerodigit (["_"] digit)* | "0" (["_"] "0")* + bininteger: "0" ("b" | "B") (["_"] bindigit)+ + octinteger: "0" ("o" | "O") (["_"] octdigit)+ + hexinteger: "0" ("x" | "X") (["_"] hexdigit)+ nonzerodigit: "1"..."9" digit: "0"..."9" - octinteger: "0" ("o" | "O") "_"* octdigit (octdigit | "_")* - hexinteger: "0" ("x" | "X") "_"* hexdigit (hexdigit | "_")* - bininteger: "0" ("b" | "B") "_"* bindigit (bindigit | "_")* + bindigit: "0" | "1" octdigit: "0"..."7" hexdigit: digit | "a"..."f" | "A"..."F" - bindigit: "0" | "1" For floating-point and complex literals:: floatnumber: pointfloat | exponentfloat - pointfloat: [intpart] fraction | intpart "." - exponentfloat: (intpart | pointfloat) exponent - intpart: digit (digit | "_")* - fraction: "." intpart - exponent: ("e" | "E") ["+" | "-"] intpart - imagnumber: (floatnumber | intpart) ("j" | "J") + pointfloat: [digitpart] fraction | digitpart "." + exponentfloat: (digitpart | pointfloat) exponent + digitpart: digit (["_"] digit)* + fraction: "." digitpart + exponent: ("e" | "E") ["+" | "-"] digitpart + imagnumber: (floatnumber | digitpart) ("j" | "J") + +Constructors +------------ + +Following the same rules for placement, underscores will be allowed in +the following constructors: + +- ``int()`` (with any base) +- ``float()`` +- ``complex()`` +- ``Decimal()`` + + +Prior Art +========= + +Those languages that do allow underscore grouping implement a large +variety of rules for allowed placement of underscores. In cases where +the language spec contradicts the actual behavior, the actual behavior +is listed. ("single" or "multiple" refer to allowing runs of +consecutive underscores.) + +* Ada: single, only between digits [8]_ +* C# (open proposal for 7.0): multiple, only between digits [6]_ +* C++ (C++14): single, between digits (different separator chosen) [1]_ +* D: multiple, anywhere, including trailing [2]_ +* Java: multiple, only between digits [7]_ +* Julia: single, only between digits (but not in float exponent parts) + [9]_ +* Perl 5: multiple, basically anywhere, although docs say it's + restricted to one underscore between digits [3]_ +* Ruby: single, only between digits (although docs say "anywhere") + [10]_ +* Rust: multiple, anywhere, except for between exponent "e" and digits + [4]_ +* Swift: multiple, between digits and trailing (although textual + description says only "between digits") [5]_ Alternative Syntax @@ -73,81 +116,53 @@ Underscore Placement Rules -------------------------- -Instead of the liberal rule specified above, the use of underscores could be -limited. Common rules are (see the "other languages" section): +Instead of the relatively strict rule specified above, the use of +underscores could be limited. As we seen from other languages, common +rules include: * Only one consecutive underscore allowed, and only between digits. -* Multiple consecutive underscore allowed, but only between digits. +* Multiple consecutive underscores allowed, but only between digits. +* Multiple consecutive underscores allowed, in most positions except + for the start of the literal, or special positions like after a + decimal point. -A less common rule would be to allow underscores only every N digits (where N -could be 3 for decimal literals, or 4 for hexadecimal ones). This is -unnecessarily restrictive, especially considering the separator placement is -different in different cultures. +The syntax in this PEP has ultimately been selected because it covers +the common use cases, and does not allow for syntax that would have to +be discouraged in style guides anyway. + +A less common rule would be to allow underscores only every N digits +(where N could be 3 for decimal literals, or 4 for hexadecimal ones). +This is unnecessarily restrictive, especially considering the +separator placement is different in different cultures. Different Separators -------------------- -A proposed alternate syntax was to use whitespace for grouping. Although -strings are a precedent for combining adjoining literals, the behavior can lead -to unexpected effects which are not possible with underscores. Also, no other -language is known to use this rule, except for languages that generally -disregard any whitespace. +A proposed alternate syntax was to use whitespace for grouping. +Although strings are a precedent for combining adjoining literals, the +behavior can lead to unexpected effects which are not possible with +underscores. Also, no other language is known to use this rule, +except for languages that generally disregard any whitespace. -C++14 introduces apostrophes for grouping, which is not considered due to the -conflict with Python's string literals. [1]_ +C++14 introduces apostrophes for grouping (because underscores introduce +ambiguity with user-defined literals), which is not considered because of the +use in Python's string literals. [1]_ -Behavior in Other Languages -=========================== +Open Proposals +============== -Those languages that do allow underscore grouping implement a large variety of -rules for allowed placement of underscores. This is a listing placing the known -rules into three major groups. In cases where the language spec contradicts the -actual behavior, the actual behavior is listed. - -**Group 1: liberal** - -This group is the least homogeneous: the rules vary slightly between languages. -All of them allow trailing underscores. Some allow underscores after non-digits -like the ``e`` or the sign in exponents. - -* D [2]_ -* Perl 5 (underscores basically allowed anywhere, although docs say it's more - restricted) [3]_ -* Rust (allows between exponent sign and digits) [4]_ -* Swift (although textual description says "between digits") [5]_ - -**Group 2: only between digits, multiple consecutive underscores** - -* C# (open proposal for 7.0) [6]_ -* Java [7]_ - -**Group 3: only between digits, only one underscore** - -* Ada [8]_ -* Julia (but not in the exponent part of floats) [9]_ -* Ruby (docs say "anywhere", in reality only between digits) [10]_ +It has been proposed [11]_ to extend the number-to-string formatting +language to allow ``_`` as a thousans separator, where currently only +``,`` is supported. This could be used to easily generate code with +more readable literals. Implementation ============== -A preliminary patch that implements the specification given above has been -posted to the issue tracker. [11]_ - - -Open Questions -============== - -This PEP currently only proposes changing the literal syntax. The following -extensions are open for discussion: - -* Allowing underscores in string arguments to the ``Decimal`` constructor. It - could be argued that these are akin to literals, since there is no Decimal - literal available (yet). - -* Allowing underscores in string arguments to ``int()`` with base argument 0, - ``float()`` and ``complex()``. +A preliminary patch that implements the specification given above has +been posted to the issue tracker. [12]_ References @@ -173,7 +188,9 @@ .. [10] http://ruby-doc.org/core-2.3.0/doc/syntax/literals_rdoc.html#label-Numbers -.. [11] http://bugs.python.org/issue26331 +.. [11] https://mail.python.org/pipermail/python-dev/2016-February/143283.html + +.. [12] http://bugs.python.org/issue26331 Copyright -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Sat Feb 13 03:46:03 2016 From: python-checkins at python.org (georg.brandl) Date: Sat, 13 Feb 2016 08:46:03 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Minor_fix=2E?= Message-ID: <20160213084603.18358.32357@psf.io> https://hg.python.org/peps/rev/3c22cf6e06e5 changeset: 6234:3c22cf6e06e5 user: Georg Brandl date: Sat Feb 13 09:46:00 2016 +0100 summary: Minor fix. files: pep-0515.txt | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pep-0515.txt b/pep-0515.txt --- a/pep-0515.txt +++ b/pep-0515.txt @@ -95,7 +95,7 @@ * Ada: single, only between digits [8]_ * C# (open proposal for 7.0): multiple, only between digits [6]_ -* C++ (C++14): single, between digits (different separator chosen) [1]_ +* C++14: single, between digits (different separator chosen) [1]_ * D: multiple, anywhere, including trailing [2]_ * Java: multiple, only between digits [7]_ * Julia: single, only between digits (but not in float exponent parts) @@ -144,9 +144,9 @@ underscores. Also, no other language is known to use this rule, except for languages that generally disregard any whitespace. -C++14 introduces apostrophes for grouping (because underscores introduce -ambiguity with user-defined literals), which is not considered because of the -use in Python's string literals. [1]_ +C++14 introduces apostrophes for grouping (because underscores +introduce ambiguity with user-defined literals), which is not +considered because of the use in Python's string literals. [1]_ Open Proposals -- Repository URL: https://hg.python.org/peps From solipsis at pitrou.net Sat Feb 13 04:44:50 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Sat, 13 Feb 2016 09:44:50 +0000 Subject: [Python-checkins] Daily reference leaks (f4d7de7d18c0): sum=62 Message-ID: <20160213094450.18350.32890@psf.io> results for f4d7de7d18c0 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 test_multiprocessing_fork leaked [0, 0, 38] references, sum=38 test_multiprocessing_fork leaked [0, 0, 18] memory blocks, sum=18 test_multiprocessing_fork leaked [0, 0, 2] file descriptors, sum=2 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogRG_PPX', '--timeout', '7200'] From python-checkins at python.org Sat Feb 13 07:24:52 2016 From: python-checkins at python.org (georg.brandl) Date: Sat, 13 Feb 2016 12:24:52 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Change_example_constant=2E?= Message-ID: <20160213122452.61239.13359@psf.io> https://hg.python.org/peps/rev/13f432526dde changeset: 6235:13f432526dde user: Georg Brandl date: Sat Feb 13 13:24:48 2016 +0100 summary: Change example constant. files: pep-0515.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/pep-0515.txt b/pep-0515.txt --- a/pep-0515.txt +++ b/pep-0515.txt @@ -28,7 +28,7 @@ amount = 10_000_000.0 # grouping hexadecimal addresses by words - addr = 0xDEAD_BEEF + addr = 0xCAFE_F00D # grouping bits into nibbles in a binary literal flags = 0b_0011_1111_0100_1110 -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Sat Feb 13 11:27:35 2016 From: python-checkins at python.org (vinay.sajip) Date: Sat, 13 Feb 2016 16:27:35 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogRml4ZXMgIzI2MzQ4?= =?utf-8?q?=3A_Corrected_typos_in_activate=2Efish_script=2E?= Message-ID: <20160213162735.1699.74160@psf.io> https://hg.python.org/cpython/rev/cfc66e37eb8e changeset: 100234:cfc66e37eb8e branch: 3.5 parent: 100227:e951d76f1945 user: Vinay Sajip date: Sat Feb 13 16:26:35 2016 +0000 summary: Fixes #26348: Corrected typos in activate.fish script. files: Lib/venv/scripts/posix/activate.fish | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/venv/scripts/posix/activate.fish b/Lib/venv/scripts/posix/activate.fish --- a/Lib/venv/scripts/posix/activate.fish +++ b/Lib/venv/scripts/posix/activate.fish @@ -55,8 +55,8 @@ # with the original prompt function renamed, we can override with our own. function fish_prompt # Prompt override? - if test -n "__VENV_PROMPT__" - printf "%s%s%s" "__VENV_PROMPT__" (set_color normal) (_old_fish_prompt) + if test -n "$__VENV_PROMPT__" + printf "%s%s%s" "$__VENV_PROMPT__" (set_color normal) (_old_fish_prompt) return end # ...Otherwise, prepend env -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Feb 13 11:27:38 2016 From: python-checkins at python.org (vinay.sajip) Date: Sat, 13 Feb 2016 16:27:38 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Fixes_=2326348=3A_Merged_fix_from_3=2E5=2E?= Message-ID: <20160213162735.53097.58335@psf.io> https://hg.python.org/cpython/rev/0f1ac94d2f98 changeset: 100235:0f1ac94d2f98 parent: 100233:f4d7de7d18c0 parent: 100234:cfc66e37eb8e user: Vinay Sajip date: Sat Feb 13 16:27:25 2016 +0000 summary: Fixes #26348: Merged fix from 3.5. files: Lib/venv/scripts/posix/activate.fish | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/venv/scripts/posix/activate.fish b/Lib/venv/scripts/posix/activate.fish --- a/Lib/venv/scripts/posix/activate.fish +++ b/Lib/venv/scripts/posix/activate.fish @@ -55,8 +55,8 @@ # with the original prompt function renamed, we can override with our own. function fish_prompt # Prompt override? - if test -n "__VENV_PROMPT__" - printf "%s%s%s" "__VENV_PROMPT__" (set_color normal) (_old_fish_prompt) + if test -n "$__VENV_PROMPT__" + printf "%s%s%s" "$__VENV_PROMPT__" (set_color normal) (_old_fish_prompt) return end # ...Otherwise, prepend env -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Feb 13 13:21:38 2016 From: python-checkins at python.org (georg.brandl) Date: Sat, 13 Feb 2016 18:21:38 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Fix_grammar=2E?= Message-ID: <20160213182138.5750.2710@psf.io> https://hg.python.org/peps/rev/bfb678d3fc9f changeset: 6236:bfb678d3fc9f user: Georg Brandl date: Sat Feb 13 19:21:34 2016 +0100 summary: Fix grammar. files: pep-0515.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/pep-0515.txt b/pep-0515.txt --- a/pep-0515.txt +++ b/pep-0515.txt @@ -117,7 +117,7 @@ -------------------------- Instead of the relatively strict rule specified above, the use of -underscores could be limited. As we seen from other languages, common +underscores could be less limited. As seen in other languages, common rules include: * Only one consecutive underscore allowed, and only between digits. -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Sat Feb 13 18:00:42 2016 From: python-checkins at python.org (yury.selivanov) Date: Sat, 13 Feb 2016 23:00:42 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?b?KTogTWVyZ2UgMy41IChpc3N1ZSAjMjU4ODcp?= Message-ID: <20160213230042.18342.23757@psf.io> https://hg.python.org/cpython/rev/23297d5bbd29 changeset: 100237:23297d5bbd29 parent: 100235:0f1ac94d2f98 parent: 100236:c2a2685ab89b user: Yury Selivanov date: Sat Feb 13 18:00:31 2016 -0500 summary: Merge 3.5 (issue #25887) files: Doc/reference/datamodel.rst | 4 + Lib/test/test_coroutines.py | 141 ++++++++++++++++++++++++ Misc/NEWS | 3 + Objects/genobject.c | 33 +++-- 4 files changed, 169 insertions(+), 12 deletions(-) diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -2317,6 +2317,10 @@ those of generators (see :ref:`generator-methods`). However, unlike generators, coroutines do not directly support iteration. +.. versionchanged:: 3.5.2 + It is a :exc:`RuntimeError` to await on a coroutine more than once. + + .. method:: coroutine.send(value) Starts or resumes execution of the coroutine. If *value* is ``None``, diff --git a/Lib/test/test_coroutines.py b/Lib/test/test_coroutines.py --- a/Lib/test/test_coroutines.py +++ b/Lib/test/test_coroutines.py @@ -569,6 +569,147 @@ "coroutine ignored GeneratorExit"): c.close() + def test_func_15(self): + # See http://bugs.python.org/issue25887 for details + + async def spammer(): + return 'spam' + async def reader(coro): + return await coro + + spammer_coro = spammer() + + with self.assertRaisesRegex(StopIteration, 'spam'): + reader(spammer_coro).send(None) + + with self.assertRaisesRegex(RuntimeError, + 'cannot reuse already awaited coroutine'): + reader(spammer_coro).send(None) + + def test_func_16(self): + # See http://bugs.python.org/issue25887 for details + + @types.coroutine + def nop(): + yield + async def send(): + await nop() + return 'spam' + async def read(coro): + await nop() + return await coro + + spammer = send() + + reader = read(spammer) + reader.send(None) + reader.send(None) + with self.assertRaisesRegex(Exception, 'ham'): + reader.throw(Exception('ham')) + + reader = read(spammer) + reader.send(None) + with self.assertRaisesRegex(RuntimeError, + 'cannot reuse already awaited coroutine'): + reader.send(None) + + with self.assertRaisesRegex(RuntimeError, + 'cannot reuse already awaited coroutine'): + reader.throw(Exception('wat')) + + def test_func_17(self): + # See http://bugs.python.org/issue25887 for details + + async def coroutine(): + return 'spam' + + coro = coroutine() + with self.assertRaisesRegex(StopIteration, 'spam'): + coro.send(None) + + with self.assertRaisesRegex(RuntimeError, + 'cannot reuse already awaited coroutine'): + coro.send(None) + + with self.assertRaisesRegex(RuntimeError, + 'cannot reuse already awaited coroutine'): + coro.throw(Exception('wat')) + + # Closing a coroutine shouldn't raise any exception even if it's + # already closed/exhausted (similar to generators) + coro.close() + coro.close() + + def test_func_18(self): + # See http://bugs.python.org/issue25887 for details + + async def coroutine(): + return 'spam' + + coro = coroutine() + await_iter = coro.__await__() + it = iter(await_iter) + + with self.assertRaisesRegex(StopIteration, 'spam'): + it.send(None) + + with self.assertRaisesRegex(RuntimeError, + 'cannot reuse already awaited coroutine'): + it.send(None) + + with self.assertRaisesRegex(RuntimeError, + 'cannot reuse already awaited coroutine'): + # Although the iterator protocol requires iterators to + # raise another StopIteration here, we don't want to do + # that. In this particular case, the iterator will raise + # a RuntimeError, so that 'yield from' and 'await' + # expressions will trigger the error, instead of silently + # ignoring the call. + next(it) + + with self.assertRaisesRegex(RuntimeError, + 'cannot reuse already awaited coroutine'): + it.throw(Exception('wat')) + + with self.assertRaisesRegex(RuntimeError, + 'cannot reuse already awaited coroutine'): + it.throw(Exception('wat')) + + # Closing a coroutine shouldn't raise any exception even if it's + # already closed/exhausted (similar to generators) + it.close() + it.close() + + def test_func_19(self): + CHK = 0 + + @types.coroutine + def foo(): + nonlocal CHK + yield + try: + yield + except GeneratorExit: + CHK += 1 + + async def coroutine(): + await foo() + + coro = coroutine() + + coro.send(None) + coro.send(None) + + self.assertEqual(CHK, 0) + coro.close() + self.assertEqual(CHK, 1) + + for _ in range(3): + # Closing a coroutine shouldn't raise any exception even if it's + # already closed/exhausted (similar to generators) + coro.close() + self.assertEqual(CHK, 1) + def test_cr_await(self): @types.coroutine def a(): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -180,6 +180,9 @@ single-digit longs. Microbenchmarks show 2-2.5x improvement. Built-in 'divmod' function is now also ~10% faster. +- Issue #25887: Raise a RuntimeError when a coroutine object is awaited + more than once. + Library ------- diff --git a/Objects/genobject.c b/Objects/genobject.c --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -78,7 +78,7 @@ } static PyObject * -gen_send_ex(PyGenObject *gen, PyObject *arg, int exc) +gen_send_ex(PyGenObject *gen, PyObject *arg, int exc, int closing) { PyThreadState *tstate = PyThreadState_GET(); PyFrameObject *f = gen->gi_frame; @@ -92,9 +92,18 @@ return NULL; } if (f == NULL || f->f_stacktop == NULL) { - /* Only set exception if called from send() */ - if (arg && !exc) + if (PyCoro_CheckExact(gen) && !closing) { + /* `gen` is an exhausted coroutine: raise an error, + except when called from gen_close(), which should + always be a silent method. */ + PyErr_SetString( + PyExc_RuntimeError, + "cannot reuse already awaited coroutine"); + } else if (arg && !exc) { + /* `gen` is an exhausted generator: + only set exception if called from send(). */ PyErr_SetNone(PyExc_StopIteration); + } return NULL; } @@ -220,7 +229,7 @@ PyObject * _PyGen_Send(PyGenObject *gen, PyObject *arg) { - return gen_send_ex(gen, arg, 0); + return gen_send_ex(gen, arg, 0, 0); } PyDoc_STRVAR(close_doc, @@ -292,7 +301,7 @@ } if (err == 0) PyErr_SetNone(PyExc_GeneratorExit); - retval = gen_send_ex(gen, Py_None, 1); + retval = gen_send_ex(gen, Py_None, 1, 1); if (retval) { char *msg = "generator ignored GeneratorExit"; if (PyCoro_CheckExact(gen)) @@ -336,7 +345,7 @@ gen->gi_running = 0; Py_DECREF(yf); if (err < 0) - return gen_send_ex(gen, Py_None, 1); + return gen_send_ex(gen, Py_None, 1, 0); goto throw_here; } if (PyGen_CheckExact(yf)) { @@ -369,10 +378,10 @@ /* Termination repetition of YIELD_FROM */ gen->gi_frame->f_lasti++; if (_PyGen_FetchStopIterationValue(&val) == 0) { - ret = gen_send_ex(gen, val, 0); + ret = gen_send_ex(gen, val, 0, 0); Py_DECREF(val); } else { - ret = gen_send_ex(gen, Py_None, 1); + ret = gen_send_ex(gen, Py_None, 1, 0); } } return ret; @@ -426,7 +435,7 @@ } PyErr_Restore(typ, val, tb); - return gen_send_ex(gen, Py_None, 1); + return gen_send_ex(gen, Py_None, 1, 0); failed_throw: /* Didn't use our arguments, so restore their original refcounts */ @@ -440,7 +449,7 @@ static PyObject * gen_iternext(PyGenObject *gen) { - return gen_send_ex(gen, NULL, 0); + return gen_send_ex(gen, NULL, 0, 0); } /* @@ -893,13 +902,13 @@ static PyObject * coro_wrapper_iternext(PyCoroWrapper *cw) { - return gen_send_ex((PyGenObject *)cw->cw_coroutine, NULL, 0); + return gen_send_ex((PyGenObject *)cw->cw_coroutine, NULL, 0, 0); } static PyObject * coro_wrapper_send(PyCoroWrapper *cw, PyObject *arg) { - return gen_send_ex((PyGenObject *)cw->cw_coroutine, arg, 0); + return gen_send_ex((PyGenObject *)cw->cw_coroutine, arg, 0, 0); } static PyObject * -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Feb 13 18:00:42 2016 From: python-checkins at python.org (yury.selivanov) Date: Sat, 13 Feb 2016 23:00:42 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1ODg3?= =?utf-8?q?=3A_Raise_a_RuntimeError_when_a_coroutine_is_awaited_more_than_?= =?utf-8?q?once=2E?= Message-ID: <20160213230042.18336.83321@psf.io> https://hg.python.org/cpython/rev/c2a2685ab89b changeset: 100236:c2a2685ab89b branch: 3.5 parent: 100234:cfc66e37eb8e user: Yury Selivanov date: Sat Feb 13 17:59:05 2016 -0500 summary: Issue #25887: Raise a RuntimeError when a coroutine is awaited more than once. files: Doc/reference/datamodel.rst | 4 + Lib/test/test_coroutines.py | 141 ++++++++++++++++++++++++ Misc/NEWS | 3 + Objects/genobject.c | 33 +++-- 4 files changed, 169 insertions(+), 12 deletions(-) diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -2316,6 +2316,10 @@ those of generators (see :ref:`generator-methods`). However, unlike generators, coroutines do not directly support iteration. +.. versionchanged:: 3.5.2 + It is a :exc:`RuntimeError` to await on a coroutine more than once. + + .. method:: coroutine.send(value) Starts or resumes execution of the coroutine. If *value* is ``None``, diff --git a/Lib/test/test_coroutines.py b/Lib/test/test_coroutines.py --- a/Lib/test/test_coroutines.py +++ b/Lib/test/test_coroutines.py @@ -569,6 +569,147 @@ "coroutine ignored GeneratorExit"): c.close() + def test_func_15(self): + # See http://bugs.python.org/issue25887 for details + + async def spammer(): + return 'spam' + async def reader(coro): + return await coro + + spammer_coro = spammer() + + with self.assertRaisesRegex(StopIteration, 'spam'): + reader(spammer_coro).send(None) + + with self.assertRaisesRegex(RuntimeError, + 'cannot reuse already awaited coroutine'): + reader(spammer_coro).send(None) + + def test_func_16(self): + # See http://bugs.python.org/issue25887 for details + + @types.coroutine + def nop(): + yield + async def send(): + await nop() + return 'spam' + async def read(coro): + await nop() + return await coro + + spammer = send() + + reader = read(spammer) + reader.send(None) + reader.send(None) + with self.assertRaisesRegex(Exception, 'ham'): + reader.throw(Exception('ham')) + + reader = read(spammer) + reader.send(None) + with self.assertRaisesRegex(RuntimeError, + 'cannot reuse already awaited coroutine'): + reader.send(None) + + with self.assertRaisesRegex(RuntimeError, + 'cannot reuse already awaited coroutine'): + reader.throw(Exception('wat')) + + def test_func_17(self): + # See http://bugs.python.org/issue25887 for details + + async def coroutine(): + return 'spam' + + coro = coroutine() + with self.assertRaisesRegex(StopIteration, 'spam'): + coro.send(None) + + with self.assertRaisesRegex(RuntimeError, + 'cannot reuse already awaited coroutine'): + coro.send(None) + + with self.assertRaisesRegex(RuntimeError, + 'cannot reuse already awaited coroutine'): + coro.throw(Exception('wat')) + + # Closing a coroutine shouldn't raise any exception even if it's + # already closed/exhausted (similar to generators) + coro.close() + coro.close() + + def test_func_18(self): + # See http://bugs.python.org/issue25887 for details + + async def coroutine(): + return 'spam' + + coro = coroutine() + await_iter = coro.__await__() + it = iter(await_iter) + + with self.assertRaisesRegex(StopIteration, 'spam'): + it.send(None) + + with self.assertRaisesRegex(RuntimeError, + 'cannot reuse already awaited coroutine'): + it.send(None) + + with self.assertRaisesRegex(RuntimeError, + 'cannot reuse already awaited coroutine'): + # Although the iterator protocol requires iterators to + # raise another StopIteration here, we don't want to do + # that. In this particular case, the iterator will raise + # a RuntimeError, so that 'yield from' and 'await' + # expressions will trigger the error, instead of silently + # ignoring the call. + next(it) + + with self.assertRaisesRegex(RuntimeError, + 'cannot reuse already awaited coroutine'): + it.throw(Exception('wat')) + + with self.assertRaisesRegex(RuntimeError, + 'cannot reuse already awaited coroutine'): + it.throw(Exception('wat')) + + # Closing a coroutine shouldn't raise any exception even if it's + # already closed/exhausted (similar to generators) + it.close() + it.close() + + def test_func_19(self): + CHK = 0 + + @types.coroutine + def foo(): + nonlocal CHK + yield + try: + yield + except GeneratorExit: + CHK += 1 + + async def coroutine(): + await foo() + + coro = coroutine() + + coro.send(None) + coro.send(None) + + self.assertEqual(CHK, 0) + coro.close() + self.assertEqual(CHK, 1) + + for _ in range(3): + # Closing a coroutine shouldn't raise any exception even if it's + # already closed/exhausted (similar to generators) + coro.close() + self.assertEqual(CHK, 1) + def test_cr_await(self): @types.coroutine def a(): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -69,6 +69,9 @@ - Issue #25660: Fix TAB key behaviour in REPL with readline. +- Issue #25887: Raise a RuntimeError when a coroutine object is awaited + more than once. + Library ------- diff --git a/Objects/genobject.c b/Objects/genobject.c --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -78,7 +78,7 @@ } static PyObject * -gen_send_ex(PyGenObject *gen, PyObject *arg, int exc) +gen_send_ex(PyGenObject *gen, PyObject *arg, int exc, int closing) { PyThreadState *tstate = PyThreadState_GET(); PyFrameObject *f = gen->gi_frame; @@ -92,9 +92,18 @@ return NULL; } if (f == NULL || f->f_stacktop == NULL) { - /* Only set exception if called from send() */ - if (arg && !exc) + if (PyCoro_CheckExact(gen) && !closing) { + /* `gen` is an exhausted coroutine: raise an error, + except when called from gen_close(), which should + always be a silent method. */ + PyErr_SetString( + PyExc_RuntimeError, + "cannot reuse already awaited coroutine"); + } else if (arg && !exc) { + /* `gen` is an exhausted generator: + only set exception if called from send(). */ PyErr_SetNone(PyExc_StopIteration); + } return NULL; } @@ -220,7 +229,7 @@ PyObject * _PyGen_Send(PyGenObject *gen, PyObject *arg) { - return gen_send_ex(gen, arg, 0); + return gen_send_ex(gen, arg, 0, 0); } PyDoc_STRVAR(close_doc, @@ -292,7 +301,7 @@ } if (err == 0) PyErr_SetNone(PyExc_GeneratorExit); - retval = gen_send_ex(gen, Py_None, 1); + retval = gen_send_ex(gen, Py_None, 1, 1); if (retval) { char *msg = "generator ignored GeneratorExit"; if (PyCoro_CheckExact(gen)) @@ -336,7 +345,7 @@ gen->gi_running = 0; Py_DECREF(yf); if (err < 0) - return gen_send_ex(gen, Py_None, 1); + return gen_send_ex(gen, Py_None, 1, 0); goto throw_here; } if (PyGen_CheckExact(yf)) { @@ -369,10 +378,10 @@ /* Termination repetition of YIELD_FROM */ gen->gi_frame->f_lasti++; if (_PyGen_FetchStopIterationValue(&val) == 0) { - ret = gen_send_ex(gen, val, 0); + ret = gen_send_ex(gen, val, 0, 0); Py_DECREF(val); } else { - ret = gen_send_ex(gen, Py_None, 1); + ret = gen_send_ex(gen, Py_None, 1, 0); } } return ret; @@ -426,7 +435,7 @@ } PyErr_Restore(typ, val, tb); - return gen_send_ex(gen, Py_None, 1); + return gen_send_ex(gen, Py_None, 1, 0); failed_throw: /* Didn't use our arguments, so restore their original refcounts */ @@ -440,7 +449,7 @@ static PyObject * gen_iternext(PyGenObject *gen) { - return gen_send_ex(gen, NULL, 0); + return gen_send_ex(gen, NULL, 0, 0); } /* @@ -901,13 +910,13 @@ static PyObject * coro_wrapper_iternext(PyCoroWrapper *cw) { - return gen_send_ex((PyGenObject *)cw->cw_coroutine, NULL, 0); + return gen_send_ex((PyGenObject *)cw->cw_coroutine, NULL, 0, 0); } static PyObject * coro_wrapper_send(PyCoroWrapper *cw, PyObject *arg) { - return gen_send_ex((PyGenObject *)cw->cw_coroutine, arg, 0); + return gen_send_ex((PyGenObject *)cw->cw_coroutine, arg, 0, 0); } static PyObject * -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Feb 13 22:25:44 2016 From: python-checkins at python.org (martin.panter) Date: Sun, 14 Feb 2016 03:25:44 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2MzE2?= =?utf-8?q?=3A_Fix_variable_name_typo_in_Argument_Clinic?= Message-ID: <20160214032544.30209.38819@psf.io> https://hg.python.org/cpython/rev/aec2eae8933e changeset: 100238:aec2eae8933e branch: 3.5 parent: 100236:c2a2685ab89b user: Martin Panter date: Sun Feb 14 03:23:13 2016 +0000 summary: Issue #26316: Fix variable name typo in Argument Clinic files: Misc/NEWS | 6 ++++++ Tools/clinic/clinic.py | 2 +- 2 files changed, 7 insertions(+), 1 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -256,6 +256,12 @@ - Issue #26065: Excludes venv from library when generating embeddable distro. +Tools/Demos +----------- + +- Issue #26316: Fix variable name typo in Argument Clinic. + + What's New in Python 3.5.1 final? ================================= diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py --- a/Tools/clinic/clinic.py +++ b/Tools/clinic/clinic.py @@ -199,7 +199,7 @@ add('\n') continue - name, curl, trailing = trailing.partition('}') + name, curly, trailing = trailing.partition('}') if not curly or name not in kwargs: add(line) add('\n') -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Feb 13 22:25:44 2016 From: python-checkins at python.org (martin.panter) Date: Sun, 14 Feb 2016 03:25:44 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326316=3A_Merge_Arg_Clinic_fix_from_3=2E5?= Message-ID: <20160214032544.124190.22784@psf.io> https://hg.python.org/cpython/rev/6c122e4e1cb2 changeset: 100239:6c122e4e1cb2 parent: 100237:23297d5bbd29 parent: 100238:aec2eae8933e user: Martin Panter date: Sun Feb 14 03:25:48 2016 +0000 summary: Issue #26316: Merge Arg Clinic fix from 3.5 files: Misc/NEWS | 2 ++ Tools/clinic/clinic.py | 2 +- 2 files changed, 3 insertions(+), 1 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -748,6 +748,8 @@ Tools/Demos ----------- +- Issue #26316: Fix variable name typo in Argument Clinic. + - Issue #25440: Fix output of python-config --extension-suffix. - Issue #25154: The pyvenv script has been deprecated in favour of diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py --- a/Tools/clinic/clinic.py +++ b/Tools/clinic/clinic.py @@ -199,7 +199,7 @@ add('\n') continue - name, curl, trailing = trailing.partition('}') + name, curly, trailing = trailing.partition('}') if not curly or name not in kwargs: add(line) add('\n') -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Feb 14 04:41:40 2016 From: python-checkins at python.org (raymond.hettinger) Date: Sun, 14 Feb 2016 09:41:40 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_The_return_type_of_a_rich_?= =?utf-8?q?comparison_is_an_int?= Message-ID: <20160214094140.25279.8841@psf.io> https://hg.python.org/cpython/rev/4523a0375f71 changeset: 100240:4523a0375f71 user: Raymond Hettinger date: Sun Feb 14 01:41:35 2016 -0800 summary: The return type of a rich comparison is an int files: Modules/_bisectmodule.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Modules/_bisectmodule.c b/Modules/_bisectmodule.c --- a/Modules/_bisectmodule.c +++ b/Modules/_bisectmodule.c @@ -12,7 +12,8 @@ internal_bisect_right(PyObject *list, PyObject *item, Py_ssize_t lo, Py_ssize_t hi) { PyObject *litem; - Py_ssize_t mid, res; + Py_ssize_t mid; + int res; if (lo < 0) { PyErr_SetString(PyExc_ValueError, "lo must be non-negative"); @@ -115,7 +116,8 @@ internal_bisect_left(PyObject *list, PyObject *item, Py_ssize_t lo, Py_ssize_t hi) { PyObject *litem; - Py_ssize_t mid, res; + Py_ssize_t mid; + int res; if (lo < 0) { PyErr_SetString(PyExc_ValueError, "lo must be non-negative"); -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Sun Feb 14 04:44:51 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Sun, 14 Feb 2016 09:44:51 +0000 Subject: [Python-checkins] Daily reference leaks (6c122e4e1cb2): sum=4 Message-ID: <20160214094451.24191.80014@psf.io> results for 6c122e4e1cb2 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogTql8R0', '--timeout', '7200'] From python-checkins at python.org Mon Feb 15 00:47:46 2016 From: python-checkins at python.org (ned.deily) Date: Mon, 15 Feb 2016 05:47:46 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2MjY4?= =?utf-8?q?=3A_Update_OS_X_10=2E5+_installer_build_to_use_OpenSSL_1=2E0=2E?= =?utf-8?b?MmYu?= Message-ID: <20160215054746.18340.27736@psf.io> https://hg.python.org/cpython/rev/3c3eae72dd04 changeset: 100242:3c3eae72dd04 branch: 3.5 parent: 100238:aec2eae8933e user: Ned Deily date: Mon Feb 15 16:44:38 2016 +1100 summary: Issue #26268: Update OS X 10.5+ installer build to use OpenSSL 1.0.2f. files: Mac/BuildScript/build-installer.py | 6 +- Mac/BuildScript/openssl_sdk_makedepend.patch | 22 +-------- Misc/NEWS | 2 +- 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/Mac/BuildScript/build-installer.py b/Mac/BuildScript/build-installer.py --- a/Mac/BuildScript/build-installer.py +++ b/Mac/BuildScript/build-installer.py @@ -237,9 +237,9 @@ result.extend([ dict( - name="OpenSSL 1.0.2e", - url="https://www.openssl.org/source/openssl-1.0.2e.tar.gz", - checksum='5262bfa25b60ed9de9f28d5d52d77fc5', + name="OpenSSL 1.0.2f", + url="https://www.openssl.org/source/openssl-1.0.2f.tar.gz", + checksum='b3bf73f507172be9292ea2a8c28b659d', patches=[ "openssl_sdk_makedepend.patch", ], diff --git a/Mac/BuildScript/openssl_sdk_makedepend.patch b/Mac/BuildScript/openssl_sdk_makedepend.patch --- a/Mac/BuildScript/openssl_sdk_makedepend.patch +++ b/Mac/BuildScript/openssl_sdk_makedepend.patch @@ -1,18 +1,17 @@ # HG changeset patch -# Parent ff8a7557607cffd626997e57ed31c1012a3018aa +# Parent d377390f787c0739a3e89f669def72d7167e5108 # openssl_sdk_makedepend.patch # -# using openssl 1.0.2e +# using openssl 1.0.2f # # - support building with an OS X SDK -# - allow "make depend" to use compilers with names other than "gcc" diff Configure diff --git a/Configure b/Configure --- a/Configure +++ b/Configure -@@ -635,12 +635,12 @@ +@@ -638,12 +638,12 @@ ##### MacOS X (a.k.a. Rhapsody or Darwin) setup "rhapsody-ppc-cc","cc:-O3 -DB_ENDIAN::(unknown):MACOSX_RHAPSODY::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}::", @@ -31,7 +30,7 @@ "debug-darwin-ppc-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DB_ENDIAN -g -Wall -O::-D_REENTRANT:MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc32_asm}:osx32:dlfcn:darwin-shared:-fPIC:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", # iPhoneOS/iOS "iphoneos-cross","llvm-gcc:-O3 -isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fomit-frame-pointer -fno-common::-D_REENTRANT:iOS:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", -@@ -1714,8 +1714,7 @@ +@@ -1717,8 +1717,7 @@ s/^CC=.*$/CC= $cc/; s/^AR=\s*ar/AR= $ar/; s/^RANLIB=.*/RANLIB= $ranlib/; @@ -41,16 +40,3 @@ } s/^CFLAG=.*$/CFLAG= $cflags/; s/^DEPFLAG=.*$/DEPFLAG=$depflags/; -diff --git a/util/domd b/util/domd ---- a/util/domd -+++ b/util/domd -@@ -14,8 +14,7 @@ - cp Makefile Makefile.save - # fake the presence of Kerberos - touch $TOP/krb5.h --if ${MAKEDEPEND} --version 2>&1 | grep -q "clang" || -- echo $MAKEDEPEND | grep -q "gcc"; then -+if true ; then - args="" - while [ $# -gt 0 ]; do - if [ "$1" != "--" ]; then args="$args $1"; fi diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -243,7 +243,7 @@ - Issue #25696: Fix installation of Python on UNIX with make -j9. -- Issue #25798: Update OS X 10.5 installer to use OpenSSL 1.0.2e. +- Issue #26268: Update OS X 10.5 installer to use OpenSSL 1.0.2f. Windows ------- -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 15 00:47:46 2016 From: python-checkins at python.org (ned.deily) Date: Mon, 15 Feb 2016 05:47:46 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326268=3A_merge_from_3=2E5?= Message-ID: <20160215054746.5752.96302@psf.io> https://hg.python.org/cpython/rev/6759581f9fd3 changeset: 100243:6759581f9fd3 parent: 100240:4523a0375f71 parent: 100242:3c3eae72dd04 user: Ned Deily date: Mon Feb 15 16:47:03 2016 +1100 summary: Issue #26268: merge from 3.5 files: Mac/BuildScript/build-installer.py | 6 +- Mac/BuildScript/openssl_sdk_makedepend.patch | 22 +-------- Misc/NEWS | 2 +- 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/Mac/BuildScript/build-installer.py b/Mac/BuildScript/build-installer.py --- a/Mac/BuildScript/build-installer.py +++ b/Mac/BuildScript/build-installer.py @@ -237,9 +237,9 @@ result.extend([ dict( - name="OpenSSL 1.0.2e", - url="https://www.openssl.org/source/openssl-1.0.2e.tar.gz", - checksum='5262bfa25b60ed9de9f28d5d52d77fc5', + name="OpenSSL 1.0.2f", + url="https://www.openssl.org/source/openssl-1.0.2f.tar.gz", + checksum='b3bf73f507172be9292ea2a8c28b659d', patches=[ "openssl_sdk_makedepend.patch", ], diff --git a/Mac/BuildScript/openssl_sdk_makedepend.patch b/Mac/BuildScript/openssl_sdk_makedepend.patch --- a/Mac/BuildScript/openssl_sdk_makedepend.patch +++ b/Mac/BuildScript/openssl_sdk_makedepend.patch @@ -1,18 +1,17 @@ # HG changeset patch -# Parent ff8a7557607cffd626997e57ed31c1012a3018aa +# Parent d377390f787c0739a3e89f669def72d7167e5108 # openssl_sdk_makedepend.patch # -# using openssl 1.0.2e +# using openssl 1.0.2f # # - support building with an OS X SDK -# - allow "make depend" to use compilers with names other than "gcc" diff Configure diff --git a/Configure b/Configure --- a/Configure +++ b/Configure -@@ -635,12 +635,12 @@ +@@ -638,12 +638,12 @@ ##### MacOS X (a.k.a. Rhapsody or Darwin) setup "rhapsody-ppc-cc","cc:-O3 -DB_ENDIAN::(unknown):MACOSX_RHAPSODY::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}::", @@ -31,7 +30,7 @@ "debug-darwin-ppc-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DB_ENDIAN -g -Wall -O::-D_REENTRANT:MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc32_asm}:osx32:dlfcn:darwin-shared:-fPIC:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", # iPhoneOS/iOS "iphoneos-cross","llvm-gcc:-O3 -isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fomit-frame-pointer -fno-common::-D_REENTRANT:iOS:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", -@@ -1714,8 +1714,7 @@ +@@ -1717,8 +1717,7 @@ s/^CC=.*$/CC= $cc/; s/^AR=\s*ar/AR= $ar/; s/^RANLIB=.*/RANLIB= $ranlib/; @@ -41,16 +40,3 @@ } s/^CFLAG=.*$/CFLAG= $cflags/; s/^DEPFLAG=.*$/DEPFLAG=$depflags/; -diff --git a/util/domd b/util/domd ---- a/util/domd -+++ b/util/domd -@@ -14,8 +14,7 @@ - cp Makefile Makefile.save - # fake the presence of Kerberos - touch $TOP/krb5.h --if ${MAKEDEPEND} --version 2>&1 | grep -q "clang" || -- echo $MAKEDEPEND | grep -q "gcc"; then -+if true ; then - args="" - while [ $# -gt 0 ]; do - if [ "$1" != "--" ]; then args="$args $1"; fi diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -730,7 +730,7 @@ Previously it could fail to compile properly if the math and cmath builds were concurrent. -- Issue #25798: Update OS X 10.5 installer to use OpenSSL 1.0.2e. +- Issue #26268: Update OS X 10.5 installer to use OpenSSL 1.0.2f. Windows ------- -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 15 00:47:46 2016 From: python-checkins at python.org (ned.deily) Date: Mon, 15 Feb 2016 05:47:46 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI2MjY4?= =?utf-8?q?=3A_Update_OS_X_10=2E5+_installer_build_to_use_OpenSSL_1=2E0=2E?= =?utf-8?b?MmYu?= Message-ID: <20160215054746.24201.61394@psf.io> https://hg.python.org/cpython/rev/1ceb431e1876 changeset: 100241:1ceb431e1876 branch: 2.7 parent: 100232:d3662c088db8 user: Ned Deily date: Mon Feb 15 16:42:36 2016 +1100 summary: Issue #26268: Update OS X 10.5+ installer build to use OpenSSL 1.0.2f. files: Mac/BuildScript/build-installer.py | 6 +- Mac/BuildScript/openssl_sdk_makedepend.patch | 22 +-------- Misc/NEWS | 4 +- 3 files changed, 9 insertions(+), 23 deletions(-) diff --git a/Mac/BuildScript/build-installer.py b/Mac/BuildScript/build-installer.py --- a/Mac/BuildScript/build-installer.py +++ b/Mac/BuildScript/build-installer.py @@ -237,9 +237,9 @@ result.extend([ dict( - name="OpenSSL 1.0.2e", - url="https://www.openssl.org/source/openssl-1.0.2e.tar.gz", - checksum='5262bfa25b60ed9de9f28d5d52d77fc5', + name="OpenSSL 1.0.2f", + url="https://www.openssl.org/source/openssl-1.0.2f.tar.gz", + checksum='b3bf73f507172be9292ea2a8c28b659d', patches=[ "openssl_sdk_makedepend.patch", ], diff --git a/Mac/BuildScript/openssl_sdk_makedepend.patch b/Mac/BuildScript/openssl_sdk_makedepend.patch --- a/Mac/BuildScript/openssl_sdk_makedepend.patch +++ b/Mac/BuildScript/openssl_sdk_makedepend.patch @@ -1,18 +1,17 @@ # HG changeset patch -# Parent ff8a7557607cffd626997e57ed31c1012a3018aa +# Parent d377390f787c0739a3e89f669def72d7167e5108 # openssl_sdk_makedepend.patch # -# using openssl 1.0.2e +# using openssl 1.0.2f # # - support building with an OS X SDK -# - allow "make depend" to use compilers with names other than "gcc" diff Configure diff --git a/Configure b/Configure --- a/Configure +++ b/Configure -@@ -635,12 +635,12 @@ +@@ -638,12 +638,12 @@ ##### MacOS X (a.k.a. Rhapsody or Darwin) setup "rhapsody-ppc-cc","cc:-O3 -DB_ENDIAN::(unknown):MACOSX_RHAPSODY::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}::", @@ -31,7 +30,7 @@ "debug-darwin-ppc-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DB_ENDIAN -g -Wall -O::-D_REENTRANT:MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc32_asm}:osx32:dlfcn:darwin-shared:-fPIC:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", # iPhoneOS/iOS "iphoneos-cross","llvm-gcc:-O3 -isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fomit-frame-pointer -fno-common::-D_REENTRANT:iOS:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", -@@ -1714,8 +1714,7 @@ +@@ -1717,8 +1717,7 @@ s/^CC=.*$/CC= $cc/; s/^AR=\s*ar/AR= $ar/; s/^RANLIB=.*/RANLIB= $ranlib/; @@ -41,16 +40,3 @@ } s/^CFLAG=.*$/CFLAG= $cflags/; s/^DEPFLAG=.*$/DEPFLAG=$depflags/; -diff --git a/util/domd b/util/domd ---- a/util/domd -+++ b/util/domd -@@ -14,8 +14,7 @@ - cp Makefile Makefile.save - # fake the presence of Kerberos - touch $TOP/krb5.h --if ${MAKEDEPEND} --version 2>&1 | grep -q "clang" || -- echo $MAKEDEPEND | grep -q "gcc"; then -+if true ; then - args="" - while [ $# -gt 0 ]; do - if [ "$1" != "--" ]; then args="$args $1"; fi diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -136,8 +136,8 @@ - Issue #25696: Fix installation of Python on UNIX with make -j9. -- Issue #25798: Update OS X 10.5+ 32-bit-only installer to build - and link with OpenSSL 1.0.2e. +- Issue #26268: Update OS X 10.5+ 32-bit-only installer to build + and link with OpenSSL 1.0.2f. What's New in Python 2.7.11? -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 15 00:58:06 2016 From: python-checkins at python.org (ned.deily) Date: Mon, 15 Feb 2016 05:58:06 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1OTI0?= =?utf-8?q?=3A_Avoid_unnecessary_serialization_of_getaddrinfo=283=29_calls?= =?utf-8?q?_on_OS_X?= Message-ID: <20160215055806.53113.92653@psf.io> https://hg.python.org/cpython/rev/86ddb4d747f8 changeset: 100245:86ddb4d747f8 branch: 3.5 parent: 100242:3c3eae72dd04 user: Ned Deily date: Mon Feb 15 16:54:08 2016 +1100 summary: Issue #25924: Avoid unnecessary serialization of getaddrinfo(3) calls on OS X versions 10.5 or higher. Original patch by A. Jesse Jiryu Davis. files: Misc/NEWS | 3 +++ Modules/socketmodule.c | 20 ++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -212,6 +212,9 @@ - Issue #26050: Add asyncio.StreamReader.readuntil() method. Patch by ???? ?????????. +- Issue #25924: Avoid unnecessary serialization of getaddrinfo(3) calls on + OS X versions 10.5 or higher. Original patch by A. Jesse Jiryu Davis. + Documentation ------------- diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -84,6 +84,11 @@ */ #ifdef __APPLE__ +#include +/* for getaddrinfo thread safety test on old versions of OS X */ +#ifndef MAC_OS_X_VERSION_10_5 +#define MAC_OS_X_VERSION_10_5 1050 +#endif /* * inet_aton is not available on OSX 10.3, yet we want to use a binary * that was build on 10.4 or later to work on that release, weak linking @@ -184,8 +189,19 @@ #include #endif /* On systems on which getaddrinfo() is believed to not be thread-safe, - (this includes the getaddrinfo emulation) protect access with a lock. */ -#if defined(WITH_THREAD) && (defined(__APPLE__) || \ + (this includes the getaddrinfo emulation) protect access with a lock. + + getaddrinfo is thread-safe on Mac OS X 10.5 and later. Originally it was + a mix of code including an unsafe implementation from an old BSD's + libresolv. In 10.5 Apple reimplemented it as a safe IPC call to the + mDNSResponder process. 10.5 is the first be UNIX '03 certified, which + includes the requirement that getaddrinfo be thread-safe. + + See issue #25924 for details. + */ +#if defined(WITH_THREAD) && ( \ + (defined(__APPLE__) && \ + MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5) || \ (defined(__FreeBSD__) && __FreeBSD_version+0 < 503000) || \ defined(__OpenBSD__) || defined(__NetBSD__) || \ !defined(HAVE_GETADDRINFO)) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 15 00:58:06 2016 From: python-checkins at python.org (ned.deily) Date: Mon, 15 Feb 2016 05:58:06 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI1OTI0?= =?utf-8?q?=3A_Avoid_unnecessary_serialization_of_getaddrinfo=283=29_calls?= =?utf-8?q?_on_OS_X?= Message-ID: <20160215055805.124190.33429@psf.io> https://hg.python.org/cpython/rev/58ebfa7c1361 changeset: 100244:58ebfa7c1361 branch: 2.7 parent: 100241:1ceb431e1876 user: Ned Deily date: Mon Feb 15 16:51:24 2016 +1100 summary: Issue #25924: Avoid unnecessary serialization of getaddrinfo(3) calls on OS X versions 10.5 or higher. Original patch by A. Jesse Jiryu Davis. files: Misc/NEWS | 3 +++ Modules/socketmodule.c | 20 ++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -112,6 +112,9 @@ - Issue #23914: Fixed SystemError raised by CPickle unpickler on broken data. +- Issue #25924: Avoid unnecessary serialization of getaddrinfo(3) calls on + OS X versions 10.5 or higher. Original patch by A. Jesse Jiryu Davis.. + Tests ----- diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -82,6 +82,11 @@ */ #ifdef __APPLE__ +#include +/* for getaddrinfo thread safety test on old versions of OS X */ +#ifndef MAC_OS_X_VERSION_10_5 +#define MAC_OS_X_VERSION_10_5 1050 +#endif /* * inet_aton is not available on OSX 10.3, yet we want to use a binary * that was build on 10.4 or later to work on that release, weak linking @@ -183,8 +188,19 @@ #include #endif /* On systems on which getaddrinfo() is believed to not be thread-safe, - (this includes the getaddrinfo emulation) protect access with a lock. */ -#if defined(WITH_THREAD) && (defined(__APPLE__) || \ + (this includes the getaddrinfo emulation) protect access with a lock. + + getaddrinfo is thread-safe on Mac OS X 10.5 and later. Originally it was + a mix of code including an unsafe implementation from an old BSD's + libresolv. In 10.5 Apple reimplemented it as a safe IPC call to the + mDNSResponder process. 10.5 is the first be UNIX '03 certified, which + includes the requirement that getaddrinfo be thread-safe. + + See issue #25924 for details. + */ +#if defined(WITH_THREAD) && ( \ + (defined(__APPLE__) && \ + MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5) || \ (defined(__FreeBSD__) && __FreeBSD_version+0 < 503000) || \ defined(__OpenBSD__) || defined(__NetBSD__) || \ defined(__VMS) || !defined(HAVE_GETADDRINFO)) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 15 00:58:06 2016 From: python-checkins at python.org (ned.deily) Date: Mon, 15 Feb 2016 05:58:06 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325924=3A_merge_with_3=2E5?= Message-ID: <20160215055806.5756.5893@psf.io> https://hg.python.org/cpython/rev/caca2b354773 changeset: 100246:caca2b354773 parent: 100243:6759581f9fd3 parent: 100245:86ddb4d747f8 user: Ned Deily date: Mon Feb 15 16:57:04 2016 +1100 summary: Issue #25924: merge with 3.5 files: Misc/NEWS | 3 +++ Modules/socketmodule.c | 20 ++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -579,6 +579,9 @@ - Issue #26050: Add asyncio.StreamReader.readuntil() method. Patch by ???? ?????????. +- Issue #25924: Avoid unnecessary serialization of getaddrinfo(3) calls on + OS X versions 10.5 or higher. Original patch by A. Jesse Jiryu Davis. + IDLE ---- diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -84,6 +84,11 @@ */ #ifdef __APPLE__ +#include +/* for getaddrinfo thread safety test on old versions of OS X */ +#ifndef MAC_OS_X_VERSION_10_5 +#define MAC_OS_X_VERSION_10_5 1050 +#endif /* * inet_aton is not available on OSX 10.3, yet we want to use a binary * that was build on 10.4 or later to work on that release, weak linking @@ -184,8 +189,19 @@ #include #endif /* On systems on which getaddrinfo() is believed to not be thread-safe, - (this includes the getaddrinfo emulation) protect access with a lock. */ -#if defined(WITH_THREAD) && (defined(__APPLE__) || \ + (this includes the getaddrinfo emulation) protect access with a lock. + + getaddrinfo is thread-safe on Mac OS X 10.5 and later. Originally it was + a mix of code including an unsafe implementation from an old BSD's + libresolv. In 10.5 Apple reimplemented it as a safe IPC call to the + mDNSResponder process. 10.5 is the first be UNIX '03 certified, which + includes the requirement that getaddrinfo be thread-safe. + + See issue #25924 for details. + */ +#if defined(WITH_THREAD) && ( \ + (defined(__APPLE__) && \ + MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5) || \ (defined(__FreeBSD__) && __FreeBSD_version+0 < 503000) || \ defined(__OpenBSD__) || defined(__NetBSD__) || \ !defined(HAVE_GETADDRINFO)) -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Mon Feb 15 04:55:16 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Mon, 15 Feb 2016 09:55:16 +0000 Subject: [Python-checkins] Daily reference leaks (4523a0375f71): sum=4 Message-ID: <20160215094505.24201.86417@psf.io> results for 4523a0375f71 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflog8bGeSt', '--timeout', '7200'] From lp_benchmark_robot at intel.com Mon Feb 15 07:38:59 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Mon, 15 Feb 2016 12:38:59 +0000 Subject: [Python-checkins] GOOD Benchmark Results for Python Default 2016-02-15 Message-ID: <6756a424-3c9d-4e37-9ebb-4854349f3b9a@irsmsx106.ger.corp.intel.com> Results for project Python default, build date 2016-02-15 03:09:42 +0000 commit: 4523a0375f71 previous commit: 37bacf3fa1f5 revision date: 2016-02-14 09:41:35 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.23% 1.59% 10.30% 14.92% :-| pybench 0.13% -0.17% 0.40% 5.15% :-( regex_v8 3.00% 0.53% -4.74% 4.63% :-| nbody 0.10% 1.24% -0.81% 6.48% :-| json_dump_v2 0.21% 0.32% -0.53% 10.19% :-| normal_startup 0.71% 0.07% 0.13% 5.04% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/good-benchmark-results-for-python-default-2016-02-15/ Note: Benchmark results are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Mon Feb 15 07:39:46 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Mon, 15 Feb 2016 12:39:46 +0000 Subject: [Python-checkins] GOOD Benchmark Results for Python 2.7 2016-02-15 Message-ID: <36ccbb69-7061-4b3c-83b8-da371b4232b0@irsmsx106.ger.corp.intel.com> Results for project Python 2.7, build date 2016-02-15 04:01:30 +0000 commit: d3662c088db8 previous commit: 5715a6d9ff12 revision date: 2016-02-12 22:39:21 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dc from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.14% 1.03% 5.49% 4.16% :-) pybench 0.08% -0.04% 6.22% 4.91% :-( regex_v8 0.79% -0.33% -2.93% 11.11% :-) nbody 0.26% 0.43% 4.84% 5.94% :-) json_dump_v2 0.19% 0.11% 4.54% 9.67% :-( normal_startup 1.81% -0.23% -5.80% 2.26% :-) ssbench 0.27% 0.66% 2.21% 1.80% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/good-benchmark-results-for-python-2-7-2016-02-15/ Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Mon Feb 15 11:50:46 2016 From: python-checkins at python.org (georg.brandl) Date: Mon, 15 Feb 2016 16:50:46 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Minor_clarification_in_tut?= =?utf-8?q?orial=2E?= Message-ID: <20160215165045.18336.58518@psf.io> https://hg.python.org/cpython/rev/6c6f7dff597b changeset: 100247:6c6f7dff597b user: Georg Brandl date: Mon Feb 15 17:50:33 2016 +0100 summary: Minor clarification in tutorial. files: Doc/tutorial/controlflow.rst | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst --- a/Doc/tutorial/controlflow.rst +++ b/Doc/tutorial/controlflow.rst @@ -78,6 +78,9 @@ >>> words ['defenestrate', 'cat', 'window', 'defenestrate'] +With ``for w in words:``, the example would attempt to create an infinite list, +inserting ``defenestrate`` over and over again. + .. _tut-range: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 15 21:28:41 2016 From: python-checkins at python.org (ned.deily) Date: Tue, 16 Feb 2016 02:28:41 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326368=3A_fix_typo_in_asynchio_stream_doc=2C_rep?= =?utf-8?q?orted_by_Ryan_Stuart=2E?= Message-ID: <20160216022841.18342.30270@psf.io> https://hg.python.org/cpython/rev/12502327d2c0 changeset: 100249:12502327d2c0 parent: 100247:6c6f7dff597b parent: 100248:8ee91cb2e2a4 user: Ned Deily date: Tue Feb 16 13:27:45 2016 +1100 summary: Issue #26368: fix typo in asynchio stream doc, reported by Ryan Stuart. files: Doc/library/asyncio-stream.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/library/asyncio-stream.rst b/Doc/library/asyncio-stream.rst --- a/Doc/library/asyncio-stream.rst +++ b/Doc/library/asyncio-stream.rst @@ -11,7 +11,7 @@ .. note:: - The top-level functions in this module are meant convenience wrappers + The top-level functions in this module are meant as convenience wrappers only; there's really nothing special there, and if they don't do exactly what you want, feel free to copy their code. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 15 21:28:42 2016 From: python-checkins at python.org (ned.deily) Date: Tue, 16 Feb 2016 02:28:42 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2MzY4?= =?utf-8?q?=3A_fix_typo_in_asynchio_stream_doc=2C_reported_by_Ryan_Stuart?= =?utf-8?q?=2E?= Message-ID: <20160216022841.61233.75265@psf.io> https://hg.python.org/cpython/rev/8ee91cb2e2a4 changeset: 100248:8ee91cb2e2a4 branch: 3.5 parent: 100245:86ddb4d747f8 user: Ned Deily date: Tue Feb 16 13:27:04 2016 +1100 summary: Issue #26368: fix typo in asynchio stream doc, reported by Ryan Stuart. files: Doc/library/asyncio-stream.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/library/asyncio-stream.rst b/Doc/library/asyncio-stream.rst --- a/Doc/library/asyncio-stream.rst +++ b/Doc/library/asyncio-stream.rst @@ -11,7 +11,7 @@ .. note:: - The top-level functions in this module are meant convenience wrappers + The top-level functions in this module are meant as convenience wrappers only; there's really nothing special there, and if they don't do exactly what you want, feel free to copy their code. -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Tue Feb 16 04:47:22 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Tue, 16 Feb 2016 09:47:22 +0000 Subject: [Python-checkins] Daily reference leaks (12502327d2c0): sum=4 Message-ID: <20160216094720.56714.54962@psf.io> results for 12502327d2c0 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogpVTcre', '--timeout', '7200'] From lp_benchmark_robot at intel.com Tue Feb 16 09:25:10 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Tue, 16 Feb 2016 14:25:10 +0000 Subject: [Python-checkins] BAD Benchmark Results for Python Default 2016-02-16 Message-ID: <5406ab32-500a-4198-a4aa-91494756ebe5@irsmsx104.ger.corp.intel.com> Results for project Python default, build date 2016-02-16 03:02:54 +0000 commit: 12502327d2c0 previous commit: 4523a0375f71 revision date: 2016-02-16 02:27:45 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.16% -1.92% 8.58% 15.21% :-| pybench 0.30% 0.10% 0.50% 5.26% :-( regex_v8 2.87% 0.09% -4.64% 4.45% :-| nbody 0.18% -0.76% -1.58% 8.17% :-| json_dump_v2 0.24% 0.23% -0.30% 11.38% :-| normal_startup 0.83% -0.04% 0.07% 5.94% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/bad-benchmark-results-for-python-default-2016-02-16/ Note: Benchmark results are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Tue Feb 16 09:27:07 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Tue, 16 Feb 2016 14:27:07 +0000 Subject: [Python-checkins] GOOD Benchmark Results for Python 2.7 2016-02-16 Message-ID: <19415d9a-4433-4584-8a9d-6a01adf6336c@irsmsx104.ger.corp.intel.com> Results for project Python 2.7, build date 2016-02-16 03:56:49 +0000 commit: 58ebfa7c1361 previous commit: d3662c088db8 revision date: 2016-02-15 05:51:24 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dc from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.14% 0.94% 6.38% 4.25% :-) pybench 0.14% 0.01% 6.22% 3.53% :-( regex_v8 0.76% 0.28% -2.64% 10.58% :-) nbody 0.12% 3.10% 7.79% 4.37% :-) json_dump_v2 0.25% -0.12% 4.43% 11.87% :-( normal_startup 1.95% -0.21% -6.02% 2.92% :-| ssbench 0.12% -0.26% 1.95% 1.45% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/good-benchmark-results-for-python-2-7-2016-02-16/ Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Wed Feb 17 08:20:18 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Wed, 17 Feb 2016 13:20:18 +0000 Subject: [Python-checkins] BAD Benchmark Results for Python Default 2016-02-17 Message-ID: <6a8eb47a-e965-42f2-96c8-34e656ddc76e@irsmsx103.ger.corp.intel.com> No new revisions. Here are the previous results: Results for project Python default, build date 2016-02-17 03:05:04 +0000 commit: 12502327d2c0 previous commit: 4523a0375f71 revision date: 2016-02-16 02:27:45 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.16% -1.92% 8.58% 15.21% :-| pybench 0.30% 0.10% 0.50% 5.26% :-( regex_v8 2.87% 0.09% -4.64% 4.45% :-| nbody 0.18% -0.76% -1.58% 8.17% :-| json_dump_v2 0.24% 0.23% -0.30% 11.38% :-| normal_startup 0.83% -0.04% 0.07% 5.94% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/bad-benchmark-results-for-python-default-2016-02-17/ Note: Benchmark results are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Wed Feb 17 08:21:36 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Wed, 17 Feb 2016 13:21:36 +0000 Subject: [Python-checkins] GOOD Benchmark Results for Python 2.7 2016-02-17 Message-ID: <8745f36c-452f-4baf-af5c-004631b1e41b@irsmsx103.ger.corp.intel.com> No new revisions. Here are the previous results: Results for project Python 2.7, build date 2016-02-17 03:06:58 +0000 commit: 58ebfa7c1361 previous commit: d3662c088db8 revision date: 2016-02-15 05:51:24 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dc from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.14% 0.94% 6.38% 4.25% :-) pybench 0.14% 0.01% 6.22% 3.53% :-( regex_v8 0.76% 0.28% -2.64% 10.58% :-) nbody 0.12% 3.10% 7.79% 4.37% :-) json_dump_v2 0.25% -0.12% 4.43% 11.87% :-( normal_startup 1.95% -0.21% -6.02% 2.92% :-| ssbench 0.12% -0.26% 1.95% 1.45% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/good-benchmark-results-for-python-2-7-2016-02-17/ Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Wed Feb 17 18:25:24 2016 From: python-checkins at python.org (donald.stufft) Date: Wed, 17 Feb 2016 23:25:24 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Update_PEP_508?= Message-ID: <20160217232524.1701.63856@psf.io> https://hg.python.org/peps/rev/655a101719a5 changeset: 6237:655a101719a5 user: Donald Stufft date: Wed Feb 17 18:25:21 2016 -0500 summary: Update PEP 508 files: pep-0508.txt | 19 +++++++++---------- 1 files changed, 9 insertions(+), 10 deletions(-) diff --git a/pep-0508.txt b/pep-0508.txt --- a/pep-0508.txt +++ b/pep-0508.txt @@ -107,7 +107,7 @@ env_var = ('python_version' | 'python_full_version' | 'os_name' | 'sys_platform' | 'platform_release' | 'platform_system' | 'platform_version' | - 'platform_machine' | 'python_implementation' | + 'platform_machine' | 'platform_python_implementation' | 'implementation_name' | 'implementation_version' | 'extra' # ONLY when defined by a containing layer ) @@ -124,9 +124,8 @@ Optional components of a distribution may be specified using the extras field:: - identifier = letterOrDigit ( - letterOrDigit | - (( letterOrDigit | '-' | '_' | '.')* letterOrDigit ) )* + identifer_end = letterOrDigit | (('-' | '_' | '.' )* letterOrDigit) + identifier = letterOrDigit identifier_end* name = identifier extras_list = identifier (wsp* ',' wsp* identifier)* extras = '[' wsp* extras_list? wsp* ']' @@ -263,7 +262,7 @@ * - ``platform_machine`` - ``platform.machine()`` - ``x86_64`` - * - ``python_implementation`` + * - ``platform_python_implementation`` - ``platform.python_implementation()`` - ``CPython``, ``Jython`` * - ``platform_release`` @@ -375,7 +374,7 @@ env_var = ('python_version' | 'python_full_version' | 'os_name' | 'sys_platform' | 'platform_release' | 'platform_system' | 'platform_version' | - 'platform_machine' | 'python_implementation' | + 'platform_machine' | 'platform_python_implementation' | 'implementation_name' | 'implementation_version' | 'extra' # ONLY when defined by a containing layer ):varname -> lookup(varname) @@ -388,9 +387,8 @@ | marker_and:m -> m marker = marker_or quoted_marker = ';' wsp* marker - identifier = + identifer_end = letterOrDigit | (('-' | '_' | '.' )* letterOrDigit) + identifier = < letterOrDigit identifier_end* > name = identifier extras_list = identifier:i (wsp* ',' wsp* identifier)*:ids -> [i] + ids extras = '[' wsp* extras_list?:e wsp* ']' -> e @@ -475,6 +473,7 @@ """ tests = [ "A", + "A.B-C_D", "aa", "name", "name>=3", @@ -510,11 +509,11 @@ 'implementation_version': implementation_version, 'os_name': os.name, 'platform_machine': platform.machine(), + 'platform_python_implementation': platform.python_implementation(), 'platform_release': platform.release(), 'platform_system': platform.system(), 'platform_version': platform.version(), 'python_full_version': platform.python_version(), - 'python_implementation': platform.python_implementation(), 'python_version': platform.python_version()[:3], 'sys_platform': sys.platform, } -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Thu Feb 18 01:18:44 2016 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 18 Feb 2016 06:18:44 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_open_the_cert_?= =?utf-8?q?store_readonly?= Message-ID: <20160218061843.1959.78646@psf.io> https://hg.python.org/cpython/rev/3cddcf471c70 changeset: 100250:3cddcf471c70 branch: 2.7 parent: 100244:58ebfa7c1361 user: Benjamin Peterson date: Wed Feb 17 22:13:19 2016 -0800 summary: open the cert store readonly Patch from Chi Hsuan Yen. files: Misc/NEWS | 2 ++ Modules/_ssl.c | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -50,6 +50,8 @@ Library ------- +- Issue #25939: On Windows open the cert store readonly in ssl.enum_certificates. + - Issue #24303: Fix random EEXIST upon multiprocessing semaphores creation with Linux PID namespaces enabled. diff --git a/Modules/_ssl.c b/Modules/_ssl.c --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -3653,7 +3653,9 @@ if (result == NULL) { return NULL; } - hStore = CertOpenSystemStore((HCRYPTPROV)NULL, store_name); + hStore = CertOpenStore(CERT_STORE_PROV_SYSTEM_A, 0, (HCRYPTPROV)NULL, + CERT_STORE_READONLY_FLAG | CERT_SYSTEM_STORE_LOCAL_MACHINE, + store_name); if (hStore == NULL) { Py_DECREF(result); return PyErr_SetFromWindowsErr(GetLastError()); @@ -3741,7 +3743,9 @@ if (result == NULL) { return NULL; } - hStore = CertOpenSystemStore((HCRYPTPROV)NULL, store_name); + hStore = CertOpenStore(CERT_STORE_PROV_SYSTEM_A, 0, (HCRYPTPROV)NULL, + CERT_STORE_READONLY_FLAG | CERT_SYSTEM_STORE_LOCAL_MACHINE, + store_name); if (hStore == NULL) { Py_DECREF(result); return PyErr_SetFromWindowsErr(GetLastError()); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 18 01:18:47 2016 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 18 Feb 2016 06:18:47 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E4=29=3A_open_the_cert_?= =?utf-8?q?store_readonly?= Message-ID: <20160218061844.1699.38855@psf.io> https://hg.python.org/cpython/rev/9f29cf9ad17f changeset: 100251:9f29cf9ad17f branch: 3.4 parent: 100035:8b58c9328f5c user: Benjamin Peterson date: Wed Feb 17 22:13:19 2016 -0800 summary: open the cert store readonly Patch from Chi Hsuan Yen. files: Misc/NEWS | 2 ++ Modules/_ssl.c | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -16,6 +16,8 @@ Library ------- +- Issue #25939: On Windows open the cert store readonly in ssl.enum_certificates. + - Issue #22570: Add 'path' attribute to pathlib.Path objects, returning the same as str(), to make it more similar to DirEntry. Library code can now write getattr(p, 'path', p) to get the path as diff --git a/Modules/_ssl.c b/Modules/_ssl.c --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -3597,7 +3597,9 @@ if (result == NULL) { return NULL; } - hStore = CertOpenSystemStore((HCRYPTPROV)NULL, store_name); + hStore = CertOpenStore(CERT_STORE_PROV_SYSTEM_A, 0, (HCRYPTPROV)NULL, + CERT_STORE_READONLY_FLAG | CERT_SYSTEM_STORE_LOCAL_MACHINE, + store_name); if (hStore == NULL) { Py_DECREF(result); return PyErr_SetFromWindowsErr(GetLastError()); @@ -3685,7 +3687,9 @@ if (result == NULL) { return NULL; } - hStore = CertOpenSystemStore((HCRYPTPROV)NULL, store_name); + hStore = CertOpenStore(CERT_STORE_PROV_SYSTEM_A, 0, (HCRYPTPROV)NULL, + CERT_STORE_READONLY_FLAG | CERT_SYSTEM_STORE_LOCAL_MACHINE, + store_name); if (hStore == NULL) { Py_DECREF(result); return PyErr_SetFromWindowsErr(GetLastError()); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 18 01:18:47 2016 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 18 Feb 2016 06:18:47 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_merge_3=2E4_=28closes_=2325939=29?= Message-ID: <20160218061844.1534.92637@psf.io> https://hg.python.org/cpython/rev/8ff4c1827499 changeset: 100252:8ff4c1827499 branch: 3.5 parent: 100248:8ee91cb2e2a4 parent: 100251:9f29cf9ad17f user: Benjamin Peterson date: Wed Feb 17 22:18:20 2016 -0800 summary: merge 3.4 (closes #25939) files: Misc/NEWS | 2 ++ Modules/_ssl.c | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -76,6 +76,8 @@ Library ------- +- Issue #25939: On Windows open the cert store readonly in ssl.enum_certificates. + - Issue #25995: os.walk() no longer uses FDs proportional to the tree depth. - Issue #26117: The os.scandir() iterator now closes file descriptor not only diff --git a/Modules/_ssl.c b/Modules/_ssl.c --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -4198,7 +4198,9 @@ if (result == NULL) { return NULL; } - hStore = CertOpenSystemStore((HCRYPTPROV)NULL, store_name); + hStore = CertOpenStore(CERT_STORE_PROV_SYSTEM_A, 0, (HCRYPTPROV)NULL, + CERT_STORE_READONLY_FLAG | CERT_SYSTEM_STORE_LOCAL_MACHINE, + store_name); if (hStore == NULL) { Py_DECREF(result); return PyErr_SetFromWindowsErr(GetLastError()); @@ -4284,7 +4286,9 @@ if (result == NULL) { return NULL; } - hStore = CertOpenSystemStore((HCRYPTPROV)NULL, store_name); + hStore = CertOpenStore(CERT_STORE_PROV_SYSTEM_A, 0, (HCRYPTPROV)NULL, + CERT_STORE_READONLY_FLAG | CERT_SYSTEM_STORE_LOCAL_MACHINE, + store_name); if (hStore == NULL) { Py_DECREF(result); return PyErr_SetFromWindowsErr(GetLastError()); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 18 01:18:54 2016 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 18 Feb 2016 06:18:54 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_merge_3=2E5_=28closes_=2325939=29?= Message-ID: <20160218061849.1723.72030@psf.io> https://hg.python.org/cpython/rev/d6474257ef38 changeset: 100253:d6474257ef38 parent: 100249:12502327d2c0 parent: 100252:8ff4c1827499 user: Benjamin Peterson date: Wed Feb 17 22:18:35 2016 -0800 summary: merge 3.5 (closes #25939) files: Misc/NEWS | 2 ++ Modules/_ssl.c | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -186,6 +186,8 @@ Library ------- +- Issue #25939: On Windows open the cert store readonly in ssl.enum_certificates. + - Issue #25995: os.walk() no longer uses FDs proportional to the tree depth. - Issue #25994: Added the close() method and the support of the context manager diff --git a/Modules/_ssl.c b/Modules/_ssl.c --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -4198,7 +4198,9 @@ if (result == NULL) { return NULL; } - hStore = CertOpenSystemStore((HCRYPTPROV)NULL, store_name); + hStore = CertOpenStore(CERT_STORE_PROV_SYSTEM_A, 0, (HCRYPTPROV)NULL, + CERT_STORE_READONLY_FLAG | CERT_SYSTEM_STORE_LOCAL_MACHINE, + store_name); if (hStore == NULL) { Py_DECREF(result); return PyErr_SetFromWindowsErr(GetLastError()); @@ -4284,7 +4286,9 @@ if (result == NULL) { return NULL; } - hStore = CertOpenSystemStore((HCRYPTPROV)NULL, store_name); + hStore = CertOpenStore(CERT_STORE_PROV_SYSTEM_A, 0, (HCRYPTPROV)NULL, + CERT_STORE_READONLY_FLAG | CERT_SYSTEM_STORE_LOCAL_MACHINE, + store_name); if (hStore == NULL) { Py_DECREF(result); return PyErr_SetFromWindowsErr(GetLastError()); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 18 02:43:17 2016 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 18 Feb 2016 07:43:17 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogZml4IHR5cG8gKGNs?= =?utf-8?q?oses_=2326378=29?= Message-ID: <20160218074317.1975.60105@psf.io> https://hg.python.org/cpython/rev/69717fdd9d5a changeset: 100255:69717fdd9d5a branch: 3.5 parent: 100252:8ff4c1827499 user: Benjamin Peterson date: Wed Feb 17 23:42:46 2016 -0800 summary: fix typo (closes #26378) files: Doc/howto/regex.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/howto/regex.rst b/Doc/howto/regex.rst --- a/Doc/howto/regex.rst +++ b/Doc/howto/regex.rst @@ -178,7 +178,7 @@ Repetitions such as ``*`` are :dfn:`greedy`; when repeating a RE, the matching engine will try to repeat it as many times as possible. If later portions of the pattern don't match, the matching engine will then back up and try again with -few repetitions. +fewer repetitions. A step-by-step example will make this more obvious. Let's consider the expression ``a[bcd]*b``. This matches the letter ``'a'``, zero or more letters -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 18 02:43:19 2016 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 18 Feb 2016 07:43:19 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogZml4IHR5cG8gKGNs?= =?utf-8?q?oses_=2326378=29?= Message-ID: <20160218074317.1720.33049@psf.io> https://hg.python.org/cpython/rev/c272a1e53f5b changeset: 100254:c272a1e53f5b branch: 2.7 parent: 100250:3cddcf471c70 user: Benjamin Peterson date: Wed Feb 17 23:42:46 2016 -0800 summary: fix typo (closes #26378) files: Doc/howto/regex.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/howto/regex.rst b/Doc/howto/regex.rst --- a/Doc/howto/regex.rst +++ b/Doc/howto/regex.rst @@ -172,7 +172,7 @@ Repetitions such as ``*`` are :dfn:`greedy`; when repeating a RE, the matching engine will try to repeat it as many times as possible. If later portions of the pattern don't match, the matching engine will then back up and try again with -few repetitions. +fewer repetitions. A step-by-step example will make this more obvious. Let's consider the expression ``a[bcd]*b``. This matches the letter ``'a'``, zero or more letters -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 18 02:43:37 2016 From: python-checkins at python.org (benjamin.peterson) Date: Thu, 18 Feb 2016 07:43:37 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?b?KTogbWVyZ2UgMy41ICgjMjYzNzgp?= Message-ID: <20160218074317.1711.48553@psf.io> https://hg.python.org/cpython/rev/6f0d3ae9f1f3 changeset: 100256:6f0d3ae9f1f3 parent: 100253:d6474257ef38 parent: 100255:69717fdd9d5a user: Benjamin Peterson date: Wed Feb 17 23:43:08 2016 -0800 summary: merge 3.5 (#26378) files: Doc/howto/regex.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/howto/regex.rst b/Doc/howto/regex.rst --- a/Doc/howto/regex.rst +++ b/Doc/howto/regex.rst @@ -178,7 +178,7 @@ Repetitions such as ``*`` are :dfn:`greedy`; when repeating a RE, the matching engine will try to repeat it as many times as possible. If later portions of the pattern don't match, the matching engine will then back up and try again with -few repetitions. +fewer repetitions. A step-by-step example will make this more obvious. Let's consider the expression ``a[bcd]*b``. This matches the letter ``'a'``, zero or more letters -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Thu Feb 18 04:46:15 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Thu, 18 Feb 2016 09:46:15 +0000 Subject: [Python-checkins] Daily reference leaks (12502327d2c0): sum=7 Message-ID: <20160218094615.1975.44087@psf.io> results for 12502327d2c0 on branch "default" -------------------------------------------- test_asyncio leaked [3, 0, 0] memory blocks, sum=3 test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogPjeXTX', '--timeout', '7200'] From python-checkins at python.org Thu Feb 18 05:55:10 2016 From: python-checkins at python.org (donald.stufft) Date: Thu, 18 Feb 2016 10:55:10 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Add_PEP_516?= Message-ID: <20160218105510.1584.66874@psf.io> https://hg.python.org/peps/rev/7e55223080b7 changeset: 6238:7e55223080b7 user: Donald Stufft date: Thu Feb 18 05:52:24 2016 -0500 summary: Add PEP 516 files: pep-0516.txt | 485 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 485 insertions(+), 0 deletions(-) diff --git a/pep-0516.txt b/pep-0516.txt new file mode 100644 --- /dev/null +++ b/pep-0516.txt @@ -0,0 +1,485 @@ +PEP: 516 +Title: Build system abstraction for pip/conda etc +Version: $Revision$ +Last-Modified: $Date$ +Author: Robert Collins , + Nathaniel Smith +BDFL-Delegate: Donald Stufft +Discussions-To: distutils-sig +Status: Draft +Type: Standards Track +Content-Type: text/x-rst +Created: 26-Oct-2015 + + +Abstract +======== + +This PEP specifies a programmatic interface for pip [#pip]_ and other +distribution or installation tools to use when working with Python +source trees (both the developer tree - e.g. the git tree - and source +distributions). + +The programmatic interface allows decoupling of pip from its current +hard dependency on setuptools [#setuptools]_ able for two +key reasons: + +1. It enables new build systems that may be much easier to use without + requiring them to even appear to be setuptools. + +2. It facilitates setuptools itself changing its user interface without + breaking pip, giving looser coupling. + +The interface needed to permit pip to install build systems also enables pip to +install build time requirements for packages which is an important step in +getting pip to full feature parity with the installation components of +easy-install. + +As PEP-426 [#pep426]_ is draft, we cannot utilise the metadata format it +defined. However PEP-427 wheels are in wide use and fairly well specified, so +we have adopted the METADATA format from that for specifying distribution +dependencies and general project metadata. PEP-0508 [#pep508] provides a self +contained language for describing a dependency, which we encapsulate in a thin +JSON schema to describe bootstrap dependencies. + +Since Python sdists specified in PEP-0314 [#pep314] are also source trees, this +PEP is updating the definition of sdists. + +Motivation +========== + +There is significant pent-up frustration in the Python packaging ecosystem +around the current lock-in between build system and pip. Breaking that lock-in +is better for pip, for setuptools, and for other build systems like flit +[#flit]_. + +Specification +============= + +Overview +-------- + +Build tools will be located by reading a file ``pypa.json`` from the root +directory of the source tree. That file describes how to get the build tool +and the name of the command to run to invoke the tool. + +All tools will be expected to conform to a single command line interface +modelled on pip's existing use of the setuptools setup.py interface. + +pypa.json +--------- + +The file ``pypa.json`` acts as a neutral configuration file for pip and other +tools that want to build source trees to consult for configuration. The +absence of a ``pypa.json`` file in a Python source tree implies a setuptools +or setuptools compatible build system. + +The JSON has the following schema. Extra keys are ignored, which permits the +use of ``pypa.json`` as a configuration file for other related tools. If doing +that the chosen keys must be namespaced under ``tools``:: + + {"tools": {"flit": ["Flits content here"]}} + +schema + The version of the schema. This PEP defines version "1". Defaults to "1" + when absent. All tools reading the file must error on an unrecognised + schema version. + +bootstrap_requires + Optional list of dependency specifications [#dependencyspec] that must be + installed before running the build tool. For instance, if using flit, then + the requirements might be:: + + bootstrap_requires: ["flit"] + +build_command + A mandatory key, this is a list of Python format strings [#strformat]_ + describing the command to run. For instance, if using flit then the build + command might be:: + + build_command: ["flit"] + + If using a command which is a runnable module fred:: + + build_command: ["{PYTHON}", "-m", "fred"] + +Process interface +----------------- + +The command to run is defined by a simple Python format string [#strformat]_. + +This permits build systems with dedicated scripts and those that are invoked +using "python -m somemodule". + +Processes will be run with the current working directory set to the root of +the source tree. + +When run, processes should not read from stdin - while pip currently runs +build systems with stdin connected to it's own stdin, stdout and stderr are +redirected and no communication with the user is possible. + +As usual with processes, a non-zero exit status indicates an error. + +Available format variables +-------------------------- + +PYTHON + The Python interpreter in use. This is important to enable calling things + which are just Python entry points. + + {PYTHON} -m foo + +Available environment variables +------------------------------- + +These variables are set by the caller of the build system and will always be +available. + +PATH + The standard system path. + +PYTHON + As for format variables. + +PYTHONPATH + Used to control sys.path per the normal Python mechanisms. + +Subcommands +----------- + +There are a number of separate subcommands that build systems must support. +The examples below use a build_command of ``flit`` for illustrative purposes. + +build_requires + Query build requirements. Build requirements are returned as a UTF-8 + encoded JSON document with one key ``build_requires`` consisting of a list + of dependency specifications [#dependencyspec]_. Additional keys must be + ignored. The build_requires command is the only command run without + setting up a build environment. + + Example command:: + + flit build_requires + +metadata + Query project metadata. The metadata and only the metadata should + be output on stdout in UTF-8 encoding. pip would run metadata just once to + determine what other packages need to be downloaded and installed. The + metadata is output as a wheel METADATA file per PEP-427 [#pep427]_. + + Note that the metadata generated by the metadata command, and the metadata + present in a generated wheel must be identical. + + Example command:: + + flit metadata + +wheel -d OUTPUT_DIR + Command to run to build a wheel of the project. OUTPUT_DIR will point to + an existing directory where the wheel should be output. Stdout and stderr + have no semantic meaning. Only one file should be output - if more are + output then pip would pick an arbitrary one to consume. + + Example command:: + + flit wheel -d /tmp/pip-build_1234 + +develop [--prefix PREFIX] + Command to do an in-place 'development' installation of the project. + Stdout and stderr have no semantic meaning. + + Not all build systems will be able to perform develop installs. If a build + system cannot do develop installs, then it should error when run. Note + that doing so will cause use operations like ``pip install -e foo`` to + fail. + + The prefix option is used for defining an alternative prefix for the + installation. While setuptools has ``--root`` and ``--user`` options, + they can be done equivalently using ``--prefix``, and pip or other + tools that accept ``--root`` or ``--user`` options should translate + appropriately. + + The root option is used to define an alternative root within which the + command should operate. + + For instance:: + + flit develop --root /tmp/ --prefix /usr/local + + Should install scripts within `/tmp/usr/local/bin`, even if the Python + environment in use reports that the sys.prefix is `/usr/` which would lead + to using `/tmp/usr/bin/`. Similar logic applies for package files etc. + +The build environment +--------------------- + +Except for the build_requires command, all commands are run within a build +environment. No specific implementation is required, but a build environment +must achieve the following requirements. + +1. All dependencies specified by the project's build_requires must be + available for import from within ``$PYTHON``. + +1. All command-line scripts provided by the build-required packages must be + present in ``$PATH``. + +A corollary of this is that build systems cannot assume access to any Python +package that is not declared as a build_requires or in the Python standard +library. + +Hermetic builds +--------------- + +This specification does not prescribe whether builds should be hermetic or not. +Existing build tools like setuptools will use installed versions of build time +requirements (e.g. setuptools_scm) and only install other versions on version +conflicts or missing dependencies. However its likely that better consistency +can be created by always isolation builds and using only the specified dependencies. + +However there are nuanced problems there - such as how can users force the +avoidance of a bad version of a build requirement which meets some packages +dependencies. Future PEPs may tackle this problem, but it is not currently in +scope - it does not affect the metadata required to coordinate between build +systems and things that need to do builds, and thus is not PEP material. + +Upgrades +-------- + +'pypa.json' is versioned to permit future changes without requiring +compatibility. + +The sequence for upgrading either of schemas in a new PEP will be: + +1. Issue new PEP defining an updated schema. If the schema is not entirely + backward compatible then a new version number must be defined. +2. Consumers (e.g. pip) implement support for the new schema version. +3. Package authors opt into the new schema when they are happy to introduce a + dependency on the version of 'pip' (and potentially other consumers) that + introduced support for the new schema version. + +The *same* process will take place for the initial deployment of this PEP:- +the propogation of the capability to use this PEP without a `setuptools shim`_ +will be largely gated by the adoption rate of the first version of pip that +supports it. + +Static metadata in sdists +------------------------- + +This PEP does not tackle the current inability to trust static metadata in +sdists. That is a separate problem to identifying and consuming the build +system that is in use in a source tree, whether it came from an sdist or not. + +Handling of compiler options +---------------------------- + +Handling of different compiler options is out of scope for this specification. + +pip currently handles compiler options by appending user supplied strings to +the command line it runs when running setuptools. This approach is sufficient +to work with the build system interface defined in this PEP, with the +exception that globally specified options will stop working globally as +different build systems evolve. That problem can be solved in pip (or conda or +other installers) without affecting interoperability. + +In the long term, wheels should be able to express the difference between +wheels built with one compiler or options vs another, and that is PEP +material. + +Examples +======== + +An example 'pypa.json' for using flit:: + + {"bootstrap_requires": ["flit"], + "build_command": "flit"} + +When 'pip' reads this it would prepare an environment with flit in it before +trying to use flit. + +Because flit doesn't have setup-requires support today, +`flit build_requires` would just output a constant string:: + + {"build_requires": []} + +`flit metadata` would interrogate `flit.ini` and marshal the metadata into +a wheel METADATA file and output that on stdout. + +`flit wheel` would need to accept a `-d` parameter that tells it where to output the +wheel (pip needs this). + +Backwards Compatibility +======================= + +Older pips will remain unable to handle alternative build systems. +This is no worse than the status quo - and individual build system +projects can decide whether to include a shim ``setup.py`` or not. + +All existing build systems that can product wheels and do develop installs +should be able to run under this abstraction and will only need a specific +adapter for them constructed and published on PyPI. + +In the absence of a ``pypa.json`` file, tools like pip should assume a +setuptools build system and use setuptools commands directly. + +Network effects +--------------- + +Projects that adopt build systems that are not setuptools compatible - that +is that they have no setup.py, or the setup.py doesn't accept commands that +existing tools try to use - will not be installable by those existing tools. + +Where those projects are used by other projects, this effect will cascade. + +In particular, because pip does not handle setup-requires today, any project +(A) that adopts a setuptools-incompatible build system and is consumed as a +setup-requirement by a second project (B) which has not itself transitioned to +having a pypa.json will make B uninstallable by any version of pip. This is +because setup.py in B will trigger easy-install when 'setup.py egg_info' is +run by pip, and that will try and fail to install A. + +As such we recommend that tools which are currently used as setup-requires +either ensure that they keep a `setuptools shim`_ or find their consumers and +get them all to upgrade to the use of a `pypa.json` in advance of moving +themselves. Pragmatically that is impossible, so the advice is to keep a +setuptools shim indefinitely - both for projects like pbr, setuptools_scm and +also projects like numpy. + +setuptools shim +--------------- + +It would be possible to write a generic setuptools shim that looks like +``setup.py`` and under the hood uses ``pypa.json`` to drive the builds. This +is not needed for pip to use the system, but would allow package authors to +use the new features while still retaining compatibility with older pip +versions. + +Rationale +========= + +This PEP started with a long mailing list thread on distutils-sig [#thread]_. +Subsequent to that a online meeting was held to debug all the positions folk +had. Minutes from that were posted to the list [#minutes]_. + +This specification is a translation of the consensus reached there into PEP +form, along with some arbitrary choices on the minor remaining questions. + +The basic heuristic for the design has been to focus on introducing an +abstraction without requiring development not strictly tied to the +abstraction. Where the gap is small to improvements, or the cost of using the +existing interface is very high, then we've taken on having the improvement as +a dependency, but otherwise defered such to future iterations. + +We chose wheel METADATA files rather than defining a new specification, +because pip can already handle wheel .dist-info directories which encode all +the necessary data in a METADATA file. PEP-426 can't be used as it's still +draft, and defining a new metadata format, while we should do that, is a +separate problem. Using a directory on disk would not add any value to the +interface (pip has to do that today due to limitations in the setuptools +CLI). + +The use of 'develop' as a command is because there is no PEP specifying the +interoperability of things that do what 'setuptools develop' does - so we'll +need to define that before pip can take on the responsibility for doing the +'develop' step. Once that's done we can issue a successor PEP to this one. + +The use of a command line API rather than a Python API is a little +contentious. Fundamentally anything can be made to work, and the pip +maintainers have spoken strongly in favour of retaining a process based +interface - something that is mature and robust in pip today. + +The choice of JSON as a file format is a compromise between several +constraints. Firstly there is no stdlib YAML interpreter, nor one for any of +the other low-friction structured file formats. Secondly, INIParser is a poor +format for a number of reasons, primarily that it has very minimal structure - +but pip's maintainers are not fond of it. JSON is in the stdlib, has +sufficient structure to permit embedding anything we want in future without +requiring embedded DSL's. + +Donald suggested using ``setup.cfg`` and the existing setuptools command line +rather than inventing something new. While that would permit interoperability +with less visible changes, it requires nearly as much engineering on the pip +side - looking for the new key in setup.cfg, implementing the non-installed +environments to run the build in. And the desire from other build system +authors not to confuse their users by delivering something that looks like but +behaves quite differently to setuptools seems like a bigger issue than pip +learning how to invoke a custom build tool. + +The metadata and wheel commands are required to have consistent metadata to +avoid a race condition that could otherwise happen where pip reads the +metadata, acts on it, and then the resulting wheel has incompatible +requirements. That race is exploited today by packages using PEP-426 +environment markers, to work with older pip versions that do not support +environment markers. That exploit is not needed with this PEP, because either +the setuptools shim is in use (with older pip versions), or an environment +marker ready pip is in use. The setuptools shim can take care of exploiting +the difference older pip versions require. + +We discussed having an sdist verb. The main driver for this was to make sure +that build systems were able to produce sdists that pip can build - but this is +circular: the whole point of this PEP is to let pip consume such sdists or VCS +source trees reliably and without requiring an implementation of setuptools. +Being able to create new sdists from existing source trees isn't a thing pip +does today, and while there is a PR to do that as part of building from +source, it is contentious and lacks consensus. Rather than impose a +requirement on all build systems, we are treating it as a YAGNI, and will add +such a verb in a future version of the interface if required. The existing +PEP-314 [#pep314] requirements for sdists still apply, and distutils or setuptools +users can use ``setup.py sdist`` to create an sdist. Other tools should create +sdists compatible with PEP-314 [#pep314]. Note that pip itself does not require +PEP-314 compatibility - it does not use any of the metadata from sdists - they +are treated like source trees from disk or version control. + +References +========== + +.. [#pip] pip, the recommended installer for Python packages + (http://pip.readthedocs.org/en/stable/) + +.. [#setuptools] setuptools, the defacto Python package build system + (https://pythonhosted.org/setuptools/) + +.. [#flit] flit, a simple way to put packages in PyPI + (http://flit.readthedocs.org/en/latest/) + +.. [#pypi] PyPI, the Python Package Index + (https://pypi.python.org/) + +.. [#shellvars] Shellvars, an implementation of shell variable rules for Python. + (https://github.com/testing-cabal/shellvars) + +.. [#pep426] PEP-426, Python distribution metadata. + (https://www.python.org/dev/peps/pep-0426/) + +.. [#pep427] PEP-427, Python distribution metadata. + (https://www.python.org/dev/peps/pep-0427/) + +.. [#thread] The kick-off thread. + (https://mail.python.org/pipermail/distutils-sig/2015-October/026925.html) + +.. [#minutes] The minutes. + (https://mail.python.org/pipermail/distutils-sig/2015-October/027214.html) + +.. [#strformat] The Python string formatting syntax. + (https://docs.python.org/3.1/library/string.html#format-string-syntax) + +.. [#pep314] Metadata for Python Software Packages v1.1 + (https://www.python.org/dev/peps/pep-0314/) + +.. [#pep508] Dependency specification language PEP. + (https://www.python.org/dev/peps/pep-0508/) + +Copyright +========= + +This document has been placed in the public domain. + + + +.. + Local Variables: + mode: indented-text + indent-tabs-mode: nil + sentence-end-double-space: t + fill-column: 70 + coding: utf-8 + End: -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Thu Feb 18 06:01:12 2016 From: python-checkins at python.org (donald.stufft) Date: Thu, 18 Feb 2016 11:01:12 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Assign_PEP_517?= Message-ID: <20160218110100.1519.13153@psf.io> https://hg.python.org/peps/rev/7a5c2eb792a7 changeset: 6239:7a5c2eb792a7 user: Donald Stufft date: Thu Feb 18 06:00:57 2016 -0500 summary: Assign PEP 517 files: pep-0517.txt | 726 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 726 insertions(+), 0 deletions(-) diff --git a/pep-0517.txt b/pep-0517.txt new file mode 100644 --- /dev/null +++ b/pep-0517.txt @@ -0,0 +1,726 @@ +PEP: 517 +Title: A build-system independent format for source trees +Version: $Revision$ +Last-Modified: $Date$ +Author: Nathaniel J. Smith +BDFL-Delegate: Nick Coghlan +Discussions-To: +Status: Draft +Type: Standards Track +Content-Type: text/x-rst +Created: 30-Sep-2015 +Post-History: 1 Oct 2015, 25 Oct 2015 + + +========== + Abstract +========== + +While ``distutils`` / ``setuptools`` have taken us a long way, they +suffer from three serious problems: (a) they're missing important +features like usable build-time dependency declaration, +autoconfiguration, and even basic ergonomic niceties like `DRY +`_-compliant +version number management, and (b) extending them is difficult, so +while there do exist various solutions to the above problems, they're +often quirky, fragile, and expensive to maintain, and yet (c) it's +very difficult to use anything else, because distutils/setuptools +provide the standard interface for installing packages expected by +both users and installation tools like ``pip``. + +Previous efforts (e.g. distutils2 or setuptools itself) have attempted +to solve problems (a) and/or (b). This proposal aims to solve (c). + +The goal of this PEP is get distutils-sig out of the business of being +a gatekeeper for Python build systems. If you want to use distutils, +great; if you want to use something else, then that should be easy to +do using standardized methods. The difficulty of interfacing with +distutils means that there aren't many such systems right now, but to +give a sense of what we're thinking about see `flit +`_ or `bento +`_. Fortunately, wheels have now +solved many of the hard problems here -- e.g. it's no longer necessary +that a build system also know about every possible installation +configuration -- so pretty much all we really need from a build system +is that it have some way to spit out standard-compliant wheels and +sdists. + +We therefore propose a new, relatively minimal interface for +installation tools like ``pip`` to interact with package source trees +and source distributions. + + +======================= + Terminology and goals +======================= + +A *source tree* is something like a VCS checkout. We need a standard +interface for installing from this format, to support usages like +``pip install some-directory/``. + +A *source distribution* is a static snapshot representing a particular +release of some source code, like ``lxml-3.4.4.zip``. Source +distributions serve many purposes: they form an archival record of +releases, they provide a stupid-simple de facto standard for tools +that want to ingest and process large corpora of code, possibly +written in many languages (e.g. code search), they act as the input to +downstream packaging systems like Debian/Fedora/Conda/..., and so +forth. In the Python ecosystem they additionally have a particularly +important role to play, because packaging tools like ``pip`` are able +to use source distributions to fulfill binary dependencies, e.g. if +there is a distribution ``foo.whl`` which declares a dependency on +``bar``, then we need to support the case where ``pip install bar`` or +``pip install foo`` automatically locates the sdist for ``bar``, +downloads it, builds it, and installs the resulting package. + +Source distributions are also known as *sdists* for short. + +A *build frontend* is a tool that users might run that takes arbitrary +source trees or source distributions and builds wheels from them. The +actual building is done by each source tree's *build backend*. In a +command like ``pip wheel some-directory/``, pip is acting as a build +frontend. + +An *integration frontend* is a tool that users might run that takes a +set of package requirements (e.g. a requirements.txt file) and +attempts to update a working environment to satisfy those +requirements. This may require locating, building, and installing a +combination of wheels and sdists. In a command like ``pip install +lxml==2.4.0``, pip is acting as an integration frontend. + + +============== + Source trees +============== + +There is an existing, legacy source tree format involving +``setup.py``. We don't try to specify it further; its de facto +specification is encoded in the source code and documentation of +``distutils``, ``setuptools``, ``pip``, and other tools. We'll refer +to it as the ``setup.py``\-style. + +Here we define a new ``pypackage.json``\-style source tree. This +consists of any any directory which contains a file named +``pypackage.json``. (If a tree contains both ``pypackage.json`` and +``setup.py`` then it is a ``pypackage.json``\-style source tree, and +``pypackage.json``\-aware tools should ignore the ``setup.py``; this +allows packages to include a ``setup.py`` for compatibility with old +build frontends, while using the new system with new build frontends.) + +This file has the following schema. Extra keys are ignored. + +schema + The version of the schema. This PEP defines version "1". Defaults to "1" + when absent. All tools reading the file MUST error on an unrecognised + schema version. + +bootstrap_requires + Optional list of PEP 508 dependency specifications that the + build frontend must ensure are available before invoking the build + backend. For instance, if using flit, then the requirements might + be:: + + "bootstrap_requires": ["flit"] + +build_backend + A mandatory string naming a Python object that will be used to + perform the build (see below for details). This is formatted + following the same ``module:object`` syntax as a ``setuptools`` + entry point. For instance, if using flit, then the build system + might be specified as:: + + "build_system": "flit.api:main" + + and this object would be looked up by executing the equivalent of:: + + import flit.api + backend = flit.api.main + + It's also legal to leave out the ``:object`` part, e.g. :: + + "build_system": "flit.api" + + which acts like:: + + import flit.api + backend = flit.api + + Formally, the string should satisfy this grammar:: + + identifier = (letter | '_') (letter | '_' | digit)* + module_path = identifier ('.' identifier)* + object_path = identifier ('.' identifier)* + entry_point = module_path (':' object_path)? + + And we import ``module_path`` and then lookup + ``module_path.object_path`` (or just ``module_path`` if + ``object_path`` is missing). + + +========================= + Build backend interface +========================= + +The build backend object is expected to have attributes which provide +some or all of the following hooks. The common ``config_settings`` +argument is described after the individual hooks:: + + def get_build_requires(config_settings): + ... + +This hook MUST return an additional list of strings containing PEP 508 +dependency specifications, above and beyond those specified in the +``pypackage.json`` file. Example:: + + def get_build_requires(config_settings): + return ["wheel >= 0.25", "setuptools"] + +Optional. If not defined, the default implementation is equivalent to +``return []``. + +:: + + def get_wheel_metadata(metadata_directory, config_settings): + ... + +Must create a ``.dist-info`` directory containing wheel metadata +inside the specified ``metadata_directory`` (i.e., creates a directory +like ``{metadata_directory}/{package}-{version}.dist-info/``. This +directory MUST be a valid ``.dist-info`` directory as defined in the +wheel specification, except that it need not contain ``RECORD`` or +signatures. The hook MAY also create other files inside this +directory, and a build frontend MUST ignore such files; the intention +here is that in cases where the metadata depends on build-time +decisions, the build backend may need to record these decisions in +some convenient format for re-use by the actual wheel-building step. + +Return value is ignored. + +Optional. If a build frontend needs this information and the method is +not defined, it should call ``build_wheel`` and look at the resulting +metadata directly. + +:: + + def build_wheel(wheel_directory, config_settings, metadata_directory=None): + ... + +Must build a ``.whl`` file, and place it in the specified +``wheel_directory``. + +If the build frontend has previously called ``get_wheel_metadata`` and +depends on the wheel resulting from this call to have metadata +matching this earlier call, then it should provide the path to the +previous ``metadata_directory`` as an argument. If this argument is +provided, then ``build_wheel`` MUST produce a wheel with identical +metadata. The directory passed in by the build frontend MUST be +identical to the directory created by ``get_wheel_metadata``, +including any unrecognized files it created. + +Mandatory. + +:: + + def install_editable(prefix, config_settings, metadata_directory=None): + ... + +Must perform whatever actions are necessary to install the current +project into the Python installation at ``install_prefix`` in an +"editable" fashion. This is intentionally underspecified, because it's +included as a stopgap to avoid regressing compared to the current +equally underspecified setuptools ``develop`` command; hopefully a +future PEP will replace this hook with something that works better and +is better specified. (Unfortunately, cleaning up editable installs to +actually work well and be well-specified turns out to be a large and +difficult job, so we prefer not to do a half-way job here.) + +For the meaning and requirements of the ``metadata_directory`` +argument, see ``build_wheel`` above. + +[XX UNRESOLVED: it isn't entirely clear whether ``prefix`` alone is +enough to support all needed configurations -- in particular, + at takluyver has suggested that contra to the distutils docs, ``--user`` +on Windows is not expressible in terms of a regular prefix install.] + +Optional. If not defined, then this build backend does not support +editable builds. + +:: + + config_settings + +This argument, which is passed to all hooks, is an arbitrary +dictionary provided as an "escape hatch" for users to pass ad-hoc +configuration into individual package builds. Build backends MAY +assign any semantics they like to this dictionary. Build frontends +SHOULD provide some mechanism for users to specify arbitrary +string-key/string-value pairs to be placed in this dictionary. For +example, they might support some syntax like ``--package-config +CC=gcc``. Build frontends MAY also provide arbitrary other mechanisms +for users to place entries in this dictionary. For example, ``pip`` +might choose to map a mix of modern and legacy command line arguments +like:: + + pip install \ + --package-config CC=gcc \ + --global-option="--some-global-option" \ + --build-option="--build-option1" \ + --build-option="--build-option2" + +into a ``config_settings`` dictionary like:: + + { + "CC": "gcc", + "--global-option": ["--some-global-option"], + "--build-option": ["--build-option1", "--build-option2"], + } + +Of course, it's up to users to make sure that they pass options which +make sense for the particular build backend and package that they are +building. + +All hooks are run with working directory set to the root of the source +tree, and MAY print arbitrary informational text on stdout and +stderr. They MUST NOT read from stdin, and the build frontend MAY +close stdin before invoking the hooks. + +If a hook raises an exception, or causes the process to terminate, +then this indicates an error. + + +Build environment +================= + +One of the responsibilities of a build frontend is to set up the +Python environment in which the build backend will run. + +We do not require that any particular "virtual environment" mechanism +be used; a build frontend might use virtualenv, or venv, or no special +mechanism at all. But whatever mechanism is used MUST meet the +following criteria: + +- All requirements specified by the project's build-requirements must + be available for import from Python. In particular: + + - The ``get_build_requires`` hook is executed in an environment + which contains the bootstrap requirements specified in the + ``pypackage.json`` file. + + - All other hooks are executed in an environment which contains both + the bootstrap requirements specified in the ``pypackage.json`` hook + and those specified by the ``get_build_requires`` hook. + +- This must remain true even for new Python subprocesses spawned by + the build environment, e.g. code like:: + + import sys, subprocess + subprocess.check_call([sys.executable, ...]) + + must spawn a Python process which has access to all the project's + build-requirements. This is necessary e.g. for build backends that + want to run legacy ``setup.py`` scripts in a subprocess. + +- All command-line scripts provided by the build-required packages + must be present in the build environment's PATH. For example, if a + project declares a build-requirement on `flit + `_, then the following must + work as a mechanism for running the flit command-line tool:: + + import subprocess + subprocess.check_call(["flit", ...]) + +A build backend MUST be prepared to function in any environment which +meets the above criteria. In particular, it MUST NOT assume that it +has access to any packages except those that are present in the +stdlib, or that are explicitly declared as build-requirements. + + +Recommendations for build frontends (non-normative) +--------------------------------------------------- + +A build frontend MAY use any mechanism for setting up a build +environment that meets the above criteria. For example, simply +installing all build-requirements into the global environment would be +sufficient to build any compliant package -- but this would be +sub-optimal for a number of reasons. This section contains +non-normative advice to frontend implementors. + +A build frontend SHOULD, by default, create an isolated environment +for each build, containing only the standard library and any +explicitly requested build-dependencies. This has two benefits: + +- It allows for a single installation run to build multiple packages + that have contradictory build-requirements. E.g. if package1 + build-requires pbr==1.8.1, and package2 build-requires pbr==1.7.2, + then these cannot both be installed simultaneously into the global + environment -- which is a problem when the user requests ``pip + install package1 package2``. Or if the user already has pbr==1.8.1 + installed in their global environment, and a package build-requires + pbr==1.7.2, then downgrading the user's version would be rather + rude. + +- It acts as a kind of public health measure to maximize the number of + packages that actually do declare accurate build-dependencies. We + can write all the strongly worded admonitions to package authors we + want, but if build frontends don't enforce isolation by default, + then we'll inevitably end up with lots of packages on PyPI that + build fine on the original author's machine and nowhere else, which + is a headache that no-one needs. + +However, there will also be situations where build-requirements are +problematic in various ways. For example, a package author might +accidentally leave off some crucial requirement despite our best +efforts; or, a package might declare a build-requirement on `foo >= +1.0` which worked great when 1.0 was the latest version, but now 1.1 +is out and it has a showstopper bug; or, the user might decide to +build a package against numpy==1.7 -- overriding the package's +preferred numpy==1.8 -- to guarantee that the resulting build will be +compatible at the C ABI level with an older version of numpy (even if +this means the resulting build is unsupported upstream). Therefore, +build frontends SHOULD provide some mechanism for users to override +the above defaults. For example, a build frontend could have a +``--build-with-system-site-packages`` option that causes the +``--system-site-packages`` option to be passed to +virtualenv-or-equivalent when creating build environments, or a +``--build-requirements-override=my-requirements.txt`` option that +overrides the project's normal build-requirements. + +The general principle here is that we want to enforce hygiene on +package *authors*, while still allowing *end-users* to open up the +hood and apply duct tape when necessary. + + +====================== + Source distributions +====================== + +For now, we continue with the legacy sdist format which is mostly +undefined, but basically comes down to: a file named +``{NAME}-{VERSION}.{EXT}``, which unpacks into a buildable source tree +called ``{NAME}-{VERSION}/``. Traditionally these have always +contained ``setup.py``\-style source trees; we now allow them to also +contain ``pypackage.json``\-style source trees. + +Integration frontends require that an sdist named +``{NAME}-{VERSION}.{EXT}`` will generate a wheel named +``{NAME}-{VERSION}-{COMPAT-INFO}.whl``. + + +=================================== + Comparison to competing proposals +=================================== + +The primary difference between this and competing proposals (`in +particular +`_) is +that our build backend is defined via a Python hook-based interface +rather than a command-line based interface. + +We do *not* expect that this will, by itself, intrinsically reduce the +complexity calling into the backend, because build frontends will +in any case want to run hooks inside a child -- this is important to +isolate the build frontend itself from the backend code and to better +control the build backends execution environment. So under both +proposals, there will need to be some code in ``pip`` to spawn a +subprocess and talk to some kind of command-line/IPC interface, and +there will need to be some code in the subprocess that knows how to +parse these command line arguments and call the actual build backend +implementation. So this diagram applies to all proposals equally:: + + +-----------+ +---------------+ +----------------+ + | frontend | -spawn-> | child cmdline | -Python-> | backend | + | (pip) | | interface | | implementation | + +-----------+ +---------------+ +----------------+ + + + +The key difference between the two approaches is how these interface +boundaries map onto project structure:: + + .-= This PEP =-. + + +-----------+ +---------------+ | +----------------+ + | frontend | -spawn-> | child cmdline | -Python-> | backend | + | (pip) | | interface | | | implementation | + +-----------+ +---------------+ | +----------------+ + | + |______________________________________| | + Owned by pip, updated in lockstep | + | + | + PEP-defined interface boundary + Changes here require distutils-sig + + + .-= Alternative =-. + + +-----------+ | +---------------+ +----------------+ + | frontend | -spawn-> | child cmdline | -Python-> | backend | + | (pip) | | | interface | | implementation | + +-----------+ | +---------------+ +----------------+ + | + | |____________________________________________| + | Owned by build backend, updated in lockstep + | + PEP-defined interface boundary + Changes here require distutils-sig + + +By moving the PEP-defined interface boundary into Python code, we gain +three key advantages. + +**First**, because there will likely be only a small number of build +frontends (``pip``, and... maybe a few others?), while there will +likely be a long tail of custom build backends (since these are chosen +separately by each package to match their particular build +requirements), the actual diagrams probably look more like:: + + .-= This PEP =-. + + +-----------+ +---------------+ +----------------+ + | frontend | -spawn-> | child cmdline | -Python+> | backend | + | (pip) | | interface | | | implementation | + +-----------+ +---------------+ | +----------------+ + | + | +----------------+ + +> | backend | + | | implementation | + | +----------------+ + : + : + + .-= Alternative =-. + + +-----------+ +---------------+ +----------------+ + | frontend | -spawn+> | child cmdline | -Python-> | backend | + | (pip) | | | interface | | implementation | + +-----------+ | +---------------+ +----------------+ + | + | +---------------+ +----------------+ + +> | child cmdline | -Python-> | backend | + | | interface | | implementation | + | +---------------+ +----------------+ + : + : + +That is, this PEP leads to less total code in the overall +ecosystem. And in particular, it reduces the barrier to entry of +making a new build system. For example, this is a complete, working +build backend:: + + # mypackage_custom_build_backend.py + import os.path + + def get_build_requires(config_settings, config_directory): + return ["wheel"] + + def build_wheel(wheel_directory, config_settings, config_directory=None): + from wheel.archive import archive_wheelfile + path = os.path.join(wheel_directory, + "mypackage-0.1-py2.py3-none-any") + archive_wheelfile(path, "src/") + +Of course, this is a *terrible* build backend: it requires the user to +have manually set up the wheel metadata in +``src/mypackage-0.1.dist-info/``; when the version number changes it +must be manually updated in multiple places; it doesn't implement the +metadata or develop hooks, ... but it works, and these features can be +added incrementally. Much experience suggests that large successful +projects often originate as quick hacks (e.g., Linux -- "just a hobby, +won't be big and professional"; `IPython/Jupyter +`_ -- `a grad +student's ``$PYTHONSTARTUP`` file +`_), +so if our goal is to encourage the growth of a vibrant ecosystem of +good build tools, it's important to minimize the barrier to entry. + + +**Second**, because Python provides a simpler yet richer structure for +describing interfaces, we remove unnecessary complexity from the +specification -- and specifications are the worst place for +complexity, because changing specifications requires painful +consensus-building across many stakeholders. In the command-line +interface approach, we have to come up with ad hoc ways to map +multiple different kinds of inputs into a single linear command line +(e.g. how do we avoid collisions between user-specified configuration +arguments and PEP-defined arguments? how do we specify optional +arguments? when working with a Python interface these questions have +simple, obvious answers). When spawning and managing subprocesses, +there are many fiddly details that must be gotten right, subtle +cross-platform differences, and some of the most obvious approaches -- +e.g., using stdout to return data for the ``build_requires`` operation +-- can create unexpected pitfalls (e.g., what happens when computing +the build requirements requires spawning some child processes, and +these children occasionally print an error message to stdout? +obviously a careful build backend author can avoid this problem, but +the most obvious way of defining a Python interface removes this +possibility entirely, because the hook return value is clearly +demarcated). + +In general, the need to isolate build backends into their own process +means that we can't remove IPC complexity entirely -- but by placing +both sides of the IPC channel under the control of a single project, +we make it much much cheaper to fix bugs in the IPC interface than if +fixing bugs requires coordinated agreement and coordinated changes +across the ecosystem. + +**Third**, and most crucially, the Python hook approach gives us much +more powerful options for evolving this specification in the future. + +For concreteness, imagine that next year we add a new +``install_editable2`` hook, which replaces the current +``install_editable`` hook with something better specified. In order to +manage the transition, we want it to be possible for build frontends +to transparently use ``install_editable2`` when available and fall +back onto ``install_editable`` otherwise; and we want it to be +possible for build backends to define both methods, for compatibility +with both old and new build frontends. + +Furthermore, our mechanism should also fulfill two more goals: (a) If +new versions of e.g. ``pip`` and ``flit`` are both updated to support +the new interface, then this should be sufficient for it to be used; +in particular, it should *not* be necessary for every project that +*uses* ``flit`` to update its individual ``pypackage.json`` file. (b) +We do not want to have to spawn extra processes just to perform this +negotiation, because process spawns can easily become a bottleneck when +deploying large multi-package stacks on some platforms (Windows). + +In the interface described here, all of these goals are easy to +achieve. Because ``pip`` controls the code that runs inside the child +process, it can easily write it to do something like:: + + command, backend, args = parse_command_line_args(...) + if command == "do_editable_install": + if hasattr(backend, "install_editable2"): + backend.install_editable2(...) + elif hasattr(backend, "install_editable"): + backend.install_editable(...) + else: + # error handling + +In the alternative where the public interface boundary is placed at +the subprocess call, this is not possible -- either we need to spawn +an extra process just to query what interfaces are supported (as was +included in an earlier version of `this alternative PEP +`_), or +else we give up on autonegotiation entirely (as in the current version +of that PEP), meaning that any changes in the interface will require +N individual packages to update their ``pypackage.json`` files before +any change can go live, and that any changes will necessarily be +restricted to new releases. + +One specific consequence of this is that in this PEP, we're able to +make the ``get_wheel_metadata`` command optional. In our design, this +can easily be worked around by a tool like ``pip``, which can put code +in its subprocess runner like:: + + def get_wheel_metadata(output_dir, config_settings): + if hasattr(backend, "get_wheel_metadata"): + backend.get_wheel_metadata(output_dir, config_settings) + else: + backend.build_wheel(output_dir, config_settings) + touch(output_dir / "PIP_ALREADY_BUILT_WHEELS") + unzip_metadata(output_dir/*.whl) + + def build_wheel(output_dir, config_settings, metadata_dir): + if os.path.exists(metadata_dir / "PIP_ALREADY_BUILT_WHEELS"): + copy(metadata_dir / *.whl, output_dir) + else: + backend.build_wheel(output_dir, config_settings, metadata_dir) + +and thus expose a totally uniform interface to the rest of ``pip``, +with no extra subprocess calls, no duplicated builds, etc. But +obviously this is the kind of code that you only want to write as part +of a private, within-project interface. + +(And, of course, making the ``metadata`` command optional is one piece +of lowering the barrier to entry, as discussed above.) + + +Other differences +----------------- + +Besides the key command line versus Python hook difference described +above, there are a few other differences in this proposal: + +* Metadata command is optional (as described above). + +* We return metadata as a directory, rather than a single METADATA + file. This aligns better with the way that in practice wheel metadata + is distributed across multiple files (e.g. entry points), and gives us + more options in the future. (For example, instead of following the PEP + 426 proposal of switching the format of METADATA to JSON, we might + decide to keep the existing METADATA the way it is for backcompat, + while adding new extensions as JSON "sidecar" files inside the same + directory. Or maybe not; the point is it keeps our options more open.) + +* We provide a mechanism for passing information between the metadata + step and the wheel building step. I guess everyone probably will + agree this is a good idea? + +* We call our config file ``pypackage.json`` instead of + ``pypa.json``. This is because it describes a package, rather than + describing a packaging authority. But really, who cares. + +* We provide more detailed recommendations about the build environment, + but these aren't normative anyway. + + +==================== + Evolutionary notes +==================== + +A goal here is to make it as simple as possible to convert old-style +sdists to new-style sdists. (E.g., this is one motivation for +supporting dynamic build requirements.) The ideal would be that there +would be a single static pypackage.json that could be dropped into any +"version 0" VCS checkout to convert it to the new shiny. This is +probably not 100% possible, but we can get close, and it's important +to keep track of how close we are... hence this section. + +A rough plan would be: Create a build system package +(``setuptools_pypackage`` or whatever) that knows how to speak +whatever hook language we come up with, and convert them into calls to +``setup.py``. This will probably require some sort of hooking or +monkeypatching to setuptools to provide a way to extract the +``setup_requires=`` argument when needed, and to provide a new version +of the sdist command that generates the new-style format. This all +seems doable and sufficient for a large proportion of packages (though +obviously we'll want to prototype such a system before we finalize +anything here). (Alternatively, these changes could be made to +setuptools itself rather than going into a separate package.) + +But there remain two obstacles that mean we probably won't be able to +automatically upgrade packages to the new format: + +1) There currently exist packages which insist on particular packages + being available in their environment before setup.py is + executed. This means that if we decide to execute build scripts in + an isolated virtualenv-like environment, then projects will need to + check whether they do this, and if so then when upgrading to the + new system they will have to start explicitly declaring these + dependencies (either via ``setup_requires=`` or via static + declaration in ``pypackage.json``). + +2) There currently exist packages which do not declare consistent + metadata (e.g. ``egg_info`` and ``bdist_wheel`` might get different + ``install_requires=``). When upgrading to the new system, projects + will have to evaluate whether this applies to them, and if so they + will need to stop doing that. + + +=========== + Copyright +=========== + +This document has been placed in the public domain. + + +.. + Local Variables: + mode: indented-text + indent-tabs-mode: nil + sentence-end-double-space: t + fill-column: 70 + coding: utf-8 + End: -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Thu Feb 18 06:03:28 2016 From: python-checkins at python.org (donald.stufft) Date: Thu, 18 Feb 2016 11:03:28 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Switch_the_BDFL-Delegate_to_N?= =?utf-8?q?ick?= Message-ID: <20160218110327.1984.77665@psf.io> https://hg.python.org/peps/rev/6f8f8dc146fb changeset: 6240:6f8f8dc146fb user: Donald Stufft date: Thu Feb 18 06:03:25 2016 -0500 summary: Switch the BDFL-Delegate to Nick files: pep-0516.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/pep-0516.txt b/pep-0516.txt --- a/pep-0516.txt +++ b/pep-0516.txt @@ -4,7 +4,7 @@ Last-Modified: $Date$ Author: Robert Collins , Nathaniel Smith -BDFL-Delegate: Donald Stufft +BDFL-Delegate: Nick Coghlan Discussions-To: distutils-sig Status: Draft Type: Standards Track -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Thu Feb 18 06:54:35 2016 From: python-checkins at python.org (martin.panter) Date: Thu, 18 Feb 2016 11:54:35 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2MzA5?= =?utf-8?q?=3A_Shut_down_socketserver_request_if_verify=5Frequest=28=29_is?= =?utf-8?q?_false?= Message-ID: <20160218115434.2140.26991@psf.io> https://hg.python.org/cpython/rev/651a6d47bc78 changeset: 100257:651a6d47bc78 branch: 3.5 parent: 100255:69717fdd9d5a user: Martin Panter date: Thu Feb 18 10:43:55 2016 +0000 summary: Issue #26309: Shut down socketserver request if verify_request() is false Patch by Aviv Palivoda. files: Lib/socketserver.py | 2 + Lib/test/test_socketserver.py | 24 +++++++++++++++++++++++ Misc/NEWS | 4 +++ 3 files changed, 30 insertions(+), 0 deletions(-) diff --git a/Lib/socketserver.py b/Lib/socketserver.py --- a/Lib/socketserver.py +++ b/Lib/socketserver.py @@ -319,6 +319,8 @@ except: self.handle_error(request, client_address) self.shutdown_request(request) + else: + self.shutdown_request(request) def handle_timeout(self): """Called if no new request arrives within self.timeout. diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py --- a/Lib/test/test_socketserver.py +++ b/Lib/test/test_socketserver.py @@ -280,6 +280,30 @@ socketserver.TCPServer((HOST, -1), socketserver.StreamRequestHandler) + def test_shutdown_request_called_if_verify_request_false(self): + # Issue #26309: BaseServer should call shutdown_request even if + # verify_request is False + shutdown_called = False + + class MyServer(socketserver.TCPServer): + def verify_request(self, request, client_address): + return False + + def shutdown_request(self, request): + nonlocal shutdown_called + shutdown_called = True + super().shutdown_request(request) + + def connect_to_server(proto, addr): + s = socket.socket(proto, socket.SOCK_STREAM) + s.connect(addr) + s.close() + + self.run_server(MyServer, + socketserver.StreamRequestHandler, + connect_to_server) + self.assertEqual(shutdown_called, True) + class MiscTestCase(unittest.TestCase): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -76,6 +76,10 @@ Library ------- +- Issue #26309: In the "socketserver" module, shut down the request (closing + the connected socket) when verify_request() returns false. Patch by Aviv + Palivoda. + - Issue #25939: On Windows open the cert store readonly in ssl.enum_certificates. - Issue #25995: os.walk() no longer uses FDs proportional to the tree depth. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 18 06:54:35 2016 From: python-checkins at python.org (martin.panter) Date: Thu, 18 Feb 2016 11:54:35 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI2MzA5?= =?utf-8?q?=3A_Shut_down_SocketServer_request_if_verify=5Frequest=28=29_is?= =?utf-8?q?_false?= Message-ID: <20160218115435.1986.13928@psf.io> https://hg.python.org/cpython/rev/e0fbd25f0b36 changeset: 100259:e0fbd25f0b36 branch: 2.7 parent: 100254:c272a1e53f5b user: Martin Panter date: Thu Feb 18 10:43:55 2016 +0000 summary: Issue #26309: Shut down SocketServer request if verify_request() is false Based on patch by Aviv Palivoda. files: Lib/SocketServer.py | 2 ++ Lib/test/test_socketserver.py | 23 +++++++++++++++++++++++ Misc/NEWS | 4 ++++ 3 files changed, 29 insertions(+), 0 deletions(-) diff --git a/Lib/SocketServer.py b/Lib/SocketServer.py --- a/Lib/SocketServer.py +++ b/Lib/SocketServer.py @@ -296,6 +296,8 @@ except: self.handle_error(request, client_address) self.shutdown_request(request) + else: + self.shutdown_request(request) def handle_timeout(self): """Called if no new request arrives within self.timeout. diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py --- a/Lib/test/test_socketserver.py +++ b/Lib/test/test_socketserver.py @@ -326,6 +326,29 @@ SocketServer.TCPServer((HOST, -1), SocketServer.StreamRequestHandler) + def test_shutdown_request_called_if_verify_request_false(self): + # Issue #26309: BaseServer should call shutdown_request even if + # verify_request is False + result = {"shutdown_called": False} + + class MyServer(SocketServer.TCPServer): + def verify_request(self, request, client_address): + return False + + def shutdown_request(self, request): + result["shutdown_called"] = True + SocketServer.TCPServer.shutdown_request(self, request) + + def connect_to_server(proto, addr): + s = socket.socket(proto, socket.SOCK_STREAM) + s.connect(addr) + s.close() + + self.run_server(MyServer, + SocketServer.StreamRequestHandler, + connect_to_server) + self.assertEqual(result["shutdown_called"], True) + def test_main(): if imp.lock_held(): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -50,6 +50,10 @@ Library ------- +- Issue #26309: In the "socketserver" module, shut down the request (closing + the connected socket) when verify_request() returns false. Based on patch + by Aviv Palivoda. + - Issue #25939: On Windows open the cert store readonly in ssl.enum_certificates. - Issue #24303: Fix random EEXIST upon multiprocessing semaphores creation with -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 18 06:54:36 2016 From: python-checkins at python.org (martin.panter) Date: Thu, 18 Feb 2016 11:54:36 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326309=3A_Merge_socketserver_fix_from_3=2E5?= Message-ID: <20160218115435.1534.87396@psf.io> https://hg.python.org/cpython/rev/0768edf5878d changeset: 100258:0768edf5878d parent: 100256:6f0d3ae9f1f3 parent: 100257:651a6d47bc78 user: Martin Panter date: Thu Feb 18 11:01:32 2016 +0000 summary: Issue #26309: Merge socketserver fix from 3.5 files: Lib/socketserver.py | 2 + Lib/test/test_socketserver.py | 24 +++++++++++++++++++++++ Misc/NEWS | 4 +++ 3 files changed, 30 insertions(+), 0 deletions(-) diff --git a/Lib/socketserver.py b/Lib/socketserver.py --- a/Lib/socketserver.py +++ b/Lib/socketserver.py @@ -319,6 +319,8 @@ except: self.handle_error(request, client_address) self.shutdown_request(request) + else: + self.shutdown_request(request) def handle_timeout(self): """Called if no new request arrives within self.timeout. diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py --- a/Lib/test/test_socketserver.py +++ b/Lib/test/test_socketserver.py @@ -280,6 +280,30 @@ socketserver.TCPServer((HOST, -1), socketserver.StreamRequestHandler) + def test_shutdown_request_called_if_verify_request_false(self): + # Issue #26309: BaseServer should call shutdown_request even if + # verify_request is False + shutdown_called = False + + class MyServer(socketserver.TCPServer): + def verify_request(self, request, client_address): + return False + + def shutdown_request(self, request): + nonlocal shutdown_called + shutdown_called = True + super().shutdown_request(request) + + def connect_to_server(proto, addr): + s = socket.socket(proto, socket.SOCK_STREAM) + s.connect(addr) + s.close() + + self.run_server(MyServer, + socketserver.StreamRequestHandler, + connect_to_server) + self.assertEqual(shutdown_called, True) + class MiscTestCase(unittest.TestCase): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -186,6 +186,10 @@ Library ------- +- Issue #26309: In the "socketserver" module, shut down the request (closing + the connected socket) when verify_request() returns false. Patch by Aviv + Palivoda. + - Issue #25939: On Windows open the cert store readonly in ssl.enum_certificates. - Issue #25995: os.walk() no longer uses FDs proportional to the tree depth. -- Repository URL: https://hg.python.org/cpython From lp_benchmark_robot at intel.com Thu Feb 18 07:07:52 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Thu, 18 Feb 2016 12:07:52 +0000 Subject: [Python-checkins] BAD Benchmark Results for Python Default 2016-02-18 Message-ID: <9d7b95bb-e161-43f3-9114-087e812f9241@irsmsx102.ger.corp.intel.com> No new revisions. Here are the previous results: Results for project Python default, build date 2016-02-18 03:05:01 +0000 commit: 12502327d2c0 previous commit: 4523a0375f71 revision date: 2016-02-16 02:27:45 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.16% -1.92% 8.58% 15.21% :-| pybench 0.30% 0.10% 0.50% 5.26% :-( regex_v8 2.87% 0.09% -4.64% 4.45% :-| nbody 0.18% -0.76% -1.58% 8.17% :-| json_dump_v2 0.24% 0.23% -0.30% 11.38% :-| normal_startup 0.83% -0.04% 0.07% 5.94% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/bad-benchmark-results-for-python-default-2016-02-18/ Note: Benchmark results are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Thu Feb 18 07:08:35 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Thu, 18 Feb 2016 12:08:35 +0000 Subject: [Python-checkins] GOOD Benchmark Results for Python 2.7 2016-02-18 Message-ID: No new revisions. Here are the previous results: Results for project Python 2.7, build date 2016-02-18 03:06:58 +0000 commit: 58ebfa7c1361 previous commit: d3662c088db8 revision date: 2016-02-15 05:51:24 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dc from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.14% 0.94% 6.38% 4.25% :-) pybench 0.14% 0.01% 6.22% 3.53% :-( regex_v8 0.76% 0.28% -2.64% 10.58% :-) nbody 0.12% 3.10% 7.79% 4.37% :-) json_dump_v2 0.25% -0.12% 4.43% 11.87% :-( normal_startup 1.95% -0.21% -6.02% 2.92% :-| ssbench 0.12% -0.26% 1.95% 1.45% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/good-benchmark-results-for-python-2-7-2016-02-18/ Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Thu Feb 18 10:34:54 2016 From: python-checkins at python.org (berker.peksag) Date: Thu, 18 Feb 2016 15:34:54 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2316915=3A_Clarify_that_mode_parameter_of_socket?= =?utf-8?q?=2Emakefile=28=29_does_not_accept?= Message-ID: <20160218153454.1971.10946@psf.io> https://hg.python.org/cpython/rev/bbfbde6ee9d0 changeset: 100261:bbfbde6ee9d0 parent: 100258:0768edf5878d parent: 100260:a7391c31ec4e user: Berker Peksag date: Thu Feb 18 17:34:32 2016 +0200 summary: Issue #16915: Clarify that mode parameter of socket.makefile() does not accept the same values as open(). files: Doc/library/socket.rst | 3 ++- Lib/socket.py | 6 +++--- Lib/test/test_socket.py | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -1006,7 +1006,8 @@ Return a :term:`file object` associated with the socket. The exact returned type depends on the arguments given to :meth:`makefile`. These arguments are - interpreted the same way as by the built-in :func:`open` function. + interpreted the same way as by the built-in :func:`open` function, except + the only supported *mode* values are ``'r'`` (default), ``'w'`` and ``'b'``. The socket must be in blocking mode; it can have a timeout, but the file object's internal buffer may end up in an inconsistent state if a timeout diff --git a/Lib/socket.py b/Lib/socket.py --- a/Lib/socket.py +++ b/Lib/socket.py @@ -209,10 +209,10 @@ encoding=None, errors=None, newline=None): """makefile(...) -> an I/O stream connected to the socket - The arguments are as for io.open() after the filename, - except the only mode characters supported are 'r', 'w' and 'b'. - The semantics are similar too. (XXX refactor to share code?) + The arguments are as for io.open() after the filename, except the only + supported mode values are 'r' (default), 'w' and 'b'. """ + # XXX refactor to share code? if not set(mode) <= {"r", "w", "b"}: raise ValueError("invalid mode %r (only r, w, b allowed)" % (mode,)) writing = "w" in mode diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -1374,6 +1374,20 @@ self.assertRaises(ValueError, fp.writable) self.assertRaises(ValueError, fp.seekable) + def test_makefile_mode(self): + for mode in 'r', 'rb', 'rw', 'w', 'wb': + with self.subTest(mode=mode): + with socket.socket() as sock: + with sock.makefile(mode) as fp: + self.assertEqual(fp.mode, mode) + + def test_makefile_invalid_mode(self): + for mode in 'rt', 'x', '+', 'a': + with self.subTest(mode=mode): + with socket.socket() as sock: + with self.assertRaisesRegex(ValueError, 'invalid mode'): + sock.makefile(mode) + def test_pickle(self): sock = socket.socket() with sock: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 18 10:34:54 2016 From: python-checkins at python.org (berker.peksag) Date: Thu, 18 Feb 2016 15:34:54 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzE2OTE1?= =?utf-8?q?=3A_Clarify_that_mode_parameter_of_socket=2Emakefile=28=29_does?= =?utf-8?q?_not_accept?= Message-ID: <20160218153454.1969.58944@psf.io> https://hg.python.org/cpython/rev/a7391c31ec4e changeset: 100260:a7391c31ec4e branch: 3.5 parent: 100257:651a6d47bc78 user: Berker Peksag date: Thu Feb 18 17:34:00 2016 +0200 summary: Issue #16915: Clarify that mode parameter of socket.makefile() does not accept the same values as open(). files: Doc/library/socket.rst | 3 ++- Lib/socket.py | 6 +++--- Lib/test/test_socket.py | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -1006,7 +1006,8 @@ Return a :term:`file object` associated with the socket. The exact returned type depends on the arguments given to :meth:`makefile`. These arguments are - interpreted the same way as by the built-in :func:`open` function. + interpreted the same way as by the built-in :func:`open` function, except + the only supported *mode* values are ``'r'`` (default), ``'w'`` and ``'b'``. The socket must be in blocking mode; it can have a timeout, but the file object's internal buffer may end up in an inconsistent state if a timeout diff --git a/Lib/socket.py b/Lib/socket.py --- a/Lib/socket.py +++ b/Lib/socket.py @@ -209,10 +209,10 @@ encoding=None, errors=None, newline=None): """makefile(...) -> an I/O stream connected to the socket - The arguments are as for io.open() after the filename, - except the only mode characters supported are 'r', 'w' and 'b'. - The semantics are similar too. (XXX refactor to share code?) + The arguments are as for io.open() after the filename, except the only + supported mode values are 'r' (default), 'w' and 'b'. """ + # XXX refactor to share code? if not set(mode) <= {"r", "w", "b"}: raise ValueError("invalid mode %r (only r, w, b allowed)" % (mode,)) writing = "w" in mode diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -1374,6 +1374,20 @@ self.assertRaises(ValueError, fp.writable) self.assertRaises(ValueError, fp.seekable) + def test_makefile_mode(self): + for mode in 'r', 'rb', 'rw', 'w', 'wb': + with self.subTest(mode=mode): + with socket.socket() as sock: + with sock.makefile(mode) as fp: + self.assertEqual(fp.mode, mode) + + def test_makefile_invalid_mode(self): + for mode in 'rt', 'x', '+', 'a': + with self.subTest(mode=mode): + with socket.socket() as sock: + with self.assertRaisesRegex(ValueError, 'invalid mode'): + sock.makefile(mode) + def test_pickle(self): sock = socket.socket() with sock: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 18 10:45:44 2016 From: python-checkins at python.org (donald.stufft) Date: Thu, 18 Feb 2016 15:45:44 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Fix_errors/warnings_on_PEP_51?= =?utf-8?q?7?= Message-ID: <20160218154543.1973.2087@psf.io> https://hg.python.org/peps/rev/b5824266af5a changeset: 6241:b5824266af5a user: Donald Stufft date: Thu Feb 18 07:02:27 2016 -0500 summary: Fix errors/warnings on PEP 517 files: pep-0517.txt | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pep-0517.txt b/pep-0517.txt --- a/pep-0517.txt +++ b/pep-0517.txt @@ -323,7 +323,7 @@ - All command-line scripts provided by the build-required packages must be present in the build environment's PATH. For example, if a project declares a build-requirement on `flit - `_, then the following must + `__, then the following must work as a mechanism for running the flit command-line tool:: import subprocess @@ -638,7 +638,7 @@ Other differences ------------------ +================= Besides the key command line versus Python hook difference described above, there are a few other differences in this proposal: -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Thu Feb 18 21:43:34 2016 From: python-checkins at python.org (martin.panter) Date: Fri, 19 Feb 2016 02:43:34 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2MzA5?= =?utf-8?q?=3A_Rewrite_test_in_main_thread_and_avoid_race_condition?= Message-ID: <20160219024334.2202.97139@psf.io> https://hg.python.org/cpython/rev/537608bafa5a changeset: 100263:537608bafa5a branch: 3.5 parent: 100260:a7391c31ec4e user: Martin Panter date: Fri Feb 19 02:16:42 2016 +0000 summary: Issue #26309: Rewrite test in main thread and avoid race condition files: Lib/test/test_socketserver.py | 45 ++++++++++------------ 1 files changed, 21 insertions(+), 24 deletions(-) diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py --- a/Lib/test/test_socketserver.py +++ b/Lib/test/test_socketserver.py @@ -280,30 +280,6 @@ socketserver.TCPServer((HOST, -1), socketserver.StreamRequestHandler) - def test_shutdown_request_called_if_verify_request_false(self): - # Issue #26309: BaseServer should call shutdown_request even if - # verify_request is False - shutdown_called = False - - class MyServer(socketserver.TCPServer): - def verify_request(self, request, client_address): - return False - - def shutdown_request(self, request): - nonlocal shutdown_called - shutdown_called = True - super().shutdown_request(request) - - def connect_to_server(proto, addr): - s = socket.socket(proto, socket.SOCK_STREAM) - s.connect(addr) - s.close() - - self.run_server(MyServer, - socketserver.StreamRequestHandler, - connect_to_server) - self.assertEqual(shutdown_called, True) - class MiscTestCase(unittest.TestCase): @@ -317,6 +293,27 @@ expected.append(name) self.assertCountEqual(socketserver.__all__, expected) + def test_shutdown_request_called_if_verify_request_false(self): + # Issue #26309: BaseServer should call shutdown_request even if + # verify_request is False + + class MyServer(socketserver.TCPServer): + def verify_request(self, request, client_address): + return False + + shutdown_called = 0 + def shutdown_request(self, request): + self.shutdown_called += 1 + socketserver.TCPServer.shutdown_request(self, request) + + server = MyServer((HOST, 0), socketserver.StreamRequestHandler) + s = socket.socket(server.address_family, socket.SOCK_STREAM) + s.connect(server.server_address) + s.close() + server.handle_request() + self.assertEqual(server.shutdown_called, 1) + server.server_close() + if __name__ == "__main__": unittest.main() -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 18 21:43:34 2016 From: python-checkins at python.org (martin.panter) Date: Fri, 19 Feb 2016 02:43:34 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI2MzA5?= =?utf-8?q?=3A_Rewrite_test_in_main_thread_and_avoid_race_condition?= Message-ID: <20160219024334.1955.31460@psf.io> https://hg.python.org/cpython/rev/cba717fa8e10 changeset: 100262:cba717fa8e10 branch: 2.7 parent: 100259:e0fbd25f0b36 user: Martin Panter date: Fri Feb 19 02:16:42 2016 +0000 summary: Issue #26309: Rewrite test in main thread and avoid race condition files: Lib/test/test_socketserver.py | 23 ++++++++++++----------- 1 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py --- a/Lib/test/test_socketserver.py +++ b/Lib/test/test_socketserver.py @@ -326,28 +326,29 @@ SocketServer.TCPServer((HOST, -1), SocketServer.StreamRequestHandler) + +class MiscTestCase(unittest.TestCase): + def test_shutdown_request_called_if_verify_request_false(self): # Issue #26309: BaseServer should call shutdown_request even if # verify_request is False - result = {"shutdown_called": False} class MyServer(SocketServer.TCPServer): def verify_request(self, request, client_address): return False + shutdown_called = 0 def shutdown_request(self, request): - result["shutdown_called"] = True + self.shutdown_called += 1 SocketServer.TCPServer.shutdown_request(self, request) - def connect_to_server(proto, addr): - s = socket.socket(proto, socket.SOCK_STREAM) - s.connect(addr) - s.close() - - self.run_server(MyServer, - SocketServer.StreamRequestHandler, - connect_to_server) - self.assertEqual(result["shutdown_called"], True) + server = MyServer((HOST, 0), SocketServer.StreamRequestHandler) + s = socket.socket(server.address_family, socket.SOCK_STREAM) + s.connect(server.server_address) + s.close() + server.handle_request() + self.assertEqual(server.shutdown_called, 1) + server.server_close() def test_main(): -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 18 21:43:41 2016 From: python-checkins at python.org (martin.panter) Date: Fri, 19 Feb 2016 02:43:41 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326309=3A_Merge_socketserver_fix_from_3=2E5?= Message-ID: <20160219024334.1682.80869@psf.io> https://hg.python.org/cpython/rev/c791d57c8168 changeset: 100264:c791d57c8168 parent: 100261:bbfbde6ee9d0 parent: 100263:537608bafa5a user: Martin Panter date: Fri Feb 19 02:38:34 2016 +0000 summary: Issue #26309: Merge socketserver fix from 3.5 files: Lib/test/test_socketserver.py | 45 ++++++++++------------ 1 files changed, 21 insertions(+), 24 deletions(-) diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py --- a/Lib/test/test_socketserver.py +++ b/Lib/test/test_socketserver.py @@ -280,30 +280,6 @@ socketserver.TCPServer((HOST, -1), socketserver.StreamRequestHandler) - def test_shutdown_request_called_if_verify_request_false(self): - # Issue #26309: BaseServer should call shutdown_request even if - # verify_request is False - shutdown_called = False - - class MyServer(socketserver.TCPServer): - def verify_request(self, request, client_address): - return False - - def shutdown_request(self, request): - nonlocal shutdown_called - shutdown_called = True - super().shutdown_request(request) - - def connect_to_server(proto, addr): - s = socket.socket(proto, socket.SOCK_STREAM) - s.connect(addr) - s.close() - - self.run_server(MyServer, - socketserver.StreamRequestHandler, - connect_to_server) - self.assertEqual(shutdown_called, True) - class MiscTestCase(unittest.TestCase): @@ -317,6 +293,27 @@ expected.append(name) self.assertCountEqual(socketserver.__all__, expected) + def test_shutdown_request_called_if_verify_request_false(self): + # Issue #26309: BaseServer should call shutdown_request even if + # verify_request is False + + class MyServer(socketserver.TCPServer): + def verify_request(self, request, client_address): + return False + + shutdown_called = 0 + def shutdown_request(self, request): + self.shutdown_called += 1 + socketserver.TCPServer.shutdown_request(self, request) + + server = MyServer((HOST, 0), socketserver.StreamRequestHandler) + s = socket.socket(server.address_family, socket.SOCK_STREAM) + s.connect(server.server_address) + s.close() + server.handle_request() + self.assertEqual(server.shutdown_called, 1) + server.server_close() + if __name__ == "__main__": unittest.main() -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 18 22:35:04 2016 From: python-checkins at python.org (martin.panter) Date: Fri, 19 Feb 2016 03:35:04 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzE1NjA4?= =?utf-8?q?=3A_Improve_socketserver_module_documentation?= Message-ID: <20160219033446.1979.7561@psf.io> https://hg.python.org/cpython/rev/8b71cd67f548 changeset: 100265:8b71cd67f548 branch: 3.5 parent: 100263:537608bafa5a user: Martin Panter date: Fri Feb 19 03:27:46 2016 +0000 summary: Issue #15608: Improve socketserver module documentation * Add headings for each concrete and mix-in class and list methods and attributes under them * Fix class and method cross references * Changed RequestHandler to BaseRequestHandler and added class heading * Pull out Stream/DatagramRequestHandler definitions * Reordered the request handler setup(), handle(), finish() methods * Document constructor parameters for the server classes * Remove version 2.6 not relevant for Python 3 documentation files: Doc/library/socketserver.rst | 356 +++++++++++++--------- 1 files changed, 202 insertions(+), 154 deletions(-) diff --git a/Doc/library/socketserver.rst b/Doc/library/socketserver.rst --- a/Doc/library/socketserver.rst +++ b/Doc/library/socketserver.rst @@ -10,16 +10,34 @@ The :mod:`socketserver` module simplifies the task of writing network servers. -There are four basic server classes: :class:`TCPServer` uses the Internet TCP -protocol, which provides for continuous streams of data between the client and -server. :class:`UDPServer` uses datagrams, which are discrete packets of -information that may arrive out of order or be lost while in transit. The more -infrequently used :class:`UnixStreamServer` and :class:`UnixDatagramServer` -classes are similar, but use Unix domain sockets; they're not available on -non-Unix platforms. For more details on network programming, consult a book -such as -W. Richard Steven's UNIX Network Programming or Ralph Davis's Win32 Network -Programming. +There are four basic concrete server classes: + + +.. class:: TCPServer(server_address, RequestHandlerClass, bind_and_activate=True) + + This uses the Internet TCP protocol, which provides for + continuous streams of data between the client and server. + If *bind_and_activate* is true, the constructor automatically attempts to + invoke :meth:`~BaseServer.server_bind` and + :meth:`~BaseServer.server_activate`. The other parameters are passed to + the :class:`BaseServer` base class. + + +.. class:: UDPServer(server_address, RequestHandlerClass, bind_and_activate=True) + + This uses datagrams, which are discrete packets of information that may + arrive out of order or be lost while in transit. The parameters are + the same as for :class:`TCPServer`. + + +.. class:: UnixStreamServer(server_address, RequestHandlerClass, bind_and_activate=True) + UnixDatagramServer(server_address, RequestHandlerClass, bind_and_activate=True) + + These more infrequently used classes are similar to the TCP and + UDP classes, but use Unix domain sockets; they're not available on + non-Unix platforms. The parameters are the same as for + :class:`TCPServer`. + These four classes process requests :dfn:`synchronously`; each request must be completed before the next request can be started. This isn't suitable if each @@ -31,10 +49,12 @@ Creating a server requires several steps. First, you must create a request handler class by subclassing the :class:`BaseRequestHandler` class and -overriding its :meth:`handle` method; this method will process incoming +overriding its :meth:`~BaseRequestHandler.handle` method; +this method will process incoming requests. Second, you must instantiate one of the server classes, passing it the server's address and the request handler class. Then call the -:meth:`handle_request` or :meth:`serve_forever` method of the server object to +:meth:`~BaseServer.handle_request` or +:meth:`~BaseServer.serve_forever` method of the server object to process one or many requests. Finally, call :meth:`~BaseServer.server_close` to close the socket. @@ -76,18 +96,33 @@ stream server is the address family, which is simply repeated in both Unix server classes. -Forking and threading versions of each type of server can be created using the -:class:`ForkingMixIn` and :class:`ThreadingMixIn` mix-in classes. For instance, -a threading UDP server class is created as follows:: - class ThreadingUDPServer(ThreadingMixIn, UDPServer): pass +.. class:: ForkingMixIn + ThreadingMixIn -The mix-in class must come first, since it overrides a method defined in -:class:`UDPServer`. Setting the various attributes also change the -behavior of the underlying server mechanism. + Forking and threading versions of each type of server can be created + using these mix-in classes. For instance, :class:`ThreadingUDPServer` + is created as follows:: + + class ThreadingUDPServer(ThreadingMixIn, UDPServer): + pass + + The mix-in class comes first, since it overrides a method defined in + :class:`UDPServer`. Setting the various attributes also changes the + behavior of the underlying server mechanism. + + +.. class:: ForkingTCPServer + ForkingUDPServer + ThreadingTCPServer + ThreadingUDPServer + + These classes are pre-defined using the mix-in classes. + To implement a service, you must derive a class from :class:`BaseRequestHandler` -and redefine its :meth:`handle` method. You can then run various versions of +and redefine its :meth:`~BaseRequestHandler.handle` method. +You can then run various versions of the service by combining one of the server classes with your request handler class. The request handler class must be different for datagram or stream services. This can be hidden by using the handler subclasses @@ -109,7 +144,7 @@ In some cases, it may be appropriate to process part of a request synchronously, but to finish processing in a forked child depending on the request data. This can be implemented by using a synchronous server and doing an explicit fork in -the request handler class :meth:`handle` method. +the request handler class :meth:`~BaseRequestHandler.handle` method. Another approach to handling multiple simultaneous requests in an environment that supports neither threads nor :func:`~os.fork` (or where these are too @@ -127,227 +162,240 @@ Server Objects -------------- -.. class:: BaseServer +.. class:: BaseServer(server_address, RequestHandlerClass) This is the superclass of all Server objects in the module. It defines the interface, given below, but does not implement most of the methods, which is - done in subclasses. + done in subclasses. The two parameters are stored in the respective + :attr:`server_address` and :attr:`RequestHandlerClass` attributes. -.. method:: BaseServer.fileno() + .. method:: fileno() - Return an integer file descriptor for the socket on which the server is - listening. This function is most commonly passed to :mod:`selectors`, to - allow monitoring multiple servers in the same process. + Return an integer file descriptor for the socket on which the server is + listening. This function is most commonly passed to :mod:`selectors`, to + allow monitoring multiple servers in the same process. -.. method:: BaseServer.handle_request() + .. method:: handle_request() - Process a single request. This function calls the following methods in - order: :meth:`get_request`, :meth:`verify_request`, and - :meth:`process_request`. If the user-provided :meth:`handle` method of the - handler class raises an exception, the server's :meth:`handle_error` method - will be called. If no request is received within :attr:`self.timeout` - seconds, :meth:`handle_timeout` will be called and :meth:`handle_request` - will return. + Process a single request. This function calls the following methods in + order: :meth:`get_request`, :meth:`verify_request`, and + :meth:`process_request`. If the user-provided + :meth:`~BaseRequestHandler.handle` method of the + handler class raises an exception, the server's :meth:`handle_error` method + will be called. If no request is received within :attr:`timeout` + seconds, :meth:`handle_timeout` will be called and :meth:`handle_request` + will return. -.. method:: BaseServer.serve_forever(poll_interval=0.5) + .. method:: serve_forever(poll_interval=0.5) - Handle requests until an explicit :meth:`shutdown` request. Poll for - shutdown every *poll_interval* seconds. Ignores :attr:`self.timeout`. It - also calls :meth:`service_actions`, which may be used by a subclass or mixin - to provide actions specific to a given service. For example, the - :class:`ForkingMixIn` class uses :meth:`service_actions` to clean up zombie - child processes. + Handle requests until an explicit :meth:`shutdown` request. Poll for + shutdown every *poll_interval* seconds. + Ignores the :attr:`timeout` attribute. It + also calls :meth:`service_actions`, which may be used by a subclass or mixin + to provide actions specific to a given service. For example, the + :class:`ForkingMixIn` class uses :meth:`service_actions` to clean up zombie + child processes. - .. versionchanged:: 3.3 - Added ``service_actions`` call to the ``serve_forever`` method. + .. versionchanged:: 3.3 + Added ``service_actions`` call to the ``serve_forever`` method. -.. method:: BaseServer.service_actions() + .. method:: service_actions() - This is called in the :meth:`serve_forever` loop. This method can be - overridden by subclasses or mixin classes to perform actions specific to - a given service, such as cleanup actions. + This is called in the :meth:`serve_forever` loop. This method can be + overridden by subclasses or mixin classes to perform actions specific to + a given service, such as cleanup actions. - .. versionadded:: 3.3 + .. versionadded:: 3.3 -.. method:: BaseServer.shutdown() + .. method:: shutdown() - Tell the :meth:`serve_forever` loop to stop and wait until it does. + Tell the :meth:`serve_forever` loop to stop and wait until it does. -.. method:: BaseServer.server_close() + .. method:: server_close() - Clean up the server. May be overridden. + Clean up the server. May be overridden. - .. versionadded:: 2.6 + .. attribute:: address_family -.. attribute:: BaseServer.address_family + The family of protocols to which the server's socket belongs. + Common examples are :const:`socket.AF_INET` and :const:`socket.AF_UNIX`. - The family of protocols to which the server's socket belongs. - Common examples are :const:`socket.AF_INET` and :const:`socket.AF_UNIX`. + .. attribute:: RequestHandlerClass -.. attribute:: BaseServer.RequestHandlerClass + The user-provided request handler class; an instance of this class is created + for each request. - The user-provided request handler class; an instance of this class is created - for each request. + .. attribute:: server_address -.. attribute:: BaseServer.server_address + The address on which the server is listening. The format of addresses varies + depending on the protocol family; + see the documentation for the :mod:`socket` module + for details. For Internet protocols, this is a tuple containing a string giving + the address, and an integer port number: ``('127.0.0.1', 80)``, for example. - The address on which the server is listening. The format of addresses varies - depending on the protocol family; see the documentation for the socket module - for details. For Internet protocols, this is a tuple containing a string giving - the address, and an integer port number: ``('127.0.0.1', 80)``, for example. + .. attribute:: socket -.. attribute:: BaseServer.socket + The socket object on which the server will listen for incoming requests. - The socket object on which the server will listen for incoming requests. + The server classes support the following class variables: -The server classes support the following class variables: + .. XXX should class variables be covered before instance variables, or vice versa? -.. XXX should class variables be covered before instance variables, or vice versa? + .. attribute:: allow_reuse_address -.. attribute:: BaseServer.allow_reuse_address + Whether the server will allow the reuse of an address. This defaults to + :const:`False`, and can be set in subclasses to change the policy. - Whether the server will allow the reuse of an address. This defaults to - :const:`False`, and can be set in subclasses to change the policy. + .. attribute:: request_queue_size -.. attribute:: BaseServer.request_queue_size + The size of the request queue. If it takes a long time to process a single + request, any requests that arrive while the server is busy are placed into a + queue, up to :attr:`request_queue_size` requests. Once the queue is full, + further requests from clients will get a "Connection denied" error. The default + value is usually 5, but this can be overridden by subclasses. - The size of the request queue. If it takes a long time to process a single - request, any requests that arrive while the server is busy are placed into a - queue, up to :attr:`request_queue_size` requests. Once the queue is full, - further requests from clients will get a "Connection denied" error. The default - value is usually 5, but this can be overridden by subclasses. + .. attribute:: socket_type -.. attribute:: BaseServer.socket_type + The type of socket used by the server; :const:`socket.SOCK_STREAM` and + :const:`socket.SOCK_DGRAM` are two common values. - The type of socket used by the server; :const:`socket.SOCK_STREAM` and - :const:`socket.SOCK_DGRAM` are two common values. + .. attribute:: timeout -.. attribute:: BaseServer.timeout + Timeout duration, measured in seconds, or :const:`None` if no timeout is + desired. If :meth:`handle_request` receives no incoming requests within the + timeout period, the :meth:`handle_timeout` method is called. - Timeout duration, measured in seconds, or :const:`None` if no timeout is - desired. If :meth:`handle_request` receives no incoming requests within the - timeout period, the :meth:`handle_timeout` method is called. + There are various server methods that can be overridden by subclasses of base + server classes like :class:`TCPServer`; these methods aren't useful to external + users of the server object. -There are various server methods that can be overridden by subclasses of base -server classes like :class:`TCPServer`; these methods aren't useful to external -users of the server object. + .. XXX should the default implementations of these be documented, or should + it be assumed that the user will look at socketserver.py? -.. XXX should the default implementations of these be documented, or should - it be assumed that the user will look at socketserver.py? + .. method:: finish_request() -.. method:: BaseServer.finish_request() + Actually processes the request by instantiating :attr:`RequestHandlerClass` and + calling its :meth:`~BaseRequestHandler.handle` method. - Actually processes the request by instantiating :attr:`RequestHandlerClass` and - calling its :meth:`handle` method. + .. method:: get_request() -.. method:: BaseServer.get_request() + Must accept a request from the socket, and return a 2-tuple containing the *new* + socket object to be used to communicate with the client, and the client's + address. - Must accept a request from the socket, and return a 2-tuple containing the *new* - socket object to be used to communicate with the client, and the client's - address. + .. method:: handle_error(request, client_address) -.. method:: BaseServer.handle_error(request, client_address) + This function is called if the :meth:`~BaseRequestHandler.handle` + method of a :attr:`RequestHandlerClass` instance raises + an exception. The default action is to print the traceback to + standard output and continue handling further requests. - This function is called if the :attr:`RequestHandlerClass`'s :meth:`handle` - method raises an exception. The default action is to print the traceback to - standard output and continue handling further requests. + .. method:: handle_timeout() -.. method:: BaseServer.handle_timeout() + This function is called when the :attr:`timeout` attribute has been set to a + value other than :const:`None` and the timeout period has passed with no + requests being received. The default action for forking servers is + to collect the status of any child processes that have exited, while + in threading servers this method does nothing. - This function is called when the :attr:`timeout` attribute has been set to a - value other than :const:`None` and the timeout period has passed with no - requests being received. The default action for forking servers is - to collect the status of any child processes that have exited, while - in threading servers this method does nothing. + .. method:: process_request(request, client_address) -.. method:: BaseServer.process_request(request, client_address) + Calls :meth:`finish_request` to create an instance of the + :attr:`RequestHandlerClass`. If desired, this function can create a new process + or thread to handle the request; the :class:`ForkingMixIn` and + :class:`ThreadingMixIn` classes do this. - Calls :meth:`finish_request` to create an instance of the - :attr:`RequestHandlerClass`. If desired, this function can create a new process - or thread to handle the request; the :class:`ForkingMixIn` and - :class:`ThreadingMixIn` classes do this. + .. Is there any point in documenting the following two functions? + What would the purpose of overriding them be: initializing server + instance variables, adding new network families? -.. Is there any point in documenting the following two functions? - What would the purpose of overriding them be: initializing server - instance variables, adding new network families? + .. method:: server_activate() -.. method:: BaseServer.server_activate() + Called by the server's constructor to activate the server. The default behavior + for a TCP server just invokes :meth:`~socket.socket.listen` + on the server's socket. May be overridden. - Called by the server's constructor to activate the server. The default behavior - just :meth:`listen`\ s to the server's socket. May be overridden. + .. method:: server_bind() -.. method:: BaseServer.server_bind() + Called by the server's constructor to bind the socket to the desired address. + May be overridden. - Called by the server's constructor to bind the socket to the desired address. - May be overridden. + .. method:: verify_request(request, client_address) -.. method:: BaseServer.verify_request(request, client_address) + Must return a Boolean value; if the value is :const:`True`, the request will + be processed, and if it's :const:`False`, the request will be denied. This + function can be overridden to implement access controls for a server. The + default implementation always returns :const:`True`. - Must return a Boolean value; if the value is :const:`True`, the request will - be processed, and if it's :const:`False`, the request will be denied. This - function can be overridden to implement access controls for a server. The - default implementation always returns :const:`True`. +Request Handler Objects +----------------------- -RequestHandler Objects ----------------------- +.. class:: BaseRequestHandler -The request handler class must define a new :meth:`handle` method, and can -override any of the following methods. A new instance is created for each -request. + This is the superclass of all request handler objects. It defines + the interface, given below. A concrete request handler subclass must + define a new :meth:`handle` method, and can override any of + the other methods. A new instance of the subclass is created for each + request. -.. method:: RequestHandler.finish() + .. method:: setup() - Called after the :meth:`handle` method to perform any clean-up actions - required. The default implementation does nothing. If :meth:`setup` - raises an exception, this function will not be called. + Called before the :meth:`handle` method to perform any initialization actions + required. The default implementation does nothing. -.. method:: RequestHandler.handle() + .. method:: handle() - This function must do all the work required to service a request. The - default implementation does nothing. Several instance attributes are - available to it; the request is available as :attr:`self.request`; the client - address as :attr:`self.client_address`; and the server instance as - :attr:`self.server`, in case it needs access to per-server information. + This function must do all the work required to service a request. The + default implementation does nothing. Several instance attributes are + available to it; the request is available as :attr:`self.request`; the client + address as :attr:`self.client_address`; and the server instance as + :attr:`self.server`, in case it needs access to per-server information. - The type of :attr:`self.request` is different for datagram or stream - services. For stream services, :attr:`self.request` is a socket object; for - datagram services, :attr:`self.request` is a pair of string and socket. - However, this can be hidden by using the request handler subclasses - :class:`StreamRequestHandler` or :class:`DatagramRequestHandler`, which - override the :meth:`setup` and :meth:`finish` methods, and provide - :attr:`self.rfile` and :attr:`self.wfile` attributes. :attr:`self.rfile` and - :attr:`self.wfile` can be read or written, respectively, to get the request - data or return data to the client. + The type of :attr:`self.request` is different for datagram or stream + services. For stream services, :attr:`self.request` is a socket object; for + datagram services, :attr:`self.request` is a pair of string and socket. -.. method:: RequestHandler.setup() + .. method:: finish() - Called before the :meth:`handle` method to perform any initialization actions - required. The default implementation does nothing. + Called after the :meth:`handle` method to perform any clean-up actions + required. The default implementation does nothing. If :meth:`setup` + raises an exception, this function will not be called. + + +.. class:: StreamRequestHandler + DatagramRequestHandler + + These :class:`BaseRequestHandler` subclasses override the + :meth:`~BaseRequestHandler.setup` and :meth:`~BaseRequestHandler.finish` + methods, and provide :attr:`self.rfile` and :attr:`self.wfile` attributes. + The :attr:`self.rfile` and :attr:`self.wfile` attributes can be + read or written, respectively, to get the request data or return data + to the client. Examples @@ -362,7 +410,7 @@ class MyTCPHandler(socketserver.BaseRequestHandler): """ - The RequestHandler class for our server. + The request handler class for our server. It is instantiated once per connection to the server, and must override the handle() method to implement communication to the -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 18 22:35:06 2016 From: python-checkins at python.org (martin.panter) Date: Fri, 19 Feb 2016 03:35:06 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2315608=3A_Merge_socketserver_doc_from_3=2E5?= Message-ID: <20160219033446.1969.80524@psf.io> https://hg.python.org/cpython/rev/fbb8b634fe59 changeset: 100266:fbb8b634fe59 parent: 100264:c791d57c8168 parent: 100265:8b71cd67f548 user: Martin Panter date: Fri Feb 19 03:35:00 2016 +0000 summary: Issue #15608: Merge socketserver doc from 3.5 files: Doc/library/socketserver.rst | 356 +++++++++++++--------- 1 files changed, 202 insertions(+), 154 deletions(-) diff --git a/Doc/library/socketserver.rst b/Doc/library/socketserver.rst --- a/Doc/library/socketserver.rst +++ b/Doc/library/socketserver.rst @@ -10,16 +10,34 @@ The :mod:`socketserver` module simplifies the task of writing network servers. -There are four basic server classes: :class:`TCPServer` uses the Internet TCP -protocol, which provides for continuous streams of data between the client and -server. :class:`UDPServer` uses datagrams, which are discrete packets of -information that may arrive out of order or be lost while in transit. The more -infrequently used :class:`UnixStreamServer` and :class:`UnixDatagramServer` -classes are similar, but use Unix domain sockets; they're not available on -non-Unix platforms. For more details on network programming, consult a book -such as -W. Richard Steven's UNIX Network Programming or Ralph Davis's Win32 Network -Programming. +There are four basic concrete server classes: + + +.. class:: TCPServer(server_address, RequestHandlerClass, bind_and_activate=True) + + This uses the Internet TCP protocol, which provides for + continuous streams of data between the client and server. + If *bind_and_activate* is true, the constructor automatically attempts to + invoke :meth:`~BaseServer.server_bind` and + :meth:`~BaseServer.server_activate`. The other parameters are passed to + the :class:`BaseServer` base class. + + +.. class:: UDPServer(server_address, RequestHandlerClass, bind_and_activate=True) + + This uses datagrams, which are discrete packets of information that may + arrive out of order or be lost while in transit. The parameters are + the same as for :class:`TCPServer`. + + +.. class:: UnixStreamServer(server_address, RequestHandlerClass, bind_and_activate=True) + UnixDatagramServer(server_address, RequestHandlerClass, bind_and_activate=True) + + These more infrequently used classes are similar to the TCP and + UDP classes, but use Unix domain sockets; they're not available on + non-Unix platforms. The parameters are the same as for + :class:`TCPServer`. + These four classes process requests :dfn:`synchronously`; each request must be completed before the next request can be started. This isn't suitable if each @@ -31,10 +49,12 @@ Creating a server requires several steps. First, you must create a request handler class by subclassing the :class:`BaseRequestHandler` class and -overriding its :meth:`handle` method; this method will process incoming +overriding its :meth:`~BaseRequestHandler.handle` method; +this method will process incoming requests. Second, you must instantiate one of the server classes, passing it the server's address and the request handler class. Then call the -:meth:`handle_request` or :meth:`serve_forever` method of the server object to +:meth:`~BaseServer.handle_request` or +:meth:`~BaseServer.serve_forever` method of the server object to process one or many requests. Finally, call :meth:`~BaseServer.server_close` to close the socket. @@ -76,18 +96,33 @@ stream server is the address family, which is simply repeated in both Unix server classes. -Forking and threading versions of each type of server can be created using the -:class:`ForkingMixIn` and :class:`ThreadingMixIn` mix-in classes. For instance, -a threading UDP server class is created as follows:: - class ThreadingUDPServer(ThreadingMixIn, UDPServer): pass +.. class:: ForkingMixIn + ThreadingMixIn -The mix-in class must come first, since it overrides a method defined in -:class:`UDPServer`. Setting the various attributes also change the -behavior of the underlying server mechanism. + Forking and threading versions of each type of server can be created + using these mix-in classes. For instance, :class:`ThreadingUDPServer` + is created as follows:: + + class ThreadingUDPServer(ThreadingMixIn, UDPServer): + pass + + The mix-in class comes first, since it overrides a method defined in + :class:`UDPServer`. Setting the various attributes also changes the + behavior of the underlying server mechanism. + + +.. class:: ForkingTCPServer + ForkingUDPServer + ThreadingTCPServer + ThreadingUDPServer + + These classes are pre-defined using the mix-in classes. + To implement a service, you must derive a class from :class:`BaseRequestHandler` -and redefine its :meth:`handle` method. You can then run various versions of +and redefine its :meth:`~BaseRequestHandler.handle` method. +You can then run various versions of the service by combining one of the server classes with your request handler class. The request handler class must be different for datagram or stream services. This can be hidden by using the handler subclasses @@ -109,7 +144,7 @@ In some cases, it may be appropriate to process part of a request synchronously, but to finish processing in a forked child depending on the request data. This can be implemented by using a synchronous server and doing an explicit fork in -the request handler class :meth:`handle` method. +the request handler class :meth:`~BaseRequestHandler.handle` method. Another approach to handling multiple simultaneous requests in an environment that supports neither threads nor :func:`~os.fork` (or where these are too @@ -127,227 +162,240 @@ Server Objects -------------- -.. class:: BaseServer +.. class:: BaseServer(server_address, RequestHandlerClass) This is the superclass of all Server objects in the module. It defines the interface, given below, but does not implement most of the methods, which is - done in subclasses. + done in subclasses. The two parameters are stored in the respective + :attr:`server_address` and :attr:`RequestHandlerClass` attributes. -.. method:: BaseServer.fileno() + .. method:: fileno() - Return an integer file descriptor for the socket on which the server is - listening. This function is most commonly passed to :mod:`selectors`, to - allow monitoring multiple servers in the same process. + Return an integer file descriptor for the socket on which the server is + listening. This function is most commonly passed to :mod:`selectors`, to + allow monitoring multiple servers in the same process. -.. method:: BaseServer.handle_request() + .. method:: handle_request() - Process a single request. This function calls the following methods in - order: :meth:`get_request`, :meth:`verify_request`, and - :meth:`process_request`. If the user-provided :meth:`handle` method of the - handler class raises an exception, the server's :meth:`handle_error` method - will be called. If no request is received within :attr:`self.timeout` - seconds, :meth:`handle_timeout` will be called and :meth:`handle_request` - will return. + Process a single request. This function calls the following methods in + order: :meth:`get_request`, :meth:`verify_request`, and + :meth:`process_request`. If the user-provided + :meth:`~BaseRequestHandler.handle` method of the + handler class raises an exception, the server's :meth:`handle_error` method + will be called. If no request is received within :attr:`timeout` + seconds, :meth:`handle_timeout` will be called and :meth:`handle_request` + will return. -.. method:: BaseServer.serve_forever(poll_interval=0.5) + .. method:: serve_forever(poll_interval=0.5) - Handle requests until an explicit :meth:`shutdown` request. Poll for - shutdown every *poll_interval* seconds. Ignores :attr:`self.timeout`. It - also calls :meth:`service_actions`, which may be used by a subclass or mixin - to provide actions specific to a given service. For example, the - :class:`ForkingMixIn` class uses :meth:`service_actions` to clean up zombie - child processes. + Handle requests until an explicit :meth:`shutdown` request. Poll for + shutdown every *poll_interval* seconds. + Ignores the :attr:`timeout` attribute. It + also calls :meth:`service_actions`, which may be used by a subclass or mixin + to provide actions specific to a given service. For example, the + :class:`ForkingMixIn` class uses :meth:`service_actions` to clean up zombie + child processes. - .. versionchanged:: 3.3 - Added ``service_actions`` call to the ``serve_forever`` method. + .. versionchanged:: 3.3 + Added ``service_actions`` call to the ``serve_forever`` method. -.. method:: BaseServer.service_actions() + .. method:: service_actions() - This is called in the :meth:`serve_forever` loop. This method can be - overridden by subclasses or mixin classes to perform actions specific to - a given service, such as cleanup actions. + This is called in the :meth:`serve_forever` loop. This method can be + overridden by subclasses or mixin classes to perform actions specific to + a given service, such as cleanup actions. - .. versionadded:: 3.3 + .. versionadded:: 3.3 -.. method:: BaseServer.shutdown() + .. method:: shutdown() - Tell the :meth:`serve_forever` loop to stop and wait until it does. + Tell the :meth:`serve_forever` loop to stop and wait until it does. -.. method:: BaseServer.server_close() + .. method:: server_close() - Clean up the server. May be overridden. + Clean up the server. May be overridden. - .. versionadded:: 2.6 + .. attribute:: address_family -.. attribute:: BaseServer.address_family + The family of protocols to which the server's socket belongs. + Common examples are :const:`socket.AF_INET` and :const:`socket.AF_UNIX`. - The family of protocols to which the server's socket belongs. - Common examples are :const:`socket.AF_INET` and :const:`socket.AF_UNIX`. + .. attribute:: RequestHandlerClass -.. attribute:: BaseServer.RequestHandlerClass + The user-provided request handler class; an instance of this class is created + for each request. - The user-provided request handler class; an instance of this class is created - for each request. + .. attribute:: server_address -.. attribute:: BaseServer.server_address + The address on which the server is listening. The format of addresses varies + depending on the protocol family; + see the documentation for the :mod:`socket` module + for details. For Internet protocols, this is a tuple containing a string giving + the address, and an integer port number: ``('127.0.0.1', 80)``, for example. - The address on which the server is listening. The format of addresses varies - depending on the protocol family; see the documentation for the socket module - for details. For Internet protocols, this is a tuple containing a string giving - the address, and an integer port number: ``('127.0.0.1', 80)``, for example. + .. attribute:: socket -.. attribute:: BaseServer.socket + The socket object on which the server will listen for incoming requests. - The socket object on which the server will listen for incoming requests. + The server classes support the following class variables: -The server classes support the following class variables: + .. XXX should class variables be covered before instance variables, or vice versa? -.. XXX should class variables be covered before instance variables, or vice versa? + .. attribute:: allow_reuse_address -.. attribute:: BaseServer.allow_reuse_address + Whether the server will allow the reuse of an address. This defaults to + :const:`False`, and can be set in subclasses to change the policy. - Whether the server will allow the reuse of an address. This defaults to - :const:`False`, and can be set in subclasses to change the policy. + .. attribute:: request_queue_size -.. attribute:: BaseServer.request_queue_size + The size of the request queue. If it takes a long time to process a single + request, any requests that arrive while the server is busy are placed into a + queue, up to :attr:`request_queue_size` requests. Once the queue is full, + further requests from clients will get a "Connection denied" error. The default + value is usually 5, but this can be overridden by subclasses. - The size of the request queue. If it takes a long time to process a single - request, any requests that arrive while the server is busy are placed into a - queue, up to :attr:`request_queue_size` requests. Once the queue is full, - further requests from clients will get a "Connection denied" error. The default - value is usually 5, but this can be overridden by subclasses. + .. attribute:: socket_type -.. attribute:: BaseServer.socket_type + The type of socket used by the server; :const:`socket.SOCK_STREAM` and + :const:`socket.SOCK_DGRAM` are two common values. - The type of socket used by the server; :const:`socket.SOCK_STREAM` and - :const:`socket.SOCK_DGRAM` are two common values. + .. attribute:: timeout -.. attribute:: BaseServer.timeout + Timeout duration, measured in seconds, or :const:`None` if no timeout is + desired. If :meth:`handle_request` receives no incoming requests within the + timeout period, the :meth:`handle_timeout` method is called. - Timeout duration, measured in seconds, or :const:`None` if no timeout is - desired. If :meth:`handle_request` receives no incoming requests within the - timeout period, the :meth:`handle_timeout` method is called. + There are various server methods that can be overridden by subclasses of base + server classes like :class:`TCPServer`; these methods aren't useful to external + users of the server object. -There are various server methods that can be overridden by subclasses of base -server classes like :class:`TCPServer`; these methods aren't useful to external -users of the server object. + .. XXX should the default implementations of these be documented, or should + it be assumed that the user will look at socketserver.py? -.. XXX should the default implementations of these be documented, or should - it be assumed that the user will look at socketserver.py? + .. method:: finish_request() -.. method:: BaseServer.finish_request() + Actually processes the request by instantiating :attr:`RequestHandlerClass` and + calling its :meth:`~BaseRequestHandler.handle` method. - Actually processes the request by instantiating :attr:`RequestHandlerClass` and - calling its :meth:`handle` method. + .. method:: get_request() -.. method:: BaseServer.get_request() + Must accept a request from the socket, and return a 2-tuple containing the *new* + socket object to be used to communicate with the client, and the client's + address. - Must accept a request from the socket, and return a 2-tuple containing the *new* - socket object to be used to communicate with the client, and the client's - address. + .. method:: handle_error(request, client_address) -.. method:: BaseServer.handle_error(request, client_address) + This function is called if the :meth:`~BaseRequestHandler.handle` + method of a :attr:`RequestHandlerClass` instance raises + an exception. The default action is to print the traceback to + standard output and continue handling further requests. - This function is called if the :attr:`RequestHandlerClass`'s :meth:`handle` - method raises an exception. The default action is to print the traceback to - standard output and continue handling further requests. + .. method:: handle_timeout() -.. method:: BaseServer.handle_timeout() + This function is called when the :attr:`timeout` attribute has been set to a + value other than :const:`None` and the timeout period has passed with no + requests being received. The default action for forking servers is + to collect the status of any child processes that have exited, while + in threading servers this method does nothing. - This function is called when the :attr:`timeout` attribute has been set to a - value other than :const:`None` and the timeout period has passed with no - requests being received. The default action for forking servers is - to collect the status of any child processes that have exited, while - in threading servers this method does nothing. + .. method:: process_request(request, client_address) -.. method:: BaseServer.process_request(request, client_address) + Calls :meth:`finish_request` to create an instance of the + :attr:`RequestHandlerClass`. If desired, this function can create a new process + or thread to handle the request; the :class:`ForkingMixIn` and + :class:`ThreadingMixIn` classes do this. - Calls :meth:`finish_request` to create an instance of the - :attr:`RequestHandlerClass`. If desired, this function can create a new process - or thread to handle the request; the :class:`ForkingMixIn` and - :class:`ThreadingMixIn` classes do this. + .. Is there any point in documenting the following two functions? + What would the purpose of overriding them be: initializing server + instance variables, adding new network families? -.. Is there any point in documenting the following two functions? - What would the purpose of overriding them be: initializing server - instance variables, adding new network families? + .. method:: server_activate() -.. method:: BaseServer.server_activate() + Called by the server's constructor to activate the server. The default behavior + for a TCP server just invokes :meth:`~socket.socket.listen` + on the server's socket. May be overridden. - Called by the server's constructor to activate the server. The default behavior - just :meth:`listen`\ s to the server's socket. May be overridden. + .. method:: server_bind() -.. method:: BaseServer.server_bind() + Called by the server's constructor to bind the socket to the desired address. + May be overridden. - Called by the server's constructor to bind the socket to the desired address. - May be overridden. + .. method:: verify_request(request, client_address) -.. method:: BaseServer.verify_request(request, client_address) + Must return a Boolean value; if the value is :const:`True`, the request will + be processed, and if it's :const:`False`, the request will be denied. This + function can be overridden to implement access controls for a server. The + default implementation always returns :const:`True`. - Must return a Boolean value; if the value is :const:`True`, the request will - be processed, and if it's :const:`False`, the request will be denied. This - function can be overridden to implement access controls for a server. The - default implementation always returns :const:`True`. +Request Handler Objects +----------------------- -RequestHandler Objects ----------------------- +.. class:: BaseRequestHandler -The request handler class must define a new :meth:`handle` method, and can -override any of the following methods. A new instance is created for each -request. + This is the superclass of all request handler objects. It defines + the interface, given below. A concrete request handler subclass must + define a new :meth:`handle` method, and can override any of + the other methods. A new instance of the subclass is created for each + request. -.. method:: RequestHandler.finish() + .. method:: setup() - Called after the :meth:`handle` method to perform any clean-up actions - required. The default implementation does nothing. If :meth:`setup` - raises an exception, this function will not be called. + Called before the :meth:`handle` method to perform any initialization actions + required. The default implementation does nothing. -.. method:: RequestHandler.handle() + .. method:: handle() - This function must do all the work required to service a request. The - default implementation does nothing. Several instance attributes are - available to it; the request is available as :attr:`self.request`; the client - address as :attr:`self.client_address`; and the server instance as - :attr:`self.server`, in case it needs access to per-server information. + This function must do all the work required to service a request. The + default implementation does nothing. Several instance attributes are + available to it; the request is available as :attr:`self.request`; the client + address as :attr:`self.client_address`; and the server instance as + :attr:`self.server`, in case it needs access to per-server information. - The type of :attr:`self.request` is different for datagram or stream - services. For stream services, :attr:`self.request` is a socket object; for - datagram services, :attr:`self.request` is a pair of string and socket. - However, this can be hidden by using the request handler subclasses - :class:`StreamRequestHandler` or :class:`DatagramRequestHandler`, which - override the :meth:`setup` and :meth:`finish` methods, and provide - :attr:`self.rfile` and :attr:`self.wfile` attributes. :attr:`self.rfile` and - :attr:`self.wfile` can be read or written, respectively, to get the request - data or return data to the client. + The type of :attr:`self.request` is different for datagram or stream + services. For stream services, :attr:`self.request` is a socket object; for + datagram services, :attr:`self.request` is a pair of string and socket. -.. method:: RequestHandler.setup() + .. method:: finish() - Called before the :meth:`handle` method to perform any initialization actions - required. The default implementation does nothing. + Called after the :meth:`handle` method to perform any clean-up actions + required. The default implementation does nothing. If :meth:`setup` + raises an exception, this function will not be called. + + +.. class:: StreamRequestHandler + DatagramRequestHandler + + These :class:`BaseRequestHandler` subclasses override the + :meth:`~BaseRequestHandler.setup` and :meth:`~BaseRequestHandler.finish` + methods, and provide :attr:`self.rfile` and :attr:`self.wfile` attributes. + The :attr:`self.rfile` and :attr:`self.wfile` attributes can be + read or written, respectively, to get the request data or return data + to the client. Examples @@ -362,7 +410,7 @@ class MyTCPHandler(socketserver.BaseRequestHandler): """ - The RequestHandler class for our server. + The request handler class for our server. It is instantiated once per connection to the server, and must override the handle() method to implement communication to the -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 18 23:01:25 2016 From: python-checkins at python.org (martin.panter) Date: Fri, 19 Feb 2016 04:01:25 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE1NjA4?= =?utf-8?q?=3A_Improve_socketserver_module_documentation?= Message-ID: <20160219040125.2202.95352@psf.io> https://hg.python.org/cpython/rev/9211b7e60c92 changeset: 100267:9211b7e60c92 branch: 2.7 parent: 100262:cba717fa8e10 user: Martin Panter date: Fri Feb 19 03:27:46 2016 +0000 summary: Issue #15608: Improve socketserver module documentation * Add headings for each concrete and mix-in class and list methods and attributes under them * Fix class and method cross references * Changed RequestHandler to BaseRequestHandler and added class heading * Pull out Stream/DatagramRequestHandler definitions * Reordered the request handler setup(), handle(), finish() methods * Document constructor parameters for the server classes files: Doc/library/socketserver.rst | 340 +++++++++++++--------- 1 files changed, 195 insertions(+), 145 deletions(-) diff --git a/Doc/library/socketserver.rst b/Doc/library/socketserver.rst --- a/Doc/library/socketserver.rst +++ b/Doc/library/socketserver.rst @@ -16,16 +16,34 @@ The :mod:`SocketServer` module simplifies the task of writing network servers. -There are four basic server classes: :class:`TCPServer` uses the Internet TCP -protocol, which provides for continuous streams of data between the client and -server. :class:`UDPServer` uses datagrams, which are discrete packets of -information that may arrive out of order or be lost while in transit. The more -infrequently used :class:`UnixStreamServer` and :class:`UnixDatagramServer` -classes are similar, but use Unix domain sockets; they're not available on -non-Unix platforms. For more details on network programming, consult a book -such as -W. Richard Steven's UNIX Network Programming or Ralph Davis's Win32 Network -Programming. +There are four basic concrete server classes: + + +.. class:: TCPServer(server_address, RequestHandlerClass, bind_and_activate=True) + + This uses the Internet TCP protocol, which provides for + continuous streams of data between the client and server. + If *bind_and_activate* is true, the constructor automatically attempts to + invoke :meth:`~BaseServer.server_bind` and + :meth:`~BaseServer.server_activate`. The other parameters are passed to + the :class:`BaseServer` base class. + + +.. class:: UDPServer(server_address, RequestHandlerClass, bind_and_activate=True) + + This uses datagrams, which are discrete packets of information that may + arrive out of order or be lost while in transit. The parameters are + the same as for :class:`TCPServer`. + + +.. class:: UnixStreamServer(server_address, RequestHandlerClass, bind_and_activate=True) + UnixDatagramServer(server_address, RequestHandlerClass, bind_and_activate=True) + + These more infrequently used classes are similar to the TCP and + UDP classes, but use Unix domain sockets; they're not available on + non-Unix platforms. The parameters are the same as for + :class:`TCPServer`. + These four classes process requests :dfn:`synchronously`; each request must be completed before the next request can be started. This isn't suitable if each @@ -37,10 +55,12 @@ Creating a server requires several steps. First, you must create a request handler class by subclassing the :class:`BaseRequestHandler` class and -overriding its :meth:`handle` method; this method will process incoming +overriding its :meth:`~BaseRequestHandler.handle` method; +this method will process incoming requests. Second, you must instantiate one of the server classes, passing it the server's address and the request handler class. Then call the -:meth:`handle_request` or :meth:`serve_forever` method of the server object to +:meth:`~BaseServer.handle_request` or +:meth:`~BaseServer.serve_forever` method of the server object to process one or many requests. Finally, call :meth:`~BaseServer.server_close` to close the socket. @@ -81,18 +101,33 @@ stream server is the address family, which is simply repeated in both Unix server classes. -Forking and threading versions of each type of server can be created using the -:class:`ForkingMixIn` and :class:`ThreadingMixIn` mix-in classes. For instance, -a threading UDP server class is created as follows:: - class ThreadingUDPServer(ThreadingMixIn, UDPServer): pass +.. class:: ForkingMixIn + ThreadingMixIn -The mix-in class must come first, since it overrides a method defined in -:class:`UDPServer`. Setting the various attributes also change the -behavior of the underlying server mechanism. + Forking and threading versions of each type of server can be created + using these mix-in classes. For instance, :class:`ThreadingUDPServer` + is created as follows:: + + class ThreadingUDPServer(ThreadingMixIn, UDPServer): + pass + + The mix-in class comes first, since it overrides a method defined in + :class:`UDPServer`. Setting the various attributes also changes the + behavior of the underlying server mechanism. + + +.. class:: ForkingTCPServer + ForkingUDPServer + ThreadingTCPServer + ThreadingUDPServer + + These classes are pre-defined using the mix-in classes. + To implement a service, you must derive a class from :class:`BaseRequestHandler` -and redefine its :meth:`handle` method. You can then run various versions of +and redefine its :meth:`~BaseRequestHandler.handle` method. +You can then run various versions of the service by combining one of the server classes with your request handler class. The request handler class must be different for datagram or stream services. This can be hidden by using the handler subclasses @@ -114,7 +149,7 @@ In some cases, it may be appropriate to process part of a request synchronously, but to finish processing in a forked child depending on the request data. This can be implemented by using a synchronous server and doing an explicit fork in -the request handler class :meth:`handle` method. +the request handler class :meth:`~BaseRequestHandler.handle` method. Another approach to handling multiple simultaneous requests in an environment that supports neither threads nor :func:`~os.fork` (or where these are too @@ -132,215 +167,230 @@ Server Objects -------------- -.. class:: BaseServer +.. class:: BaseServer(server_address, RequestHandlerClass) This is the superclass of all Server objects in the module. It defines the interface, given below, but does not implement most of the methods, which is - done in subclasses. + done in subclasses. The two parameters are stored in the respective + :attr:`server_address` and :attr:`RequestHandlerClass` attributes. -.. method:: BaseServer.fileno() + .. method:: fileno() - Return an integer file descriptor for the socket on which the server is - listening. This function is most commonly passed to :func:`select.select`, to - allow monitoring multiple servers in the same process. + Return an integer file descriptor for the socket on which the server is + listening. This function is most commonly passed to :func:`select.select`, to + allow monitoring multiple servers in the same process. -.. method:: BaseServer.handle_request() + .. method:: handle_request() - Process a single request. This function calls the following methods in - order: :meth:`get_request`, :meth:`verify_request`, and - :meth:`process_request`. If the user-provided :meth:`handle` method of the - handler class raises an exception, the server's :meth:`handle_error` method - will be called. If no request is received within :attr:`self.timeout` - seconds, :meth:`handle_timeout` will be called and :meth:`handle_request` - will return. + Process a single request. This function calls the following methods in + order: :meth:`get_request`, :meth:`verify_request`, and + :meth:`process_request`. If the user-provided + :meth:`~BaseRequestHandler.handle` method of the + handler class raises an exception, the server's :meth:`handle_error` method + will be called. If no request is received within :attr:`timeout` + seconds, :meth:`handle_timeout` will be called and :meth:`handle_request` + will return. -.. method:: BaseServer.serve_forever(poll_interval=0.5) + .. method:: serve_forever(poll_interval=0.5) - Handle requests until an explicit :meth:`shutdown` request. - Poll for shutdown every *poll_interval* seconds. Ignores :attr:`self.timeout`. - If you need to do periodic tasks, do them in another thread. + Handle requests until an explicit :meth:`shutdown` request. Poll for + shutdown every *poll_interval* seconds. + Ignores the :attr:`timeout` attribute. + If you need to do periodic tasks, do them in another thread. -.. method:: BaseServer.shutdown() + .. method:: shutdown() - Tell the :meth:`serve_forever` loop to stop and wait until it does. + Tell the :meth:`serve_forever` loop to stop and wait until it does. - .. versionadded:: 2.6 + .. versionadded:: 2.6 -.. method:: BaseServer.server_close() + .. method:: server_close() - Clean up the server. May be overridden. + Clean up the server. May be overridden. - .. versionadded:: 2.6 + .. versionadded:: 2.6 -.. attribute:: BaseServer.address_family + .. attribute:: address_family - The family of protocols to which the server's socket belongs. - Common examples are :const:`socket.AF_INET` and :const:`socket.AF_UNIX`. + The family of protocols to which the server's socket belongs. + Common examples are :const:`socket.AF_INET` and :const:`socket.AF_UNIX`. -.. attribute:: BaseServer.RequestHandlerClass + .. attribute:: RequestHandlerClass - The user-provided request handler class; an instance of this class is created - for each request. + The user-provided request handler class; an instance of this class is created + for each request. -.. attribute:: BaseServer.server_address + .. attribute:: server_address - The address on which the server is listening. The format of addresses varies - depending on the protocol family; see the documentation for the socket module - for details. For Internet protocols, this is a tuple containing a string giving - the address, and an integer port number: ``('127.0.0.1', 80)``, for example. + The address on which the server is listening. The format of addresses varies + depending on the protocol family; + see the documentation for the :mod:`socket` module + for details. For Internet protocols, this is a tuple containing a string giving + the address, and an integer port number: ``('127.0.0.1', 80)``, for example. -.. attribute:: BaseServer.socket + .. attribute:: socket - The socket object on which the server will listen for incoming requests. + The socket object on which the server will listen for incoming requests. -The server classes support the following class variables: + The server classes support the following class variables: -.. XXX should class variables be covered before instance variables, or vice versa? + .. XXX should class variables be covered before instance variables, or vice versa? -.. attribute:: BaseServer.allow_reuse_address + .. attribute:: allow_reuse_address - Whether the server will allow the reuse of an address. This defaults to - :const:`False`, and can be set in subclasses to change the policy. + Whether the server will allow the reuse of an address. This defaults to + :const:`False`, and can be set in subclasses to change the policy. -.. attribute:: BaseServer.request_queue_size + .. attribute:: request_queue_size - The size of the request queue. If it takes a long time to process a single - request, any requests that arrive while the server is busy are placed into a - queue, up to :attr:`request_queue_size` requests. Once the queue is full, - further requests from clients will get a "Connection denied" error. The default - value is usually 5, but this can be overridden by subclasses. + The size of the request queue. If it takes a long time to process a single + request, any requests that arrive while the server is busy are placed into a + queue, up to :attr:`request_queue_size` requests. Once the queue is full, + further requests from clients will get a "Connection denied" error. The default + value is usually 5, but this can be overridden by subclasses. -.. attribute:: BaseServer.socket_type + .. attribute:: socket_type - The type of socket used by the server; :const:`socket.SOCK_STREAM` and - :const:`socket.SOCK_DGRAM` are two common values. + The type of socket used by the server; :const:`socket.SOCK_STREAM` and + :const:`socket.SOCK_DGRAM` are two common values. -.. attribute:: BaseServer.timeout + .. attribute:: timeout - Timeout duration, measured in seconds, or :const:`None` if no timeout is - desired. If :meth:`handle_request` receives no incoming requests within the - timeout period, the :meth:`handle_timeout` method is called. + Timeout duration, measured in seconds, or :const:`None` if no timeout is + desired. If :meth:`handle_request` receives no incoming requests within the + timeout period, the :meth:`handle_timeout` method is called. -There are various server methods that can be overridden by subclasses of base -server classes like :class:`TCPServer`; these methods aren't useful to external -users of the server object. + There are various server methods that can be overridden by subclasses of base + server classes like :class:`TCPServer`; these methods aren't useful to external + users of the server object. -.. XXX should the default implementations of these be documented, or should - it be assumed that the user will look at SocketServer.py? + .. XXX should the default implementations of these be documented, or should + it be assumed that the user will look at SocketServer.py? -.. method:: BaseServer.finish_request() + .. method:: finish_request() - Actually processes the request by instantiating :attr:`RequestHandlerClass` and - calling its :meth:`handle` method. + Actually processes the request by instantiating :attr:`RequestHandlerClass` and + calling its :meth:`~BaseRequestHandler.handle` method. -.. method:: BaseServer.get_request() + .. method:: get_request() - Must accept a request from the socket, and return a 2-tuple containing the *new* - socket object to be used to communicate with the client, and the client's - address. + Must accept a request from the socket, and return a 2-tuple containing the *new* + socket object to be used to communicate with the client, and the client's + address. -.. method:: BaseServer.handle_error(request, client_address) + .. method:: handle_error(request, client_address) - This function is called if the :attr:`RequestHandlerClass`'s :meth:`handle` - method raises an exception. The default action is to print the traceback to - standard output and continue handling further requests. + This function is called if the :meth:`~BaseRequestHandler.handle` + method of a :attr:`RequestHandlerClass` instance raises + an exception. The default action is to print the traceback to + standard output and continue handling further requests. -.. method:: BaseServer.handle_timeout() + .. method:: handle_timeout() - This function is called when the :attr:`timeout` attribute has been set to a - value other than :const:`None` and the timeout period has passed with no - requests being received. The default action for forking servers is - to collect the status of any child processes that have exited, while - in threading servers this method does nothing. + This function is called when the :attr:`timeout` attribute has been set to a + value other than :const:`None` and the timeout period has passed with no + requests being received. The default action for forking servers is + to collect the status of any child processes that have exited, while + in threading servers this method does nothing. -.. method:: BaseServer.process_request(request, client_address) + .. method:: process_request(request, client_address) - Calls :meth:`finish_request` to create an instance of the - :attr:`RequestHandlerClass`. If desired, this function can create a new process - or thread to handle the request; the :class:`ForkingMixIn` and - :class:`ThreadingMixIn` classes do this. + Calls :meth:`finish_request` to create an instance of the + :attr:`RequestHandlerClass`. If desired, this function can create a new process + or thread to handle the request; the :class:`ForkingMixIn` and + :class:`ThreadingMixIn` classes do this. -.. Is there any point in documenting the following two functions? - What would the purpose of overriding them be: initializing server - instance variables, adding new network families? + .. Is there any point in documenting the following two functions? + What would the purpose of overriding them be: initializing server + instance variables, adding new network families? -.. method:: BaseServer.server_activate() + .. method:: server_activate() - Called by the server's constructor to activate the server. The default behavior - just :meth:`listen`\ s to the server's socket. May be overridden. + Called by the server's constructor to activate the server. The default behavior + for a TCP server just invokes :meth:`~socket.socket.listen` + on the server's socket. May be overridden. -.. method:: BaseServer.server_bind() + .. method:: server_bind() - Called by the server's constructor to bind the socket to the desired address. - May be overridden. + Called by the server's constructor to bind the socket to the desired address. + May be overridden. -.. method:: BaseServer.verify_request(request, client_address) + .. method:: verify_request(request, client_address) - Must return a Boolean value; if the value is :const:`True`, the request will be - processed, and if it's :const:`False`, the request will be denied. This function - can be overridden to implement access controls for a server. The default - implementation always returns :const:`True`. + Must return a Boolean value; if the value is :const:`True`, the request will be + processed, and if it's :const:`False`, the request will be denied. This function + can be overridden to implement access controls for a server. The default + implementation always returns :const:`True`. -RequestHandler Objects ----------------------- +Request Handler Objects +----------------------- -The request handler class must define a new :meth:`handle` method, and can -override any of the following methods. A new instance is created for each -request. +.. class:: BaseRequestHandler + This is the superclass of all request handler objects. It defines + the interface, given below. A concrete request handler subclass must + define a new :meth:`handle` method, and can override any of + the other methods. A new instance of the subclass is created for each + request. -.. method:: RequestHandler.finish() - Called after the :meth:`handle` method to perform any clean-up actions - required. The default implementation does nothing. If :meth:`setup` - raises an exception, this function will not be called. + .. method:: setup() + Called before the :meth:`handle` method to perform any initialization actions + required. The default implementation does nothing. -.. method:: RequestHandler.handle() - This function must do all the work required to service a request. The - default implementation does nothing. Several instance attributes are - available to it; the request is available as :attr:`self.request`; the client - address as :attr:`self.client_address`; and the server instance as - :attr:`self.server`, in case it needs access to per-server information. + .. method:: handle() - The type of :attr:`self.request` is different for datagram or stream - services. For stream services, :attr:`self.request` is a socket object; for - datagram services, :attr:`self.request` is a pair of string and socket. - However, this can be hidden by using the request handler subclasses - :class:`StreamRequestHandler` or :class:`DatagramRequestHandler`, which - override the :meth:`setup` and :meth:`finish` methods, and provide - :attr:`self.rfile` and :attr:`self.wfile` attributes. :attr:`self.rfile` and - :attr:`self.wfile` can be read or written, respectively, to get the request - data or return data to the client. + This function must do all the work required to service a request. The + default implementation does nothing. Several instance attributes are + available to it; the request is available as :attr:`self.request`; the client + address as :attr:`self.client_address`; and the server instance as + :attr:`self.server`, in case it needs access to per-server information. + The type of :attr:`self.request` is different for datagram or stream + services. For stream services, :attr:`self.request` is a socket object; for + datagram services, :attr:`self.request` is a pair of string and socket. -.. method:: RequestHandler.setup() - Called before the :meth:`handle` method to perform any initialization actions - required. The default implementation does nothing. + .. method:: finish() + + Called after the :meth:`handle` method to perform any clean-up actions + required. The default implementation does nothing. If :meth:`setup` + raises an exception, this function will not be called. + + +.. class:: StreamRequestHandler + DatagramRequestHandler + + These :class:`BaseRequestHandler` subclasses override the + :meth:`~BaseRequestHandler.setup` and :meth:`~BaseRequestHandler.finish` + methods, and provide :attr:`self.rfile` and :attr:`self.wfile` attributes. + The :attr:`self.rfile` and :attr:`self.wfile` attributes can be + read or written, respectively, to get the request data or return data + to the client. Examples @@ -355,7 +405,7 @@ class MyTCPHandler(SocketServer.BaseRequestHandler): """ - The RequestHandler class for our server. + The request handler class for our server. It is instantiated once per connection to the server, and must override the handle() method to implement communication to the -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Feb 19 02:57:56 2016 From: python-checkins at python.org (georg.brandl) Date: Fri, 19 Feb 2016 07:57:56 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogQ2xvc2VzICMyMDE2?= =?utf-8?q?9=3A_fix_inner_links_random_doc=2E?= Message-ID: <20160219075756.1963.43929@psf.io> https://hg.python.org/cpython/rev/426ac89548b3 changeset: 100269:426ac89548b3 branch: 3.5 parent: 100265:8b71cd67f548 user: Georg Brandl date: Fri Feb 19 08:57:38 2016 +0100 summary: Closes #20169: fix inner links random doc. files: Doc/library/random.rst | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/library/random.rst b/Doc/library/random.rst --- a/Doc/library/random.rst +++ b/Doc/library/random.rst @@ -20,7 +20,7 @@ lognormal, negative exponential, gamma, and beta distributions. For generating distributions of angles, the von Mises distribution is available. -Almost all module functions depend on the basic function :func:`random`, which +Almost all module functions depend on the basic function :func:`.random`, which generates a random float uniformly in the semi-open range [0.0, 1.0). Python uses the Mersenne Twister as the core generator. It produces 53-bit precision floats and has a period of 2\*\*19937-1. The underlying implementation in C is @@ -34,9 +34,9 @@ instances of :class:`Random` to get generators that don't share state. Class :class:`Random` can also be subclassed if you want to use a different -basic generator of your own devising: in that case, override the :meth:`random`, -:meth:`seed`, :meth:`getstate`, and :meth:`setstate` methods. -Optionally, a new generator can supply a :meth:`getrandbits` method --- this +basic generator of your own devising: in that case, override the :meth:`~Random.random`, +:meth:`~Random.seed`, :meth:`~Random.getstate`, and :meth:`~Random.setstate` methods. +Optionally, a new generator can supply a :meth:`~Random.getrandbits` method --- this allows :meth:`randrange` to produce selections over an arbitrarily large range. The :mod:`random` module also provides the :class:`SystemRandom` class which @@ -125,7 +125,7 @@ Shuffle the sequence *x* in place. The optional argument *random* is a 0-argument function returning a random float in [0.0, 1.0); by default, this is - the function :func:`random`. + the function :func:`.random`. Note that for even rather small ``len(x)``, the total number of permutations of *x* is larger than the period of most random number generators; this implies @@ -285,7 +285,7 @@ * If a new seeding method is added, then a backward compatible seeder will be offered. -* The generator's :meth:`random` method will continue to produce the same +* The generator's :meth:`~Random.random` method will continue to produce the same sequence when the compatible seeder is given the same seed. .. _random-examples: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Feb 19 02:57:56 2016 From: python-checkins at python.org (georg.brandl) Date: Fri, 19 Feb 2016 07:57:56 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_merge_with_3=2E5?= Message-ID: <20160219075756.1965.71171@psf.io> https://hg.python.org/cpython/rev/f9391e2b74a5 changeset: 100270:f9391e2b74a5 parent: 100266:fbb8b634fe59 parent: 100269:426ac89548b3 user: Georg Brandl date: Fri Feb 19 08:57:50 2016 +0100 summary: merge with 3.5 files: Doc/library/random.rst | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/library/random.rst b/Doc/library/random.rst --- a/Doc/library/random.rst +++ b/Doc/library/random.rst @@ -20,7 +20,7 @@ lognormal, negative exponential, gamma, and beta distributions. For generating distributions of angles, the von Mises distribution is available. -Almost all module functions depend on the basic function :func:`random`, which +Almost all module functions depend on the basic function :func:`.random`, which generates a random float uniformly in the semi-open range [0.0, 1.0). Python uses the Mersenne Twister as the core generator. It produces 53-bit precision floats and has a period of 2\*\*19937-1. The underlying implementation in C is @@ -34,9 +34,9 @@ instances of :class:`Random` to get generators that don't share state. Class :class:`Random` can also be subclassed if you want to use a different -basic generator of your own devising: in that case, override the :meth:`random`, -:meth:`seed`, :meth:`getstate`, and :meth:`setstate` methods. -Optionally, a new generator can supply a :meth:`getrandbits` method --- this +basic generator of your own devising: in that case, override the :meth:`~Random.random`, +:meth:`~Random.seed`, :meth:`~Random.getstate`, and :meth:`~Random.setstate` methods. +Optionally, a new generator can supply a :meth:`~Random.getrandbits` method --- this allows :meth:`randrange` to produce selections over an arbitrarily large range. The :mod:`random` module also provides the :class:`SystemRandom` class which @@ -125,7 +125,7 @@ Shuffle the sequence *x* in place. The optional argument *random* is a 0-argument function returning a random float in [0.0, 1.0); by default, this is - the function :func:`random`. + the function :func:`.random`. Note that for even rather small ``len(x)``, the total number of permutations of *x* is larger than the period of most random number generators; this implies @@ -285,7 +285,7 @@ * If a new seeding method is added, then a backward compatible seeder will be offered. -* The generator's :meth:`random` method will continue to produce the same +* The generator's :meth:`~Random.random` method will continue to produce the same sequence when the compatible seeder is given the same seed. .. _random-examples: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Feb 19 02:57:58 2016 From: python-checkins at python.org (georg.brandl) Date: Fri, 19 Feb 2016 07:57:58 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogQ2xvc2VzICMyMDE2?= =?utf-8?q?9=3A_fix_inner_links_random_doc=2E?= Message-ID: <20160219075756.1694.56441@psf.io> https://hg.python.org/cpython/rev/2d8e8d0e7162 changeset: 100268:2d8e8d0e7162 branch: 2.7 user: Georg Brandl date: Fri Feb 19 08:57:23 2016 +0100 summary: Closes #20169: fix inner links random doc. files: Doc/library/random.rst | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Doc/library/random.rst b/Doc/library/random.rst --- a/Doc/library/random.rst +++ b/Doc/library/random.rst @@ -19,7 +19,7 @@ lognormal, negative exponential, gamma, and beta distributions. For generating distributions of angles, the von Mises distribution is available. -Almost all module functions depend on the basic function :func:`random`, which +Almost all module functions depend on the basic function :func:`.random`, which generates a random float uniformly in the semi-open range [0.0, 1.0). Python uses the Mersenne Twister as the core generator. It produces 53-bit precision floats and has a period of 2\*\*19937-1. The underlying implementation in C is @@ -36,9 +36,10 @@ it likely that the generated sequences seen by each thread don't overlap. Class :class:`Random` can also be subclassed if you want to use a different -basic generator of your own devising: in that case, override the :meth:`random`, -:meth:`seed`, :meth:`getstate`, :meth:`setstate` and :meth:`jumpahead` methods. -Optionally, a new generator can supply a :meth:`getrandbits` method --- this +basic generator of your own devising: in that case, override the :meth:`~Random.random`, +:meth:`~Random.seed`, :meth:`~Random.getstate`, :meth:`~Random.setstate` and +:meth:`~Random.jumpahead` methods. Optionally, a new generator can supply a +:meth:`~Random.getrandbits` method --- this allows :meth:`randrange` to produce selections over an arbitrarily large range. .. versionadded:: 2.4 @@ -158,7 +159,7 @@ Shuffle the sequence *x* in place. The optional argument *random* is a 0-argument function returning a random float in [0.0, 1.0); by default, this is - the function :func:`random`. + the function :func:`.random`. Note that for even rather small ``len(x)``, the total number of permutations of *x* is larger than the period of most random number generators; this implies -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Fri Feb 19 04:46:21 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Fri, 19 Feb 2016 09:46:21 +0000 Subject: [Python-checkins] Daily reference leaks (fbb8b634fe59): sum=4 Message-ID: <20160219094619.1701.52323@psf.io> results for fbb8b634fe59 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogXIrKd1', '--timeout', '7200'] From lp_benchmark_robot at intel.com Fri Feb 19 11:25:14 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Fri, 19 Feb 2016 16:25:14 +0000 Subject: [Python-checkins] GOOD Benchmark Results for Python Default 2016-02-19 Message-ID: <19d89b84-d5ba-456f-a13e-14442870da73@irsmsx151.ger.corp.intel.com> Results for project Python default, build date 2016-02-19 03:09:42 +0000 commit: c791d57c8168 previous commit: 12502327d2c0 revision date: 2016-02-19 02:38:34 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.17% 2.41% 10.78% 12.67% :-| pybench 0.14% -0.02% 0.48% 5.65% :-( regex_v8 2.86% -0.07% -4.71% 4.55% :-| nbody 0.08% 0.78% -0.79% 8.82% :-| json_dump_v2 0.22% 0.24% -0.06% 10.03% :-| normal_startup 0.99% -0.35% -0.18% 5.65% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/good-benchmark-results-for-python-default-2016-02-19/ Note: Benchmark results are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Fri Feb 19 11:28:29 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Fri, 19 Feb 2016 16:28:29 +0000 Subject: [Python-checkins] BAD Benchmark Results for Python 2.7 2016-02-19 Message-ID: Results for project Python 2.7, build date 2016-02-19 04:03:22 +0000 commit: 9211b7e60c92 previous commit: 58ebfa7c1361 revision date: 2016-02-19 03:27:46 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dc from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.20% -0.77% 5.66% 3.48% :-) pybench 0.08% 0.04% 6.26% 3.89% :-( regex_v8 0.79% -0.07% -2.71% 11.47% :-) nbody 0.11% -0.03% 7.76% 4.23% :-) json_dump_v2 0.21% -1.15% 3.33% 13.33% :-( normal_startup 1.90% 0.62% -5.36% 1.05% :-| ssbench 0.14% -0.18% 1.76% 1.90% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/bad-benchmark-results-for-python-2-7-2016-02-19/ Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Fri Feb 19 19:18:59 2016 From: python-checkins at python.org (martin.panter) Date: Sat, 20 Feb 2016 00:18:59 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWVzICMyMjQ2?= =?utf-8?q?8=2C_=2321996=2C_=2322208=3A_Clarify_gettarinfo=28=29_and_TarIn?= =?utf-8?q?fo_usage?= Message-ID: <20160220001859.1988.84684@psf.io> https://hg.python.org/cpython/rev/9d5217aaea13 changeset: 100273:9d5217aaea13 branch: 2.7 parent: 100268:2d8e8d0e7162 user: Martin Panter date: Fri Feb 19 23:34:56 2016 +0000 summary: Issues #22468, #21996, #22208: Clarify gettarinfo() and TarInfo usage * Make it more obvious gettarinfo() is based on stat(), and that non-ordinary files may need special care * Filename taken from fileobj.name; suggest dummy arcname as a workaround * Indicate TarInfo may be used directly, not just via gettarinfo() files: Doc/library/tarfile.rst | 21 +++++++++++++++------ Lib/tarfile.py | 15 ++++++++------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst --- a/Doc/library/tarfile.rst +++ b/Doc/library/tarfile.rst @@ -438,20 +438,29 @@ Add the :class:`TarInfo` object *tarinfo* to the archive. If *fileobj* is given, ``tarinfo.size`` bytes are read from it and added to the archive. You can - create :class:`TarInfo` objects using :meth:`gettarinfo`. + create :class:`TarInfo` objects directly, or by using :meth:`gettarinfo`. .. note:: - On Windows platforms, *fileobj* should always be opened with mode ``'rb'`` to avoid irritation about the file size. .. method:: TarFile.gettarinfo(name=None, arcname=None, fileobj=None) - Create a :class:`TarInfo` object for either the file *name* or the file object - *fileobj* (using :func:`os.fstat` on its file descriptor). You can modify some - of the :class:`TarInfo`'s attributes before you add it using :meth:`addfile`. - If given, *arcname* specifies an alternative name for the file in the archive. + Create a :class:`TarInfo` object from the result of :func:`os.stat` or + equivalent on an existing file. The file is either named by *name*, or + specified as a file object *fileobj* with a file descriptor. If + given, *arcname* specifies an alternative name for the file in the + archive, otherwise, the name is taken from *fileobj*?s + :attr:`~file.name` attribute, or the *name* argument. + + You can modify some + of the :class:`TarInfo`?s attributes before you add it using :meth:`addfile`. + If the file object is not an ordinary file object positioned at the + beginning of the file, attributes such as :attr:`~TarInfo.size` may need + modifying. This is the case for objects such as :class:`~gzip.GzipFile`. + The :attr:`~TarInfo.name` may also be modified, in which case *arcname* + could be a dummy string. .. method:: TarFile.close() diff --git a/Lib/tarfile.py b/Lib/tarfile.py --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -1844,11 +1844,12 @@ return [tarinfo.name for tarinfo in self.getmembers()] def gettarinfo(self, name=None, arcname=None, fileobj=None): - """Create a TarInfo object for either the file `name' or the file - object `fileobj' (using os.fstat on its file descriptor). You can - modify some of the TarInfo's attributes before you add it using - addfile(). If given, `arcname' specifies an alternative name for the - file in the archive. + """Create a TarInfo object from the result of os.stat or equivalent + on an existing file. The file is either named by `name', or + specified as a file object `fileobj' with a file descriptor. If + given, `arcname' specifies an alternative name for the file in the + archive, otherwise, the name is taken from the 'name' attribute of + 'fileobj', or the 'name' argument. """ self._check("aw") @@ -1869,7 +1870,7 @@ # Now, fill the TarInfo object with # information specific for the file. tarinfo = self.tarinfo() - tarinfo.tarfile = self + tarinfo.tarfile = self # Not needed # Use os.stat or os.lstat, depending on platform # and if symlinks shall be resolved. @@ -2034,7 +2035,7 @@ def addfile(self, tarinfo, fileobj=None): """Add the TarInfo object `tarinfo' to the archive. If `fileobj' is given, tarinfo.size bytes are read from it and added to the archive. - You can create TarInfo objects using gettarinfo(). + You can create TarInfo objects directly, or by using gettarinfo(). On Windows platforms, `fileobj' should always be opened with mode 'rb' to avoid irritation about the file size. """ -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Feb 19 19:19:04 2016 From: python-checkins at python.org (martin.panter) Date: Sat, 20 Feb 2016 00:19:04 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2322468=3A_Merge_gettarinfo=28=29_doc_from_3=2E5?= Message-ID: <20160220001854.1554.86080@psf.io> https://hg.python.org/cpython/rev/e66c476b25ec changeset: 100272:e66c476b25ec parent: 100270:f9391e2b74a5 parent: 100271:94a94deaf06a user: Martin Panter date: Fri Feb 19 23:46:59 2016 +0000 summary: Issue #22468: Merge gettarinfo() doc from 3.5 files: Doc/library/tarfile.rst | 27 +++++++++++++++++---------- Lib/tarfile.py | 21 +++++++++++---------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst --- a/Doc/library/tarfile.rst +++ b/Doc/library/tarfile.rst @@ -456,21 +456,28 @@ .. method:: TarFile.addfile(tarinfo, fileobj=None) Add the :class:`TarInfo` object *tarinfo* to the archive. If *fileobj* is given, + it should be a :term:`binary file`, and ``tarinfo.size`` bytes are read from it and added to the archive. You can - create :class:`TarInfo` objects using :meth:`gettarinfo`. - - .. note:: - - On Windows platforms, *fileobj* should always be opened with mode ``'rb'`` to - avoid irritation about the file size. + create :class:`TarInfo` objects directly, or by using :meth:`gettarinfo`. .. method:: TarFile.gettarinfo(name=None, arcname=None, fileobj=None) - Create a :class:`TarInfo` object for either the file *name* or the :term:`file - object` *fileobj* (using :func:`os.fstat` on its file descriptor). You can modify - some of the :class:`TarInfo`'s attributes before you add it using :meth:`addfile`. - If given, *arcname* specifies an alternative name for the file in the archive. + Create a :class:`TarInfo` object from the result of :func:`os.stat` or + equivalent on an existing file. The file is either named by *name*, or + specified as a :term:`file object` *fileobj* with a file descriptor. If + given, *arcname* specifies an alternative name for the file in the + archive, otherwise, the name is taken from *fileobj*?s + :attr:`~io.FileIO.name` attribute, or the *name* argument. The name + should be a text string. + + You can modify + some of the :class:`TarInfo`?s attributes before you add it using :meth:`addfile`. + If the file object is not an ordinary file object positioned at the + beginning of the file, attributes such as :attr:`~TarInfo.size` may need + modifying. This is the case for objects such as :class:`~gzip.GzipFile`. + The :attr:`~TarInfo.name` may also be modified, in which case *arcname* + could be a dummy string. .. method:: TarFile.close() diff --git a/Lib/tarfile.py b/Lib/tarfile.py --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -1757,11 +1757,13 @@ return [tarinfo.name for tarinfo in self.getmembers()] def gettarinfo(self, name=None, arcname=None, fileobj=None): - """Create a TarInfo object for either the file `name' or the file - object `fileobj' (using os.fstat on its file descriptor). You can - modify some of the TarInfo's attributes before you add it using - addfile(). If given, `arcname' specifies an alternative name for the - file in the archive. + """Create a TarInfo object from the result of os.stat or equivalent + on an existing file. The file is either named by `name', or + specified as a file object `fileobj' with a file descriptor. If + given, `arcname' specifies an alternative name for the file in the + archive, otherwise, the name is taken from the 'name' attribute of + 'fileobj', or the 'name' argument. The name should be a text + string. """ self._check("awx") @@ -1782,7 +1784,7 @@ # Now, fill the TarInfo object with # information specific for the file. tarinfo = self.tarinfo() - tarinfo.tarfile = self + tarinfo.tarfile = self # Not needed # Use os.stat or os.lstat, depending on platform # and if symlinks shall be resolved. @@ -1949,10 +1951,9 @@ def addfile(self, tarinfo, fileobj=None): """Add the TarInfo object `tarinfo' to the archive. If `fileobj' is - given, tarinfo.size bytes are read from it and added to the archive. - You can create TarInfo objects using gettarinfo(). - On Windows platforms, `fileobj' should always be opened with mode - 'rb' to avoid irritation about the file size. + given, it should be a binary file, and tarinfo.size bytes are read + from it and added to the archive. You can create TarInfo objects + directly, or by using gettarinfo(). """ self._check("awx") -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Feb 19 19:19:04 2016 From: python-checkins at python.org (martin.panter) Date: Sat, 20 Feb 2016 00:19:04 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWVzICMyMjQ2?= =?utf-8?q?8=2C_=2321996=2C_=2322208=3A_Clarify_gettarinfo=28=29_and_TarIn?= =?utf-8?q?fo_usage?= Message-ID: <20160220001854.1678.24484@psf.io> https://hg.python.org/cpython/rev/94a94deaf06a changeset: 100271:94a94deaf06a branch: 3.5 parent: 100269:426ac89548b3 user: Martin Panter date: Fri Feb 19 23:34:56 2016 +0000 summary: Issues #22468, #21996, #22208: Clarify gettarinfo() and TarInfo usage * The Windows-specific binary notice was probably a Python 2 thing * Make it more obvious gettarinfo() is based on stat(), and that non-ordinary files may need special care * The file name must be text; suggest dummy arcname as a workaround * Indicate TarInfo may be used directly, not just via gettarinfo() files: Doc/library/tarfile.rst | 27 +++++++++++++++++---------- Lib/tarfile.py | 21 +++++++++++---------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst --- a/Doc/library/tarfile.rst +++ b/Doc/library/tarfile.rst @@ -456,21 +456,28 @@ .. method:: TarFile.addfile(tarinfo, fileobj=None) Add the :class:`TarInfo` object *tarinfo* to the archive. If *fileobj* is given, + it should be a :term:`binary file`, and ``tarinfo.size`` bytes are read from it and added to the archive. You can - create :class:`TarInfo` objects using :meth:`gettarinfo`. - - .. note:: - - On Windows platforms, *fileobj* should always be opened with mode ``'rb'`` to - avoid irritation about the file size. + create :class:`TarInfo` objects directly, or by using :meth:`gettarinfo`. .. method:: TarFile.gettarinfo(name=None, arcname=None, fileobj=None) - Create a :class:`TarInfo` object for either the file *name* or the :term:`file - object` *fileobj* (using :func:`os.fstat` on its file descriptor). You can modify - some of the :class:`TarInfo`'s attributes before you add it using :meth:`addfile`. - If given, *arcname* specifies an alternative name for the file in the archive. + Create a :class:`TarInfo` object from the result of :func:`os.stat` or + equivalent on an existing file. The file is either named by *name*, or + specified as a :term:`file object` *fileobj* with a file descriptor. If + given, *arcname* specifies an alternative name for the file in the + archive, otherwise, the name is taken from *fileobj*?s + :attr:`~io.FileIO.name` attribute, or the *name* argument. The name + should be a text string. + + You can modify + some of the :class:`TarInfo`?s attributes before you add it using :meth:`addfile`. + If the file object is not an ordinary file object positioned at the + beginning of the file, attributes such as :attr:`~TarInfo.size` may need + modifying. This is the case for objects such as :class:`~gzip.GzipFile`. + The :attr:`~TarInfo.name` may also be modified, in which case *arcname* + could be a dummy string. .. method:: TarFile.close() diff --git a/Lib/tarfile.py b/Lib/tarfile.py --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -1754,11 +1754,13 @@ return [tarinfo.name for tarinfo in self.getmembers()] def gettarinfo(self, name=None, arcname=None, fileobj=None): - """Create a TarInfo object for either the file `name' or the file - object `fileobj' (using os.fstat on its file descriptor). You can - modify some of the TarInfo's attributes before you add it using - addfile(). If given, `arcname' specifies an alternative name for the - file in the archive. + """Create a TarInfo object from the result of os.stat or equivalent + on an existing file. The file is either named by `name', or + specified as a file object `fileobj' with a file descriptor. If + given, `arcname' specifies an alternative name for the file in the + archive, otherwise, the name is taken from the 'name' attribute of + 'fileobj', or the 'name' argument. The name should be a text + string. """ self._check("awx") @@ -1779,7 +1781,7 @@ # Now, fill the TarInfo object with # information specific for the file. tarinfo = self.tarinfo() - tarinfo.tarfile = self + tarinfo.tarfile = self # Not needed # Use os.stat or os.lstat, depending on platform # and if symlinks shall be resolved. @@ -1946,10 +1948,9 @@ def addfile(self, tarinfo, fileobj=None): """Add the TarInfo object `tarinfo' to the archive. If `fileobj' is - given, tarinfo.size bytes are read from it and added to the archive. - You can create TarInfo objects using gettarinfo(). - On Windows platforms, `fileobj' should always be opened with mode - 'rb' to avoid irritation about the file size. + given, it should be a binary file, and tarinfo.size bytes are read + from it and added to the archive. You can create TarInfo objects + directly, or by using gettarinfo(). """ self._check("awx") -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Sat Feb 20 04:46:08 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Sat, 20 Feb 2016 09:46:08 +0000 Subject: [Python-checkins] Daily reference leaks (e66c476b25ec): sum=4 Message-ID: <20160220094608.1962.68995@psf.io> results for e66c476b25ec on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflog3Elz3F', '--timeout', '7200'] From python-checkins at python.org Sat Feb 20 14:03:41 2016 From: python-checkins at python.org (vinay.sajip) Date: Sat, 20 Feb 2016 19:03:41 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Added_simple_t?= =?utf-8?q?hreading_example_to_logging_cookbook=2E?= Message-ID: <20160220190341.1959.2807@psf.io> https://hg.python.org/cpython/rev/ada8023878d0 changeset: 100274:ada8023878d0 branch: 2.7 user: Vinay Sajip date: Sat Feb 20 19:02:04 2016 +0000 summary: Added simple threading example to logging cookbook. files: Doc/howto/logging-cookbook.rst | 55 ++++++++++++++++++++++ 1 files changed, 55 insertions(+), 0 deletions(-) diff --git a/Doc/howto/logging-cookbook.rst b/Doc/howto/logging-cookbook.rst --- a/Doc/howto/logging-cookbook.rst +++ b/Doc/howto/logging-cookbook.rst @@ -94,6 +94,61 @@ 2005-03-23 23:47:11,673 - spam_application - INFO - done with auxiliary_module.some_function() +Logging from multiple threads +----------------------------- + +Logging from multiple threads requires no special effort. The following example +shows logging from the main (initIal) thread and another thread:: + + import logging + import threading + import time + + def worker(arg): + while not arg['stop']: + logging.debug('Hi from myfunc') + time.sleep(0.5) + + def main(): + logging.basicConfig(level=logging.DEBUG, format='%(relativeCreated)6d %(threadName)s %(message)s') + info = {'stop': False} + thread = threading.Thread(target=worker, args=(info,)) + thread.start() + while True: + try: + logging.debug('Hello from main') + time.sleep(0.75) + except KeyboardInterrupt: + info['stop'] = True + break + thread.join() + + if __name__ == '__main__': + main() + +When run, the script should print something like the following:: + + 0 Thread-1 Hi from myfunc + 3 MainThread Hello from main + 505 Thread-1 Hi from myfunc + 755 MainThread Hello from main + 1007 Thread-1 Hi from myfunc + 1507 MainThread Hello from main + 1508 Thread-1 Hi from myfunc + 2010 Thread-1 Hi from myfunc + 2258 MainThread Hello from main + 2512 Thread-1 Hi from myfunc + 3009 MainThread Hello from main + 3013 Thread-1 Hi from myfunc + 3515 Thread-1 Hi from myfunc + 3761 MainThread Hello from main + 4017 Thread-1 Hi from myfunc + 4513 MainThread Hello from main + 4518 Thread-1 Hi from myfunc + +This shows the logging output interspersed as one might expect. This approach +works for more threads than shown here, of course. + Multiple handlers and formatters -------------------------------- -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Feb 20 14:03:41 2016 From: python-checkins at python.org (vinay.sajip) Date: Sat, 20 Feb 2016 19:03:41 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Added_simple_t?= =?utf-8?q?hreading_example_to_logging_cookbook=2E?= Message-ID: <20160220190341.1979.50224@psf.io> https://hg.python.org/cpython/rev/f82fa44da266 changeset: 100275:f82fa44da266 branch: 3.5 parent: 100271:94a94deaf06a user: Vinay Sajip date: Sat Feb 20 19:02:46 2016 +0000 summary: Added simple threading example to logging cookbook. files: Doc/howto/logging-cookbook.rst | 55 ++++++++++++++++++++++ 1 files changed, 55 insertions(+), 0 deletions(-) diff --git a/Doc/howto/logging-cookbook.rst b/Doc/howto/logging-cookbook.rst --- a/Doc/howto/logging-cookbook.rst +++ b/Doc/howto/logging-cookbook.rst @@ -94,6 +94,61 @@ 2005-03-23 23:47:11,673 - spam_application - INFO - done with auxiliary_module.some_function() +Logging from multiple threads +----------------------------- + +Logging from multiple threads requires no special effort. The following example +shows logging from the main (initIal) thread and another thread:: + + import logging + import threading + import time + + def worker(arg): + while not arg['stop']: + logging.debug('Hi from myfunc') + time.sleep(0.5) + + def main(): + logging.basicConfig(level=logging.DEBUG, format='%(relativeCreated)6d %(threadName)s %(message)s') + info = {'stop': False} + thread = threading.Thread(target=worker, args=(info,)) + thread.start() + while True: + try: + logging.debug('Hello from main') + time.sleep(0.75) + except KeyboardInterrupt: + info['stop'] = True + break + thread.join() + + if __name__ == '__main__': + main() + +When run, the script should print something like the following:: + + 0 Thread-1 Hi from myfunc + 3 MainThread Hello from main + 505 Thread-1 Hi from myfunc + 755 MainThread Hello from main + 1007 Thread-1 Hi from myfunc + 1507 MainThread Hello from main + 1508 Thread-1 Hi from myfunc + 2010 Thread-1 Hi from myfunc + 2258 MainThread Hello from main + 2512 Thread-1 Hi from myfunc + 3009 MainThread Hello from main + 3013 Thread-1 Hi from myfunc + 3515 Thread-1 Hi from myfunc + 3761 MainThread Hello from main + 4017 Thread-1 Hi from myfunc + 4513 MainThread Hello from main + 4518 Thread-1 Hi from myfunc + +This shows the logging output interspersed as one might expect. This approach +works for more threads than shown here, of course. + Multiple handlers and formatters -------------------------------- -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Feb 20 14:03:46 2016 From: python-checkins at python.org (vinay.sajip) Date: Sat, 20 Feb 2016 19:03:46 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Merged_cookbook_update_from_3=2E5=2E?= Message-ID: <20160220190341.1720.89491@psf.io> https://hg.python.org/cpython/rev/9955fd3869b6 changeset: 100276:9955fd3869b6 parent: 100272:e66c476b25ec parent: 100275:f82fa44da266 user: Vinay Sajip date: Sat Feb 20 19:03:29 2016 +0000 summary: Merged cookbook update from 3.5. files: Doc/howto/logging-cookbook.rst | 55 ++++++++++++++++++++++ 1 files changed, 55 insertions(+), 0 deletions(-) diff --git a/Doc/howto/logging-cookbook.rst b/Doc/howto/logging-cookbook.rst --- a/Doc/howto/logging-cookbook.rst +++ b/Doc/howto/logging-cookbook.rst @@ -94,6 +94,61 @@ 2005-03-23 23:47:11,673 - spam_application - INFO - done with auxiliary_module.some_function() +Logging from multiple threads +----------------------------- + +Logging from multiple threads requires no special effort. The following example +shows logging from the main (initIal) thread and another thread:: + + import logging + import threading + import time + + def worker(arg): + while not arg['stop']: + logging.debug('Hi from myfunc') + time.sleep(0.5) + + def main(): + logging.basicConfig(level=logging.DEBUG, format='%(relativeCreated)6d %(threadName)s %(message)s') + info = {'stop': False} + thread = threading.Thread(target=worker, args=(info,)) + thread.start() + while True: + try: + logging.debug('Hello from main') + time.sleep(0.75) + except KeyboardInterrupt: + info['stop'] = True + break + thread.join() + + if __name__ == '__main__': + main() + +When run, the script should print something like the following:: + + 0 Thread-1 Hi from myfunc + 3 MainThread Hello from main + 505 Thread-1 Hi from myfunc + 755 MainThread Hello from main + 1007 Thread-1 Hi from myfunc + 1507 MainThread Hello from main + 1508 Thread-1 Hi from myfunc + 2010 Thread-1 Hi from myfunc + 2258 MainThread Hello from main + 2512 Thread-1 Hi from myfunc + 3009 MainThread Hello from main + 3013 Thread-1 Hi from myfunc + 3515 Thread-1 Hi from myfunc + 3761 MainThread Hello from main + 4017 Thread-1 Hi from myfunc + 4513 MainThread Hello from main + 4518 Thread-1 Hi from myfunc + +This shows the logging output interspersed as one might expect. This approach +works for more threads than shown here, of course. + Multiple handlers and formatters -------------------------------- -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Feb 20 15:59:41 2016 From: python-checkins at python.org (brett.cannon) Date: Sat, 20 Feb 2016 20:59:41 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Merge_for_issue_=2326367?= Message-ID: <20160220205941.1975.75355@psf.io> https://hg.python.org/cpython/rev/8f72bf88f471 changeset: 100278:8f72bf88f471 parent: 100276:9955fd3869b6 parent: 100277:e523efd47418 user: Brett Cannon date: Sat Feb 20 12:59:36 2016 -0800 summary: Merge for issue #26367 files: Lib/importlib/_bootstrap.py | 5 +- Lib/test/test_importlib/import_/test_relative_imports.py | 5 + Misc/NEWS | 3 + Python/importlib.h | 791 +++++---- 4 files changed, 410 insertions(+), 394 deletions(-) diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -922,9 +922,12 @@ raise TypeError('module name must be str, not {}'.format(type(name))) if level < 0: raise ValueError('level must be >= 0') - if package: + if level > 0: if not isinstance(package, str): raise TypeError('__package__ not set to a string') + elif not package: + raise ImportError('attempted relative import with no known parent ' + 'package') elif package not in sys.modules: msg = ('Parent module {!r} not loaded, cannot perform relative ' 'import') diff --git a/Lib/test/test_importlib/import_/test_relative_imports.py b/Lib/test/test_importlib/import_/test_relative_imports.py --- a/Lib/test/test_importlib/import_/test_relative_imports.py +++ b/Lib/test/test_importlib/import_/test_relative_imports.py @@ -218,6 +218,11 @@ self.__import__('a', {'__package__': '', '__spec__': None}, level=1) + def test_relative_import_no_package_exists_absolute(self): + with self.assertRaises(ImportError): + self.__import__('sys', {'__package__': '', '__spec__': None}, + level=1) + (Frozen_RelativeImports, Source_RelativeImports diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -185,6 +185,9 @@ Library ------- +- Issue #26367: importlib.__init__() raises ImportError like + builtins.__import__() when ``level`` is specified but without an accompanying + package specified. - Issue #26309: In the "socketserver" module, shut down the request (closing the connected socket) when verify_request() returns false. Patch by Aviv diff --git a/Python/importlib.h b/Python/importlib.h --- a/Python/importlib.h +++ b/Python/importlib.h [stripped] -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Feb 20 15:59:42 2016 From: python-checkins at python.org (brett.cannon) Date: Sat, 20 Feb 2016 20:59:42 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2MzY3?= =?utf-8?q?=3A_Have_importlib=2E=5F=5Finit=5F=5F=28=29_raise_RuntimeError_?= =?utf-8?q?when?= Message-ID: <20160220205941.1501.42678@psf.io> https://hg.python.org/cpython/rev/e523efd47418 changeset: 100277:e523efd47418 branch: 3.5 parent: 100275:f82fa44da266 user: Brett Cannon date: Sat Feb 20 12:52:06 2016 -0800 summary: Issue #26367: Have importlib.__init__() raise RuntimeError when 'level' is specified but no __package__. This brings the function inline with builtins.__import__(). Thanks to Manuel Jacob for the patch. files: Lib/importlib/_bootstrap.py | 2 +- Lib/test/test_importlib/import_/test_relative_imports.py | 5 + Misc/NEWS | 4 + Python/importlib.h | 741 +++++---- 4 files changed, 381 insertions(+), 371 deletions(-) diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -922,7 +922,7 @@ raise TypeError('module name must be str, not {}'.format(type(name))) if level < 0: raise ValueError('level must be >= 0') - if package: + if level > 0: if not isinstance(package, str): raise TypeError('__package__ not set to a string') elif package not in sys.modules: diff --git a/Lib/test/test_importlib/import_/test_relative_imports.py b/Lib/test/test_importlib/import_/test_relative_imports.py --- a/Lib/test/test_importlib/import_/test_relative_imports.py +++ b/Lib/test/test_importlib/import_/test_relative_imports.py @@ -207,6 +207,11 @@ with self.assertRaises(KeyError): self.__import__('sys', level=1) + def test_relative_import_no_package_exists_absolute(self): + with self.assertRaises(SystemError): + self.__import__('sys', {'__package__': '', '__spec__': None}, + level=1) + (Frozen_RelativeImports, Source_RelativeImports diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -76,6 +76,10 @@ Library ------- +- Issue #26367: importlib.__init__() raises RuntimeError like + builtins.__import__() when ``level`` is specified but without an accompanying + package specified. + - Issue #26309: In the "socketserver" module, shut down the request (closing the connected socket) when verify_request() returns false. Patch by Aviv Palivoda. diff --git a/Python/importlib.h b/Python/importlib.h --- a/Python/importlib.h +++ b/Python/importlib.h [stripped] -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Feb 20 21:37:10 2016 From: python-checkins at python.org (brett.cannon) Date: Sun, 21 Feb 2016 02:37:10 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2MTg2?= =?utf-8?q?=3A_Remove_an_invalid_type_check_in?= Message-ID: <20160221023710.1987.98991@psf.io> https://hg.python.org/cpython/rev/9f1e680896ef changeset: 100279:9f1e680896ef branch: 3.5 parent: 100277:e523efd47418 user: Brett Cannon date: Sat Feb 20 18:35:41 2016 -0800 summary: Issue #26186: Remove an invalid type check in importlib.util.LazyLoader. The class was checking its argument as to whether its implementation of create_module() came directly from importlib.abc.Loader. The problem is that the classes coming from imoprtlib.machinery do not directly inherit from the ABC as they come from _frozen_importlib. Because the documentation has always said that create_module() was ignored, the check has simply been removed. files: Lib/importlib/abc.py | 1 - Lib/importlib/util.py | 5 ----- Lib/test/test_importlib/test_lazy.py | 1 + Misc/NEWS | 2 ++ 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Lib/importlib/abc.py b/Lib/importlib/abc.py --- a/Lib/importlib/abc.py +++ b/Lib/importlib/abc.py @@ -4,7 +4,6 @@ from . import machinery try: import _frozen_importlib -# import _frozen_importlib_external except ImportError as exc: if exc.name != '_frozen_importlib': raise diff --git a/Lib/importlib/util.py b/Lib/importlib/util.py --- a/Lib/importlib/util.py +++ b/Lib/importlib/util.py @@ -263,11 +263,6 @@ def __check_eager_loader(loader): if not hasattr(loader, 'exec_module'): raise TypeError('loader must define exec_module()') - elif hasattr(loader.__class__, 'create_module'): - if abc.Loader.create_module != loader.__class__.create_module: - # Only care if create_module() is overridden in a subclass of - # importlib.abc.Loader. - raise TypeError('loader cannot define create_module()') @classmethod def factory(cls, loader): diff --git a/Lib/test/test_importlib/test_lazy.py b/Lib/test/test_importlib/test_lazy.py --- a/Lib/test/test_importlib/test_lazy.py +++ b/Lib/test/test_importlib/test_lazy.py @@ -54,6 +54,7 @@ def test_init(self): with self.assertRaises(TypeError): + # Classes that dono't define exec_module() trigger TypeError. util.LazyLoader(object) def new_module(self, source_code=None): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -76,6 +76,8 @@ Library ------- +- Issue #26186: Remove an invalid type check in importlib.util.LazyLoader. + - Issue #26367: importlib.__init__() raises RuntimeError like builtins.__import__() when ``level`` is specified but without an accompanying package specified. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Feb 20 21:37:11 2016 From: python-checkins at python.org (brett.cannon) Date: Sun, 21 Feb 2016 02:37:11 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Merge_for_issue_=2326186?= Message-ID: <20160221023710.1715.38413@psf.io> https://hg.python.org/cpython/rev/86fc6cdd65de changeset: 100280:86fc6cdd65de parent: 100278:8f72bf88f471 parent: 100279:9f1e680896ef user: Brett Cannon date: Sat Feb 20 18:37:04 2016 -0800 summary: Merge for issue #26186 files: Lib/importlib/abc.py | 1 - Lib/importlib/util.py | 5 ----- Lib/test/test_importlib/test_lazy.py | 1 + Misc/NEWS | 3 +++ 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Lib/importlib/abc.py b/Lib/importlib/abc.py --- a/Lib/importlib/abc.py +++ b/Lib/importlib/abc.py @@ -4,7 +4,6 @@ from . import machinery try: import _frozen_importlib -# import _frozen_importlib_external except ImportError as exc: if exc.name != '_frozen_importlib': raise diff --git a/Lib/importlib/util.py b/Lib/importlib/util.py --- a/Lib/importlib/util.py +++ b/Lib/importlib/util.py @@ -263,11 +263,6 @@ def __check_eager_loader(loader): if not hasattr(loader, 'exec_module'): raise TypeError('loader must define exec_module()') - elif hasattr(loader.__class__, 'create_module'): - if abc.Loader.create_module != loader.__class__.create_module: - # Only care if create_module() is overridden in a subclass of - # importlib.abc.Loader. - raise TypeError('loader cannot define create_module()') @classmethod def factory(cls, loader): diff --git a/Lib/test/test_importlib/test_lazy.py b/Lib/test/test_importlib/test_lazy.py --- a/Lib/test/test_importlib/test_lazy.py +++ b/Lib/test/test_importlib/test_lazy.py @@ -54,6 +54,7 @@ def test_init(self): with self.assertRaises(TypeError): + # Classes that dono't define exec_module() trigger TypeError. util.LazyLoader(object) def new_module(self, source_code=None): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -185,6 +185,9 @@ Library ------- + +Issue #26186: Remove an invalid type check in importlib.util.LazyLoader. + - Issue #26367: importlib.__init__() raises ImportError like builtins.__import__() when ``level`` is specified but without an accompanying package specified. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Feb 20 21:40:24 2016 From: python-checkins at python.org (brett.cannon) Date: Sun, 21 Feb 2016 02:40:24 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_List_what_clas?= =?utf-8?q?ses_from_importlib=2Emachinery_don=27t_work_with?= Message-ID: <20160221024023.1500.84913@psf.io> https://hg.python.org/cpython/rev/43c6d087035d changeset: 100281:43c6d087035d branch: 3.5 parent: 100279:9f1e680896ef user: Brett Cannon date: Sat Feb 20 18:40:02 2016 -0800 summary: List what classes from importlib.machinery don't work with importlib.util.LazyLoader files: Doc/library/importlib.rst | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst --- a/Doc/library/importlib.rst +++ b/Doc/library/importlib.rst @@ -1273,7 +1273,8 @@ :meth:`~importlib.abc.Loader.exec_module` as control over what module type is used for the module is required. For those same reasons, the loader's :meth:`~importlib.abc.Loader.create_module` method will be ignored (i.e., the - loader's method should only return ``None``). Finally, + loader's method should only return ``None``; this excludes + :class:`BuiltinImporter` and :class:`ExtensionFileLoader`). Finally, modules which substitute the object placed into :attr:`sys.modules` will not work as there is no way to properly replace the module references throughout the interpreter safely; :exc:`ValueError` is raised if such a -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Feb 20 21:40:24 2016 From: python-checkins at python.org (brett.cannon) Date: Sun, 21 Feb 2016 02:40:24 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?b?KTogTWVyZ2Ugdy8gMy41?= Message-ID: <20160221024023.1519.28385@psf.io> https://hg.python.org/cpython/rev/cad169f10d99 changeset: 100282:cad169f10d99 parent: 100280:86fc6cdd65de parent: 100281:43c6d087035d user: Brett Cannon date: Sat Feb 20 18:40:18 2016 -0800 summary: Merge w/ 3.5 files: Doc/library/importlib.rst | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst --- a/Doc/library/importlib.rst +++ b/Doc/library/importlib.rst @@ -1281,7 +1281,8 @@ :meth:`~importlib.abc.Loader.exec_module` as control over what module type is used for the module is required. For those same reasons, the loader's :meth:`~importlib.abc.Loader.create_module` method will be ignored (i.e., the - loader's method should only return ``None``). Finally, + loader's method should only return ``None``; this excludes + :class:`BuiltinImporter` and :class:`ExtensionFileLoader`). Finally, modules which substitute the object placed into :attr:`sys.modules` will not work as there is no way to properly replace the module references throughout the interpreter safely; :exc:`ValueError` is raised if such a -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Feb 20 21:46:01 2016 From: python-checkins at python.org (brett.cannon) Date: Sun, 21 Feb 2016 02:46:01 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2326397=3A_Update_a?= =?utf-8?q?n_importlib_example_to_use_util=2Emodule=5Ffrom=5Fspec=28=29?= Message-ID: <20160221024600.1545.10123@psf.io> https://hg.python.org/cpython/rev/f2a089d68297 changeset: 100283:f2a089d68297 user: Brett Cannon date: Sat Feb 20 18:45:56 2016 -0800 summary: Issue #26397: Update an importlib example to use util.module_from_spec() instead of create_module() files: Doc/library/importlib.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst --- a/Doc/library/importlib.rst +++ b/Doc/library/importlib.rst @@ -1389,7 +1389,7 @@ break else: raise ImportError(f'No module named {absolute_name!r}') - module = spec.loader.create_module(spec) + module = util.module_from_spec(spec) spec.loader.exec_module(module) sys.modules[absolute_name] = module if path is not None: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Feb 20 21:47:14 2016 From: python-checkins at python.org (brett.cannon) Date: Sun, 21 Feb 2016 02:47:14 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Fix_a_name_in_an_example?= Message-ID: <20160221024714.1630.40899@psf.io> https://hg.python.org/cpython/rev/2d746fb08d0d changeset: 100284:2d746fb08d0d user: Brett Cannon date: Sat Feb 20 18:47:09 2016 -0800 summary: Fix a name in an example files: Doc/library/importlib.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst --- a/Doc/library/importlib.rst +++ b/Doc/library/importlib.rst @@ -1389,7 +1389,7 @@ break else: raise ImportError(f'No module named {absolute_name!r}') - module = util.module_from_spec(spec) + module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) sys.modules[absolute_name] = module if path is not None: -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Sun Feb 21 04:47:44 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Sun, 21 Feb 2016 09:47:44 +0000 Subject: [Python-checkins] Daily reference leaks (2d746fb08d0d): sum=5 Message-ID: <20160221094744.1963.90814@psf.io> results for 2d746fb08d0d on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 test_smtplib leaked [1, 0, 0] references, sum=1 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogXtiiqg', '--timeout', '7200'] From python-checkins at python.org Sun Feb 21 06:01:40 2016 From: python-checkins at python.org (martin.panter) Date: Sun, 21 Feb 2016 11:01:40 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2323430=3A_Stop_soc?= =?utf-8?q?ketserver_from_catching_SystemExit_etc_from_handlers?= Message-ID: <20160221110140.2163.11220@psf.io> https://hg.python.org/cpython/rev/d500d1a9615f changeset: 100285:d500d1a9615f user: Martin Panter date: Sun Feb 21 08:49:56 2016 +0000 summary: Issue #23430: Stop socketserver from catching SystemExit etc from handlers Also make handle_error() consistently output to stderr, and fix the documentation. files: Doc/library/socketserver.rst | 6 +- Doc/whatsnew/3.6.rst | 11 ++- Lib/socketserver.py | 31 ++++--- Lib/test/test_socketserver.py | 92 +++++++++++++++++++++++ Misc/NEWS | 6 + 5 files changed, 131 insertions(+), 15 deletions(-) diff --git a/Doc/library/socketserver.rst b/Doc/library/socketserver.rst --- a/Doc/library/socketserver.rst +++ b/Doc/library/socketserver.rst @@ -304,7 +304,11 @@ This function is called if the :meth:`~BaseRequestHandler.handle` method of a :attr:`RequestHandlerClass` instance raises an exception. The default action is to print the traceback to - standard output and continue handling further requests. + standard error and continue handling further requests. + + .. versionchanged:: 3.6 + Now only called for exceptions derived from the :exc:`Exception` + class. .. method:: handle_timeout() diff --git a/Doc/whatsnew/3.6.rst b/Doc/whatsnew/3.6.rst --- a/Doc/whatsnew/3.6.rst +++ b/Doc/whatsnew/3.6.rst @@ -334,7 +334,16 @@ * When a relative import is performed and no parent package is known, then :exc:`ImportError` will be raised. Previously, :exc:`SystemError` could be - raised. (Contribute by Brett Cannon in :issue:`18018`.) + raised. (Contributed by Brett Cannon in :issue:`18018`.) + +* Servers based on the :mod:`socketserver` module, including those + defined in :mod:`http.server`, :mod:`xmlrpc.server` and + :mod:`wsgiref.simple_server`, now only catch exceptions derived + from :exc:`Exception`. Therefore if a request handler raises + an exception like :exc:`SystemExit` or :exc:`KeyboardInterrupt`, + :meth:`~socketserver.BaseServer.handle_error` is no longer called, and + the exception will stop a single-threaded server. (Contributed by + Martin Panter in :issue:`23430`.) Changes in the C API diff --git a/Lib/socketserver.py b/Lib/socketserver.py --- a/Lib/socketserver.py +++ b/Lib/socketserver.py @@ -132,6 +132,7 @@ import selectors import os import errno +import sys try: import threading except ImportError: @@ -316,9 +317,12 @@ if self.verify_request(request, client_address): try: self.process_request(request, client_address) - except: + except Exception: self.handle_error(request, client_address) self.shutdown_request(request) + except: + self.shutdown_request(request) + raise else: self.shutdown_request(request) @@ -372,12 +376,12 @@ The default is to print a traceback and continue. """ - print('-'*40) - print('Exception happened during processing of request from', end=' ') - print(client_address) + print('-'*40, file=sys.stderr) + print('Exception happened during processing of request from', + client_address, file=sys.stderr) import traceback - traceback.print_exc() # XXX But this goes to stderr! - print('-'*40) + traceback.print_exc() + print('-'*40, file=sys.stderr) class TCPServer(BaseServer): @@ -601,16 +605,17 @@ else: # Child process. # This must never return, hence os._exit()! + status = 1 try: self.finish_request(request, client_address) - self.shutdown_request(request) - os._exit(0) - except: + status = 0 + except Exception: + self.handle_error(request, client_address) + finally: try: - self.handle_error(request, client_address) self.shutdown_request(request) finally: - os._exit(1) + os._exit(status) class ThreadingMixIn: @@ -628,9 +633,9 @@ """ try: self.finish_request(request, client_address) - self.shutdown_request(request) - except: + except Exception: self.handle_error(request, client_address) + finally: self.shutdown_request(request) def process_request(self, request, client_address): diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py --- a/Lib/test/test_socketserver.py +++ b/Lib/test/test_socketserver.py @@ -58,6 +58,7 @@ @contextlib.contextmanager def simple_subprocess(testcase): + """Tests that a custom child process is not waited on (Issue 1540386)""" pid = os.fork() if pid == 0: # Don't raise an exception; it would be caught by the test harness. @@ -281,6 +282,97 @@ socketserver.StreamRequestHandler) +class ErrorHandlerTest(unittest.TestCase): + """Test that the servers pass normal exceptions from the handler to + handle_error(), and that exiting exceptions like SystemExit and + KeyboardInterrupt are not passed.""" + + def tearDown(self): + test.support.unlink(test.support.TESTFN) + + def test_sync_handled(self): + BaseErrorTestServer(ValueError) + self.check_result(handled=True) + + def test_sync_not_handled(self): + with self.assertRaises(SystemExit): + BaseErrorTestServer(SystemExit) + self.check_result(handled=False) + + @unittest.skipUnless(threading, 'Threading required for this test.') + def test_threading_handled(self): + ThreadingErrorTestServer(ValueError) + self.check_result(handled=True) + + @unittest.skipUnless(threading, 'Threading required for this test.') + def test_threading_not_handled(self): + ThreadingErrorTestServer(SystemExit) + self.check_result(handled=False) + + @requires_forking + def test_forking_handled(self): + ForkingErrorTestServer(ValueError) + self.check_result(handled=True) + + @requires_forking + def test_forking_not_handled(self): + ForkingErrorTestServer(SystemExit) + self.check_result(handled=False) + + def check_result(self, handled): + with open(test.support.TESTFN) as log: + expected = 'Handler called\n' + 'Error handled\n' * handled + self.assertEqual(log.read(), expected) + + +class BaseErrorTestServer(socketserver.TCPServer): + def __init__(self, exception): + self.exception = exception + super().__init__((HOST, 0), BadHandler) + with socket.create_connection(self.server_address): + pass + try: + self.handle_request() + finally: + self.server_close() + self.wait_done() + + def handle_error(self, request, client_address): + with open(test.support.TESTFN, 'a') as log: + log.write('Error handled\n') + + def wait_done(self): + pass + + +class BadHandler(socketserver.BaseRequestHandler): + def handle(self): + with open(test.support.TESTFN, 'a') as log: + log.write('Handler called\n') + raise self.server.exception('Test error') + + +class ThreadingErrorTestServer(socketserver.ThreadingMixIn, + BaseErrorTestServer): + def __init__(self, *pos, **kw): + self.done = threading.Event() + super().__init__(*pos, **kw) + + def shutdown_request(self, *pos, **kw): + super().shutdown_request(*pos, **kw) + self.done.set() + + def wait_done(self): + self.done.wait() + + +class ForkingErrorTestServer(socketserver.ForkingMixIn, BaseErrorTestServer): + def wait_done(self): + [child] = self.active_children + os.waitpid(child, 0) + self.active_children.clear() + + class MiscTestCase(unittest.TestCase): def test_all(self): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -196,6 +196,12 @@ the connected socket) when verify_request() returns false. Patch by Aviv Palivoda. +- Issue #23430: Change the socketserver module to only catch exceptions + raised from a request handler that are derived from Exception (instead of + BaseException). Therefore SystemExit and KeyboardInterrupt no longer + trigger the handle_error() method, and will now to stop a single-threaded + server. + - Issue #25939: On Windows open the cert store readonly in ssl.enum_certificates. - Issue #25995: os.walk() no longer uses FDs proportional to the tree depth. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Feb 21 12:21:41 2016 From: python-checkins at python.org (brett.cannon) Date: Sun, 21 Feb 2016 17:21:41 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Fix_some_typos?= =?utf-8?q?_in_the_NEWS_file?= Message-ID: <20160221172140.1529.66269@psf.io> https://hg.python.org/cpython/rev/de03d744e84f changeset: 100286:de03d744e84f branch: 3.5 parent: 100281:43c6d087035d user: Brett Cannon date: Sun Feb 21 09:20:51 2016 -0800 summary: Fix some typos in the NEWS file files: Misc/NEWS | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -78,7 +78,7 @@ - Issue #26186: Remove an invalid type check in importlib.util.LazyLoader. -- Issue #26367: importlib.__init__() raises RuntimeError like +- Issue #26367: importlib.__import__() raises SystemError like builtins.__import__() when ``level`` is specified but without an accompanying package specified. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Feb 21 12:21:41 2016 From: python-checkins at python.org (brett.cannon) Date: Sun, 21 Feb 2016 17:21:41 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Fix_some_typos_in_the_NEWS_file?= Message-ID: <20160221172141.1545.11576@psf.io> https://hg.python.org/cpython/rev/f555ef42ad62 changeset: 100287:f555ef42ad62 parent: 100285:d500d1a9615f parent: 100286:de03d744e84f user: Brett Cannon date: Sun Feb 21 09:21:35 2016 -0800 summary: Fix some typos in the NEWS file files: Misc/NEWS | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -188,7 +188,7 @@ Issue #26186: Remove an invalid type check in importlib.util.LazyLoader. -- Issue #26367: importlib.__init__() raises ImportError like +- Issue #26367: importlib.__import__() raises ImportError like builtins.__import__() when ``level`` is specified but without an accompanying package specified. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Feb 21 15:00:20 2016 From: python-checkins at python.org (berker.peksag) Date: Sun, 21 Feb 2016 20:00:20 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2NDAx?= =?utf-8?q?=3A_Fix_compile=28=29_documentation?= Message-ID: <20160221200020.1973.95874@psf.io> https://hg.python.org/cpython/rev/0cfac9efd895 changeset: 100288:0cfac9efd895 branch: 3.5 parent: 100286:de03d744e84f user: Berker Peksag date: Sun Feb 21 22:00:12 2016 +0200 summary: Issue #26401: Fix compile() documentation After 25032ec29315, compile() will raise a ValueError if source contains null bytes. Patch by SilentGhost. files: Doc/library/functions.rst | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -230,7 +230,7 @@ or ``2`` (docstrings are removed too). This function raises :exc:`SyntaxError` if the compiled source is invalid, - and :exc:`TypeError` if the source contains null bytes. + and :exc:`ValueError` if the source contains null bytes. If you want to parse Python code into its AST representation, see :func:`ast.parse`. @@ -246,6 +246,10 @@ Allowed use of Windows and Mac newlines. Also input in ``'exec'`` mode does not have to end in a newline anymore. Added the *optimize* parameter. + .. versionchanged:: 3.5 + Previously, :exc:`TypeError` was raised when null bytes were encountered + in *source*. + .. class:: complex([real[, imag]]) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Feb 21 15:00:20 2016 From: python-checkins at python.org (berker.peksag) Date: Sun, 21 Feb 2016 20:00:20 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326401=3A_Fix_compile=28=29_documentation?= Message-ID: <20160221200020.1981.51572@psf.io> https://hg.python.org/cpython/rev/45cf82f424ce changeset: 100289:45cf82f424ce parent: 100287:f555ef42ad62 parent: 100288:0cfac9efd895 user: Berker Peksag date: Sun Feb 21 22:00:29 2016 +0200 summary: Issue #26401: Fix compile() documentation After 25032ec29315, compile() will raise a ValueError if source contains null bytes. Patch by SilentGhost. files: Doc/library/functions.rst | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -230,7 +230,7 @@ or ``2`` (docstrings are removed too). This function raises :exc:`SyntaxError` if the compiled source is invalid, - and :exc:`TypeError` if the source contains null bytes. + and :exc:`ValueError` if the source contains null bytes. If you want to parse Python code into its AST representation, see :func:`ast.parse`. @@ -246,6 +246,10 @@ Allowed use of Windows and Mac newlines. Also input in ``'exec'`` mode does not have to end in a newline anymore. Added the *optimize* parameter. + .. versionchanged:: 3.5 + Previously, :exc:`TypeError` was raised when null bytes were encountered + in *source*. + .. class:: complex([real[, imag]]) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 22 04:05:29 2016 From: python-checkins at python.org (martin.panter) Date: Mon, 22 Feb 2016 09:05:29 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Fix_errors_in_?= =?utf-8?q?XML-RPC_client_example_code?= Message-ID: <20160222090529.1955.33944@psf.io> https://hg.python.org/cpython/rev/cf842a8ccb77 changeset: 100290:cf842a8ccb77 branch: 3.5 parent: 100288:0cfac9efd895 user: Martin Panter date: Mon Feb 22 09:04:22 2016 +0000 summary: Fix errors in XML-RPC client example code * http.client.HTTP (does not exist in Python 3) ? HTTPConnection * Server (deprecated) ? ServerProxy * Transport.send_request() grew a new ?debug? parameter in Python 3 (revision a528f7f8f97a) files: Doc/library/xmlrpc.client.rst | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/library/xmlrpc.client.rst b/Doc/library/xmlrpc.client.rst --- a/Doc/library/xmlrpc.client.rst +++ b/Doc/library/xmlrpc.client.rst @@ -541,7 +541,7 @@ except Error as v: print("ERROR", v) -To access an XML-RPC server through a proxy, you need to define a custom +To access an XML-RPC server through a HTTP proxy, you need to define a custom transport. The following example shows how: .. Example taken from http://lowlife.jp/nobonobo/wiki/xmlrpcwithproxy.html @@ -555,16 +555,16 @@ self.proxy = proxy def make_connection(self, host): self.realhost = host - h = http.client.HTTP(self.proxy) + h = http.client.HTTPConnection(self.proxy) return h - def send_request(self, connection, handler, request_body): + def send_request(self, connection, handler, request_body, debug): connection.putrequest("POST", 'http://%s%s' % (self.realhost, handler)) def send_host(self, connection, host): connection.putheader('Host', self.realhost) p = ProxiedTransport() p.set_proxy('proxy-server:8080') - server = xmlrpc.client.Server('http://time.xmlrpc.com/RPC2', transport=p) + server = xmlrpc.client.ServerProxy('http://time.xmlrpc.com/RPC2', transport=p) print(server.currentTime.getCurrentTime()) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 22 04:05:29 2016 From: python-checkins at python.org (martin.panter) Date: Mon, 22 Feb 2016 09:05:29 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Merge_XML-RPC_client_documentation_from_3=2E5?= Message-ID: <20160222090529.1918.8789@psf.io> https://hg.python.org/cpython/rev/c2b594cecdcc changeset: 100291:c2b594cecdcc parent: 100289:45cf82f424ce parent: 100290:cf842a8ccb77 user: Martin Panter date: Mon Feb 22 09:05:19 2016 +0000 summary: Merge XML-RPC client documentation from 3.5 files: Doc/library/xmlrpc.client.rst | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/library/xmlrpc.client.rst b/Doc/library/xmlrpc.client.rst --- a/Doc/library/xmlrpc.client.rst +++ b/Doc/library/xmlrpc.client.rst @@ -541,7 +541,7 @@ except Error as v: print("ERROR", v) -To access an XML-RPC server through a proxy, you need to define a custom +To access an XML-RPC server through a HTTP proxy, you need to define a custom transport. The following example shows how: .. Example taken from http://lowlife.jp/nobonobo/wiki/xmlrpcwithproxy.html @@ -555,16 +555,16 @@ self.proxy = proxy def make_connection(self, host): self.realhost = host - h = http.client.HTTP(self.proxy) + h = http.client.HTTPConnection(self.proxy) return h - def send_request(self, connection, handler, request_body): + def send_request(self, connection, handler, request_body, debug): connection.putrequest("POST", 'http://%s%s' % (self.realhost, handler)) def send_host(self, connection, host): connection.putheader('Host', self.realhost) p = ProxiedTransport() p.set_proxy('proxy-server:8080') - server = xmlrpc.client.Server('http://time.xmlrpc.com/RPC2', transport=p) + server = xmlrpc.client.ServerProxy('http://time.xmlrpc.com/RPC2', transport=p) print(server.currentTime.getCurrentTime()) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 22 04:16:31 2016 From: python-checkins at python.org (martin.panter) Date: Mon, 22 Feb 2016 09:16:31 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Fix_errors_in_?= =?utf-8?q?XML-RPC_client_example_code?= Message-ID: <20160222091631.1982.19649@psf.io> https://hg.python.org/cpython/rev/39b6fad0e7bf changeset: 100292:39b6fad0e7bf branch: 2.7 parent: 100274:ada8023878d0 user: Martin Panter date: Mon Feb 22 09:10:54 2016 +0000 summary: Fix errors in XML-RPC client example code * httplib.HTTP (deprecated and does not work) ? HTTPConnection * Server (deprecated) ? ServerProxy files: Doc/library/xmlrpclib.rst | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/library/xmlrpclib.rst b/Doc/library/xmlrpclib.rst --- a/Doc/library/xmlrpclib.rst +++ b/Doc/library/xmlrpclib.rst @@ -564,7 +564,7 @@ except Error as v: print "ERROR", v -To access an XML-RPC server through a proxy, you need to define a custom +To access an XML-RPC server through a HTTP proxy, you need to define a custom transport. The following example shows how: .. Example taken from http://lowlife.jp/nobonobo/wiki/xmlrpcwithproxy.html @@ -578,7 +578,7 @@ self.proxy = proxy def make_connection(self, host): self.realhost = host - h = httplib.HTTP(self.proxy) + h = httplib.HTTPConnection(self.proxy) return h def send_request(self, connection, handler, request_body): connection.putrequest("POST", 'http://%s%s' % (self.realhost, handler)) @@ -587,7 +587,7 @@ p = ProxiedTransport() p.set_proxy('proxy-server:8080') - server = xmlrpclib.Server('http://time.xmlrpc.com/RPC2', transport=p) + server = xmlrpclib.ServerProxy('http://time.xmlrpc.com/RPC2', transport=p) print server.currentTime.getCurrentTime() -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Mon Feb 22 04:46:38 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Mon, 22 Feb 2016 09:46:38 +0000 Subject: [Python-checkins] Daily reference leaks (45cf82f424ce): sum=7 Message-ID: <20160222094630.1717.39674@psf.io> results for 45cf82f424ce on branch "default" -------------------------------------------- test_asyncio leaked [3, 0, 0] memory blocks, sum=3 test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogPJvJdr', '--timeout', '7200'] From python-checkins at python.org Mon Feb 22 05:12:10 2016 From: python-checkins at python.org (martin.panter) Date: Mon, 22 Feb 2016 10:12:10 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326261=3A_Merge_NamedTemporaryFile_docs_from_3?= =?utf-8?q?=2E5?= Message-ID: <20160222101210.1961.66743@psf.io> https://hg.python.org/cpython/rev/837bae8c8ae7 changeset: 100294:837bae8c8ae7 parent: 100291:c2b594cecdcc parent: 100293:f1982e1426ce user: Martin Panter date: Mon Feb 22 10:10:55 2016 +0000 summary: Issue #26261: Merge NamedTemporaryFile docs from 3.5 files: Doc/library/tempfile.rst | 3 ++- Lib/tempfile.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Doc/library/tempfile.rst b/Doc/library/tempfile.rst --- a/Doc/library/tempfile.rst +++ b/Doc/library/tempfile.rst @@ -74,7 +74,8 @@ This function operates exactly as :func:`TemporaryFile` does, except that the file is guaranteed to have a visible name in the file system (on Unix, the directory entry is not unlinked). That name can be retrieved - from the :attr:`name` attribute of the file object. Whether the name can be + from the :attr:`name` attribute of the returned + file-like object. Whether the name can be used to open the file a second time, while the named temporary file is still open, varies across platforms (it can be so used on Unix; it cannot on Windows NT or later). If *delete* is true (the default), the file is diff --git a/Lib/tempfile.py b/Lib/tempfile.py --- a/Lib/tempfile.py +++ b/Lib/tempfile.py @@ -533,8 +533,8 @@ The file is created as mkstemp() would do it. Returns an object with a file-like interface; the name of the file - is accessible as file.name. The file will be automatically deleted - when it is closed unless the 'delete' argument is set to False. + is accessible as its 'name' attribute. The file will be automatically + deleted when it is closed unless the 'delete' argument is set to False. """ prefix, suffix, dir, output_type = _sanitize_params(prefix, suffix, dir) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 22 05:12:12 2016 From: python-checkins at python.org (martin.panter) Date: Mon, 22 Feb 2016 10:12:12 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2MjYx?= =?utf-8?q?=3A_Clarify_NamedTemporaryFile_name_attribute_vs_file=2Ename?= Message-ID: <20160222101210.1701.62504@psf.io> https://hg.python.org/cpython/rev/f1982e1426ce changeset: 100293:f1982e1426ce branch: 3.5 parent: 100290:cf842a8ccb77 user: Martin Panter date: Mon Feb 22 10:10:00 2016 +0000 summary: Issue #26261: Clarify NamedTemporaryFile name attribute vs file.name files: Doc/library/tempfile.rst | 3 ++- Lib/tempfile.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Doc/library/tempfile.rst b/Doc/library/tempfile.rst --- a/Doc/library/tempfile.rst +++ b/Doc/library/tempfile.rst @@ -74,7 +74,8 @@ This function operates exactly as :func:`TemporaryFile` does, except that the file is guaranteed to have a visible name in the file system (on Unix, the directory entry is not unlinked). That name can be retrieved - from the :attr:`name` attribute of the file object. Whether the name can be + from the :attr:`name` attribute of the returned + file-like object. Whether the name can be used to open the file a second time, while the named temporary file is still open, varies across platforms (it can be so used on Unix; it cannot on Windows NT or later). If *delete* is true (the default), the file is diff --git a/Lib/tempfile.py b/Lib/tempfile.py --- a/Lib/tempfile.py +++ b/Lib/tempfile.py @@ -533,8 +533,8 @@ The file is created as mkstemp() would do it. Returns an object with a file-like interface; the name of the file - is accessible as file.name. The file will be automatically deleted - when it is closed unless the 'delete' argument is set to False. + is accessible as its 'name' attribute. The file will be automatically + deleted when it is closed unless the 'delete' argument is set to False. """ prefix, suffix, dir, output_type = _sanitize_params(prefix, suffix, dir) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 22 05:12:30 2016 From: python-checkins at python.org (martin.panter) Date: Mon, 22 Feb 2016 10:12:30 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI2MjYx?= =?utf-8?q?=3A_Clarify_NamedTemporaryFile_name_attribute_vs_file=2Ename?= Message-ID: <20160222101227.1669.29423@psf.io> https://hg.python.org/cpython/rev/27a140558a47 changeset: 100295:27a140558a47 branch: 2.7 parent: 100292:39b6fad0e7bf user: Martin Panter date: Mon Feb 22 10:10:00 2016 +0000 summary: Issue #26261: Clarify NamedTemporaryFile name attribute vs file.name files: Doc/library/tempfile.rst | 3 ++- Lib/tempfile.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Doc/library/tempfile.rst b/Doc/library/tempfile.rst --- a/Doc/library/tempfile.rst +++ b/Doc/library/tempfile.rst @@ -64,7 +64,8 @@ This function operates exactly as :func:`TemporaryFile` does, except that the file is guaranteed to have a visible name in the file system (on Unix, the directory entry is not unlinked). That name can be retrieved - from the :attr:`name` attribute of the file object. Whether the name can be + from the :attr:`name` attribute of the returned + file-like object. Whether the name can be used to open the file a second time, while the named temporary file is still open, varies across platforms (it can be so used on Unix; it cannot on Windows NT or later). If *delete* is true (the default), the file is diff --git a/Lib/tempfile.py b/Lib/tempfile.py --- a/Lib/tempfile.py +++ b/Lib/tempfile.py @@ -455,8 +455,8 @@ The file is created as mkstemp() would do it. Returns an object with a file-like interface; the name of the file - is accessible as file.name. The file will be automatically deleted - when it is closed unless the 'delete' argument is set to False. + is accessible as its 'name' attribute. The file will be automatically + deleted when it is closed unless the 'delete' argument is set to False. """ if dir is None: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 22 05:17:25 2016 From: python-checkins at python.org (zach.ware) Date: Mon, 22 Feb 2016 10:17:25 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2MjY4?= =?utf-8?q?=3A_Update_the_prepare=5Fssl=2Epy_script?= Message-ID: <20160222101725.1973.84939@psf.io> https://hg.python.org/cpython/rev/e1187d3204e9 changeset: 100297:e1187d3204e9 branch: 3.5 parent: 100293:f1982e1426ce user: Zachary Ware date: Mon Feb 22 04:02:30 2016 -0600 summary: Issue #26268: Update the prepare_ssl.py script It can now handle OpenSSL versions 1.0.2e and greater, which don't include include files in include/. Note that sources prepared by this script no longer support the old project files for 2.7; you now have to have Perl available to use the old build_ssl.py script with sources from svn.python.org. files: Misc/NEWS | 4 + PCbuild/prepare_ssl.py | 163 +++++++++------------------- 2 files changed, 58 insertions(+), 109 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -263,6 +263,10 @@ Windows ------- +- Issue #26268: Update the prepare_ssl.py script to handle OpenSSL releases + that don't include the contents of the include directory (that is, 1.0.2e + and later). + - Issue #26071: bdist_wininst created binaries fail to start and find 32bit Python diff --git a/PCbuild/prepare_ssl.py b/PCbuild/prepare_ssl.py --- a/PCbuild/prepare_ssl.py +++ b/PCbuild/prepare_ssl.py @@ -21,11 +21,11 @@ import os import re import sys -import shutil import subprocess +from shutil import copy # Find all "foo.exe" files on the PATH. -def find_all_on_path(filename, extras = None): +def find_all_on_path(filename, extras=None): entries = os.environ["PATH"].split(os.pathsep) ret = [] for p in entries: @@ -39,6 +39,7 @@ ret.append(fname) return ret + # Find a suitable Perl installation for OpenSSL. # cygwin perl does *not* work. ActivePerl does. # Being a Perl dummy, the simplest way I can check is if the "Win32" package @@ -61,82 +62,47 @@ print("NO perl interpreters were found on this machine at all!") print(" Please install ActivePerl and ensure it appears on your path") -def create_makefile64(makefile, m32): - """Create and fix makefile for 64bit - Replace 32 with 64bit directories - """ - if not os.path.isfile(m32): - return - with open(m32) as fin: - with open(makefile, 'w') as fout: - for line in fin: - line = line.replace("=tmp32", "=tmp64") - line = line.replace("=out32", "=out64") - line = line.replace("=inc32", "=inc64") - # force 64 bit machine - line = line.replace("MKLIB=lib", "MKLIB=lib /MACHINE:X64") - line = line.replace("LFLAGS=", "LFLAGS=/MACHINE:X64 ") - # don't link against the lib on 64bit systems - line = line.replace("bufferoverflowu.lib", "") - fout.write(line) - os.unlink(m32) - -def create_asms(makefile): +def create_asms(makefile, tmp_d): #create a custom makefile out of the provided one asm_makefile = os.path.splitext(makefile)[0] + '.asm.mak' - with open(makefile) as fin: - with open(asm_makefile, 'w') as fout: - for line in fin: - # Keep everything up to the install target (it's convenient) - if line.startswith('install: all'): - break - else: + with open(makefile) as fin, open(asm_makefile, 'w') as fout: + for line in fin: + # Keep everything up to the install target (it's convenient) + if line.startswith('install: all'): + break + fout.write(line) + asms = [] + for line in fin: + if '.asm' in line and line.strip().endswith('.pl'): + asms.append(line.split(':')[0]) + while line.strip(): fout.write(line) - asms = [] - for line in fin: - if '.asm' in line and line.strip().endswith('.pl'): - asms.append(line.split(':')[0]) - while line.strip(): - fout.write(line) - line = next(fin) - fout.write('\n') + line = next(fin) + fout.write('\n') - fout.write('asms: $(TMP_D) ') - fout.write(' '.join(asms)) - fout.write('\n') + fout.write('asms: $(TMP_D) ') + fout.write(' '.join(asms)) + fout.write('\n') + os.system('nmake /f {} PERL=perl TMP_D={} asms'.format(asm_makefile, tmp_d)) - os.system('nmake /f {} PERL=perl asms'.format(asm_makefile)) - os.unlink(asm_makefile) - - -def fix_makefile(makefile): - """Fix some stuff in all makefiles - """ - if not os.path.isfile(makefile): - return +def copy_includes(makefile, suffix): + dir = 'include'+suffix+'\\openssl' + os.makedirs(dir, exist_ok=True) copy_if_different = r'$(PERL) $(SRC_D)\util\copy-if-different.pl' with open(makefile) as fin: - lines = fin.readlines() - with open(makefile, 'w') as fout: - for line in lines: - if line.startswith("PERL="): - continue - if line.startswith("CP="): - line = "CP=copy\n" - if line.startswith("MKDIR="): - line = "MKDIR=mkdir\n" - if line.startswith("CFLAG="): - line = line.strip() - for algo in ("RC5", "MDC2", "IDEA"): - noalgo = " -DOPENSSL_NO_%s" % algo - if noalgo not in line: - line = line + noalgo - line = line + '\n' + for line in fin: if copy_if_different in line: - line = line.replace(copy_if_different, 'copy /Y') - fout.write(line) + perl, script, src, dest = line.split() + if not '$(INCO_D)' in dest: + continue + # We're in the root of the source tree + src = src.replace('$(SRC_D)', '.').strip('"') + dest = dest.strip('"').replace('$(INCO_D)', dir) + print('copying', src, 'to', dest) + copy(src, dest) + def run_configure(configure, do_script): print("perl Configure "+configure+" no-idea no-mdc2") @@ -144,61 +110,37 @@ print(do_script) os.system(do_script) -def cmp(f1, f2): - bufsize = 1024 * 8 - with open(f1, 'rb') as fp1, open(f2, 'rb') as fp2: - while True: - b1 = fp1.read(bufsize) - b2 = fp2.read(bufsize) - if b1 != b2: - return False - if not b1: - return True - -def copy(src, dst): - if os.path.isfile(dst) and cmp(src, dst): - return - shutil.copy(src, dst) def prep(arch): + makefile_template = "ms\\nt{}.mak" + generated_makefile = makefile_template.format('') if arch == "x86": configure = "VC-WIN32" do_script = "ms\\do_nasm" - makefile="ms\\nt.mak" - m32 = makefile - dirsuffix = "32" + suffix = "32" elif arch == "amd64": configure = "VC-WIN64A" do_script = "ms\\do_win64a" - makefile = "ms\\nt64.mak" - m32 = makefile.replace('64', '') - dirsuffix = "64" + suffix = "64" #os.environ["VSEXTCOMP_USECL"] = "MS_OPTERON" else: raise ValueError('Unrecognized platform: %s' % arch) - # rebuild makefile when we do the role over from 32 to 64 build - if arch == "amd64" and os.path.isfile(m32) and not os.path.isfile(makefile): - os.unlink(m32) - - # If the ssl makefiles do not exist, we invoke Perl to generate them. - # Due to a bug in this script, the makefile sometimes ended up empty - # Force a regeneration if it is. - if not os.path.isfile(makefile) or os.path.getsize(makefile)==0: - print("Creating the makefiles...") - sys.stdout.flush() - run_configure(configure, do_script) - - if arch == "amd64": - create_makefile64(makefile, m32) - fix_makefile(makefile) - copy(r"crypto\buildinf.h", r"crypto\buildinf_%s.h" % arch) - copy(r"crypto\opensslconf.h", r"crypto\opensslconf_%s.h" % arch) - else: - print(makefile, 'already exists!') + print("Creating the makefiles...") + sys.stdout.flush() + # run configure, copy includes, create asms + run_configure(configure, do_script) + makefile = makefile_template.format(suffix) + try: + os.unlink(makefile) + except FileNotFoundError: + pass + os.rename(generated_makefile, makefile) + copy_includes(makefile, suffix) print('creating asms...') - create_asms(makefile) + create_asms(makefile, 'tmp'+suffix) + def main(): if len(sys.argv) == 1: @@ -229,6 +171,9 @@ print("Found a working perl at '%s'" % (perl,)) else: sys.exit(1) + if not find_all_on_path('nmake.exe'): + print('Could not find nmake.exe, try running env.bat') + sys.exit(1) sys.stdout.flush() # Put our working Perl at the front of our path -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 22 05:17:26 2016 From: python-checkins at python.org (zach.ware) Date: Mon, 22 Feb 2016 10:17:26 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2MjY4?= =?utf-8?q?=3A_Update_Windows_builds_to_use_OpenSSL_1=2E0=2E2f?= Message-ID: <20160222101725.1695.74233@psf.io> https://hg.python.org/cpython/rev/82afdf5a8c7b changeset: 100298:82afdf5a8c7b branch: 3.5 user: Zachary Ware date: Mon Feb 22 04:08:51 2016 -0600 summary: Issue #26268: Update Windows builds to use OpenSSL 1.0.2f files: Misc/NEWS | 3 ++- PCbuild/_hashlib.vcxproj | 4 ++-- PCbuild/_ssl.vcxproj | 4 ++-- PCbuild/get_externals.bat | 2 +- PCbuild/openssl.props | 7 +++---- PCbuild/python.props | 4 +++- PCbuild/readme.txt | 2 +- 7 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -258,7 +258,8 @@ - Issue #25696: Fix installation of Python on UNIX with make -j9. -- Issue #26268: Update OS X 10.5 installer to use OpenSSL 1.0.2f. +- Issue #26268: Update OS X 10.5 installer and Windows builds to use + OpenSSL 1.0.2f. Windows ------- diff --git a/PCbuild/_hashlib.vcxproj b/PCbuild/_hashlib.vcxproj --- a/PCbuild/_hashlib.vcxproj +++ b/PCbuild/_hashlib.vcxproj @@ -61,7 +61,7 @@ - $(opensslDir)include;%(AdditionalIncludeDirectories) + $(opensslIncludeDir);%(AdditionalIncludeDirectories) ws2_32.lib;$(OutDir)libeay$(PyDebugExt).lib;$(OutDir)ssleay$(PyDebugExt).lib;%(AdditionalDependencies) @@ -87,4 +87,4 @@ - \ No newline at end of file + diff --git a/PCbuild/_ssl.vcxproj b/PCbuild/_ssl.vcxproj --- a/PCbuild/_ssl.vcxproj +++ b/PCbuild/_ssl.vcxproj @@ -61,7 +61,7 @@ - $(opensslDir)include;%(AdditionalIncludeDirectories) + $(opensslIncludeDir);%(AdditionalIncludeDirectories) ws2_32.lib;crypt32.lib;$(OutDir)libeay$(PyDebugExt).lib;$(OutDir)ssleay$(PyDebugExt).lib;%(AdditionalDependencies) @@ -91,4 +91,4 @@ - \ No newline at end of file + diff --git a/PCbuild/get_externals.bat b/PCbuild/get_externals.bat --- a/PCbuild/get_externals.bat +++ b/PCbuild/get_externals.bat @@ -54,7 +54,7 @@ set libraries= set libraries=%libraries% bzip2-1.0.6 if NOT "%IncludeSSL%"=="false" set libraries=%libraries% nasm-2.11.06 -if NOT "%IncludeSSL%"=="false" set libraries=%libraries% openssl-1.0.2d +if NOT "%IncludeSSL%"=="false" set libraries=%libraries% openssl-1.0.2f set libraries=%libraries% sqlite-3.8.11.0 if NOT "%IncludeTkinter%"=="false" set libraries=%libraries% tcl-core-8.6.4.2 if NOT "%IncludeTkinter%"=="false" set libraries=%libraries% tk-8.6.4.2 diff --git a/PCbuild/openssl.props b/PCbuild/openssl.props --- a/PCbuild/openssl.props +++ b/PCbuild/openssl.props @@ -17,9 +17,8 @@ - + - @@ -53,7 +52,7 @@ 4244;4267 - $(opensslDir);$(opensslDir)include;$(opensslDir)crypto;$(opensslDir)crypto\asn1;$(opensslDir)crypto\evp;$(opensslDir)crypto\modes + $(opensslDir);$(opensslIncludeDir);$(opensslDir)crypto;$(opensslDir)crypto\asn1;$(opensslDir)crypto\evp;$(opensslDir)crypto\modes $(_PreprocessorDefinitionList);%(PreprocessorDefinitions) @@ -74,4 +73,4 @@ - \ No newline at end of file + diff --git a/PCbuild/python.props b/PCbuild/python.props --- a/PCbuild/python.props +++ b/PCbuild/python.props @@ -41,7 +41,9 @@ $(ExternalsDir)sqlite-3.8.11.0\ $(ExternalsDir)bzip2-1.0.6\ $(ExternalsDir)xz-5.0.5\ - $(ExternalsDir)openssl-1.0.2d\ + $(ExternalsDir)openssl-1.0.2f\ + $(opensslDir)include32 + $(opensslDir)include64 $(ExternalsDir)\nasm-2.11.06\ diff --git a/PCbuild/readme.txt b/PCbuild/readme.txt --- a/PCbuild/readme.txt +++ b/PCbuild/readme.txt @@ -169,7 +169,7 @@ Homepage: http://tukaani.org/xz/ _ssl - Python wrapper for version 1.0.2d of the OpenSSL secure sockets + Python wrapper for version 1.0.2f of the OpenSSL secure sockets library, which is built by ssl.vcxproj Homepage: http://www.openssl.org/ -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 22 05:17:26 2016 From: python-checkins at python.org (zach.ware) Date: Mon, 22 Feb 2016 10:17:26 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326268=3A_Merge_with_3=2E5?= Message-ID: <20160222101725.1537.49626@psf.io> https://hg.python.org/cpython/rev/365ab6287783 changeset: 100299:365ab6287783 parent: 100294:837bae8c8ae7 parent: 100298:82afdf5a8c7b user: Zachary Ware date: Mon Feb 22 04:16:33 2016 -0600 summary: Issue #26268: Merge with 3.5 files: Misc/NEWS | 8 +- PCbuild/_hashlib.vcxproj | 4 +- PCbuild/_ssl.vcxproj | 4 +- PCbuild/get_externals.bat | 2 +- PCbuild/openssl.props | 7 +- PCbuild/prepare_ssl.py | 163 ++++++++----------------- PCbuild/python.props | 4 +- PCbuild/readme.txt | 2 +- 8 files changed, 73 insertions(+), 121 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -751,11 +751,17 @@ Previously it could fail to compile properly if the math and cmath builds were concurrent. -- Issue #26268: Update OS X 10.5 installer to use OpenSSL 1.0.2f. +- Issue #26268: Update OS X 10.5 installer and Windows builds to use + OpenSSL 1.0.2f. + Windows ------- +- Issue #26268: Update the prepare_ssl.py script to handle OpenSSL releases + that don't include the contents of the include directory (that is, 1.0.2e + and later). + - Issue #26071: bdist_wininst created binaries fail to start and find 32bit Python diff --git a/PCbuild/_hashlib.vcxproj b/PCbuild/_hashlib.vcxproj --- a/PCbuild/_hashlib.vcxproj +++ b/PCbuild/_hashlib.vcxproj @@ -61,7 +61,7 @@ - $(opensslDir)include;%(AdditionalIncludeDirectories) + $(opensslIncludeDir);%(AdditionalIncludeDirectories) ws2_32.lib;$(OutDir)libeay$(PyDebugExt).lib;$(OutDir)ssleay$(PyDebugExt).lib;%(AdditionalDependencies) @@ -87,4 +87,4 @@ - \ No newline at end of file + diff --git a/PCbuild/_ssl.vcxproj b/PCbuild/_ssl.vcxproj --- a/PCbuild/_ssl.vcxproj +++ b/PCbuild/_ssl.vcxproj @@ -61,7 +61,7 @@ - $(opensslDir)include;%(AdditionalIncludeDirectories) + $(opensslIncludeDir);%(AdditionalIncludeDirectories) ws2_32.lib;crypt32.lib;$(OutDir)libeay$(PyDebugExt).lib;$(OutDir)ssleay$(PyDebugExt).lib;%(AdditionalDependencies) @@ -91,4 +91,4 @@ - \ No newline at end of file + diff --git a/PCbuild/get_externals.bat b/PCbuild/get_externals.bat --- a/PCbuild/get_externals.bat +++ b/PCbuild/get_externals.bat @@ -54,7 +54,7 @@ set libraries= set libraries=%libraries% bzip2-1.0.6 if NOT "%IncludeSSL%"=="false" set libraries=%libraries% nasm-2.11.06 -if NOT "%IncludeSSL%"=="false" set libraries=%libraries% openssl-1.0.2d +if NOT "%IncludeSSL%"=="false" set libraries=%libraries% openssl-1.0.2f set libraries=%libraries% sqlite-3.8.11.0 if NOT "%IncludeTkinter%"=="false" set libraries=%libraries% tcl-core-8.6.4.2 if NOT "%IncludeTkinter%"=="false" set libraries=%libraries% tk-8.6.4.2 diff --git a/PCbuild/openssl.props b/PCbuild/openssl.props --- a/PCbuild/openssl.props +++ b/PCbuild/openssl.props @@ -17,9 +17,8 @@ - + - @@ -53,7 +52,7 @@ 4244;4267 - $(opensslDir);$(opensslDir)include;$(opensslDir)crypto;$(opensslDir)crypto\asn1;$(opensslDir)crypto\evp;$(opensslDir)crypto\modes + $(opensslDir);$(opensslIncludeDir);$(opensslDir)crypto;$(opensslDir)crypto\asn1;$(opensslDir)crypto\evp;$(opensslDir)crypto\modes $(_PreprocessorDefinitionList);%(PreprocessorDefinitions) @@ -74,4 +73,4 @@ - \ No newline at end of file + diff --git a/PCbuild/prepare_ssl.py b/PCbuild/prepare_ssl.py --- a/PCbuild/prepare_ssl.py +++ b/PCbuild/prepare_ssl.py @@ -21,11 +21,11 @@ import os import re import sys -import shutil import subprocess +from shutil import copy # Find all "foo.exe" files on the PATH. -def find_all_on_path(filename, extras = None): +def find_all_on_path(filename, extras=None): entries = os.environ["PATH"].split(os.pathsep) ret = [] for p in entries: @@ -39,6 +39,7 @@ ret.append(fname) return ret + # Find a suitable Perl installation for OpenSSL. # cygwin perl does *not* work. ActivePerl does. # Being a Perl dummy, the simplest way I can check is if the "Win32" package @@ -61,82 +62,47 @@ print("NO perl interpreters were found on this machine at all!") print(" Please install ActivePerl and ensure it appears on your path") -def create_makefile64(makefile, m32): - """Create and fix makefile for 64bit - Replace 32 with 64bit directories - """ - if not os.path.isfile(m32): - return - with open(m32) as fin: - with open(makefile, 'w') as fout: - for line in fin: - line = line.replace("=tmp32", "=tmp64") - line = line.replace("=out32", "=out64") - line = line.replace("=inc32", "=inc64") - # force 64 bit machine - line = line.replace("MKLIB=lib", "MKLIB=lib /MACHINE:X64") - line = line.replace("LFLAGS=", "LFLAGS=/MACHINE:X64 ") - # don't link against the lib on 64bit systems - line = line.replace("bufferoverflowu.lib", "") - fout.write(line) - os.unlink(m32) - -def create_asms(makefile): +def create_asms(makefile, tmp_d): #create a custom makefile out of the provided one asm_makefile = os.path.splitext(makefile)[0] + '.asm.mak' - with open(makefile) as fin: - with open(asm_makefile, 'w') as fout: - for line in fin: - # Keep everything up to the install target (it's convenient) - if line.startswith('install: all'): - break - else: + with open(makefile) as fin, open(asm_makefile, 'w') as fout: + for line in fin: + # Keep everything up to the install target (it's convenient) + if line.startswith('install: all'): + break + fout.write(line) + asms = [] + for line in fin: + if '.asm' in line and line.strip().endswith('.pl'): + asms.append(line.split(':')[0]) + while line.strip(): fout.write(line) - asms = [] - for line in fin: - if '.asm' in line and line.strip().endswith('.pl'): - asms.append(line.split(':')[0]) - while line.strip(): - fout.write(line) - line = next(fin) - fout.write('\n') + line = next(fin) + fout.write('\n') - fout.write('asms: $(TMP_D) ') - fout.write(' '.join(asms)) - fout.write('\n') + fout.write('asms: $(TMP_D) ') + fout.write(' '.join(asms)) + fout.write('\n') + os.system('nmake /f {} PERL=perl TMP_D={} asms'.format(asm_makefile, tmp_d)) - os.system('nmake /f {} PERL=perl asms'.format(asm_makefile)) - os.unlink(asm_makefile) - - -def fix_makefile(makefile): - """Fix some stuff in all makefiles - """ - if not os.path.isfile(makefile): - return +def copy_includes(makefile, suffix): + dir = 'include'+suffix+'\\openssl' + os.makedirs(dir, exist_ok=True) copy_if_different = r'$(PERL) $(SRC_D)\util\copy-if-different.pl' with open(makefile) as fin: - lines = fin.readlines() - with open(makefile, 'w') as fout: - for line in lines: - if line.startswith("PERL="): - continue - if line.startswith("CP="): - line = "CP=copy\n" - if line.startswith("MKDIR="): - line = "MKDIR=mkdir\n" - if line.startswith("CFLAG="): - line = line.strip() - for algo in ("RC5", "MDC2", "IDEA"): - noalgo = " -DOPENSSL_NO_%s" % algo - if noalgo not in line: - line = line + noalgo - line = line + '\n' + for line in fin: if copy_if_different in line: - line = line.replace(copy_if_different, 'copy /Y') - fout.write(line) + perl, script, src, dest = line.split() + if not '$(INCO_D)' in dest: + continue + # We're in the root of the source tree + src = src.replace('$(SRC_D)', '.').strip('"') + dest = dest.strip('"').replace('$(INCO_D)', dir) + print('copying', src, 'to', dest) + copy(src, dest) + def run_configure(configure, do_script): print("perl Configure "+configure+" no-idea no-mdc2") @@ -144,61 +110,37 @@ print(do_script) os.system(do_script) -def cmp(f1, f2): - bufsize = 1024 * 8 - with open(f1, 'rb') as fp1, open(f2, 'rb') as fp2: - while True: - b1 = fp1.read(bufsize) - b2 = fp2.read(bufsize) - if b1 != b2: - return False - if not b1: - return True - -def copy(src, dst): - if os.path.isfile(dst) and cmp(src, dst): - return - shutil.copy(src, dst) def prep(arch): + makefile_template = "ms\\nt{}.mak" + generated_makefile = makefile_template.format('') if arch == "x86": configure = "VC-WIN32" do_script = "ms\\do_nasm" - makefile="ms\\nt.mak" - m32 = makefile - dirsuffix = "32" + suffix = "32" elif arch == "amd64": configure = "VC-WIN64A" do_script = "ms\\do_win64a" - makefile = "ms\\nt64.mak" - m32 = makefile.replace('64', '') - dirsuffix = "64" + suffix = "64" #os.environ["VSEXTCOMP_USECL"] = "MS_OPTERON" else: raise ValueError('Unrecognized platform: %s' % arch) - # rebuild makefile when we do the role over from 32 to 64 build - if arch == "amd64" and os.path.isfile(m32) and not os.path.isfile(makefile): - os.unlink(m32) - - # If the ssl makefiles do not exist, we invoke Perl to generate them. - # Due to a bug in this script, the makefile sometimes ended up empty - # Force a regeneration if it is. - if not os.path.isfile(makefile) or os.path.getsize(makefile)==0: - print("Creating the makefiles...") - sys.stdout.flush() - run_configure(configure, do_script) - - if arch == "amd64": - create_makefile64(makefile, m32) - fix_makefile(makefile) - copy(r"crypto\buildinf.h", r"crypto\buildinf_%s.h" % arch) - copy(r"crypto\opensslconf.h", r"crypto\opensslconf_%s.h" % arch) - else: - print(makefile, 'already exists!') + print("Creating the makefiles...") + sys.stdout.flush() + # run configure, copy includes, create asms + run_configure(configure, do_script) + makefile = makefile_template.format(suffix) + try: + os.unlink(makefile) + except FileNotFoundError: + pass + os.rename(generated_makefile, makefile) + copy_includes(makefile, suffix) print('creating asms...') - create_asms(makefile) + create_asms(makefile, 'tmp'+suffix) + def main(): if len(sys.argv) == 1: @@ -229,6 +171,9 @@ print("Found a working perl at '%s'" % (perl,)) else: sys.exit(1) + if not find_all_on_path('nmake.exe'): + print('Could not find nmake.exe, try running env.bat') + sys.exit(1) sys.stdout.flush() # Put our working Perl at the front of our path diff --git a/PCbuild/python.props b/PCbuild/python.props --- a/PCbuild/python.props +++ b/PCbuild/python.props @@ -41,7 +41,9 @@ $(ExternalsDir)sqlite-3.8.11.0\ $(ExternalsDir)bzip2-1.0.6\ $(ExternalsDir)xz-5.0.5\ - $(ExternalsDir)openssl-1.0.2d\ + $(ExternalsDir)openssl-1.0.2f\ + $(opensslDir)include32 + $(opensslDir)include64 $(ExternalsDir)\nasm-2.11.06\ diff --git a/PCbuild/readme.txt b/PCbuild/readme.txt --- a/PCbuild/readme.txt +++ b/PCbuild/readme.txt @@ -169,7 +169,7 @@ Homepage: http://tukaani.org/xz/ _ssl - Python wrapper for version 1.0.2d of the OpenSSL secure sockets + Python wrapper for version 1.0.2f of the OpenSSL secure sockets library, which is built by ssl.vcxproj Homepage: http://www.openssl.org/ -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 22 05:17:26 2016 From: python-checkins at python.org (zach.ware) Date: Mon, 22 Feb 2016 10:17:26 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI2MjY4?= =?utf-8?q?=3A_Update_Windows_builds_to_use_OpenSSL_1=2E0=2E2f?= Message-ID: <20160222101725.1532.38719@psf.io> https://hg.python.org/cpython/rev/3be29e684ccf changeset: 100296:3be29e684ccf branch: 2.7 user: Zachary Ware date: Mon Feb 22 04:08:30 2016 -0600 summary: Issue #26268: Update Windows builds to use OpenSSL 1.0.2f files: Misc/NEWS | 2 ++ PC/VS9.0/pyproject.vsprops | 2 +- PC/VS9.0/readme.txt | 9 ++++----- PCbuild/_hashlib.vcxproj | 2 +- PCbuild/_ssl.vcxproj | 2 +- PCbuild/get_externals.bat | 2 +- PCbuild/openssl.props | 5 ++--- PCbuild/python.props | 4 +++- PCbuild/readme.txt | 2 +- 9 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -148,6 +148,8 @@ - Issue #26268: Update OS X 10.5+ 32-bit-only installer to build and link with OpenSSL 1.0.2f. +- Issue #26268: Update Windows builds to use OpenSSL 1.0.2f. + What's New in Python 2.7.11? ============================ diff --git a/PC/VS9.0/pyproject.vsprops b/PC/VS9.0/pyproject.vsprops --- a/PC/VS9.0/pyproject.vsprops +++ b/PC/VS9.0/pyproject.vsprops @@ -82,7 +82,7 @@ /> - $(opensslDir)include;%(AdditionalIncludeDirectories) + $(opensslIncludeDir);%(AdditionalIncludeDirectories) ws2_32.lib;$(OutDir)libeay$(PyDebugExt).lib;$(OutDir)ssleay$(PyDebugExt).lib;%(AdditionalDependencies) diff --git a/PCbuild/_ssl.vcxproj b/PCbuild/_ssl.vcxproj --- a/PCbuild/_ssl.vcxproj +++ b/PCbuild/_ssl.vcxproj @@ -61,7 +61,7 @@ - $(opensslDir)include;%(AdditionalIncludeDirectories) + $(opensslIncludeDir);%(AdditionalIncludeDirectories) ws2_32.lib;crypt32.lib;$(OutDir)libeay$(PyDebugExt).lib;$(OutDir)ssleay$(PyDebugExt).lib;%(AdditionalDependencies) diff --git a/PCbuild/get_externals.bat b/PCbuild/get_externals.bat --- a/PCbuild/get_externals.bat +++ b/PCbuild/get_externals.bat @@ -58,7 +58,7 @@ set libraries=%libraries% bzip2-1.0.6 if NOT "%IncludeBsddb%"=="false" set libraries=%libraries% db-4.7.25.0 if NOT "%IncludeSSL%"=="false" set libraries=%libraries% nasm-2.11.06 -if NOT "%IncludeSSL%"=="false" set libraries=%libraries% openssl-1.0.2d +if NOT "%IncludeSSL%"=="false" set libraries=%libraries% openssl-1.0.2f set libraries=%libraries% sqlite-3.6.21 if NOT "%IncludeTkinter%"=="false" set libraries=%libraries% tcl-8.5.15.0 if NOT "%IncludeTkinter%"=="false" set libraries=%libraries% tk-8.5.15.0 diff --git a/PCbuild/openssl.props b/PCbuild/openssl.props --- a/PCbuild/openssl.props +++ b/PCbuild/openssl.props @@ -15,9 +15,8 @@ - + - @@ -51,7 +50,7 @@ 4244;4267 - $(opensslDir);$(opensslDir)include;$(opensslDir)crypto;$(opensslDir)crypto\asn1;$(opensslDir)crypto\evp;$(opensslDir)crypto\modes + $(opensslDir);$(opensslIncludeDir);$(opensslDir)crypto;$(opensslDir)crypto\asn1;$(opensslDir)crypto\evp;$(opensslDir)crypto\modes $(_PreprocessorDefinitionList);%(PreprocessorDefinitions) diff --git a/PCbuild/python.props b/PCbuild/python.props --- a/PCbuild/python.props +++ b/PCbuild/python.props @@ -35,7 +35,9 @@ $(ExternalsDir)sqlite-3.6.21\ $(ExternalsDir)bzip2-1.0.6\ $(ExternalsDir)db-4.7.25.0 - $(ExternalsDir)openssl-1.0.2d\ + $(ExternalsDir)openssl-1.0.2f\ + $(opensslDir)include32 + $(opensslDir)include64 $(ExternalsDir)\nasm-2.11.06\ diff --git a/PCbuild/readme.txt b/PCbuild/readme.txt --- a/PCbuild/readme.txt +++ b/PCbuild/readme.txt @@ -183,7 +183,7 @@ Homepage: http://www.bzip.org/ _ssl - Python wrapper for version 1.0.2d of the OpenSSL secure sockets + Python wrapper for version 1.0.2f of the OpenSSL secure sockets library, which is built by ssl.vcxproj Homepage: http://www.openssl.org/ -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 22 08:53:08 2016 From: python-checkins at python.org (georg.brandl) Date: Mon, 22 Feb 2016 13:53:08 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_merge_with_3=2E5?= Message-ID: <20160222135308.1967.64647@psf.io> https://hg.python.org/cpython/rev/cbf83f55d5f3 changeset: 100301:cbf83f55d5f3 parent: 100299:365ab6287783 parent: 100300:6b502158acc8 user: Georg Brandl date: Mon Feb 22 14:53:03 2016 +0100 summary: merge with 3.5 files: Doc/tutorial/inputoutput.rst | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst --- a/Doc/tutorial/inputoutput.rst +++ b/Doc/tutorial/inputoutput.rst @@ -153,11 +153,11 @@ ``'!a'`` (apply :func:`ascii`), ``'!s'`` (apply :func:`str`) and ``'!r'`` (apply :func:`repr`) can be used to convert the value before it is formatted:: - >>> import math - >>> print('The value of PI is approximately {}.'.format(math.pi)) - The value of PI is approximately 3.14159265359. - >>> print('The value of PI is approximately {!r}.'.format(math.pi)) - The value of PI is approximately 3.141592653589793. + >>> contents = 'eels' + >>> print('My hovercraft is full of {}.'.format(contents)) + My hovercraft is full of eels. + >>> print('My hovercraft is full of {!r}.'.format(contents)) + My hovercraft is full of 'eels'. An optional ``':'`` and format specifier can follow the field name. This allows greater control over how the value is formatted. The following example -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 22 08:53:14 2016 From: python-checkins at python.org (georg.brandl) Date: Mon, 22 Feb 2016 13:53:14 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Update_example?= =?utf-8?q?=3B_str=28float=29_changed_so_there_is_difference_now=2E?= Message-ID: <20160222135308.1715.62686@psf.io> https://hg.python.org/cpython/rev/6b502158acc8 changeset: 100300:6b502158acc8 branch: 3.5 parent: 100298:82afdf5a8c7b user: Georg Brandl date: Mon Feb 22 14:52:55 2016 +0100 summary: Update example; str(float) changed so there is difference now. files: Doc/tutorial/inputoutput.rst | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst --- a/Doc/tutorial/inputoutput.rst +++ b/Doc/tutorial/inputoutput.rst @@ -152,11 +152,11 @@ ``'!a'`` (apply :func:`ascii`), ``'!s'`` (apply :func:`str`) and ``'!r'`` (apply :func:`repr`) can be used to convert the value before it is formatted:: - >>> import math - >>> print('The value of PI is approximately {}.'.format(math.pi)) - The value of PI is approximately 3.14159265359. - >>> print('The value of PI is approximately {!r}.'.format(math.pi)) - The value of PI is approximately 3.141592653589793. + >>> contents = 'eels' + >>> print('My hovercraft is full of {}.'.format(contents)) + My hovercraft is full of eels. + >>> print('My hovercraft is full of {!r}.'.format(contents)) + My hovercraft is full of 'eels'. An optional ``':'`` and format specifier can follow the field name. This allows greater control over how the value is formatted. The following example -- Repository URL: https://hg.python.org/cpython From lp_benchmark_robot at intel.com Mon Feb 22 11:15:23 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Mon, 22 Feb 2016 16:15:23 +0000 Subject: [Python-checkins] NEUTRAL Benchmark Results for Python Default 2016-02-22 Message-ID: <1be9ce9e-899b-48f6-a6f8-c58a4d362d3d@irsmsx102.ger.corp.intel.com> Results for project Python default, build date 2016-02-22 03:09:42 +0000 commit: 45cf82f424ce previous commit: c791d57c8168 revision date: 2016-02-21 20:00:29 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.23% -0.64% 10.22% 14.15% :-| pybench 0.17% -0.12% 0.36% 5.77% :-( regex_v8 2.86% -0.02% -4.74% 4.09% :-| nbody 0.15% -0.73% -1.53% 9.32% :-| json_dump_v2 0.24% 0.49% 0.43% 10.80% :-| normal_startup 0.89% 0.18% 0.55% 5.59% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/neutral-benchmark-results-for-python-default-2016-02-22/ Note: Benchmark results are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Mon Feb 22 11:16:07 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Mon, 22 Feb 2016 16:16:07 +0000 Subject: [Python-checkins] UGLY Benchmark Results for Python 2.7 2016-02-22 Message-ID: <0712bdae-60e3-4590-af10-84672439271c@irsmsx102.ger.corp.intel.com> Results for project Python 2.7, build date 2016-02-22 04:00:57 +0000 commit: ada8023878d0 previous commit: 9211b7e60c92 revision date: 2016-02-20 19:02:04 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dc from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.11% 0.09% 5.75% 4.41% :-) pybench 0.07% -0.12% 6.15% 5.11% :-( regex_v8 0.78% 0.05% -2.67% 11.33% :-( nbody 0.30% -6.37% 1.89% 9.18% :-) json_dump_v2 0.18% 1.11% 4.41% 9.82% :-( normal_startup 1.86% 0.29% -5.06% 1.52% :-) ssbench 0.17% 0.56% 2.33% -0.34% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/ugly-benchmark-results-for-python-2-7-2016-02-22/ Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Tue Feb 23 04:47:08 2016 From: python-checkins at python.org (ned.deily) Date: Tue, 23 Feb 2016 09:47:08 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI2NDE3?= =?utf-8?q?=3A_Prevent_spurious_errors_and_incorrect_defaults_when?= Message-ID: <20160223094705.1506.7330@psf.io> https://hg.python.org/cpython/rev/13826ff147e4 changeset: 100302:13826ff147e4 branch: 2.7 parent: 100296:3be29e684ccf user: Ned Deily date: Tue Feb 23 20:45:57 2016 +1100 summary: Issue #26417: Prevent spurious errors and incorrect defaults when installing IDLE 2.7 on OS X: default configuration settings are no longer installed from OS X specific copies. files: Mac/IDLE/Makefile.in | 22 ++++- Mac/IDLE/config-extensions.def | 93 ---------------------- Mac/IDLE/config-main.def | 79 ------------------ Misc/NEWS | 7 + 4 files changed, 26 insertions(+), 175 deletions(-) diff --git a/Mac/IDLE/Makefile.in b/Mac/IDLE/Makefile.in --- a/Mac/IDLE/Makefile.in +++ b/Mac/IDLE/Makefile.in @@ -7,6 +7,7 @@ LDFLAGS=@LDFLAGS@ srcdir= @srcdir@ VERSION= @VERSION@ +LIBDEST=$(prefix)/lib/python$(VERSION) UNIVERSALSDK=@UNIVERSALSDK@ builddir= ../.. PYTHONFRAMEWORK=@PYTHONFRAMEWORK@ @@ -28,13 +29,28 @@ all: IDLE.app -install: IDLE.app $(srcdir)/config-main.def $(srcdir)/config-extensions.def +install: IDLE.app test -d "$(DESTDIR)$(PYTHONAPPSDIR)" || mkdir -p "$(DESTDIR)$(PYTHONAPPSDIR)" -test -d "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app" && rm -r "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app" /bin/cp -PR IDLE.app "$(DESTDIR)$(PYTHONAPPSDIR)" touch "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app" - /bin/cp $(srcdir)/config-main.def "$(DESTDIR)$(prefix)/lib/python$(VERSION)/idlelib/config-main.def" - /bin/cp $(srcdir)/config-extensions.def "$(DESTDIR)$(prefix)/lib/python$(VERSION)/idlelib/config-extensions.def" + if [ -f "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def" ]; then \ + /bin/cp -p "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def" \ + "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def~" ; \ + sed -e 's!name= IDLE Classic Windows!name= IDLE Classic OSX!g' \ + < "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def~" \ + > "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def" ; \ + rm "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def~" ; \ + fi + if [ -f "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def" ]; then \ + /bin/cp -p "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def" \ + "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def~" ; \ + sed -e 's!zoom-height=!zoom-height=!g' \ + -e 's! "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def" ; \ + rm "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def~" ; \ + fi clean: rm -rf IDLE.app diff --git a/Mac/IDLE/config-extensions.def b/Mac/IDLE/config-extensions.def deleted file mode 100644 --- a/Mac/IDLE/config-extensions.def +++ /dev/null @@ -1,93 +0,0 @@ -# config-extensions.def -# -# IDLE reads several config files to determine user preferences. This -# file is the default configuration file for IDLE extensions settings. -# -# Each extension must have at least one section, named after the extension -# module. This section must contain an 'enable' item (=1 to enable the -# extension, =0 to disable it), it may contain 'enable_editor' or 'enable_shell' -# items, to apply it only to editor/shell windows, and may also contain any -# other general configuration items for the extension. -# -# Each extension must define at least one section named ExtensionName_bindings -# or ExtensionName_cfgBindings. If present, ExtensionName_bindings defines -# virtual event bindings for the extension that are not user re-configurable. -# If present, ExtensionName_cfgBindings defines virtual event bindings for the -# extension that may be sensibly re-configured. -# -# If there are no keybindings for a menus' virtual events, include lines like -# <>= (See [CodeContext], below.) -# -# Currently it is necessary to manually modify this file to change extension -# key bindings and default values. To customize, create -# ~/.idlerc/config-extensions.cfg and append the appropriate customized -# section(s). Those sections will override the defaults in this file. -# -# Note: If a keybinding is already in use when the extension is -# loaded, the extension's virtual event's keybinding will be set to ''. -# -# See config-keys.def for notes on specifying keys and extend.txt for -# information on creating IDLE extensions. - -[FormatParagraph] -enable=1 -[FormatParagraph_cfgBindings] -format-paragraph= - -[AutoExpand] -enable=1 -[AutoExpand_cfgBindings] -expand-word= - -[ZoomHeight] -enable=1 -[ZoomHeight_cfgBindings] -zoom-height= - -[ScriptBinding] -enable=1 -[ScriptBinding_cfgBindings] -run-module= -check-module= - -[CallTips] -enable=1 -[CallTips_cfgBindings] -force-open-calltip= -[CallTips_bindings] -try-open-calltip= -refresh-calltip= - -[ParenMatch] -enable=1 -style= expression -flash-delay= 500 -bell= 1 -[ParenMatch_cfgBindings] -flash-paren= -[ParenMatch_bindings] -paren-closed= - -[AutoComplete] -enable=1 -popupwait=2000 -[AutoComplete_cfgBindings] -force-open-completions= -[AutoComplete_bindings] -autocomplete= -try-open-completions= - -[CodeContext] -enable=1 -enable_shell=0 -numlines=3 -visible=0 -bgcolor=LightGray -fgcolor=Black -[CodeContext_bindings] -toggle-code-context= - -[RstripExtension] -enable=1 -enable_shell=0 -enable_editor=1 diff --git a/Mac/IDLE/config-main.def b/Mac/IDLE/config-main.def deleted file mode 100644 --- a/Mac/IDLE/config-main.def +++ /dev/null @@ -1,79 +0,0 @@ -# IDLE reads several config files to determine user preferences. This -# file is the default config file for general idle settings. -# -# When IDLE starts, it will look in -# the following two sets of files, in order: -# -# default configuration -# --------------------- -# config-main.def the default general config file -# config-extensions.def the default extension config file -# config-highlight.def the default highlighting config file -# config-keys.def the default keybinding config file -# -# user configuration -# ------------------- -# ~/.idlerc/config-main.cfg the user general config file -# ~/.idlerc/config-extensions.cfg the user extension config file -# ~/.idlerc/config-highlight.cfg the user highlighting config file -# ~/.idlerc/config-keys.cfg the user keybinding config file -# -# On Windows2000 and Windows XP the .idlerc directory is at -# Documents and Settings\\.idlerc -# -# On Windows98 it is at c:\.idlerc -# -# Any options the user saves through the config dialog will be saved to -# the relevant user config file. Reverting any general setting to the -# default causes that entry to be wiped from the user file and re-read -# from the default file. User highlighting themes or keybinding sets are -# retained unless specifically deleted within the config dialog. Choosing -# one of the default themes or keysets just applies the relevant settings -# from the default file. -# -# Additional help sources are listed in the [HelpFiles] section and must be -# viewable by a web browser (or the Windows Help viewer in the case of .chm -# files). These sources will be listed on the Help menu. The pattern is -# -# You can't use a semi-colon in a menu item or path. The path will be platform -# specific because of path separators, drive specs etc. -# -# It is best to use the Configuration GUI to set up additional help sources! -# Example: -#1 = My Extra Help Source;/usr/share/doc/foo/index.html -#2 = Another Help Source;/path/to/another.pdf - -[General] -editor-on-startup= 0 -autosave= 0 -print-command-posix=lpr %s -print-command-win=start /min notepad /p %s -delete-exitfunc= 1 - -[EditorWindow] -width= 80 -height= 40 -font= courier -font-size= 10 -font-bold= 0 -encoding= none - -[FormatParagraph] -paragraph=70 - -[Indent] -use-spaces= 1 -num-spaces= 4 - -[Theme] -default= 1 -name= IDLE Classic - -[Keys] -default= 1 -name= IDLE Classic OSX - -[History] -cyclic=1 - -[HelpFiles] diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -121,6 +121,13 @@ - Issue #25924: Avoid unnecessary serialization of getaddrinfo(3) calls on OS X versions 10.5 or higher. Original patch by A. Jesse Jiryu Davis.. +IDLE +---- + +- Issue #26417: Prevent spurious errors and incorrect defaults when + installing IDLE 2.7 on OS X: default configuration settings are + no longer installed from OS X specific copies. + Tests ----- -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Tue Feb 23 04:56:48 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Tue, 23 Feb 2016 09:56:48 +0000 Subject: [Python-checkins] Daily reference leaks (cbf83f55d5f3): sum=4 Message-ID: <20160223094643.1984.3680@psf.io> results for cbf83f55d5f3 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogcuMfmG', '--timeout', '7200'] From python-checkins at python.org Tue Feb 23 06:10:52 2016 From: python-checkins at python.org (ned.deily) Date: Tue, 23 Feb 2016 11:10:52 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI2NDA2?= =?utf-8?q?=3A_Avoid_unnecessary_serialization_of_getaddrinfo=283=29_calls?= =?utf-8?q?_on?= Message-ID: <20160223111052.1955.2304@psf.io> https://hg.python.org/cpython/rev/52a8c1965750 changeset: 100303:52a8c1965750 branch: 2.7 user: Ned Deily date: Tue Feb 23 22:03:39 2016 +1100 summary: Issue #26406: Avoid unnecessary serialization of getaddrinfo(3) calls on current versions of OpenBSD and NetBSD. Patch by A. Jesse Jiryu Davis. files: Misc/NEWS | 5 ++++- Modules/socketmodule.c | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -119,7 +119,10 @@ - Issue #23914: Fixed SystemError raised by CPickle unpickler on broken data. - Issue #25924: Avoid unnecessary serialization of getaddrinfo(3) calls on - OS X versions 10.5 or higher. Original patch by A. Jesse Jiryu Davis.. + OS X versions 10.5 or higher. Original patch by A. Jesse Jiryu Davis. + +- Issue #26406: Avoid unnecessary serialization of getaddrinfo(3) calls on + current versions of OpenBSD and NetBSD. Patch by A. Jesse Jiryu Davis. IDLE ---- diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -183,7 +183,7 @@ # define USE_GETHOSTBYNAME_LOCK #endif -/* To use __FreeBSD_version */ +/* To use __FreeBSD_version, __OpenBSD__, and __NetBSD_Version__ */ #ifdef HAVE_SYS_PARAM_H #include #endif @@ -194,15 +194,21 @@ a mix of code including an unsafe implementation from an old BSD's libresolv. In 10.5 Apple reimplemented it as a safe IPC call to the mDNSResponder process. 10.5 is the first be UNIX '03 certified, which - includes the requirement that getaddrinfo be thread-safe. - - See issue #25924 for details. - */ + includes the requirement that getaddrinfo be thread-safe. See issue #25924. + + It's thread-safe in OpenBSD starting with 5.4, released Nov 2013: + http://www.openbsd.org/plus54.html + + It's thread-safe in NetBSD starting with 4.0, released Dec 2007: + +http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/net/getaddrinfo.c.diff?r1=1.82&r2=1.83 +*/ #if defined(WITH_THREAD) && ( \ (defined(__APPLE__) && \ MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5) || \ (defined(__FreeBSD__) && __FreeBSD_version+0 < 503000) || \ - defined(__OpenBSD__) || defined(__NetBSD__) || \ + (defined(__OpenBSD__) && OpenBSD+0 < 201311) || \ + (defined(__NetBSD__) && __NetBSD_Version__+0 < 400000000) || \ defined(__VMS) || !defined(HAVE_GETADDRINFO)) #define USE_GETADDRINFO_LOCK #endif -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Feb 23 06:10:52 2016 From: python-checkins at python.org (ned.deily) Date: Tue, 23 Feb 2016 11:10:52 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2NDA2?= =?utf-8?q?=3A_Avoid_unnecessary_serialization_of_getaddrinfo=283=29_calls?= =?utf-8?q?_on?= Message-ID: <20160223111052.1976.28658@psf.io> https://hg.python.org/cpython/rev/419d20551d26 changeset: 100304:419d20551d26 branch: 3.5 parent: 100300:6b502158acc8 user: Ned Deily date: Tue Feb 23 22:05:29 2016 +1100 summary: Issue #26406: Avoid unnecessary serialization of getaddrinfo(3) calls on current versions of OpenBSD and NetBSD. Patch by A. Jesse Jiryu Davis. files: Misc/NEWS | 3 +++ Modules/socketmodule.c | 16 +++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -227,6 +227,9 @@ - Issue #25924: Avoid unnecessary serialization of getaddrinfo(3) calls on OS X versions 10.5 or higher. Original patch by A. Jesse Jiryu Davis. +- Issue #26406: Avoid unnecessary serialization of getaddrinfo(3) calls on + current versions of OpenBSD and NetBSD. Patch by A. Jesse Jiryu Davis. + Documentation ------------- diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -184,7 +184,7 @@ # define USE_GETHOSTBYNAME_LOCK #endif -/* To use __FreeBSD_version */ +/* To use __FreeBSD_version, __OpenBSD__, and __NetBSD_Version__ */ #ifdef HAVE_SYS_PARAM_H #include #endif @@ -195,15 +195,21 @@ a mix of code including an unsafe implementation from an old BSD's libresolv. In 10.5 Apple reimplemented it as a safe IPC call to the mDNSResponder process. 10.5 is the first be UNIX '03 certified, which - includes the requirement that getaddrinfo be thread-safe. - - See issue #25924 for details. + includes the requirement that getaddrinfo be thread-safe. See issue #25924. + + It's thread-safe in OpenBSD starting with 5.4, released Nov 2013: + http://www.openbsd.org/plus54.html + + It's thread-safe in NetBSD starting with 4.0, released Dec 2007: + +http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/net/getaddrinfo.c.diff?r1=1.82&r2=1.83 */ #if defined(WITH_THREAD) && ( \ (defined(__APPLE__) && \ MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5) || \ (defined(__FreeBSD__) && __FreeBSD_version+0 < 503000) || \ - defined(__OpenBSD__) || defined(__NetBSD__) || \ + (defined(__OpenBSD__) && OpenBSD+0 < 201311) || \ + (defined(__NetBSD__) && __NetBSD_Version__+0 < 400000000) || \ !defined(HAVE_GETADDRINFO)) #define USE_GETADDRINFO_LOCK #endif -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Feb 23 06:11:02 2016 From: python-checkins at python.org (ned.deily) Date: Tue, 23 Feb 2016 11:11:02 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326406=3A_merge_from_3=2E5?= Message-ID: <20160223111052.1678.79267@psf.io> https://hg.python.org/cpython/rev/5ffebeb3e91d changeset: 100305:5ffebeb3e91d parent: 100301:cbf83f55d5f3 parent: 100304:419d20551d26 user: Ned Deily date: Tue Feb 23 22:10:06 2016 +1100 summary: Issue #26406: merge from 3.5 files: Misc/NEWS | 3 +++ Modules/socketmodule.c | 16 +++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -600,6 +600,9 @@ - Issue #25924: Avoid unnecessary serialization of getaddrinfo(3) calls on OS X versions 10.5 or higher. Original patch by A. Jesse Jiryu Davis. +- Issue #26406: Avoid unnecessary serialization of getaddrinfo(3) calls on + current versions of OpenBSD and NetBSD. Patch by A. Jesse Jiryu Davis. + IDLE ---- diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -184,7 +184,7 @@ # define USE_GETHOSTBYNAME_LOCK #endif -/* To use __FreeBSD_version */ +/* To use __FreeBSD_version, __OpenBSD__, and __NetBSD_Version__ */ #ifdef HAVE_SYS_PARAM_H #include #endif @@ -195,15 +195,21 @@ a mix of code including an unsafe implementation from an old BSD's libresolv. In 10.5 Apple reimplemented it as a safe IPC call to the mDNSResponder process. 10.5 is the first be UNIX '03 certified, which - includes the requirement that getaddrinfo be thread-safe. - - See issue #25924 for details. + includes the requirement that getaddrinfo be thread-safe. See issue #25924. + + It's thread-safe in OpenBSD starting with 5.4, released Nov 2013: + http://www.openbsd.org/plus54.html + + It's thread-safe in NetBSD starting with 4.0, released Dec 2007: + +http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/net/getaddrinfo.c.diff?r1=1.82&r2=1.83 */ #if defined(WITH_THREAD) && ( \ (defined(__APPLE__) && \ MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5) || \ (defined(__FreeBSD__) && __FreeBSD_version+0 < 503000) || \ - defined(__OpenBSD__) || defined(__NetBSD__) || \ + (defined(__OpenBSD__) && OpenBSD+0 < 201311) || \ + (defined(__NetBSD__) && __NetBSD_Version__+0 < 400000000) || \ !defined(HAVE_GETADDRINFO)) #define USE_GETADDRINFO_LOCK #endif -- Repository URL: https://hg.python.org/cpython From lp_benchmark_robot at intel.com Tue Feb 23 12:25:36 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Tue, 23 Feb 2016 17:25:36 +0000 Subject: [Python-checkins] GOOD Benchmark Results for Python 2.7 2016-02-23 Message-ID: Results for project Python 2.7, build date 2016-02-23 04:00:45 +0000 commit: 3be29e684ccf previous commit: ada8023878d0 revision date: 2016-02-22 10:08:30 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dc from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.17% -0.30% 5.46% 3.42% :-) pybench 0.08% 0.17% 6.31% 4.52% :-( regex_v8 0.78% 0.07% -2.60% 10.76% :-) nbody 0.10% 6.02% 7.80% 2.91% :-) json_dump_v2 0.19% -0.70% 3.74% 10.59% :-( normal_startup 2.17% -0.38% -5.46% 1.93% :-| ssbench 0.23% -0.41% 1.91% 2.31% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/good-benchmark-results-for-python-2-7-2016-02-23/ Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Tue Feb 23 12:24:43 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Tue, 23 Feb 2016 17:24:43 +0000 Subject: [Python-checkins] BAD Benchmark Results for Python Default 2016-02-23 Message-ID: <637a735e-9e1c-412a-a173-678ba1bbb5ec@irsmsx101.ger.corp.intel.com> Results for project Python default, build date 2016-02-23 03:09:28 +0000 commit: cbf83f55d5f3 previous commit: 45cf82f424ce revision date: 2016-02-22 13:53:03 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.18% -1.12% 9.21% 14.98% :-| pybench 0.16% 0.00% 0.36% 5.85% :-( regex_v8 2.86% -0.00% -4.74% 4.16% :-| nbody 0.08% 0.02% -1.51% 7.57% :-| json_dump_v2 0.22% 0.05% 0.48% 10.98% :-| normal_startup 0.96% -0.02% -0.12% 5.09% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/bad-benchmark-results-for-python-default-2016-02-23/ Note: Benchmark results are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Tue Feb 23 20:19:08 2016 From: python-checkins at python.org (martin.panter) Date: Wed, 24 Feb 2016 01:19:08 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2322088=3A_Merge_base64_docs_from_3=2E5?= Message-ID: <20160224011908.2119.80070@psf.io> https://hg.python.org/cpython/rev/5ad27dcd5a97 changeset: 100308:5ad27dcd5a97 parent: 100305:5ffebeb3e91d parent: 100307:c8933fbc9171 user: Martin Panter date: Wed Feb 24 01:08:43 2016 +0000 summary: Issue #22088: Merge base64 docs from 3.5 files: Doc/library/base64.rst | 29 +++-- Lib/base64.py | 122 +++++++++++++-------------- Lib/test/test_base64.py | 20 ++++- 3 files changed, 92 insertions(+), 79 deletions(-) diff --git a/Doc/library/base64.rst b/Doc/library/base64.rst --- a/Doc/library/base64.rst +++ b/Doc/library/base64.rst @@ -24,8 +24,8 @@ There are two interfaces provided by this module. The modern interface supports encoding :term:`bytes-like objects ` to ASCII :class:`bytes`, and decoding :term:`bytes-like objects ` or -strings containing ASCII to :class:`bytes`. All three :rfc:`3548` defined -alphabets (normal, URL-safe, and filesystem-safe) are supported. +strings containing ASCII to :class:`bytes`. Both base-64 alphabets +defined in :rfc:`3548` (normal, and URL- and filesystem-safe) are supported. The legacy interface does not support decoding from strings, but it does provide functions for encoding and decoding to and from :term:`file objects @@ -69,9 +69,10 @@ A :exc:`binascii.Error` exception is raised if *s* is incorrectly padded. - If *validate* is ``False`` (the default), non-base64-alphabet characters are + If *validate* is ``False`` (the default), characters that are neither + in the normal base-64 alphabet nor the alternative alphabet are discarded prior to the padding check. If *validate* is ``True``, - non-base64-alphabet characters in the input result in a + these non-alphabet characters in the input result in a :exc:`binascii.Error`. @@ -89,7 +90,8 @@ .. function:: urlsafe_b64encode(s) - Encode :term:`bytes-like object` *s* using a URL-safe alphabet, which + Encode :term:`bytes-like object` *s* using the + URL- and filesystem-safe alphabet, which substitutes ``-`` instead of ``+`` and ``_`` instead of ``/`` in the standard Base64 alphabet, and return the encoded :class:`bytes`. The result can still contain ``=``. @@ -97,7 +99,8 @@ .. function:: urlsafe_b64decode(s) - Decode :term:`bytes-like object` or ASCII string *s* using a URL-safe + Decode :term:`bytes-like object` or ASCII string *s* + using the URL- and filesystem-safe alphabet, which substitutes ``-`` instead of ``+`` and ``_`` instead of ``/`` in the standard Base64 alphabet, and return the decoded :class:`bytes`. @@ -145,14 +148,14 @@ lowercase alphabet is acceptable as input. For security purposes, the default is ``False``. - A :exc:`TypeError` is raised if *s* is + A :exc:`binascii.Error` is raised if *s* is incorrectly padded or if there are non-alphabet characters present in the input. -.. function:: a85encode(s, *, foldspaces=False, wrapcol=0, pad=False, adobe=False) +.. function:: a85encode(b, *, foldspaces=False, wrapcol=0, pad=False, adobe=False) - Encode the :term:`bytes-like object` *s* using Ascii85 and return the + Encode the :term:`bytes-like object` *b* using Ascii85 and return the encoded :class:`bytes`. *foldspaces* is an optional flag that uses the special short sequence 'y' @@ -172,9 +175,9 @@ .. versionadded:: 3.4 -.. function:: a85decode(s, *, foldspaces=False, adobe=False, ignorechars=b' \\t\\n\\r\\v') +.. function:: a85decode(b, *, foldspaces=False, adobe=False, ignorechars=b' \\t\\n\\r\\v') - Decode the Ascii85 encoded :term:`bytes-like object` or ASCII string *s* and + Decode the Ascii85 encoded :term:`bytes-like object` or ASCII string *b* and return the decoded :class:`bytes`. *foldspaces* is a flag that specifies whether the 'y' short sequence @@ -192,9 +195,9 @@ .. versionadded:: 3.4 -.. function:: b85encode(s, pad=False) +.. function:: b85encode(b, pad=False) - Encode the :term:`bytes-like object` *s* using base85 (as used in e.g. + Encode the :term:`bytes-like object` *b* using base85 (as used in e.g. git-style binary diffs) and return the encoded :class:`bytes`. If *pad* is true, the input is padded with ``b'\0'`` so its length is a diff --git a/Lib/base64.py b/Lib/base64.py --- a/Lib/base64.py +++ b/Lib/base64.py @@ -12,7 +12,7 @@ __all__ = [ - # Legacy interface exports traditional RFC 1521 Base64 encodings + # Legacy interface exports traditional RFC 2045 Base64 encodings 'encode', 'decode', 'encodebytes', 'decodebytes', # Generalized interface for other encodings 'b64encode', 'b64decode', 'b32encode', 'b32decode', @@ -49,14 +49,11 @@ # Base64 encoding/decoding uses binascii def b64encode(s, altchars=None): - """Encode a byte string using Base64. + """Encode the bytes-like object s using Base64 and return a bytes object. - s is the byte string to encode. Optional altchars must be a byte - string of length 2 which specifies an alternative alphabet for the - '+' and '/' characters. This allows an application to - e.g. generate url or filesystem safe Base64 strings. - - The encoded byte string is returned. + Optional altchars should be a byte string of length 2 which specifies an + alternative alphabet for the '+' and '/' characters. This allows an + application to e.g. generate url or filesystem safe Base64 strings. """ encoded = binascii.b2a_base64(s, newline=False) if altchars is not None: @@ -66,18 +63,19 @@ def b64decode(s, altchars=None, validate=False): - """Decode a Base64 encoded byte string. + """Decode the Base64 encoded bytes-like object or ASCII string s. - s is the byte string to decode. Optional altchars must be a - string of length 2 which specifies the alternative alphabet used - instead of the '+' and '/' characters. + Optional altchars must be a bytes-like object or ASCII string of length 2 + which specifies the alternative alphabet used instead of the '+' and '/' + characters. - The decoded string is returned. A binascii.Error is raised if s is - incorrectly padded. + The result is returned as a bytes object. A binascii.Error is raised if + s is incorrectly padded. - If validate is False (the default), non-base64-alphabet characters are - discarded prior to the padding check. If validate is True, - non-base64-alphabet characters in the input result in a binascii.Error. + If validate is False (the default), characters that are neither in the + normal base-64 alphabet nor the alternative alphabet are discarded prior + to the padding check. If validate is True, these non-alphabet characters + in the input result in a binascii.Error. """ s = _bytes_from_decode_data(s) if altchars is not None: @@ -90,19 +88,19 @@ def standard_b64encode(s): - """Encode a byte string using the standard Base64 alphabet. + """Encode bytes-like object s using the standard Base64 alphabet. - s is the byte string to encode. The encoded byte string is returned. + The result is returned as a bytes object. """ return b64encode(s) def standard_b64decode(s): - """Decode a byte string encoded with the standard Base64 alphabet. + """Decode bytes encoded with the standard Base64 alphabet. - s is the byte string to decode. The decoded byte string is - returned. binascii.Error is raised if the input is incorrectly - padded or if there are non-alphabet characters present in the - input. + Argument s is a bytes-like object or ASCII string to decode. The result + is returned as a bytes object. A binascii.Error is raised if the input + is incorrectly padded. Characters that are not in the standard alphabet + are discarded prior to the padding check. """ return b64decode(s) @@ -111,21 +109,22 @@ _urlsafe_decode_translation = bytes.maketrans(b'-_', b'+/') def urlsafe_b64encode(s): - """Encode a byte string using a url-safe Base64 alphabet. + """Encode bytes using the URL- and filesystem-safe Base64 alphabet. - s is the byte string to encode. The encoded byte string is - returned. The alphabet uses '-' instead of '+' and '_' instead of + Argument s is a bytes-like object to encode. The result is returned as a + bytes object. The alphabet uses '-' instead of '+' and '_' instead of '/'. """ return b64encode(s).translate(_urlsafe_encode_translation) def urlsafe_b64decode(s): - """Decode a byte string encoded with the standard Base64 alphabet. + """Decode bytes using the URL- and filesystem-safe Base64 alphabet. - s is the byte string to decode. The decoded byte string is - returned. binascii.Error is raised if the input is incorrectly - padded or if there are non-alphabet characters present in the - input. + Argument s is a bytes-like object or ASCII string to decode. The result + is returned as a bytes object. A binascii.Error is raised if the input + is incorrectly padded. Characters that are not in the URL-safe base-64 + alphabet, and are not a plus '+' or slash '/', are discarded prior to the + padding check. The alphabet uses '-' instead of '+' and '_' instead of '/'. """ @@ -141,9 +140,7 @@ _b32rev = None def b32encode(s): - """Encode a byte string using Base32. - - s is the byte string to encode. The encoded byte string is returned. + """Encode the bytes-like object s using Base32 and return a bytes object. """ global _b32tab2 # Delay the initialization of the table to not waste memory @@ -181,11 +178,10 @@ return bytes(encoded) def b32decode(s, casefold=False, map01=None): - """Decode a Base32 encoded byte string. + """Decode the Base32 encoded bytes-like object or ASCII string s. - s is the byte string to decode. Optional casefold is a flag - specifying whether a lowercase alphabet is acceptable as input. - For security purposes, the default is False. + Optional casefold is a flag specifying whether a lowercase alphabet is + acceptable as input. For security purposes, the default is False. RFC 3548 allows for optional mapping of the digit 0 (zero) to the letter O (oh), and for optional mapping of the digit 1 (one) to @@ -195,7 +191,7 @@ the letter O). For security purposes the default is None, so that 0 and 1 are not allowed in the input. - The decoded byte string is returned. binascii.Error is raised if + The result is returned as a bytes object. A binascii.Error is raised if the input is incorrectly padded or if there are non-alphabet characters present in the input. """ @@ -256,23 +252,20 @@ # lowercase. The RFC also recommends against accepting input case # insensitively. def b16encode(s): - """Encode a byte string using Base16. - - s is the byte string to encode. The encoded byte string is returned. + """Encode the bytes-like object s using Base16 and return a bytes object. """ return binascii.hexlify(s).upper() def b16decode(s, casefold=False): - """Decode a Base16 encoded byte string. + """Decode the Base16 encoded bytes-like object or ASCII string s. - s is the byte string to decode. Optional casefold is a flag - specifying whether a lowercase alphabet is acceptable as input. - For security purposes, the default is False. + Optional casefold is a flag specifying whether a lowercase alphabet is + acceptable as input. For security purposes, the default is False. - The decoded byte string is returned. binascii.Error is raised if - s were incorrectly padded or if there are non-alphabet characters - present in the string. + The result is returned as a bytes object. A binascii.Error is raised if + s is incorrectly padded or if there are non-alphabet characters present + in the input. """ s = _bytes_from_decode_data(s) if casefold: @@ -315,19 +308,17 @@ return b''.join(chunks) def a85encode(b, *, foldspaces=False, wrapcol=0, pad=False, adobe=False): - """Encode a byte string using Ascii85. - - b is the byte string to encode. The encoded byte string is returned. + """Encode bytes-like object b using Ascii85 and return a bytes object. foldspaces is an optional flag that uses the special short sequence 'y' instead of 4 consecutive spaces (ASCII 0x20) as supported by 'btoa'. This feature is not supported by the "standard" Adobe encoding. - wrapcol controls whether the output should have newline ('\\n') characters + wrapcol controls whether the output should have newline (b'\\n') characters added to it. If this is non-zero, each output line will be at most this many characters long. - pad controls whether the input string is padded to a multiple of 4 before + pad controls whether the input is padded to a multiple of 4 before encoding. Note that the btoa implementation always pads. adobe controls whether the encoded byte sequence is framed with <~ and ~>, @@ -358,9 +349,7 @@ return result def a85decode(b, *, foldspaces=False, adobe=False, ignorechars=b' \t\n\r\v'): - """Decode an Ascii85 encoded byte string. - - s is the byte string to decode. + """Decode the Ascii85 encoded bytes-like object or ASCII string b. foldspaces is a flag that specifies whether the 'y' short sequence should be accepted as shorthand for 4 consecutive spaces (ASCII 0x20). This feature is @@ -372,6 +361,8 @@ ignorechars should be a byte string containing characters to ignore from the input. This should only contain whitespace characters, and by default contains all whitespace characters in ASCII. + + The result is returned as a bytes object. """ b = _bytes_from_decode_data(b) if adobe: @@ -431,10 +422,10 @@ _b85dec = None def b85encode(b, pad=False): - """Encode an ASCII-encoded byte array in base85 format. + """Encode bytes-like object b in base85 format and return a bytes object. - If pad is true, the input is padded with "\\0" so its length is a multiple of - 4 characters before encoding. + If pad is true, the input is padded with b'\\0' so its length is a multiple of + 4 bytes before encoding. """ global _b85chars, _b85chars2 # Delay the initialization of tables to not waste memory @@ -445,7 +436,10 @@ return _85encode(b, _b85chars, _b85chars2, pad) def b85decode(b): - """Decode base85-encoded byte array""" + """Decode the base85-encoded bytes-like object or ASCII string b + + The result is returned as a bytes object. + """ global _b85dec # Delay the initialization of tables to not waste memory # if the function is never called @@ -530,7 +524,7 @@ def encodebytes(s): - """Encode a bytestring into a bytestring containing multiple lines + """Encode a bytestring into a bytes object containing multiple lines of base-64 data.""" _input_type_check(s) pieces = [] @@ -548,7 +542,7 @@ def decodebytes(s): - """Decode a bytestring of base-64 data into a bytestring.""" + """Decode a bytestring of base-64 data into a bytes object.""" _input_type_check(s) return binascii.a2b_base64(s) diff --git a/Lib/test/test_base64.py b/Lib/test/test_base64.py --- a/Lib/test/test_base64.py +++ b/Lib/test/test_base64.py @@ -243,14 +243,26 @@ (b'@@', b''), (b'!', b''), (b'YWJj\nYWI=', b'abcab')) + funcs = ( + base64.b64decode, + base64.standard_b64decode, + base64.urlsafe_b64decode, + ) for bstr, res in tests: - self.assertEqual(base64.b64decode(bstr), res) - self.assertEqual(base64.b64decode(bstr.decode('ascii')), res) + for func in funcs: + with self.subTest(bstr=bstr, func=func): + self.assertEqual(func(bstr), res) + self.assertEqual(func(bstr.decode('ascii')), res) with self.assertRaises(binascii.Error): base64.b64decode(bstr, validate=True) with self.assertRaises(binascii.Error): base64.b64decode(bstr.decode('ascii'), validate=True) + # Normal alphabet characters not discarded when alternative given + res = b'\xFB\xEF\xBE\xFF\xFF\xFF' + self.assertEqual(base64.b64decode(b'++[[//]]', b'[]'), res) + self.assertEqual(base64.urlsafe_b64decode(b'++--//__'), res) + def test_b32encode(self): eq = self.assertEqual eq(base64.b32encode(b''), b'') @@ -360,6 +372,10 @@ b'\x01\x02\xab\xcd\xef') eq(base64.b16decode(array('B', b"0102abcdef"), True), b'\x01\x02\xab\xcd\xef') + # Non-alphabet characters + self.assertRaises(binascii.Error, base64.b16decode, '0102AG') + # Incorrect "padding" + self.assertRaises(binascii.Error, base64.b16decode, '010') def test_a85encode(self): eq = self.assertEqual -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Feb 23 20:19:08 2016 From: python-checkins at python.org (martin.panter) Date: Wed, 24 Feb 2016 01:19:08 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzIyMDg4?= =?utf-8?q?=3A_Clarify_base-64_alphabets_and_which_characters_are_discarde?= =?utf-8?q?d?= Message-ID: <20160224011907.1530.78219@psf.io> https://hg.python.org/cpython/rev/c62526580ff0 changeset: 100306:c62526580ff0 branch: 2.7 parent: 100303:52a8c1965750 user: Martin Panter date: Tue Feb 23 22:30:50 2016 +0000 summary: Issue #22088: Clarify base-64 alphabets and which characters are discarded * There are only two base-64 alphabets defined by the RFCs, not three * Due to the internal translation, plus (+) and slash (/) are never discarded * standard_ and urlsafe_b64decode() discard characters as well files: Doc/library/base64.rst | 15 +++++++++------ Lib/base64.py | 29 ++++++++++++++++------------- Lib/test/test_base64.py | 11 +++++++++++ 3 files changed, 36 insertions(+), 19 deletions(-) diff --git a/Doc/library/base64.rst b/Doc/library/base64.rst --- a/Doc/library/base64.rst +++ b/Doc/library/base64.rst @@ -16,8 +16,8 @@ encoding algorithm is not the same as the :program:`uuencode` program. There are two interfaces provided by this module. The modern interface supports -encoding and decoding string objects using all three :rfc:`3548` defined -alphabets (normal, URL-safe, and filesystem-safe). The legacy +encoding and decoding string objects using both base-64 alphabets defined +in :rfc:`3548` (normal, and URL- and filesystem-safe). The legacy interface provides for encoding and decoding to and from file-like objects as well as strings, but only using the Base64 standard alphabet. @@ -26,7 +26,7 @@ .. function:: b64encode(s[, altchars]) - Encode a string use Base64. + Encode a string using Base64. *s* is the string to encode. Optional *altchars* must be a string of at least length 2 (additional characters are ignored) which specifies an alternative @@ -46,7 +46,8 @@ alphabet used instead of the ``+`` and ``/`` characters. The decoded string is returned. A :exc:`TypeError` is raised if *s* is - incorrectly padded. Non-base64-alphabet characters are + incorrectly padded. Characters that are neither + in the normal base-64 alphabet nor the alternative alphabet are discarded prior to the padding check. @@ -62,14 +63,16 @@ .. function:: urlsafe_b64encode(s) - Encode string *s* using a URL-safe alphabet, which substitutes ``-`` instead of + Encode string *s* using the URL- and filesystem-safe + alphabet, which substitutes ``-`` instead of ``+`` and ``_`` instead of ``/`` in the standard Base64 alphabet. The result can still contain ``=``. .. function:: urlsafe_b64decode(s) - Decode string *s* using a URL-safe alphabet, which substitutes ``-`` instead of + Decode string *s* using the URL- and filesystem-safe + alphabet, which substitutes ``-`` instead of ``+`` and ``_`` instead of ``/`` in the standard Base64 alphabet. diff --git a/Lib/base64.py b/Lib/base64.py --- a/Lib/base64.py +++ b/Lib/base64.py @@ -65,8 +65,9 @@ alternative alphabet used instead of the '+' and '/' characters. The decoded string is returned. A TypeError is raised if s is - incorrectly padded. Non-base64-alphabet characters are discarded prior - to the padding check. + incorrectly padded. Characters that are neither in the normal base-64 + alphabet nor the alternative alphabet are discarded prior to the padding + check. """ if altchars is not None: s = s.translate(string.maketrans(altchars[:2], '+/')) @@ -87,9 +88,10 @@ def standard_b64decode(s): """Decode a string encoded with the standard Base64 alphabet. - s is the string to decode. The decoded string is returned. A TypeError - is raised if the string is incorrectly padded or if there are non-alphabet - characters present in the string. + Argument s is the string to decode. The decoded string is returned. A + TypeError is raised if the string is incorrectly padded. Characters that + are not in the standard alphabet are discarded prior to the padding + check. """ return b64decode(s) @@ -97,19 +99,20 @@ _urlsafe_decode_translation = string.maketrans(b'-_', b'+/') def urlsafe_b64encode(s): - """Encode a string using a url-safe Base64 alphabet. + """Encode a string using the URL- and filesystem-safe Base64 alphabet. - s is the string to encode. The encoded string is returned. The alphabet - uses '-' instead of '+' and '_' instead of '/'. + Argument s is the string to encode. The encoded string is returned. The + alphabet uses '-' instead of '+' and '_' instead of '/'. """ return b64encode(s).translate(_urlsafe_encode_translation) def urlsafe_b64decode(s): - """Decode a string encoded with the standard Base64 alphabet. + """Decode a string using the URL- and filesystem-safe Base64 alphabet. - s is the string to decode. The decoded string is returned. A TypeError - is raised if the string is incorrectly padded or if there are non-alphabet - characters present in the string. + Argument s is the string to decode. The decoded string is returned. A + TypeError is raised if the string is incorrectly padded. Characters that + are not in the URL-safe base-64 alphabet, and are not a plus '+' or slash + '/', are discarded prior to the padding check. The alphabet uses '-' instead of '+' and '_' instead of '/'. """ @@ -267,7 +270,7 @@ a lowercase alphabet is acceptable as input. For security purposes, the default is False. - The decoded string is returned. A TypeError is raised if s were + The decoded string is returned. A TypeError is raised if s is incorrectly padded or if there are non-alphabet characters present in the string. """ diff --git a/Lib/test/test_base64.py b/Lib/test/test_base64.py --- a/Lib/test/test_base64.py +++ b/Lib/test/test_base64.py @@ -153,6 +153,13 @@ (b'YWJj\nYWI=', b'abcab')) for bstr, res in tests: self.assertEqual(base64.b64decode(bstr), res) + self.assertEqual(base64.standard_b64decode(bstr), res) + self.assertEqual(base64.urlsafe_b64decode(bstr), res) + + # Normal alphabet characters not discarded when alternative given + res = b'\xFB\xEF\xBE\xFF\xFF\xFF' + self.assertEqual(base64.b64decode(b'++[[//]]', b'[]'), res) + self.assertEqual(base64.urlsafe_b64decode(b'++--//__'), res) def test_b32encode(self): eq = self.assertEqual @@ -220,6 +227,10 @@ eq(base64.b16decode('0102abcdef', True), '\x01\x02\xab\xcd\xef') # Non-bytes eq(base64.b16decode(bytearray("0102ABCDEF")), '\x01\x02\xab\xcd\xef') + # Non-alphabet characters + self.assertRaises(TypeError, base64.b16decode, '0102AG') + # Incorrect "padding" + self.assertRaises(TypeError, base64.b16decode, '010') -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue Feb 23 20:19:12 2016 From: python-checkins at python.org (martin.panter) Date: Wed, 24 Feb 2016 01:19:12 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzIyMDg4?= =?utf-8?q?=3A_Clarify_base-64_alphabets_and_which_characters_are_discarde?= =?utf-8?q?d?= Message-ID: <20160224011908.1654.30145@psf.io> https://hg.python.org/cpython/rev/c8933fbc9171 changeset: 100307:c8933fbc9171 branch: 3.5 parent: 100304:419d20551d26 user: Martin Panter date: Tue Feb 23 22:30:50 2016 +0000 summary: Issue #22088: Clarify base-64 alphabets and which characters are discarded * There are only two base-64 alphabets defined by the RFCs, not three * Due to the internal translation, plus (+) and slash (/) are never discarded * standard_ and urlsafe_b64decode() discard characters as well Also update the doc strings to clarify data types, based on revision 92760d2edc9e, correct the exception raised by b16decode(), and correct the parameter name for the base-85 functions. files: Doc/library/base64.rst | 29 +++-- Lib/base64.py | 122 +++++++++++++-------------- Lib/test/test_base64.py | 20 ++++- 3 files changed, 92 insertions(+), 79 deletions(-) diff --git a/Doc/library/base64.rst b/Doc/library/base64.rst --- a/Doc/library/base64.rst +++ b/Doc/library/base64.rst @@ -24,8 +24,8 @@ There are two interfaces provided by this module. The modern interface supports encoding :term:`bytes-like objects ` to ASCII :class:`bytes`, and decoding :term:`bytes-like objects ` or -strings containing ASCII to :class:`bytes`. All three :rfc:`3548` defined -alphabets (normal, URL-safe, and filesystem-safe) are supported. +strings containing ASCII to :class:`bytes`. Both base-64 alphabets +defined in :rfc:`3548` (normal, and URL- and filesystem-safe) are supported. The legacy interface does not support decoding from strings, but it does provide functions for encoding and decoding to and from :term:`file objects @@ -69,9 +69,10 @@ A :exc:`binascii.Error` exception is raised if *s* is incorrectly padded. - If *validate* is ``False`` (the default), non-base64-alphabet characters are + If *validate* is ``False`` (the default), characters that are neither + in the normal base-64 alphabet nor the alternative alphabet are discarded prior to the padding check. If *validate* is ``True``, - non-base64-alphabet characters in the input result in a + these non-alphabet characters in the input result in a :exc:`binascii.Error`. @@ -89,7 +90,8 @@ .. function:: urlsafe_b64encode(s) - Encode :term:`bytes-like object` *s* using a URL-safe alphabet, which + Encode :term:`bytes-like object` *s* using the + URL- and filesystem-safe alphabet, which substitutes ``-`` instead of ``+`` and ``_`` instead of ``/`` in the standard Base64 alphabet, and return the encoded :class:`bytes`. The result can still contain ``=``. @@ -97,7 +99,8 @@ .. function:: urlsafe_b64decode(s) - Decode :term:`bytes-like object` or ASCII string *s* using a URL-safe + Decode :term:`bytes-like object` or ASCII string *s* + using the URL- and filesystem-safe alphabet, which substitutes ``-`` instead of ``+`` and ``_`` instead of ``/`` in the standard Base64 alphabet, and return the decoded :class:`bytes`. @@ -145,14 +148,14 @@ lowercase alphabet is acceptable as input. For security purposes, the default is ``False``. - A :exc:`TypeError` is raised if *s* is + A :exc:`binascii.Error` is raised if *s* is incorrectly padded or if there are non-alphabet characters present in the input. -.. function:: a85encode(s, *, foldspaces=False, wrapcol=0, pad=False, adobe=False) +.. function:: a85encode(b, *, foldspaces=False, wrapcol=0, pad=False, adobe=False) - Encode the :term:`bytes-like object` *s* using Ascii85 and return the + Encode the :term:`bytes-like object` *b* using Ascii85 and return the encoded :class:`bytes`. *foldspaces* is an optional flag that uses the special short sequence 'y' @@ -172,9 +175,9 @@ .. versionadded:: 3.4 -.. function:: a85decode(s, *, foldspaces=False, adobe=False, ignorechars=b' \\t\\n\\r\\v') +.. function:: a85decode(b, *, foldspaces=False, adobe=False, ignorechars=b' \\t\\n\\r\\v') - Decode the Ascii85 encoded :term:`bytes-like object` or ASCII string *s* and + Decode the Ascii85 encoded :term:`bytes-like object` or ASCII string *b* and return the decoded :class:`bytes`. *foldspaces* is a flag that specifies whether the 'y' short sequence @@ -192,9 +195,9 @@ .. versionadded:: 3.4 -.. function:: b85encode(s, pad=False) +.. function:: b85encode(b, pad=False) - Encode the :term:`bytes-like object` *s* using base85 (as used in e.g. + Encode the :term:`bytes-like object` *b* using base85 (as used in e.g. git-style binary diffs) and return the encoded :class:`bytes`. If *pad* is true, the input is padded with ``b'\0'`` so its length is a diff --git a/Lib/base64.py b/Lib/base64.py --- a/Lib/base64.py +++ b/Lib/base64.py @@ -12,7 +12,7 @@ __all__ = [ - # Legacy interface exports traditional RFC 1521 Base64 encodings + # Legacy interface exports traditional RFC 2045 Base64 encodings 'encode', 'decode', 'encodebytes', 'decodebytes', # Generalized interface for other encodings 'b64encode', 'b64decode', 'b32encode', 'b32decode', @@ -49,14 +49,11 @@ # Base64 encoding/decoding uses binascii def b64encode(s, altchars=None): - """Encode a byte string using Base64. + """Encode the bytes-like object s using Base64 and return a bytes object. - s is the byte string to encode. Optional altchars must be a byte - string of length 2 which specifies an alternative alphabet for the - '+' and '/' characters. This allows an application to - e.g. generate url or filesystem safe Base64 strings. - - The encoded byte string is returned. + Optional altchars should be a byte string of length 2 which specifies an + alternative alphabet for the '+' and '/' characters. This allows an + application to e.g. generate url or filesystem safe Base64 strings. """ # Strip off the trailing newline encoded = binascii.b2a_base64(s)[:-1] @@ -67,18 +64,19 @@ def b64decode(s, altchars=None, validate=False): - """Decode a Base64 encoded byte string. + """Decode the Base64 encoded bytes-like object or ASCII string s. - s is the byte string to decode. Optional altchars must be a - string of length 2 which specifies the alternative alphabet used - instead of the '+' and '/' characters. + Optional altchars must be a bytes-like object or ASCII string of length 2 + which specifies the alternative alphabet used instead of the '+' and '/' + characters. - The decoded string is returned. A binascii.Error is raised if s is - incorrectly padded. + The result is returned as a bytes object. A binascii.Error is raised if + s is incorrectly padded. - If validate is False (the default), non-base64-alphabet characters are - discarded prior to the padding check. If validate is True, - non-base64-alphabet characters in the input result in a binascii.Error. + If validate is False (the default), characters that are neither in the + normal base-64 alphabet nor the alternative alphabet are discarded prior + to the padding check. If validate is True, these non-alphabet characters + in the input result in a binascii.Error. """ s = _bytes_from_decode_data(s) if altchars is not None: @@ -91,19 +89,19 @@ def standard_b64encode(s): - """Encode a byte string using the standard Base64 alphabet. + """Encode bytes-like object s using the standard Base64 alphabet. - s is the byte string to encode. The encoded byte string is returned. + The result is returned as a bytes object. """ return b64encode(s) def standard_b64decode(s): - """Decode a byte string encoded with the standard Base64 alphabet. + """Decode bytes encoded with the standard Base64 alphabet. - s is the byte string to decode. The decoded byte string is - returned. binascii.Error is raised if the input is incorrectly - padded or if there are non-alphabet characters present in the - input. + Argument s is a bytes-like object or ASCII string to decode. The result + is returned as a bytes object. A binascii.Error is raised if the input + is incorrectly padded. Characters that are not in the standard alphabet + are discarded prior to the padding check. """ return b64decode(s) @@ -112,21 +110,22 @@ _urlsafe_decode_translation = bytes.maketrans(b'-_', b'+/') def urlsafe_b64encode(s): - """Encode a byte string using a url-safe Base64 alphabet. + """Encode bytes using the URL- and filesystem-safe Base64 alphabet. - s is the byte string to encode. The encoded byte string is - returned. The alphabet uses '-' instead of '+' and '_' instead of + Argument s is a bytes-like object to encode. The result is returned as a + bytes object. The alphabet uses '-' instead of '+' and '_' instead of '/'. """ return b64encode(s).translate(_urlsafe_encode_translation) def urlsafe_b64decode(s): - """Decode a byte string encoded with the standard Base64 alphabet. + """Decode bytes using the URL- and filesystem-safe Base64 alphabet. - s is the byte string to decode. The decoded byte string is - returned. binascii.Error is raised if the input is incorrectly - padded or if there are non-alphabet characters present in the - input. + Argument s is a bytes-like object or ASCII string to decode. The result + is returned as a bytes object. A binascii.Error is raised if the input + is incorrectly padded. Characters that are not in the URL-safe base-64 + alphabet, and are not a plus '+' or slash '/', are discarded prior to the + padding check. The alphabet uses '-' instead of '+' and '_' instead of '/'. """ @@ -142,9 +141,7 @@ _b32rev = None def b32encode(s): - """Encode a byte string using Base32. - - s is the byte string to encode. The encoded byte string is returned. + """Encode the bytes-like object s using Base32 and return a bytes object. """ global _b32tab2 # Delay the initialization of the table to not waste memory @@ -182,11 +179,10 @@ return bytes(encoded) def b32decode(s, casefold=False, map01=None): - """Decode a Base32 encoded byte string. + """Decode the Base32 encoded bytes-like object or ASCII string s. - s is the byte string to decode. Optional casefold is a flag - specifying whether a lowercase alphabet is acceptable as input. - For security purposes, the default is False. + Optional casefold is a flag specifying whether a lowercase alphabet is + acceptable as input. For security purposes, the default is False. RFC 3548 allows for optional mapping of the digit 0 (zero) to the letter O (oh), and for optional mapping of the digit 1 (one) to @@ -196,7 +192,7 @@ the letter O). For security purposes the default is None, so that 0 and 1 are not allowed in the input. - The decoded byte string is returned. binascii.Error is raised if + The result is returned as a bytes object. A binascii.Error is raised if the input is incorrectly padded or if there are non-alphabet characters present in the input. """ @@ -257,23 +253,20 @@ # lowercase. The RFC also recommends against accepting input case # insensitively. def b16encode(s): - """Encode a byte string using Base16. - - s is the byte string to encode. The encoded byte string is returned. + """Encode the bytes-like object s using Base16 and return a bytes object. """ return binascii.hexlify(s).upper() def b16decode(s, casefold=False): - """Decode a Base16 encoded byte string. + """Decode the Base16 encoded bytes-like object or ASCII string s. - s is the byte string to decode. Optional casefold is a flag - specifying whether a lowercase alphabet is acceptable as input. - For security purposes, the default is False. + Optional casefold is a flag specifying whether a lowercase alphabet is + acceptable as input. For security purposes, the default is False. - The decoded byte string is returned. binascii.Error is raised if - s were incorrectly padded or if there are non-alphabet characters - present in the string. + The result is returned as a bytes object. A binascii.Error is raised if + s is incorrectly padded or if there are non-alphabet characters present + in the input. """ s = _bytes_from_decode_data(s) if casefold: @@ -316,19 +309,17 @@ return b''.join(chunks) def a85encode(b, *, foldspaces=False, wrapcol=0, pad=False, adobe=False): - """Encode a byte string using Ascii85. - - b is the byte string to encode. The encoded byte string is returned. + """Encode bytes-like object b using Ascii85 and return a bytes object. foldspaces is an optional flag that uses the special short sequence 'y' instead of 4 consecutive spaces (ASCII 0x20) as supported by 'btoa'. This feature is not supported by the "standard" Adobe encoding. - wrapcol controls whether the output should have newline ('\\n') characters + wrapcol controls whether the output should have newline (b'\\n') characters added to it. If this is non-zero, each output line will be at most this many characters long. - pad controls whether the input string is padded to a multiple of 4 before + pad controls whether the input is padded to a multiple of 4 before encoding. Note that the btoa implementation always pads. adobe controls whether the encoded byte sequence is framed with <~ and ~>, @@ -359,9 +350,7 @@ return result def a85decode(b, *, foldspaces=False, adobe=False, ignorechars=b' \t\n\r\v'): - """Decode an Ascii85 encoded byte string. - - s is the byte string to decode. + """Decode the Ascii85 encoded bytes-like object or ASCII string b. foldspaces is a flag that specifies whether the 'y' short sequence should be accepted as shorthand for 4 consecutive spaces (ASCII 0x20). This feature is @@ -373,6 +362,8 @@ ignorechars should be a byte string containing characters to ignore from the input. This should only contain whitespace characters, and by default contains all whitespace characters in ASCII. + + The result is returned as a bytes object. """ b = _bytes_from_decode_data(b) if adobe: @@ -432,10 +423,10 @@ _b85dec = None def b85encode(b, pad=False): - """Encode an ASCII-encoded byte array in base85 format. + """Encode bytes-like object b in base85 format and return a bytes object. - If pad is true, the input is padded with "\\0" so its length is a multiple of - 4 characters before encoding. + If pad is true, the input is padded with b'\\0' so its length is a multiple of + 4 bytes before encoding. """ global _b85chars, _b85chars2 # Delay the initialization of tables to not waste memory @@ -446,7 +437,10 @@ return _85encode(b, _b85chars, _b85chars2, pad) def b85decode(b): - """Decode base85-encoded byte array""" + """Decode the base85-encoded bytes-like object or ASCII string b + + The result is returned as a bytes object. + """ global _b85dec # Delay the initialization of tables to not waste memory # if the function is never called @@ -531,7 +525,7 @@ def encodebytes(s): - """Encode a bytestring into a bytestring containing multiple lines + """Encode a bytestring into a bytes object containing multiple lines of base-64 data.""" _input_type_check(s) pieces = [] @@ -549,7 +543,7 @@ def decodebytes(s): - """Decode a bytestring of base-64 data into a bytestring.""" + """Decode a bytestring of base-64 data into a bytes object.""" _input_type_check(s) return binascii.a2b_base64(s) diff --git a/Lib/test/test_base64.py b/Lib/test/test_base64.py --- a/Lib/test/test_base64.py +++ b/Lib/test/test_base64.py @@ -243,14 +243,26 @@ (b'@@', b''), (b'!', b''), (b'YWJj\nYWI=', b'abcab')) + funcs = ( + base64.b64decode, + base64.standard_b64decode, + base64.urlsafe_b64decode, + ) for bstr, res in tests: - self.assertEqual(base64.b64decode(bstr), res) - self.assertEqual(base64.b64decode(bstr.decode('ascii')), res) + for func in funcs: + with self.subTest(bstr=bstr, func=func): + self.assertEqual(func(bstr), res) + self.assertEqual(func(bstr.decode('ascii')), res) with self.assertRaises(binascii.Error): base64.b64decode(bstr, validate=True) with self.assertRaises(binascii.Error): base64.b64decode(bstr.decode('ascii'), validate=True) + # Normal alphabet characters not discarded when alternative given + res = b'\xFB\xEF\xBE\xFF\xFF\xFF' + self.assertEqual(base64.b64decode(b'++[[//]]', b'[]'), res) + self.assertEqual(base64.urlsafe_b64decode(b'++--//__'), res) + def test_b32encode(self): eq = self.assertEqual eq(base64.b32encode(b''), b'') @@ -360,6 +372,10 @@ b'\x01\x02\xab\xcd\xef') eq(base64.b16decode(array('B', b"0102abcdef"), True), b'\x01\x02\xab\xcd\xef') + # Non-alphabet characters + self.assertRaises(binascii.Error, base64.b16decode, '0102AG') + # Incorrect "padding" + self.assertRaises(binascii.Error, base64.b16decode, '010') def test_a85encode(self): eq = self.assertEqual -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Feb 24 01:30:09 2016 From: python-checkins at python.org (nick.coghlan) Date: Wed, 24 Feb 2016 06:30:09 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_493=3A_address_review_com?= =?utf-8?q?ments_from_Barry?= Message-ID: <20160224063009.1949.64482@psf.io> https://hg.python.org/peps/rev/56216b91fcf0 changeset: 6243:56216b91fcf0 user: Nick Coghlan date: Wed Feb 24 16:29:59 2016 +1000 summary: PEP 493: address review comments from Barry files: pep-0493.txt | 19 +++++++++++-------- 1 files changed, 11 insertions(+), 8 deletions(-) diff --git a/pep-0493.txt b/pep-0493.txt --- a/pep-0493.txt +++ b/pep-0493.txt @@ -118,16 +118,19 @@ detecting them. Instead, they are designed to allow the presence or absence of the feature to be determined using the following technique:: - python -c "import ssl; ssl._relevant_attribute" + python -c "import ssl; ssl.<_relevant_attribute>" This will fail with `AttributeError` (and hence a non-zero return code) if the relevant capability is not available. +The feature detection attributes defined by this PEP are: + +* ``ssl._https_verify_certificates``: runtime configuration API +* ``ssl._https_verify_envvar``: environment based configuration +* ``ssl._cert_verification_config``: file based configuration (PEP 476 opt-in) + The marker attributes are prefixed with an underscore to indicate the -implementation dependent nature of these capabilities - not all Python -distributions will offer them, only those that are providing a multi-stage -migration process from the original Python 2.7 HTTPS handling to the new -default behaviour. +implementation dependent and security sensitive nature of these capabilities. Feature: Configuration API @@ -186,7 +189,7 @@ This change is proposed for inclusion in CPython 2.7.12 and later CPython 2.7.x releases. It consists of a new ``PYTHONHTTPSVERIFY`` environment variable that -allows the default verification to be disabled without modifying the +can be set to ``'0'`` to disable the default verification without modifying the application source code (which may not even be available in cases of bytecode-only application distribution) @@ -285,7 +288,7 @@ There's no specific attribute indicating that this situation applies. Rather, it is indicated by the ``ssl._https_verify_certificates`` and ``ssl._https_verify_envvar`` attributes being present in a Python version that -is nominally older than Python 2.7.9. +is nominally older than Python 2.7.12. Specification ------------- @@ -501,7 +504,7 @@ verifying HTTPS certificates by default than that being provided by the upstream project * either the redistributor or the local infrastructure administrator has - determined that it is appropriate to retaing the default pre-2.7.9 behaviour + determined that it is appropriate to retain the default pre-2.7.9 behaviour (at least for the time being) Using an administrator controlled configuration file rather than an environment -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Wed Feb 24 01:30:16 2016 From: python-checkins at python.org (martin.panter) Date: Wed, 24 Feb 2016 06:30:16 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzU4MjQ6?= =?utf-8?q?_Fix_DatagramRequestHandler_tests_by_binding_the_client_socket?= Message-ID: <20160224063016.2117.1846@psf.io> https://hg.python.org/cpython/rev/92ae4a305858 changeset: 100309:92ae4a305858 branch: 2.7 parent: 100306:c62526580ff0 user: Martin Panter date: Wed Feb 24 04:45:33 2016 +0000 summary: Issue #5824: Fix DatagramRequestHandler tests by binding the client socket files: Lib/SocketServer.py | 8 ---- Lib/test/test_socketserver.py | 39 +++++++++++----------- 2 files changed, 19 insertions(+), 28 deletions(-) diff --git a/Lib/SocketServer.py b/Lib/SocketServer.py --- a/Lib/SocketServer.py +++ b/Lib/SocketServer.py @@ -121,11 +121,6 @@ # Author of the BaseServer patch: Luke Kenneth Casson Leighton -# XXX Warning! -# There is a test suite for this module, but it cannot be run by the -# standard regression test. -# To run it manually, run Lib/test/test_socketserver.py. - __version__ = "0.4" @@ -721,9 +716,6 @@ class DatagramRequestHandler(BaseRequestHandler): - # XXX Regrettably, I cannot get this working on Linux; - # s.recvfrom() doesn't return a meaningful client address. - """Define self.rfile and self.wfile for datagram sockets.""" def setup(self): diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py --- a/Lib/test/test_socketserver.py +++ b/Lib/test/test_socketserver.py @@ -175,6 +175,8 @@ def dgram_examine(self, proto, addr): s = socket.socket(proto, socket.SOCK_DGRAM) + if HAVE_UNIX_SOCKETS and proto == socket.AF_UNIX: + s.bind(self.pickaddr(proto)) s.sendto(TEST_STR, addr) buf = data = receive(s, 100) while data and '\n' not in buf: @@ -269,27 +271,24 @@ # Make sure select was called again: self.assertGreater(mock_select.called, 1) - # Alas, on Linux (at least) recvfrom() doesn't return a meaningful - # client address so this cannot work: + @requires_unix_sockets + def test_UnixDatagramServer(self): + self.run_server(SocketServer.UnixDatagramServer, + SocketServer.DatagramRequestHandler, + self.dgram_examine) - # @requires_unix_sockets - # def test_UnixDatagramServer(self): - # self.run_server(SocketServer.UnixDatagramServer, - # SocketServer.DatagramRequestHandler, - # self.dgram_examine) - # - # @requires_unix_sockets - # def test_ThreadingUnixDatagramServer(self): - # self.run_server(SocketServer.ThreadingUnixDatagramServer, - # SocketServer.DatagramRequestHandler, - # self.dgram_examine) - # - # @requires_unix_sockets - # @requires_forking - # def test_ForkingUnixDatagramServer(self): - # self.run_server(SocketServer.ForkingUnixDatagramServer, - # SocketServer.DatagramRequestHandler, - # self.dgram_examine) + @requires_unix_sockets + def test_ThreadingUnixDatagramServer(self): + self.run_server(SocketServer.ThreadingUnixDatagramServer, + SocketServer.DatagramRequestHandler, + self.dgram_examine) + + @requires_unix_sockets + @requires_forking + def test_ForkingUnixDatagramServer(self): + self.run_server(ForkingUnixDatagramServer, + SocketServer.DatagramRequestHandler, + self.dgram_examine) @reap_threads def test_shutdown(self): -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Feb 24 01:30:16 2016 From: python-checkins at python.org (martin.panter) Date: Wed, 24 Feb 2016 06:30:16 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzU4MjQ6?= =?utf-8?q?_Fix_DatagramRequestHandler_tests_by_binding_the_client_socket?= Message-ID: <20160224063016.1993.75759@psf.io> https://hg.python.org/cpython/rev/0d9d8fdd9736 changeset: 100310:0d9d8fdd9736 branch: 3.5 parent: 100307:c8933fbc9171 user: Martin Panter date: Wed Feb 24 05:12:59 2016 +0000 summary: Issue #5824: Fix DatagramRequestHandler tests by binding the client socket files: Lib/socketserver.py | 8 ---- Lib/test/test_socketserver.py | 39 +++++++++++----------- 2 files changed, 19 insertions(+), 28 deletions(-) diff --git a/Lib/socketserver.py b/Lib/socketserver.py --- a/Lib/socketserver.py +++ b/Lib/socketserver.py @@ -120,11 +120,6 @@ # Author of the BaseServer patch: Luke Kenneth Casson Leighton -# XXX Warning! -# There is a test suite for this module, but it cannot be run by the -# standard regression test. -# To run it manually, run Lib/test/test_socketserver.py. - __version__ = "0.4" @@ -750,9 +745,6 @@ class DatagramRequestHandler(BaseRequestHandler): - # XXX Regrettably, I cannot get this working on Linux; - # s.recvfrom() doesn't return a meaningful client address. - """Define self.rfile and self.wfile for datagram sockets.""" def setup(self): diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py --- a/Lib/test/test_socketserver.py +++ b/Lib/test/test_socketserver.py @@ -160,6 +160,8 @@ def dgram_examine(self, proto, addr): s = socket.socket(proto, socket.SOCK_DGRAM) + if HAVE_UNIX_SOCKETS and proto == socket.AF_UNIX: + s.bind(self.pickaddr(proto)) s.sendto(TEST_STR, addr) buf = data = receive(s, 100) while data and b'\n' not in buf: @@ -222,27 +224,24 @@ socketserver.DatagramRequestHandler, self.dgram_examine) - # Alas, on Linux (at least) recvfrom() doesn't return a meaningful - # client address so this cannot work: + @requires_unix_sockets + def test_UnixDatagramServer(self): + self.run_server(socketserver.UnixDatagramServer, + socketserver.DatagramRequestHandler, + self.dgram_examine) - # @requires_unix_sockets - # def test_UnixDatagramServer(self): - # self.run_server(socketserver.UnixDatagramServer, - # socketserver.DatagramRequestHandler, - # self.dgram_examine) - # - # @requires_unix_sockets - # def test_ThreadingUnixDatagramServer(self): - # self.run_server(socketserver.ThreadingUnixDatagramServer, - # socketserver.DatagramRequestHandler, - # self.dgram_examine) - # - # @requires_unix_sockets - # @requires_forking - # def test_ForkingUnixDatagramServer(self): - # self.run_server(socketserver.ForkingUnixDatagramServer, - # socketserver.DatagramRequestHandler, - # self.dgram_examine) + @requires_unix_sockets + def test_ThreadingUnixDatagramServer(self): + self.run_server(socketserver.ThreadingUnixDatagramServer, + socketserver.DatagramRequestHandler, + self.dgram_examine) + + @requires_unix_sockets + @requires_forking + def test_ForkingUnixDatagramServer(self): + self.run_server(ForkingUnixDatagramServer, + socketserver.DatagramRequestHandler, + self.dgram_examine) @reap_threads def test_shutdown(self): -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Feb 24 01:30:21 2016 From: python-checkins at python.org (martin.panter) Date: Wed, 24 Feb 2016 06:30:21 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=235824=3A_Merge_socketserver_tests_from_3=2E5?= Message-ID: <20160224063016.1699.65678@psf.io> https://hg.python.org/cpython/rev/113e9c6fd64d changeset: 100311:113e9c6fd64d parent: 100308:5ad27dcd5a97 parent: 100310:0d9d8fdd9736 user: Martin Panter date: Wed Feb 24 06:14:15 2016 +0000 summary: Issue #5824: Merge socketserver tests from 3.5 files: Lib/socketserver.py | 8 ---- Lib/test/test_socketserver.py | 39 +++++++++++----------- 2 files changed, 19 insertions(+), 28 deletions(-) diff --git a/Lib/socketserver.py b/Lib/socketserver.py --- a/Lib/socketserver.py +++ b/Lib/socketserver.py @@ -120,11 +120,6 @@ # Author of the BaseServer patch: Luke Kenneth Casson Leighton -# XXX Warning! -# There is a test suite for this module, but it cannot be run by the -# standard regression test. -# To run it manually, run Lib/test/test_socketserver.py. - __version__ = "0.4" @@ -755,9 +750,6 @@ class DatagramRequestHandler(BaseRequestHandler): - # XXX Regrettably, I cannot get this working on Linux; - # s.recvfrom() doesn't return a meaningful client address. - """Define self.rfile and self.wfile for datagram sockets.""" def setup(self): diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py --- a/Lib/test/test_socketserver.py +++ b/Lib/test/test_socketserver.py @@ -161,6 +161,8 @@ def dgram_examine(self, proto, addr): s = socket.socket(proto, socket.SOCK_DGRAM) + if HAVE_UNIX_SOCKETS and proto == socket.AF_UNIX: + s.bind(self.pickaddr(proto)) s.sendto(TEST_STR, addr) buf = data = receive(s, 100) while data and b'\n' not in buf: @@ -223,27 +225,24 @@ socketserver.DatagramRequestHandler, self.dgram_examine) - # Alas, on Linux (at least) recvfrom() doesn't return a meaningful - # client address so this cannot work: + @requires_unix_sockets + def test_UnixDatagramServer(self): + self.run_server(socketserver.UnixDatagramServer, + socketserver.DatagramRequestHandler, + self.dgram_examine) - # @requires_unix_sockets - # def test_UnixDatagramServer(self): - # self.run_server(socketserver.UnixDatagramServer, - # socketserver.DatagramRequestHandler, - # self.dgram_examine) - # - # @requires_unix_sockets - # def test_ThreadingUnixDatagramServer(self): - # self.run_server(socketserver.ThreadingUnixDatagramServer, - # socketserver.DatagramRequestHandler, - # self.dgram_examine) - # - # @requires_unix_sockets - # @requires_forking - # def test_ForkingUnixDatagramServer(self): - # self.run_server(socketserver.ForkingUnixDatagramServer, - # socketserver.DatagramRequestHandler, - # self.dgram_examine) + @requires_unix_sockets + def test_ThreadingUnixDatagramServer(self): + self.run_server(socketserver.ThreadingUnixDatagramServer, + socketserver.DatagramRequestHandler, + self.dgram_examine) + + @requires_unix_sockets + @requires_forking + def test_ForkingUnixDatagramServer(self): + self.run_server(ForkingUnixDatagramServer, + socketserver.DatagramRequestHandler, + self.dgram_examine) @reap_threads def test_shutdown(self): -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Wed Feb 24 04:46:42 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Wed, 24 Feb 2016 09:46:42 +0000 Subject: [Python-checkins] Daily reference leaks (5ad27dcd5a97): sum=61 Message-ID: <20160224094642.1925.58520@psf.io> results for 5ad27dcd5a97 on branch "default" -------------------------------------------- test_collections leaked [0, 0, -2] references, sum=-2 test_functools leaked [0, 2, 2] memory blocks, sum=4 test_multiprocessing_fork leaked [38, 0, 0] references, sum=38 test_multiprocessing_fork leaked [18, 0, 1] memory blocks, sum=19 test_multiprocessing_fork leaked [2, 0, 0] file descriptors, sum=2 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogQPjDEG', '--timeout', '7200'] From python-checkins at python.org Wed Feb 24 05:08:26 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 24 Feb 2016 10:08:26 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325913=3A_Leading_=3C=7E_is_optional_now_in_base?= =?utf-8?q?64=2Ea85decode=28=29_with_adobe=3DTrue=2E?= Message-ID: <20160224100826.1975.22038@psf.io> https://hg.python.org/cpython/rev/90d5473b8673 changeset: 100313:90d5473b8673 parent: 100311:113e9c6fd64d parent: 100312:ce5bf3290621 user: Serhiy Storchaka date: Wed Feb 24 12:08:11 2016 +0200 summary: Issue #25913: Leading <~ is optional now in base64.a85decode() with adobe=True. Patch by Swati Jaiswal. files: Lib/base64.py | 13 +++++++++---- Lib/test/test_base64.py | 3 +-- Misc/NEWS | 5 ++++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Lib/base64.py b/Lib/base64.py --- a/Lib/base64.py +++ b/Lib/base64.py @@ -366,10 +366,15 @@ """ b = _bytes_from_decode_data(b) if adobe: - if not (b.startswith(_A85START) and b.endswith(_A85END)): - raise ValueError("Ascii85 encoded byte sequences must be bracketed " - "by {!r} and {!r}".format(_A85START, _A85END)) - b = b[2:-2] # Strip off start/end markers + if not b.endswith(_A85END): + raise ValueError( + "Ascii85 encoded byte sequences must end " + "with {!r}".format(_A85END) + ) + if b.startswith(_A85START): + b = b[2:-2] # Strip off start/end markers + else: + b = b[:-2] # # We have to go through this stepwise, so as to ignore spaces and handle # special short sequences diff --git a/Lib/test/test_base64.py b/Lib/test/test_base64.py --- a/Lib/test/test_base64.py +++ b/Lib/test/test_base64.py @@ -494,6 +494,7 @@ eq(base64.a85decode(data, adobe=False), res, data) eq(base64.a85decode(data.decode("ascii"), adobe=False), res, data) eq(base64.a85decode(b'<~' + data + b'~>', adobe=True), res, data) + eq(base64.a85decode(data + b'~>', adobe=True), res, data) eq(base64.a85decode('<~%s~>' % data.decode("ascii"), adobe=True), res, data) @@ -584,8 +585,6 @@ b"malformed", adobe=True) self.assertRaises(ValueError, base64.a85decode, b"<~still malformed", adobe=True) - self.assertRaises(ValueError, base64.a85decode, - b"also malformed~>", adobe=True) # With adobe=False (the default), Adobe framing markers are disallowed self.assertRaises(ValueError, base64.a85decode, diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -186,7 +186,10 @@ Library ------- -Issue #26186: Remove an invalid type check in importlib.util.LazyLoader. +- Issue #25913: Leading ``<~`` is optional now in base64.a85decode() with + adobe=True. Patch by Swati Jaiswal. + +- Issue #26186: Remove an invalid type check in importlib.util.LazyLoader. - Issue #26367: importlib.__import__() raises ImportError like builtins.__import__() when ``level`` is specified but without an accompanying -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Feb 24 05:08:26 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 24 Feb 2016 10:08:26 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1OTEz?= =?utf-8?q?=3A_Leading_=3C=7E_is_optional_now_in_base64=2Ea85decode=28=29_?= =?utf-8?q?with_adobe=3DTrue=2E?= Message-ID: <20160224100826.1969.7326@psf.io> https://hg.python.org/cpython/rev/ce5bf3290621 changeset: 100312:ce5bf3290621 branch: 3.5 parent: 100310:0d9d8fdd9736 user: Serhiy Storchaka date: Wed Feb 24 12:05:50 2016 +0200 summary: Issue #25913: Leading <~ is optional now in base64.a85decode() with adobe=True. Patch by Swati Jaiswal. files: Lib/base64.py | 13 +++++++++---- Lib/test/test_base64.py | 3 +-- Misc/NEWS | 3 +++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Lib/base64.py b/Lib/base64.py --- a/Lib/base64.py +++ b/Lib/base64.py @@ -367,10 +367,15 @@ """ b = _bytes_from_decode_data(b) if adobe: - if not (b.startswith(_A85START) and b.endswith(_A85END)): - raise ValueError("Ascii85 encoded byte sequences must be bracketed " - "by {!r} and {!r}".format(_A85START, _A85END)) - b = b[2:-2] # Strip off start/end markers + if not b.endswith(_A85END): + raise ValueError( + "Ascii85 encoded byte sequences must end " + "with {!r}".format(_A85END) + ) + if b.startswith(_A85START): + b = b[2:-2] # Strip off start/end markers + else: + b = b[:-2] # # We have to go through this stepwise, so as to ignore spaces and handle # special short sequences diff --git a/Lib/test/test_base64.py b/Lib/test/test_base64.py --- a/Lib/test/test_base64.py +++ b/Lib/test/test_base64.py @@ -494,6 +494,7 @@ eq(base64.a85decode(data, adobe=False), res, data) eq(base64.a85decode(data.decode("ascii"), adobe=False), res, data) eq(base64.a85decode(b'<~' + data + b'~>', adobe=True), res, data) + eq(base64.a85decode(data + b'~>', adobe=True), res, data) eq(base64.a85decode('<~%s~>' % data.decode("ascii"), adobe=True), res, data) @@ -584,8 +585,6 @@ b"malformed", adobe=True) self.assertRaises(ValueError, base64.a85decode, b"<~still malformed", adobe=True) - self.assertRaises(ValueError, base64.a85decode, - b"also malformed~>", adobe=True) # With adobe=False (the default), Adobe framing markers are disallowed self.assertRaises(ValueError, base64.a85decode, diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -76,6 +76,9 @@ Library ------- +- Issue #25913: Leading ``<~`` is optional now in base64.a85decode() with + adobe=True. Patch by Swati Jaiswal. + - Issue #26186: Remove an invalid type check in importlib.util.LazyLoader. - Issue #26367: importlib.__import__() raises SystemError like -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Feb 24 05:17:10 2016 From: python-checkins at python.org (nick.coghlan) Date: Wed, 24 Feb 2016 10:17:10 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_493=3A_add_new_post_date?= Message-ID: <20160224101705.1519.65141@psf.io> https://hg.python.org/peps/rev/9cd3ca378b98 changeset: 6244:9cd3ca378b98 user: Nick Coghlan date: Wed Feb 24 20:16:56 2016 +1000 summary: PEP 493: add new post date files: pep-0493.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/pep-0493.txt b/pep-0493.txt --- a/pep-0493.txt +++ b/pep-0493.txt @@ -11,7 +11,7 @@ Content-Type: text/x-rst Created: 10-May-2015 Python-Version: 2.7.12 -Post-History: 06-Jul-2015, 11-Nov-2015, 24-Nov-2015 +Post-History: 06-Jul-2015, 11-Nov-2015, 24-Nov-2015, 24-Feb-2016 Abstract -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Wed Feb 24 06:04:54 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 24 Feb 2016 11:04:54 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Fixed_a_bug_in?= =?utf-8?q?_os=2Ewalk=28=29_with_bytes_path_on_Windows_caused_by_merging_f?= =?utf-8?q?ixes?= Message-ID: <20160224110453.1961.3213@psf.io> https://hg.python.org/cpython/rev/9bffe39e8273 changeset: 100314:9bffe39e8273 branch: 3.5 parent: 100312:ce5bf3290621 user: Serhiy Storchaka date: Wed Feb 24 13:03:54 2016 +0200 summary: Fixed a bug in os.walk() with bytes path on Windows caused by merging fixes for issues #25995 and #25911. files: Lib/os.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/os.py b/Lib/os.py --- a/Lib/os.py +++ b/Lib/os.py @@ -369,7 +369,7 @@ # Note that scandir is global in this module due # to earlier import-*. scandir_it = scandir(top) - entries = list(scandir(top)) + entries = list(scandir_it) except OSError as error: if onerror is not None: onerror(error) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Feb 24 06:04:57 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 24 Feb 2016 11:04:57 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Null_merge?= Message-ID: <20160224110454.1723.70369@psf.io> https://hg.python.org/cpython/rev/47fa003aa9f1 changeset: 100315:47fa003aa9f1 parent: 100313:90d5473b8673 parent: 100314:9bffe39e8273 user: Serhiy Storchaka date: Wed Feb 24 13:04:33 2016 +0200 summary: Null merge files: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Feb 24 08:51:49 2016 From: python-checkins at python.org (jason.coombs) Date: Wed, 24 Feb 2016 13:51:49 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326302=3A_merge_from_3=2E5?= Message-ID: <20160224135145.1552.45049@psf.io> https://hg.python.org/cpython/rev/91eb7ae951a1 changeset: 100317:91eb7ae951a1 parent: 100315:47fa003aa9f1 parent: 100316:758cb13aaa2c user: Jason R. Coombs date: Wed Feb 24 08:50:59 2016 -0500 summary: Issue #26302: merge from 3.5 files: Lib/http/cookies.py | 2 +- Lib/test/test_http_cookies.py | 6 ++++++ Misc/NEWS | 3 +++ 3 files changed, 10 insertions(+), 1 deletions(-) diff --git a/Lib/http/cookies.py b/Lib/http/cookies.py --- a/Lib/http/cookies.py +++ b/Lib/http/cookies.py @@ -174,7 +174,7 @@ ord('\\'): '\\\\', }) -_is_legal_key = re.compile('[%s]+' % _LegalChars).fullmatch +_is_legal_key = re.compile('[%s]+' % re.escape(_LegalChars)).fullmatch def _quote(str): r"""Quote a string for use in a cookie header. diff --git a/Lib/test/test_http_cookies.py b/Lib/test/test_http_cookies.py --- a/Lib/test/test_http_cookies.py +++ b/Lib/test/test_http_cookies.py @@ -210,6 +210,12 @@ C1 = pickle.loads(pickle.dumps(C, protocol=proto)) self.assertEqual(C1.output(), expected_output) + def test_illegal_chars(self): + rawdata = "a=b; c,d=e" + C = cookies.SimpleCookie() + with self.assertRaises(cookies.CookieError): + C.load(rawdata) + class MorselTests(unittest.TestCase): """Tests for the Morsel object.""" diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #26302: Correct behavior to reject comma as a legal character for + cookie names. + - Issue #26136: Upgrade the warning when a generator raises StopIteration from PendingDeprecationWarning to DeprecationWarning. Patch by Anish Shah. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Feb 24 08:51:51 2016 From: python-checkins at python.org (jason.coombs) Date: Wed, 24 Feb 2016 13:51:51 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2MzAy?= =?utf-8?q?=3A_Correctly_identify_comma_as_an_invalid_character_for_a_cook?= =?utf-8?q?ie?= Message-ID: <20160224135140.1975.23704@psf.io> https://hg.python.org/cpython/rev/758cb13aaa2c changeset: 100316:758cb13aaa2c branch: 3.5 parent: 100314:9bffe39e8273 user: Anish Shah date: Sun Feb 07 05:36:00 2016 +0500 summary: Issue #26302: Correctly identify comma as an invalid character for a cookie (correcting regression in Python 3.5). files: Lib/http/cookies.py | 2 +- Lib/test/test_http_cookies.py | 6 ++++++ Misc/NEWS | 3 +++ 3 files changed, 10 insertions(+), 1 deletions(-) diff --git a/Lib/http/cookies.py b/Lib/http/cookies.py --- a/Lib/http/cookies.py +++ b/Lib/http/cookies.py @@ -174,7 +174,7 @@ ord('\\'): '\\\\', }) -_is_legal_key = re.compile('[%s]+' % _LegalChars).fullmatch +_is_legal_key = re.compile('[%s]+' % re.escape(_LegalChars)).fullmatch def _quote(str): r"""Quote a string for use in a cookie header. diff --git a/Lib/test/test_http_cookies.py b/Lib/test/test_http_cookies.py --- a/Lib/test/test_http_cookies.py +++ b/Lib/test/test_http_cookies.py @@ -210,6 +210,12 @@ C1 = pickle.loads(pickle.dumps(C, protocol=proto)) self.assertEqual(C1.output(), expected_output) + def test_illegal_chars(self): + rawdata = "a=b; c,d=e" + C = cookies.SimpleCookie() + with self.assertRaises(cookies.CookieError): + C.load(rawdata) + class MorselTests(unittest.TestCase): """Tests for the Morsel object.""" diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #26302: Correct behavior to reject comma as a legal character for + cookie names. + - Issue #4806: Avoid masking the original TypeError exception when using star (*) unpacking in function calls. Based on patch by Hagen F?rstenau and Daniel Urban. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Feb 24 09:00:06 2016 From: python-checkins at python.org (ned.deily) Date: Wed, 24 Feb 2016 14:00:06 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI1MTM2?= =?utf-8?q?=3A_Support_Apple_Xcode_7=27s_new_textual_SDK_stub_libraries=2E?= Message-ID: <20160224140005.1985.58388@psf.io> https://hg.python.org/cpython/rev/59d797915dca changeset: 100318:59d797915dca branch: 2.7 parent: 100309:92ae4a305858 user: Ned Deily date: Thu Feb 25 00:55:24 2016 +1100 summary: Issue #25136: Support Apple Xcode 7's new textual SDK stub libraries. As of Xcode 7, SDKs for Apple platforms now include textual-format stub libraries whose file names have a .tbd extension rather than the standard OS X .dylib extension. The Apple compiler tool chain handles these stub libraries transparently and the installed system shared libraries are still .dylibs. However, the new stub libraries cause problems for third-party programs that support building with Apple SDKs and make build-time decisions based on the presence or paths of system-supplied shared libraries in the SDK. In particular, building Python itself with an SDK fails to find system-supplied libraries during setup.py's build of standard library extension modules. The solution is to have find_library_file() in Distutils search for .tbd files, along with the existing types (.a, .so, and .dylib). Patch by Tim Smith. files: Lib/distutils/ccompiler.py | 5 +++-- Lib/distutils/unixccompiler.py | 22 ++++++++++++++++++++++ Misc/NEWS | 2 ++ setup.py | 16 ++++++++++++++++ 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/Lib/distutils/ccompiler.py b/Lib/distutils/ccompiler.py --- a/Lib/distutils/ccompiler.py +++ b/Lib/distutils/ccompiler.py @@ -842,8 +842,9 @@ def library_filename(self, libname, lib_type='static', # or 'shared' strip_dir=0, output_dir=''): assert output_dir is not None - if lib_type not in ("static", "shared", "dylib"): - raise ValueError, "'lib_type' must be \"static\", \"shared\" or \"dylib\"" + if lib_type not in ("static", "shared", "dylib", "xcode_stub"): + raise ValueError, ("""'lib_type' must be "static", "shared", """ + """"dylib", or "xcode_stub".""") fmt = getattr(self, lib_type + "_lib_format") ext = getattr(self, lib_type + "_lib_extension") diff --git a/Lib/distutils/unixccompiler.py b/Lib/distutils/unixccompiler.py --- a/Lib/distutils/unixccompiler.py +++ b/Lib/distutils/unixccompiler.py @@ -79,7 +79,9 @@ static_lib_extension = ".a" shared_lib_extension = ".so" dylib_lib_extension = ".dylib" + xcode_stub_lib_extension = ".tbd" static_lib_format = shared_lib_format = dylib_lib_format = "lib%s%s" + xcode_stub_lib_format = dylib_lib_format if sys.platform == "cygwin": exe_extension = ".exe" @@ -245,12 +247,28 @@ def find_library_file(self, dirs, lib, debug=0): shared_f = self.library_filename(lib, lib_type='shared') dylib_f = self.library_filename(lib, lib_type='dylib') + xcode_stub_f = self.library_filename(lib, lib_type='xcode_stub') static_f = self.library_filename(lib, lib_type='static') if sys.platform == 'darwin': # On OSX users can specify an alternate SDK using # '-isysroot', calculate the SDK root if it is specified # (and use it further on) + # + # Note that, as of Xcode 7, Apple SDKs may contain textual stub + # libraries with .tbd extensions rather than the normal .dylib + # shared libraries installed in /. The Apple compiler tool + # chain handles this transparently but it can cause problems + # for programs that are being built with an SDK and searching + # for specific libraries. Callers of find_library_file need to + # keep in mind that the base filename of the returned SDK library + # file might have a different extension from that of the library + # file installed on the running system, for example: + # /Applications/Xcode.app/Contents/Developer/Platforms/ + # MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/ + # usr/lib/libedit.tbd + # vs + # /usr/lib/libedit.dylib cflags = sysconfig.get_config_var('CFLAGS') m = re.search(r'-isysroot\s+(\S+)', cflags) if m is None: @@ -264,6 +282,7 @@ shared = os.path.join(dir, shared_f) dylib = os.path.join(dir, dylib_f) static = os.path.join(dir, static_f) + xcode_stub = os.path.join(dir, xcode_stub_f) if sys.platform == 'darwin' and ( dir.startswith('/System/') or ( @@ -272,6 +291,7 @@ shared = os.path.join(sysroot, dir[1:], shared_f) dylib = os.path.join(sysroot, dir[1:], dylib_f) static = os.path.join(sysroot, dir[1:], static_f) + xcode_stub = os.path.join(sysroot, dir[1:], xcode_stub_f) # We're second-guessing the linker here, with not much hard # data to go on: GCC seems to prefer the shared library, so I'm @@ -279,6 +299,8 @@ # ignoring even GCC's "-static" option. So sue me. if os.path.exists(dylib): return dylib + elif os.path.exists(xcode_stub): + return xcode_stub elif os.path.exists(shared): return shared elif os.path.exists(static): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -160,6 +160,8 @@ - Issue #26268: Update Windows builds to use OpenSSL 1.0.2f. +- Issue #25136: Support Apple Xcode 7's new textual SDK stub libraries. + What's New in Python 2.7.11? ============================ diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -117,6 +117,22 @@ p = p.rstrip(os.sep) if host_platform == 'darwin' and is_macosx_sdk_path(p): + # Note that, as of Xcode 7, Apple SDKs may contain textual stub + # libraries with .tbd extensions rather than the normal .dylib + # shared libraries installed in /. The Apple compiler tool + # chain handles this transparently but it can cause problems + # for programs that are being built with an SDK and searching + # for specific libraries. Distutils find_library_file() now + # knows to also search for and return .tbd files. But callers + # of find_library_file need to keep in mind that the base filename + # of the returned SDK library file might have a different extension + # from that of the library file installed on the running system, + # for example: + # /Applications/Xcode.app/Contents/Developer/Platforms/ + # MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/ + # usr/lib/libedit.tbd + # vs + # /usr/lib/libedit.dylib if os.path.join(sysroot, p[1:]) == dirname: return [ ] -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Feb 24 09:00:06 2016 From: python-checkins at python.org (ned.deily) Date: Wed, 24 Feb 2016 14:00:06 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1MTM2?= =?utf-8?q?=3A_Support_Apple_Xcode_7=27s_new_textual_SDK_stub_libraries=2E?= Message-ID: <20160224140005.1951.48175@psf.io> https://hg.python.org/cpython/rev/b0490b8af7aa changeset: 100319:b0490b8af7aa branch: 3.5 parent: 100316:758cb13aaa2c user: Ned Deily date: Thu Feb 25 00:56:38 2016 +1100 summary: Issue #25136: Support Apple Xcode 7's new textual SDK stub libraries. As of Xcode 7, SDKs for Apple platforms now include textual-format stub libraries whose file names have a .tbd extension rather than the standard OS X .dylib extension. The Apple compiler tool chain handles these stub libraries transparently and the installed system shared libraries are still .dylibs. However, the new stub libraries cause problems for third-party programs that support building with Apple SDKs and make build-time decisions based on the presence or paths of system-supplied shared libraries in the SDK. In particular, building Python itself with an SDK fails to find system-supplied libraries during setup.py's build of standard library extension modules. The solution is to have find_library_file() in Distutils search for .tbd files, along with the existing types (.a, .so, and .dylib). Patch by Tim Smith. files: Lib/distutils/ccompiler.py | 4 ++-- Lib/distutils/unixccompiler.py | 22 ++++++++++++++++++++++ Misc/NEWS | 2 ++ setup.py | 16 ++++++++++++++++ 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/Lib/distutils/ccompiler.py b/Lib/distutils/ccompiler.py --- a/Lib/distutils/ccompiler.py +++ b/Lib/distutils/ccompiler.py @@ -875,9 +875,9 @@ def library_filename(self, libname, lib_type='static', # or 'shared' strip_dir=0, output_dir=''): assert output_dir is not None - if lib_type not in ("static", "shared", "dylib"): + if lib_type not in ("static", "shared", "dylib", "xcode_stub"): raise ValueError( - "'lib_type' must be \"static\", \"shared\" or \"dylib\"") + "'lib_type' must be \"static\", \"shared\", \"dylib\", or \"xcode_stub\"") fmt = getattr(self, lib_type + "_lib_format") ext = getattr(self, lib_type + "_lib_extension") diff --git a/Lib/distutils/unixccompiler.py b/Lib/distutils/unixccompiler.py --- a/Lib/distutils/unixccompiler.py +++ b/Lib/distutils/unixccompiler.py @@ -76,7 +76,9 @@ static_lib_extension = ".a" shared_lib_extension = ".so" dylib_lib_extension = ".dylib" + xcode_stub_lib_extension = ".tbd" static_lib_format = shared_lib_format = dylib_lib_format = "lib%s%s" + xcode_stub_lib_format = dylib_lib_format if sys.platform == "cygwin": exe_extension = ".exe" @@ -255,12 +257,28 @@ def find_library_file(self, dirs, lib, debug=0): shared_f = self.library_filename(lib, lib_type='shared') dylib_f = self.library_filename(lib, lib_type='dylib') + xcode_stub_f = self.library_filename(lib, lib_type='xcode_stub') static_f = self.library_filename(lib, lib_type='static') if sys.platform == 'darwin': # On OSX users can specify an alternate SDK using # '-isysroot', calculate the SDK root if it is specified # (and use it further on) + # + # Note that, as of Xcode 7, Apple SDKs may contain textual stub + # libraries with .tbd extensions rather than the normal .dylib + # shared libraries installed in /. The Apple compiler tool + # chain handles this transparently but it can cause problems + # for programs that are being built with an SDK and searching + # for specific libraries. Callers of find_library_file need to + # keep in mind that the base filename of the returned SDK library + # file might have a different extension from that of the library + # file installed on the running system, for example: + # /Applications/Xcode.app/Contents/Developer/Platforms/ + # MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/ + # usr/lib/libedit.tbd + # vs + # /usr/lib/libedit.dylib cflags = sysconfig.get_config_var('CFLAGS') m = re.search(r'-isysroot\s+(\S+)', cflags) if m is None: @@ -274,6 +292,7 @@ shared = os.path.join(dir, shared_f) dylib = os.path.join(dir, dylib_f) static = os.path.join(dir, static_f) + xcode_stub = os.path.join(dir, xcode_stub_f) if sys.platform == 'darwin' and ( dir.startswith('/System/') or ( @@ -282,6 +301,7 @@ shared = os.path.join(sysroot, dir[1:], shared_f) dylib = os.path.join(sysroot, dir[1:], dylib_f) static = os.path.join(sysroot, dir[1:], static_f) + xcode_stub = os.path.join(sysroot, dir[1:], xcode_stub_f) # We're second-guessing the linker here, with not much hard # data to go on: GCC seems to prefer the shared library, so I'm @@ -289,6 +309,8 @@ # ignoring even GCC's "-static" option. So sue me. if os.path.exists(dylib): return dylib + elif os.path.exists(xcode_stub): + return xcode_stub elif os.path.exists(shared): return shared elif os.path.exists(static): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -270,6 +270,8 @@ - Issue #26268: Update OS X 10.5 installer and Windows builds to use OpenSSL 1.0.2f. +- Issue #25136: Support Apple Xcode 7's new textual SDK stub libraries. + Windows ------- diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -136,6 +136,22 @@ p = p.rstrip(os.sep) if host_platform == 'darwin' and is_macosx_sdk_path(p): + # Note that, as of Xcode 7, Apple SDKs may contain textual stub + # libraries with .tbd extensions rather than the normal .dylib + # shared libraries installed in /. The Apple compiler tool + # chain handles this transparently but it can cause problems + # for programs that are being built with an SDK and searching + # for specific libraries. Distutils find_library_file() now + # knows to also search for and return .tbd files. But callers + # of find_library_file need to keep in mind that the base filename + # of the returned SDK library file might have a different extension + # from that of the library file installed on the running system, + # for example: + # /Applications/Xcode.app/Contents/Developer/Platforms/ + # MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/ + # usr/lib/libedit.tbd + # vs + # /usr/lib/libedit.dylib if os.path.join(sysroot, p[1:]) == dirname: return [ ] -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Feb 24 09:00:16 2016 From: python-checkins at python.org (ned.deily) Date: Wed, 24 Feb 2016 14:00:16 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325136=3A_merge_from_3=2E5?= Message-ID: <20160224140005.1542.33372@psf.io> https://hg.python.org/cpython/rev/db6c1308eb31 changeset: 100320:db6c1308eb31 parent: 100317:91eb7ae951a1 parent: 100319:b0490b8af7aa user: Ned Deily date: Thu Feb 25 00:59:16 2016 +1100 summary: Issue #25136: merge from 3.5 files: Lib/distutils/ccompiler.py | 4 ++-- Lib/distutils/unixccompiler.py | 22 ++++++++++++++++++++++ Misc/NEWS | 1 + setup.py | 16 ++++++++++++++++ 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/Lib/distutils/ccompiler.py b/Lib/distutils/ccompiler.py --- a/Lib/distutils/ccompiler.py +++ b/Lib/distutils/ccompiler.py @@ -875,9 +875,9 @@ def library_filename(self, libname, lib_type='static', # or 'shared' strip_dir=0, output_dir=''): assert output_dir is not None - if lib_type not in ("static", "shared", "dylib"): + if lib_type not in ("static", "shared", "dylib", "xcode_stub"): raise ValueError( - "'lib_type' must be \"static\", \"shared\" or \"dylib\"") + "'lib_type' must be \"static\", \"shared\", \"dylib\", or \"xcode_stub\"") fmt = getattr(self, lib_type + "_lib_format") ext = getattr(self, lib_type + "_lib_extension") diff --git a/Lib/distutils/unixccompiler.py b/Lib/distutils/unixccompiler.py --- a/Lib/distutils/unixccompiler.py +++ b/Lib/distutils/unixccompiler.py @@ -76,7 +76,9 @@ static_lib_extension = ".a" shared_lib_extension = ".so" dylib_lib_extension = ".dylib" + xcode_stub_lib_extension = ".tbd" static_lib_format = shared_lib_format = dylib_lib_format = "lib%s%s" + xcode_stub_lib_format = dylib_lib_format if sys.platform == "cygwin": exe_extension = ".exe" @@ -255,12 +257,28 @@ def find_library_file(self, dirs, lib, debug=0): shared_f = self.library_filename(lib, lib_type='shared') dylib_f = self.library_filename(lib, lib_type='dylib') + xcode_stub_f = self.library_filename(lib, lib_type='xcode_stub') static_f = self.library_filename(lib, lib_type='static') if sys.platform == 'darwin': # On OSX users can specify an alternate SDK using # '-isysroot', calculate the SDK root if it is specified # (and use it further on) + # + # Note that, as of Xcode 7, Apple SDKs may contain textual stub + # libraries with .tbd extensions rather than the normal .dylib + # shared libraries installed in /. The Apple compiler tool + # chain handles this transparently but it can cause problems + # for programs that are being built with an SDK and searching + # for specific libraries. Callers of find_library_file need to + # keep in mind that the base filename of the returned SDK library + # file might have a different extension from that of the library + # file installed on the running system, for example: + # /Applications/Xcode.app/Contents/Developer/Platforms/ + # MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/ + # usr/lib/libedit.tbd + # vs + # /usr/lib/libedit.dylib cflags = sysconfig.get_config_var('CFLAGS') m = re.search(r'-isysroot\s+(\S+)', cflags) if m is None: @@ -274,6 +292,7 @@ shared = os.path.join(dir, shared_f) dylib = os.path.join(dir, dylib_f) static = os.path.join(dir, static_f) + xcode_stub = os.path.join(dir, xcode_stub_f) if sys.platform == 'darwin' and ( dir.startswith('/System/') or ( @@ -282,6 +301,7 @@ shared = os.path.join(sysroot, dir[1:], shared_f) dylib = os.path.join(sysroot, dir[1:], dylib_f) static = os.path.join(sysroot, dir[1:], static_f) + xcode_stub = os.path.join(sysroot, dir[1:], xcode_stub_f) # We're second-guessing the linker here, with not much hard # data to go on: GCC seems to prefer the shared library, so I'm @@ -289,6 +309,8 @@ # ignoring even GCC's "-static" option. So sue me. if os.path.exists(dylib): return dylib + elif os.path.exists(xcode_stub): + return xcode_stub elif os.path.exists(shared): return shared elif os.path.exists(static): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -763,6 +763,7 @@ - Issue #26268: Update OS X 10.5 installer and Windows builds to use OpenSSL 1.0.2f. +- Issue #25136: Support Apple Xcode 7's new textual SDK stub libraries. Windows ------- diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -136,6 +136,22 @@ p = p.rstrip(os.sep) if host_platform == 'darwin' and is_macosx_sdk_path(p): + # Note that, as of Xcode 7, Apple SDKs may contain textual stub + # libraries with .tbd extensions rather than the normal .dylib + # shared libraries installed in /. The Apple compiler tool + # chain handles this transparently but it can cause problems + # for programs that are being built with an SDK and searching + # for specific libraries. Distutils find_library_file() now + # knows to also search for and return .tbd files. But callers + # of find_library_file need to keep in mind that the base filename + # of the returned SDK library file might have a different extension + # from that of the library file installed on the running system, + # for example: + # /Applications/Xcode.app/Contents/Developer/Platforms/ + # MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/ + # usr/lib/libedit.tbd + # vs + # /usr/lib/libedit.dylib if os.path.join(sysroot, p[1:]) == dirname: return [ ] -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Feb 24 09:04:05 2016 From: python-checkins at python.org (ned.deily) Date: Wed, 24 Feb 2016 14:04:05 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Change_OS_X_installer_builds_targeted_for_10=2E10_and_ab?= =?utf-8?q?ove_to_build?= Message-ID: <20160224140405.1957.68179@psf.io> https://hg.python.org/cpython/rev/2b6ca6928e75 changeset: 100323:2b6ca6928e75 parent: 100320:db6c1308eb31 parent: 100322:261e71adaf65 user: Ned Deily date: Thu Feb 25 01:03:06 2016 +1100 summary: Change OS X installer builds targeted for 10.10 and above to build and link with a private copy of OpenSSL, like installers targeted for 10.5 already do, since Apple has deprecated use of the system OpenSSL and removed its header files from the Xcode 7 SDK. Note that this configuration is not currently used to build any python.org-supplied installers and that the private copy of OpenSSL requires its own root certificates. files: Mac/BuildScript/build-installer.py | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Mac/BuildScript/build-installer.py b/Mac/BuildScript/build-installer.py --- a/Mac/BuildScript/build-installer.py +++ b/Mac/BuildScript/build-installer.py @@ -206,7 +206,7 @@ LT_10_5 = bool(getDeptargetTuple() < (10, 5)) - if getDeptargetTuple() < (10, 6): + if not (10, 5) < getDeptargetTuple() < (10, 10): # The OpenSSL libs shipped with OS X 10.5 and earlier are # hopelessly out-of-date and do not include Apple's tie-in to # the root certificates in the user and system keychains via TEA @@ -226,7 +226,8 @@ # now more obvious with cert checking enabled by default in the # standard library. # - # For builds with 10.6+ SDKs, continue to use the deprecated but + # For builds with 10.6 through 10.9 SDKs, + # continue to use the deprecated but # less out-of-date Apple 0.9.8 libs for now. While they are less # secure than using an up-to-date 1.0.1 version, doing so # avoids the big problems of forcing users to have to manage @@ -234,6 +235,10 @@ # APIs for cert validation from keychains if validation using the # standard OpenSSL locations (/System/Library/OpenSSL, normally empty) # fails. + # + # Since Apple removed the header files for the deprecated system + # OpenSSL as of the Xcode 7 release (for OS X 10.10+), we do not + # have much choice but to build our own copy here, too. result.extend([ dict( -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Feb 24 09:04:05 2016 From: python-checkins at python.org (ned.deily) Date: Wed, 24 Feb 2016 14:04:05 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Change_OS_X_in?= =?utf-8?q?staller_builds_targeted_for_10=2E10_and_above_to_build?= Message-ID: <20160224140405.1973.42012@psf.io> https://hg.python.org/cpython/rev/261e71adaf65 changeset: 100322:261e71adaf65 branch: 3.5 parent: 100319:b0490b8af7aa user: Ned Deily date: Thu Feb 25 01:01:48 2016 +1100 summary: Change OS X installer builds targeted for 10.10 and above to build and link with a private copy of OpenSSL, like installers targeted for 10.5 already do, since Apple has deprecated use of the system OpenSSL and removed its header files from the Xcode 7 SDK. Note that this configuration is not currently used to build any python.org-supplied installers and that the private copy of OpenSSL requires its own root certificates. files: Mac/BuildScript/build-installer.py | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Mac/BuildScript/build-installer.py b/Mac/BuildScript/build-installer.py --- a/Mac/BuildScript/build-installer.py +++ b/Mac/BuildScript/build-installer.py @@ -206,7 +206,7 @@ LT_10_5 = bool(getDeptargetTuple() < (10, 5)) - if getDeptargetTuple() < (10, 6): + if not (10, 5) < getDeptargetTuple() < (10, 10): # The OpenSSL libs shipped with OS X 10.5 and earlier are # hopelessly out-of-date and do not include Apple's tie-in to # the root certificates in the user and system keychains via TEA @@ -226,7 +226,8 @@ # now more obvious with cert checking enabled by default in the # standard library. # - # For builds with 10.6+ SDKs, continue to use the deprecated but + # For builds with 10.6 through 10.9 SDKs, + # continue to use the deprecated but # less out-of-date Apple 0.9.8 libs for now. While they are less # secure than using an up-to-date 1.0.1 version, doing so # avoids the big problems of forcing users to have to manage @@ -234,6 +235,10 @@ # APIs for cert validation from keychains if validation using the # standard OpenSSL locations (/System/Library/OpenSSL, normally empty) # fails. + # + # Since Apple removed the header files for the deprecated system + # OpenSSL as of the Xcode 7 release (for OS X 10.10+), we do not + # have much choice but to build our own copy here, too. result.extend([ dict( -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Feb 24 09:04:18 2016 From: python-checkins at python.org (ned.deily) Date: Wed, 24 Feb 2016 14:04:18 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Change_OS_X_in?= =?utf-8?q?staller_builds_targeted_for_10=2E10_and_above_to_build?= Message-ID: <20160224140405.1695.56795@psf.io> https://hg.python.org/cpython/rev/d315e9f98bba changeset: 100321:d315e9f98bba branch: 2.7 parent: 100318:59d797915dca user: Ned Deily date: Thu Feb 25 01:01:02 2016 +1100 summary: Change OS X installer builds targeted for 10.10 and above to build and link with a private copy of OpenSSL, like installers targeted for 10.5 already do, since Apple has deprecated use of the system OpenSSL and removed its header files from the Xcode 7 SDK. Note that this configuration is not currently used to build any python.org-supplied installers and that the private copy of OpenSSL requires its own root certificates. files: Mac/BuildScript/build-installer.py | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Mac/BuildScript/build-installer.py b/Mac/BuildScript/build-installer.py --- a/Mac/BuildScript/build-installer.py +++ b/Mac/BuildScript/build-installer.py @@ -206,7 +206,7 @@ LT_10_5 = bool(getDeptargetTuple() < (10, 5)) - if getDeptargetTuple() < (10, 6): + if not (10, 5) < getDeptargetTuple() < (10, 10): # The OpenSSL libs shipped with OS X 10.5 and earlier are # hopelessly out-of-date and do not include Apple's tie-in to # the root certificates in the user and system keychains via TEA @@ -226,7 +226,8 @@ # now more obvious with cert checking enabled by default in the # standard library. # - # For builds with 10.6+ SDKs, continue to use the deprecated but + # For builds with 10.6 through 10.9 SDKs, + # continue to use the deprecated but # less out-of-date Apple 0.9.8 libs for now. While they are less # secure than using an up-to-date 1.0.1 version, doing so # avoids the big problems of forcing users to have to manage @@ -234,6 +235,10 @@ # APIs for cert validation from keychains if validation using the # standard OpenSSL locations (/System/Library/OpenSSL, normally empty) # fails. + # + # Since Apple removed the header files for the deprecated system + # OpenSSL as of the Xcode 7 release (for OS X 10.10+), we do not + # have much choice but to build our own copy here, too. result.extend([ dict( -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Feb 24 09:35:51 2016 From: python-checkins at python.org (ned.deily) Date: Wed, 24 Feb 2016 14:35:51 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325136=3A_merge_from_3=2E5?= Message-ID: <20160224143551.1991.17622@psf.io> https://hg.python.org/cpython/rev/2c4448bbed1f changeset: 100326:2c4448bbed1f parent: 100323:2b6ca6928e75 parent: 100325:61752c7ea9c7 user: Ned Deily date: Thu Feb 25 01:35:21 2016 +1100 summary: Issue #25136: merge from 3.5 files: Mac/README | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/Mac/README b/Mac/README --- a/Mac/README +++ b/Mac/README @@ -46,7 +46,12 @@ The optional argument specifies which OS X SDK should be used to perform the build. If xcodebuild is available and configured, this defaults to the Xcode default MacOS X SDK, otherwise ``/Developer/SDKs/MacOSX.10.4u.sdk`` - if available or ``/`` if not. + if available or ``/`` if not. When building on OS X 10.5 or later, you can + specify ``/`` to use the installed system headers rather than an SDK. As of + OS X 10.9, you should install the optional system headers from the Command + Line Tools component using ``xcode-select``:: + + $ sudo xcode-select --install See the section _`Building and using a universal binary of Python on Mac OS X` for more information. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Feb 24 09:35:51 2016 From: python-checkins at python.org (ned.deily) Date: Wed, 24 Feb 2016 14:35:51 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1MTM2?= =?utf-8?q?=3A_Add_reference_to_=27xcode-select_--install=27_to_Mac_README?= =?utf-8?q?=2E?= Message-ID: <20160224143551.1984.23373@psf.io> https://hg.python.org/cpython/rev/61752c7ea9c7 changeset: 100325:61752c7ea9c7 branch: 3.5 parent: 100322:261e71adaf65 user: Ned Deily date: Thu Feb 25 01:34:34 2016 +1100 summary: Issue #25136: Add reference to 'xcode-select --install' to Mac README. files: Mac/README | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/Mac/README b/Mac/README --- a/Mac/README +++ b/Mac/README @@ -46,7 +46,12 @@ The optional argument specifies which OS X SDK should be used to perform the build. If xcodebuild is available and configured, this defaults to the Xcode default MacOS X SDK, otherwise ``/Developer/SDKs/MacOSX.10.4u.sdk`` - if available or ``/`` if not. + if available or ``/`` if not. When building on OS X 10.5 or later, you can + specify ``/`` to use the installed system headers rather than an SDK. As of + OS X 10.9, you should install the optional system headers from the Command + Line Tools component using ``xcode-select``:: + + $ sudo xcode-select --install See the section _`Building and using a universal binary of Python on Mac OS X` for more information. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed Feb 24 09:35:58 2016 From: python-checkins at python.org (ned.deily) Date: Wed, 24 Feb 2016 14:35:58 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI1MTM2?= =?utf-8?q?=3A_Add_reference_to_=27xcode-select_--install=27_to_Mac_README?= =?utf-8?q?=2E?= Message-ID: <20160224143551.1678.94969@psf.io> https://hg.python.org/cpython/rev/157eb9d40bf9 changeset: 100324:157eb9d40bf9 branch: 2.7 parent: 100321:d315e9f98bba user: Ned Deily date: Thu Feb 25 01:33:51 2016 +1100 summary: Issue #25136: Add reference to 'xcode-select --install' to Mac README. files: Mac/README | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/Mac/README b/Mac/README --- a/Mac/README +++ b/Mac/README @@ -46,7 +46,10 @@ The optional argument specifies which OS X SDK should be used to perform the build. This defaults to ``/Developer/SDKs/MacOSX.10.4u.sdk``. When building on OS X 10.5 or later, you can specify ``/`` to use the installed system - headers rather than an SDK. + headers rather than an SDK. As of OS X 10.9, you should install the optional + system headers from the Command Line Tools component using ``xcode-select``:: + + $ sudo xcode-select --install See the section _`Building and using a universal binary of Python on Mac OS X` for more information. -- Repository URL: https://hg.python.org/cpython From lp_benchmark_robot at intel.com Wed Feb 24 11:35:00 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Wed, 24 Feb 2016 16:35:00 +0000 Subject: [Python-checkins] GOOD Benchmark Results for Python Default 2016-02-24 Message-ID: Results for project Python default, build date 2016-02-24 03:09:24 +0000 commit: 5ad27dcd5a97 previous commit: cbf83f55d5f3 revision date: 2016-02-24 01:08:43 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.20% 1.63% 10.68% 11.71% :-| pybench 0.16% 0.01% 0.37% 5.53% :-( regex_v8 2.86% -0.11% -4.85% 2.98% :-| nbody 0.10% -0.05% -1.56% 7.75% :-| json_dump_v2 0.26% -0.23% 0.25% 9.76% :-| normal_startup 1.06% 0.00% -0.41% 5.43% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/good-benchmark-results-for-python-default-2016-02-24/ Note: Benchmark results are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Wed Feb 24 11:46:32 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Wed, 24 Feb 2016 16:46:32 +0000 Subject: [Python-checkins] NEUTRAL Benchmark Results for Python 2.7 2016-02-24 Message-ID: <86ccb28c-3751-4206-9678-7d90f52f854a@irsmsx153.ger.corp.intel.com> Results for project Python 2.7, build date 2016-02-24 04:00:43 +0000 commit: c62526580ff0 previous commit: 3be29e684ccf revision date: 2016-02-23 22:30:50 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dc from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.14% 1.00% 6.41% 5.43% :-) pybench 0.10% -0.16% 6.17% 4.09% :-( regex_v8 0.81% -0.25% -2.85% 11.85% :-) nbody 0.14% -0.71% 7.14% 4.90% :-) json_dump_v2 0.26% 0.17% 3.90% 10.93% :-( normal_startup 1.85% -0.51% -6.00% 2.11% :-) ssbench 0.15% 0.13% 2.05% 1.95% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/neutral-benchmark-results-for-python-2-7-2016-02-24/ Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Thu Feb 25 03:21:56 2016 From: python-checkins at python.org (nick.coghlan) Date: Thu, 25 Feb 2016 08:21:56 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_493=3A_clarify_a_security?= =?utf-8?q?_caveat?= Message-ID: <20160225082155.1975.70322@psf.io> https://hg.python.org/peps/rev/a24451715d84 changeset: 6245:a24451715d84 user: Nick Coghlan date: Thu Feb 25 18:21:44 2016 +1000 summary: PEP 493: clarify a security caveat files: pep-0493.txt | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-) diff --git a/pep-0493.txt b/pep-0493.txt --- a/pep-0493.txt +++ b/pep-0493.txt @@ -246,10 +246,19 @@ approach does introduce a new downgrade attack against the default security settings that potentially allows a sufficiently determined attacker to revert Python to the default behaviour used in CPython 2.7.8 and earlier releases. -However, such an attack requires the ability to modify the execution -environment of a Python process prior to the import of the ``ssl`` module, -and any attacker with such access would already be able to modify the -behaviour of the underlying OpenSSL implementation. + +This slight increase in the available attack surface is the main reason why: + +* security sensitive applications should still define their own SSL context +* the migration features described in this PEP are not being added to Python 3 + +However, it's also worth keeping in mind that carrying out such an attack +requires the ability to modify the execution environment of a Python process +prior to the import of the ``ssl`` module. In combination with the ability +to write to any part of the filesystem (such as ``/tmp``), any attacker with +such access would already be able to modify the behaviour of the underlying +OpenSSL implementation, the dynamic library loader, and other potentially +security sensitive components. Interaction with Python virtual environments -------------------------------------------- -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Thu Feb 25 03:25:53 2016 From: python-checkins at python.org (raymond.hettinger) Date: Thu, 25 Feb 2016 08:25:53 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Fix_out-of-date_comment?= Message-ID: <20160225082553.2121.15357@psf.io> https://hg.python.org/cpython/rev/cd69b81d231d changeset: 100327:cd69b81d231d user: Raymond Hettinger date: Thu Feb 25 00:25:45 2016 -0800 summary: Fix out-of-date comment files: Lib/collections/__init__.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py --- a/Lib/collections/__init__.py +++ b/Lib/collections/__init__.py @@ -842,7 +842,7 @@ ######################################################################## -### ChainMap (helper for configparser and string.Template) +### ChainMap ######################################################################## class ChainMap(MutableMapping): -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 25 03:32:19 2016 From: python-checkins at python.org (nick.coghlan) Date: Thu, 25 Feb 2016 08:32:19 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_493=3A_slight_wording_twe?= =?utf-8?q?ak_for_accuracy?= Message-ID: <20160225083215.6242.44030@psf.io> https://hg.python.org/peps/rev/078c6fc968bf changeset: 6246:078c6fc968bf user: Nick Coghlan date: Thu Feb 25 18:32:06 2016 +1000 summary: PEP 493: slight wording tweak for accuracy files: pep-0493.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/pep-0493.txt b/pep-0493.txt --- a/pep-0493.txt +++ b/pep-0493.txt @@ -247,7 +247,7 @@ settings that potentially allows a sufficiently determined attacker to revert Python to the default behaviour used in CPython 2.7.8 and earlier releases. -This slight increase in the available attack surface is the main reason why: +This slight increase in the available attack surface is a key reason why: * security sensitive applications should still define their own SSL context * the migration features described in this PEP are not being added to Python 3 -- Repository URL: https://hg.python.org/peps From solipsis at pitrou.net Thu Feb 25 04:47:19 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Thu, 25 Feb 2016 09:47:19 +0000 Subject: [Python-checkins] Daily reference leaks (2c4448bbed1f): sum=4 Message-ID: <20160225094718.96736.27775@psf.io> results for 2c4448bbed1f on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogkL0uP2', '--timeout', '7200'] From python-checkins at python.org Thu Feb 25 06:16:33 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 25 Feb 2016 11:16:33 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1ODAx?= =?utf-8?q?=3A_Fixed_resource_warnings_in_test=5Fzipfile64=2E?= Message-ID: <20160225111633.1980.86902@psf.io> https://hg.python.org/cpython/rev/baec3e2e1b1f changeset: 100328:baec3e2e1b1f branch: 3.5 parent: 100325:61752c7ea9c7 user: Serhiy Storchaka date: Thu Feb 25 12:55:19 2016 +0200 summary: Issue #25801: Fixed resource warnings in test_zipfile64. Patch by SilentGhost. files: Lib/test/test_zipfile64.py | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_zipfile64.py b/Lib/test/test_zipfile64.py --- a/Lib/test/test_zipfile64.py +++ b/Lib/test/test_zipfile64.py @@ -72,15 +72,19 @@ def testStored(self): # Try the temp file first. If we do TESTFN2 first, then it hogs # gigabytes of disk space for the duration of the test. - for f in TemporaryFile(), TESTFN2: + with TemporaryFile() as f: self.zipTest(f, zipfile.ZIP_STORED) + self.assertFalse(f.closed) + self.zipTest(TESTFN2, zipfile.ZIP_STORED) @requires_zlib def testDeflated(self): # Try the temp file first. If we do TESTFN2 first, then it hogs # gigabytes of disk space for the duration of the test. - for f in TemporaryFile(), TESTFN2: + with TemporaryFile() as f: self.zipTest(f, zipfile.ZIP_DEFLATED) + self.assertFalse(f.closed) + self.zipTest(TESTFN2, zipfile.ZIP_DEFLATED) def tearDown(self): for fname in TESTFN, TESTFN2: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 25 06:16:41 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 25 Feb 2016 11:16:41 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325801=3A_Fixed_resource_warnings_in_test=5Fzipf?= =?utf-8?q?ile64=2E?= Message-ID: <20160225111633.6260.2896@psf.io> https://hg.python.org/cpython/rev/2193f8b956de changeset: 100330:2193f8b956de parent: 100327:cd69b81d231d parent: 100328:baec3e2e1b1f user: Serhiy Storchaka date: Thu Feb 25 13:16:02 2016 +0200 summary: Issue #25801: Fixed resource warnings in test_zipfile64. Patch by SilentGhost. files: Lib/test/test_zipfile64.py | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_zipfile64.py b/Lib/test/test_zipfile64.py --- a/Lib/test/test_zipfile64.py +++ b/Lib/test/test_zipfile64.py @@ -72,15 +72,19 @@ def testStored(self): # Try the temp file first. If we do TESTFN2 first, then it hogs # gigabytes of disk space for the duration of the test. - for f in TemporaryFile(), TESTFN2: + with TemporaryFile() as f: self.zipTest(f, zipfile.ZIP_STORED) + self.assertFalse(f.closed) + self.zipTest(TESTFN2, zipfile.ZIP_STORED) @requires_zlib def testDeflated(self): # Try the temp file first. If we do TESTFN2 first, then it hogs # gigabytes of disk space for the duration of the test. - for f in TemporaryFile(), TESTFN2: + with TemporaryFile() as f: self.zipTest(f, zipfile.ZIP_DEFLATED) + self.assertFalse(f.closed) + self.zipTest(TESTFN2, zipfile.ZIP_DEFLATED) def tearDown(self): for fname in TESTFN, TESTFN2: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 25 06:16:41 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 25 Feb 2016 11:16:41 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI1ODAx?= =?utf-8?q?=3A_Fixed_resource_warnings_in_test=5Fzipfile64=2E?= Message-ID: <20160225111633.96706.76952@psf.io> https://hg.python.org/cpython/rev/32051701a49d changeset: 100329:32051701a49d branch: 2.7 parent: 100324:157eb9d40bf9 user: Serhiy Storchaka date: Thu Feb 25 12:55:19 2016 +0200 summary: Issue #25801: Fixed resource warnings in test_zipfile64. Patch by SilentGhost. files: Lib/test/test_zipfile64.py | 18 +++++++++++------- 1 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Lib/test/test_zipfile64.py b/Lib/test/test_zipfile64.py --- a/Lib/test/test_zipfile64.py +++ b/Lib/test/test_zipfile64.py @@ -79,15 +79,19 @@ def testStored(self): # Try the temp file first. If we do TESTFN2 first, then it hogs # gigabytes of disk space for the duration of the test. - for f in TemporaryFile(), TESTFN2: + with TemporaryFile() as f: self.zipTest(f, zipfile.ZIP_STORED) + self.assertFalse(f.closed) + self.zipTest(TESTFN2, zipfile.ZIP_STORED) - if zlib: - def testDeflated(self): - # Try the temp file first. If we do TESTFN2 first, then it hogs - # gigabytes of disk space for the duration of the test. - for f in TemporaryFile(), TESTFN2: - self.zipTest(f, zipfile.ZIP_DEFLATED) + @unittest.skipUnless(zlib, "requires zlib") + def testDeflated(self): + # Try the temp file first. If we do TESTFN2 first, then it hogs + # gigabytes of disk space for the duration of the test. + with TemporaryFile() as f: + self.zipTest(f, zipfile.ZIP_DEFLATED) + self.assertFalse(f.closed) + self.zipTest(TESTFN2, zipfile.ZIP_DEFLATED) def tearDown(self): for fname in TESTFN, TESTFN2: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 25 07:16:42 2016 From: python-checkins at python.org (martin.panter) Date: Thu, 25 Feb 2016 12:16:42 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2NDAy?= =?utf-8?q?=3A_Fix_XML-RPC_client_retrying_after_server_disconnection?= Message-ID: <20160225121642.1971.19356@psf.io> https://hg.python.org/cpython/rev/d668b5595534 changeset: 100331:d668b5595534 branch: 3.5 parent: 100328:baec3e2e1b1f user: Martin Panter date: Thu Feb 25 11:53:40 2016 +0000 summary: Issue #26402: Fix XML-RPC client retrying after server disconnection This is a regression introduced in 3.5 by revision eba80326ba53. Fix by Jelte Fennema, test case by me. files: Lib/test/test_xmlrpc.py | 37 +++++++++++++++++++++++++++++ Lib/xmlrpc/client.py | 6 ++-- Misc/NEWS | 4 +++ 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py --- a/Lib/test/test_xmlrpc.py +++ b/Lib/test/test_xmlrpc.py @@ -7,6 +7,7 @@ import xmlrpc.client as xmlrpclib import xmlrpc.server import http.client +import http, http.server import socket import os import re @@ -244,6 +245,42 @@ except OSError: self.assertTrue(has_ssl) + @unittest.skipUnless(threading, "Threading required for this test.") + def test_keepalive_disconnect(self): + class RequestHandler(http.server.BaseHTTPRequestHandler): + protocol_version = "HTTP/1.1" + handled = False + + def do_POST(self): + length = int(self.headers.get("Content-Length")) + self.rfile.read(length) + if self.handled: + self.close_connection = True + return + response = xmlrpclib.dumps((5,), methodresponse=True) + response = response.encode() + self.send_response(http.HTTPStatus.OK) + self.send_header("Content-Length", len(response)) + self.end_headers() + self.wfile.write(response) + self.handled = True + self.close_connection = False + + def run_server(): + server.socket.settimeout(float(1)) # Don't hang if client fails + server.handle_request() # First request and attempt at second + server.handle_request() # Retried second request + + server = http.server.HTTPServer((support.HOST, 0), RequestHandler) + self.addCleanup(server.server_close) + thread = threading.Thread(target=run_server) + thread.start() + self.addCleanup(thread.join) + url = "http://{}:{}/".format(*server.server_address) + with xmlrpclib.ServerProxy(url) as p: + self.assertEqual(p.method(), 5) + self.assertEqual(p.method(), 5) + class HelperTestCase(unittest.TestCase): def test_escape(self): self.assertEqual(xmlrpclib.escape("a&b"), "a&b") diff --git a/Lib/xmlrpc/client.py b/Lib/xmlrpc/client.py --- a/Lib/xmlrpc/client.py +++ b/Lib/xmlrpc/client.py @@ -1129,13 +1129,13 @@ for i in (0, 1): try: return self.single_request(host, handler, request_body, verbose) + except http.client.RemoteDisconnected: + if i: + raise except OSError as e: if i or e.errno not in (errno.ECONNRESET, errno.ECONNABORTED, errno.EPIPE): raise - except http.client.RemoteDisconnected: - if i: - raise def single_request(self, host, handler, request_body, verbose=False): # issue XML-RPC request diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -79,6 +79,10 @@ Library ------- +- Issue #26402: Fix XML-RPC client to retry when the server shuts down a + persistent connection. This was a regression related to the new + http.client.RemoteDisconnected exception in 3.5.0a4. + - Issue #25913: Leading ``<~`` is optional now in base64.a85decode() with adobe=True. Patch by Swati Jaiswal. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 25 07:16:56 2016 From: python-checkins at python.org (martin.panter) Date: Thu, 25 Feb 2016 12:16:56 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326402=3A_Merge_XML-RPC_client_fix_from_3=2E5?= Message-ID: <20160225121642.83589.80846@psf.io> https://hg.python.org/cpython/rev/70bf0d764939 changeset: 100332:70bf0d764939 parent: 100330:2193f8b956de parent: 100331:d668b5595534 user: Martin Panter date: Thu Feb 25 12:13:50 2016 +0000 summary: Issue #26402: Merge XML-RPC client fix from 3.5 files: Lib/test/test_xmlrpc.py | 37 +++++++++++++++++++++++++++++ Lib/xmlrpc/client.py | 6 ++-- Misc/NEWS | 4 +++ 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py --- a/Lib/test/test_xmlrpc.py +++ b/Lib/test/test_xmlrpc.py @@ -7,6 +7,7 @@ import xmlrpc.client as xmlrpclib import xmlrpc.server import http.client +import http, http.server import socket import os import re @@ -244,6 +245,42 @@ except OSError: self.assertTrue(has_ssl) + @unittest.skipUnless(threading, "Threading required for this test.") + def test_keepalive_disconnect(self): + class RequestHandler(http.server.BaseHTTPRequestHandler): + protocol_version = "HTTP/1.1" + handled = False + + def do_POST(self): + length = int(self.headers.get("Content-Length")) + self.rfile.read(length) + if self.handled: + self.close_connection = True + return + response = xmlrpclib.dumps((5,), methodresponse=True) + response = response.encode() + self.send_response(http.HTTPStatus.OK) + self.send_header("Content-Length", len(response)) + self.end_headers() + self.wfile.write(response) + self.handled = True + self.close_connection = False + + def run_server(): + server.socket.settimeout(float(1)) # Don't hang if client fails + server.handle_request() # First request and attempt at second + server.handle_request() # Retried second request + + server = http.server.HTTPServer((support.HOST, 0), RequestHandler) + self.addCleanup(server.server_close) + thread = threading.Thread(target=run_server) + thread.start() + self.addCleanup(thread.join) + url = "http://{}:{}/".format(*server.server_address) + with xmlrpclib.ServerProxy(url) as p: + self.assertEqual(p.method(), 5) + self.assertEqual(p.method(), 5) + class HelperTestCase(unittest.TestCase): def test_escape(self): self.assertEqual(xmlrpclib.escape("a&b"), "a&b") diff --git a/Lib/xmlrpc/client.py b/Lib/xmlrpc/client.py --- a/Lib/xmlrpc/client.py +++ b/Lib/xmlrpc/client.py @@ -1129,13 +1129,13 @@ for i in (0, 1): try: return self.single_request(host, handler, request_body, verbose) + except http.client.RemoteDisconnected: + if i: + raise except OSError as e: if i or e.errno not in (errno.ECONNRESET, errno.ECONNABORTED, errno.EPIPE): raise - except http.client.RemoteDisconnected: - if i: - raise def single_request(self, host, handler, request_body, verbose=False): # issue XML-RPC request diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -189,6 +189,10 @@ Library ------- +- Issue #26402: Fix XML-RPC client to retry when the server shuts down a + persistent connection. This was a regression related to the new + http.client.RemoteDisconnected exception in 3.5.0a4. + - Issue #25913: Leading ``<~`` is optional now in base64.a85decode() with adobe=True. Patch by Swati Jaiswal. -- Repository URL: https://hg.python.org/cpython From lp_benchmark_robot at intel.com Thu Feb 25 12:05:44 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Thu, 25 Feb 2016 17:05:44 +0000 Subject: [Python-checkins] NEUTRAL Benchmark Results for Python Default 2016-02-25 Message-ID: <0fe54851-d586-458e-ae1c-dabb59881cf2@irsmsx106.ger.corp.intel.com> Results for project Python default, build date 2016-02-25 03:09:28 +0000 commit: 2c4448bbed1f previous commit: 5ad27dcd5a97 revision date: 2016-02-24 14:35:21 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.23% -0.30% 10.42% 12.92% :-| pybench 0.16% 0.01% 0.38% 5.33% :-( regex_v8 2.86% 0.10% -4.75% 2.12% :-| nbody 0.10% 0.12% -1.44% 9.42% :-| json_dump_v2 0.23% -0.43% -0.18% 10.16% :-| normal_startup 0.69% 0.24% 0.40% 4.96% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/neutral-benchmark-results-for-python-default-2016-02-25/ Note: Benchmark results are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Thu Feb 25 12:06:19 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Thu, 25 Feb 2016 17:06:19 +0000 Subject: [Python-checkins] NEUTRAL Benchmark Results for Python 2.7 2016-02-25 Message-ID: Results for project Python 2.7, build date 2016-02-25 04:00:42 +0000 commit: 157eb9d40bf9 previous commit: c62526580ff0 revision date: 2016-02-24 14:33:51 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dc from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.20% -0.91% 5.56% 6.68% :-) pybench 0.09% 0.16% 6.31% 4.57% :-( regex_v8 0.79% 0.04% -2.81% 11.54% :-) nbody 0.11% 0.55% 7.65% 1.55% :-) json_dump_v2 0.21% 0.96% 4.82% 10.81% :-( normal_startup 1.74% 0.42% -5.55% 2.34% :-| ssbench 0.11% -0.17% 1.87% 1.74% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/neutral-benchmark-results-for-python-2-7-2016-02-25/ Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Thu Feb 25 14:14:42 2016 From: python-checkins at python.org (georg.brandl) Date: Thu, 25 Feb 2016 19:14:42 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Fix_rstlint_to?= =?utf-8?q?_also_look_for_indented_comments_that_should_be_directives=2E?= Message-ID: <20160225191442.1993.45274@psf.io> https://hg.python.org/cpython/rev/6281f080cb94 changeset: 100333:6281f080cb94 branch: 3.5 parent: 100331:d668b5595534 user: Georg Brandl date: Thu Feb 25 20:14:10 2016 +0100 summary: Fix rstlint to also look for indented comments that should be directives. files: Doc/tools/rstlint.py | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/tools/rstlint.py b/Doc/tools/rstlint.py --- a/Doc/tools/rstlint.py +++ b/Doc/tools/rstlint.py @@ -43,7 +43,7 @@ ] all_directives = '(' + '|'.join(directives) + ')' -seems_directive_re = re.compile(r'\.\. %s([^a-z:]|:(?!:))' % all_directives) +seems_directive_re = re.compile(r'(? https://hg.python.org/cpython/rev/ca1f87cda826 changeset: 100335:ca1f87cda826 branch: 2.7 parent: 100329:32051701a49d user: Georg Brandl date: Thu Feb 25 20:14:10 2016 +0100 summary: Fix rstlint to also look for indented comments that should be directives. files: Doc/tools/rstlint.py | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/tools/rstlint.py b/Doc/tools/rstlint.py --- a/Doc/tools/rstlint.py +++ b/Doc/tools/rstlint.py @@ -42,7 +42,7 @@ ] all_directives = '(' + '|'.join(directives) + ')' -seems_directive_re = re.compile(r'\.\. %s([^a-z:]|:(?!:))' % all_directives) +seems_directive_re = re.compile(r'(? https://hg.python.org/cpython/rev/7acba55cca95 changeset: 100334:7acba55cca95 parent: 100332:70bf0d764939 parent: 100333:6281f080cb94 user: Georg Brandl date: Thu Feb 25 20:14:21 2016 +0100 summary: merge with 3.5 files: Doc/tools/rstlint.py | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/tools/rstlint.py b/Doc/tools/rstlint.py --- a/Doc/tools/rstlint.py +++ b/Doc/tools/rstlint.py @@ -43,7 +43,7 @@ ] all_directives = '(' + '|'.join(directives) + ')' -seems_directive_re = re.compile(r'\.\. %s([^a-z:]|:(?!:))' % all_directives) +seems_directive_re = re.compile(r'(? https://hg.python.org/cpython/rev/1f8dc6f2b171 changeset: 100336:1f8dc6f2b171 branch: 3.5 parent: 100333:6281f080cb94 user: Georg Brandl date: Thu Feb 25 20:17:45 2016 +0100 summary: Closes #26435: fix syntax in directives. Thanks to Jakub Stasiak. files: Doc/distutils/apiref.rst | 6 +++--- Doc/library/email.charset.rst | 5 +++-- Doc/library/mmap.rst | 6 +++--- Doc/library/ossaudiodev.rst | 4 ++-- Doc/library/re.rst | 2 +- Doc/library/socket.rst | 6 +++--- Doc/library/ssl.rst | 2 +- Doc/library/stdtypes.rst | 6 +++--- Doc/using/cmdline.rst | 2 +- Lib/logging/__init__.py | 4 ++-- 10 files changed, 22 insertions(+), 21 deletions(-) diff --git a/Doc/distutils/apiref.rst b/Doc/distutils/apiref.rst --- a/Doc/distutils/apiref.rst +++ b/Doc/distutils/apiref.rst @@ -876,7 +876,7 @@ archive. *root_dir* and *base_dir* both default to the current directory. Returns the name of the archive file. - .. versionchanged: 3.5 + .. versionchanged:: 3.5 Added support for the ``xztar`` format. @@ -891,7 +891,7 @@ compression extension (``.gz``, ``.bz2``, ``.xz`` or ``.Z``). Return the output filename. - .. versionchanged: 3.5 + .. versionchanged:: 3.5 Added support for the ``xz`` compression. @@ -1234,7 +1234,7 @@ ` in their name, in a :file:`__pycache__` subdirectory instead of files without tag in the current directory. - .. versionchanged: 3.5 + .. versionchanged:: 3.5 Create ``.pyc`` files according to :pep:`488`. diff --git a/Doc/library/email.charset.rst b/Doc/library/email.charset.rst --- a/Doc/library/email.charset.rst +++ b/Doc/library/email.charset.rst @@ -101,9 +101,10 @@ returns the string ``base64`` if *body_encoding* is ``BASE64``, and returns the string ``7bit`` otherwise. + .. XXX to_splittable and from_splittable are not there anymore! - .. method to_splittable(s) + .. to_splittable(s) Convert a possibly multibyte string to a safely splittable format. *s* is the string to split. @@ -118,7 +119,7 @@ the Unicode replacement character ``'U+FFFD'``. - .. method from_splittable(ustr[, to_output]) + .. from_splittable(ustr[, to_output]) Convert a splittable string back into an encoded string. *ustr* is a Unicode string to "unsplit". diff --git a/Doc/library/mmap.rst b/Doc/library/mmap.rst --- a/Doc/library/mmap.rst +++ b/Doc/library/mmap.rst @@ -174,7 +174,7 @@ Optional arguments *start* and *end* are interpreted as in slice notation. Returns ``-1`` on failure. - .. versionchanged: 3.5 + .. versionchanged:: 3.5 Writable :term:`bytes-like object` is now accepted. @@ -237,7 +237,7 @@ Optional arguments *start* and *end* are interpreted as in slice notation. Returns ``-1`` on failure. - .. versionchanged: 3.5 + .. versionchanged:: 3.5 Writable :term:`bytes-like object` is now accepted. @@ -267,7 +267,7 @@ were written. If the mmap was created with :const:`ACCESS_READ`, then writing to it will raise a :exc:`TypeError` exception. - .. versionchanged: 3.5 + .. versionchanged:: 3.5 Writable :term:`bytes-like object` is now accepted. diff --git a/Doc/library/ossaudiodev.rst b/Doc/library/ossaudiodev.rst --- a/Doc/library/ossaudiodev.rst +++ b/Doc/library/ossaudiodev.rst @@ -155,7 +155,7 @@ data may not be written ---see :meth:`writeall`. - .. versionchanged: 3.5 + .. versionchanged:: 3.5 Writable :term:`bytes-like object` is now accepted. @@ -169,7 +169,7 @@ no return value, since the amount of data written is always equal to the amount of data supplied. - .. versionchanged: 3.5 + .. versionchanged:: 3.5 Writable :term:`bytes-like object` is now accepted. diff --git a/Doc/library/re.rst b/Doc/library/re.rst --- a/Doc/library/re.rst +++ b/Doc/library/re.rst @@ -297,7 +297,7 @@ >>> m.group(0) 'egg' - .. versionchanged: 3.5 + .. versionchanged:: 3.5 Added support for group references of fixed length. ``(? https://hg.python.org/cpython/rev/a8c761bcbf3f changeset: 100337:a8c761bcbf3f parent: 100334:7acba55cca95 parent: 100336:1f8dc6f2b171 user: Georg Brandl date: Thu Feb 25 20:18:00 2016 +0100 summary: merge with 3.5 files: Doc/distutils/apiref.rst | 6 +++--- Doc/library/email.charset.rst | 5 +++-- Doc/library/mmap.rst | 6 +++--- Doc/library/ossaudiodev.rst | 4 ++-- Doc/library/re.rst | 2 +- Doc/library/socket.rst | 6 +++--- Doc/library/ssl.rst | 2 +- Doc/library/stdtypes.rst | 6 +++--- Doc/using/cmdline.rst | 2 +- Lib/logging/__init__.py | 4 ++-- 10 files changed, 22 insertions(+), 21 deletions(-) diff --git a/Doc/distutils/apiref.rst b/Doc/distutils/apiref.rst --- a/Doc/distutils/apiref.rst +++ b/Doc/distutils/apiref.rst @@ -876,7 +876,7 @@ archive. *root_dir* and *base_dir* both default to the current directory. Returns the name of the archive file. - .. versionchanged: 3.5 + .. versionchanged:: 3.5 Added support for the ``xztar`` format. @@ -891,7 +891,7 @@ compression extension (``.gz``, ``.bz2``, ``.xz`` or ``.Z``). Return the output filename. - .. versionchanged: 3.5 + .. versionchanged:: 3.5 Added support for the ``xz`` compression. @@ -1234,7 +1234,7 @@ ` in their name, in a :file:`__pycache__` subdirectory instead of files without tag in the current directory. - .. versionchanged: 3.5 + .. versionchanged:: 3.5 Create ``.pyc`` files according to :pep:`488`. diff --git a/Doc/library/email.charset.rst b/Doc/library/email.charset.rst --- a/Doc/library/email.charset.rst +++ b/Doc/library/email.charset.rst @@ -101,9 +101,10 @@ returns the string ``base64`` if *body_encoding* is ``BASE64``, and returns the string ``7bit`` otherwise. + .. XXX to_splittable and from_splittable are not there anymore! - .. method to_splittable(s) + .. to_splittable(s) Convert a possibly multibyte string to a safely splittable format. *s* is the string to split. @@ -118,7 +119,7 @@ the Unicode replacement character ``'U+FFFD'``. - .. method from_splittable(ustr[, to_output]) + .. from_splittable(ustr[, to_output]) Convert a splittable string back into an encoded string. *ustr* is a Unicode string to "unsplit". diff --git a/Doc/library/mmap.rst b/Doc/library/mmap.rst --- a/Doc/library/mmap.rst +++ b/Doc/library/mmap.rst @@ -174,7 +174,7 @@ Optional arguments *start* and *end* are interpreted as in slice notation. Returns ``-1`` on failure. - .. versionchanged: 3.5 + .. versionchanged:: 3.5 Writable :term:`bytes-like object` is now accepted. @@ -237,7 +237,7 @@ Optional arguments *start* and *end* are interpreted as in slice notation. Returns ``-1`` on failure. - .. versionchanged: 3.5 + .. versionchanged:: 3.5 Writable :term:`bytes-like object` is now accepted. @@ -267,7 +267,7 @@ were written. If the mmap was created with :const:`ACCESS_READ`, then writing to it will raise a :exc:`TypeError` exception. - .. versionchanged: 3.5 + .. versionchanged:: 3.5 Writable :term:`bytes-like object` is now accepted. diff --git a/Doc/library/ossaudiodev.rst b/Doc/library/ossaudiodev.rst --- a/Doc/library/ossaudiodev.rst +++ b/Doc/library/ossaudiodev.rst @@ -155,7 +155,7 @@ data may not be written ---see :meth:`writeall`. - .. versionchanged: 3.5 + .. versionchanged:: 3.5 Writable :term:`bytes-like object` is now accepted. @@ -169,7 +169,7 @@ no return value, since the amount of data written is always equal to the amount of data supplied. - .. versionchanged: 3.5 + .. versionchanged:: 3.5 Writable :term:`bytes-like object` is now accepted. diff --git a/Doc/library/re.rst b/Doc/library/re.rst --- a/Doc/library/re.rst +++ b/Doc/library/re.rst @@ -297,7 +297,7 @@ >>> m.group(0) 'egg' - .. versionchanged: 3.5 + .. versionchanged:: 3.5 Added support for group references of fixed length. ``(? https://hg.python.org/cpython/rev/7609aaf180b4 changeset: 100338:7609aaf180b4 branch: 3.5 parent: 100336:1f8dc6f2b171 user: Martin Panter date: Mon Feb 22 09:21:49 2016 +0000 summary: Issue #26390: Fix and test pbkdf2_hmac() parameter names Based on patch by Daan Bakker. files: Doc/library/hashlib.rst | 13 +++++++------ Lib/test/test_hashlib.py | 3 +++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Doc/library/hashlib.rst b/Doc/library/hashlib.rst --- a/Doc/library/hashlib.rst +++ b/Doc/library/hashlib.rst @@ -185,22 +185,23 @@ include a `salt `_. -.. function:: pbkdf2_hmac(name, password, salt, rounds, dklen=None) +.. function:: pbkdf2_hmac(hash_name, password, salt, iterations, dklen=None) The function provides PKCS#5 password-based key derivation function 2. It uses HMAC as pseudorandom function. - The string *name* is the desired name of the hash digest algorithm for + The string *hash_name* is the desired name of the hash digest algorithm for HMAC, e.g. 'sha1' or 'sha256'. *password* and *salt* are interpreted as buffers of bytes. Applications and libraries should limit *password* to - a sensible value (e.g. 1024). *salt* should be about 16 or more bytes from + a sensible length (e.g. 1024). *salt* should be about 16 or more bytes from a proper source, e.g. :func:`os.urandom`. - The number of *rounds* should be chosen based on the hash algorithm and - computing power. As of 2013, at least 100,000 rounds of SHA-256 is suggested. + The number of *iterations* should be chosen based on the hash algorithm and + computing power. As of 2013, at least 100,000 iterations of SHA-256 are + suggested. *dklen* is the length of the derived key. If *dklen* is ``None`` then the - digest size of the hash algorithm *name* is used, e.g. 64 for SHA-512. + digest size of the hash algorithm *hash_name* is used, e.g. 64 for SHA-512. >>> import hashlib, binascii >>> dk = hashlib.pbkdf2_hmac('sha256', b'password', b'salt', 100000) diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py --- a/Lib/test/test_hashlib.py +++ b/Lib/test/test_hashlib.py @@ -513,6 +513,9 @@ self.assertRaises(ValueError, pbkdf2, 'sha1', b'pass', b'salt', 1, -1) with self.assertRaisesRegex(ValueError, 'unsupported hash type'): pbkdf2('unknown', b'pass', b'salt', 1) + out = pbkdf2(hash_name='sha1', password=b'password', salt=b'salt', + iterations=1, dklen=None) + self.assertEqual(out, self.pbkdf2_results['sha1'][0][0]) def test_pbkdf2_hmac_py(self): self._test_pbkdf2_hmac(py_hashlib.pbkdf2_hmac) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 25 20:14:04 2016 From: python-checkins at python.org (martin.panter) Date: Fri, 26 Feb 2016 01:14:04 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Dummy_merge_with_3=2E5?= Message-ID: <20160226011404.1988.13089@psf.io> https://hg.python.org/cpython/rev/ed30eac90f60 changeset: 100341:ed30eac90f60 parent: 100340:a74420677e6b parent: 100339:a99580157968 user: Martin Panter date: Fri Feb 26 00:42:33 2016 +0000 summary: Dummy merge with 3.5 files: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 25 20:14:06 2016 From: python-checkins at python.org (martin.panter) Date: Fri, 26 Feb 2016 01:14:06 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326390=3A_Merge_pbkdf2=5Fhmac=28=29_doc_from_3?= =?utf-8?q?=2E5?= Message-ID: <20160226011404.6248.40332@psf.io> https://hg.python.org/cpython/rev/a74420677e6b changeset: 100340:a74420677e6b parent: 100337:a8c761bcbf3f parent: 100338:7609aaf180b4 user: Martin Panter date: Fri Feb 26 00:41:38 2016 +0000 summary: Issue #26390: Merge pbkdf2_hmac() doc from 3.5 files: Doc/library/hashlib.rst | 13 +++++++------ Lib/test/test_hashlib.py | 3 +++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Doc/library/hashlib.rst b/Doc/library/hashlib.rst --- a/Doc/library/hashlib.rst +++ b/Doc/library/hashlib.rst @@ -185,22 +185,23 @@ include a `salt `_. -.. function:: pbkdf2_hmac(name, password, salt, rounds, dklen=None) +.. function:: pbkdf2_hmac(hash_name, password, salt, iterations, dklen=None) The function provides PKCS#5 password-based key derivation function 2. It uses HMAC as pseudorandom function. - The string *name* is the desired name of the hash digest algorithm for + The string *hash_name* is the desired name of the hash digest algorithm for HMAC, e.g. 'sha1' or 'sha256'. *password* and *salt* are interpreted as buffers of bytes. Applications and libraries should limit *password* to - a sensible value (e.g. 1024). *salt* should be about 16 or more bytes from + a sensible length (e.g. 1024). *salt* should be about 16 or more bytes from a proper source, e.g. :func:`os.urandom`. - The number of *rounds* should be chosen based on the hash algorithm and - computing power. As of 2013, at least 100,000 rounds of SHA-256 is suggested. + The number of *iterations* should be chosen based on the hash algorithm and + computing power. As of 2013, at least 100,000 iterations of SHA-256 are + suggested. *dklen* is the length of the derived key. If *dklen* is ``None`` then the - digest size of the hash algorithm *name* is used, e.g. 64 for SHA-512. + digest size of the hash algorithm *hash_name* is used, e.g. 64 for SHA-512. >>> import hashlib, binascii >>> dk = hashlib.pbkdf2_hmac('sha256', b'password', b'salt', 100000) diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py --- a/Lib/test/test_hashlib.py +++ b/Lib/test/test_hashlib.py @@ -513,6 +513,9 @@ self.assertRaises(ValueError, pbkdf2, 'sha1', b'pass', b'salt', 1, -1) with self.assertRaisesRegex(ValueError, 'unsupported hash type'): pbkdf2('unknown', b'pass', b'salt', 1) + out = pbkdf2(hash_name='sha1', password=b'password', salt=b'salt', + iterations=1, dklen=None) + self.assertEqual(out, self.pbkdf2_results['sha1'][0][0]) def test_pbkdf2_hmac_py(self): self._test_pbkdf2_hmac(py_hashlib.pbkdf2_hmac) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 25 20:14:05 2016 From: python-checkins at python.org (martin.panter) Date: Fri, 26 Feb 2016 01:14:05 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI0NDIx?= =?utf-8?q?=3A_Compile_=5Fmath=2Ec_separately_to_avoid_race_condition?= Message-ID: <20160226011404.64519.77647@psf.io> https://hg.python.org/cpython/rev/a99580157968 changeset: 100339:a99580157968 branch: 3.5 user: Martin Panter date: Wed Feb 03 05:19:44 2016 +0000 summary: Issue #24421: Compile _math.c separately to avoid race condition files: Makefile.pre.in | 6 +++++- Misc/NEWS | 4 ++++ setup.py | 12 ++++++++---- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -586,11 +586,15 @@ exit 1 ; \ fi +# This is shared by the math and cmath modules +Modules/_math.o: Modules/_math.c Modules/_math.h + $(CC) -c $(CCSHARED) $(PY_CORE_CFLAGS) -o $@ $< + # Build the shared modules # Under GNU make, MAKEFLAGS are sorted and normalized; the 's' for # -s, --silent or --quiet is always the first char. # Under BSD make, MAKEFLAGS might be " -s -v x=y". -sharedmods: $(BUILDPYTHON) pybuilddir.txt +sharedmods: $(BUILDPYTHON) pybuilddir.txt Modules/_math.o @case "$$MAKEFLAGS" in \ *\ -s*|s*) quiet="-q";; \ *) quiet="";; \ diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -261,6 +261,10 @@ Build ----- +- Issue #24421: Compile Modules/_math.c once, before building extensions. + Previously it could fail to compile properly if the math and cmath builds + were concurrent. + - Issue #25348: Added ``--pgo`` and ``--pgo-job`` arguments to ``PCbuild\build.bat`` for building with Profile-Guided Optimization. The old ``PCbuild\build_pgo.bat`` script is now deprecated, and simply calls diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -598,13 +598,17 @@ # array objects exts.append( Extension('array', ['arraymodule.c']) ) + + shared_math = 'Modules/_math.o' # complex math library functions - exts.append( Extension('cmath', ['cmathmodule.c', '_math.c'], - depends=['_math.h'], + exts.append( Extension('cmath', ['cmathmodule.c'], + extra_objects=[shared_math], + depends=['_math.h', shared_math], libraries=math_libs) ) # math library functions, e.g. sin() - exts.append( Extension('math', ['mathmodule.c', '_math.c'], - depends=['_math.h'], + exts.append( Extension('math', ['mathmodule.c'], + extra_objects=[shared_math], + depends=['_math.h', shared_math], libraries=math_libs) ) # time libraries: librt may be needed for clock_gettime() -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu Feb 25 21:14:58 2016 From: python-checkins at python.org (martin.panter) Date: Fri, 26 Feb 2016 02:14:58 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI0NDIx?= =?utf-8?q?=3A_Compile_=5Fmath=2Ec_separately_to_avoid_race_condition?= Message-ID: <20160226021457.1967.77635@psf.io> https://hg.python.org/cpython/rev/d4190ed586a4 changeset: 100342:d4190ed586a4 branch: 2.7 parent: 100335:ca1f87cda826 user: Martin Panter date: Wed Feb 03 05:19:44 2016 +0000 summary: Issue #24421: Compile _math.c separately to avoid race condition files: Makefile.pre.in | 6 +++++- Misc/NEWS | 4 ++++ setup.py | 12 ++++++++---- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -528,11 +528,15 @@ exit 1 ; \ fi +# This is shared by the math and cmath modules +Modules/_math.o: Modules/_math.c Modules/_math.h + $(CC) -c $(CCSHARED) $(PY_CFLAGS) -o $@ $< + # Build the shared modules # Under GNU make, MAKEFLAGS are sorted and normalized; the 's' for # -s, --silent or --quiet is always the first char. # Under BSD make, MAKEFLAGS might be " -s -v x=y". -sharedmods: $(BUILDPYTHON) pybuilddir.txt +sharedmods: $(BUILDPYTHON) pybuilddir.txt Modules/_math.o @case "$$MAKEFLAGS" in \ *\ -s*|s*) quiet="-q";; \ *) quiet="";; \ diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -143,6 +143,10 @@ Build ----- +- Issue #24421: Compile Modules/_math.c once, before building extensions. + Previously it could fail to compile properly if the math and cmath builds + were concurrent. + - Issue #25824: Fixes sys.winver to not include any architecture suffix. - Issue #25348: Added ``--pgo`` and ``--pgo-job`` arguments to diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -584,13 +584,17 @@ # array objects exts.append( Extension('array', ['arraymodule.c']) ) + + shared_math = 'Modules/_math.o' # complex math library functions - exts.append( Extension('cmath', ['cmathmodule.c', '_math.c'], - depends=['_math.h'], + exts.append( Extension('cmath', ['cmathmodule.c'], + extra_objects=[shared_math], + depends=['_math.h', shared_math], libraries=math_libs) ) # math library functions, e.g. sin() - exts.append( Extension('math', ['mathmodule.c', '_math.c'], - depends=['_math.h'], + exts.append( Extension('math', ['mathmodule.c'], + extra_objects=[shared_math], + depends=['_math.h', shared_math], libraries=math_libs) ) # fast string operations implemented in C exts.append( Extension('strop', ['stropmodule.c']) ) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Feb 26 01:34:51 2016 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 26 Feb 2016 06:34:51 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_c=5Fencoding_can_never_be_?= =?utf-8?q?NULL=2C_which_allows_some_code_simplification?= Message-ID: <20160226063450.96718.32341@psf.io> https://hg.python.org/cpython/rev/4d4de230309d changeset: 100343:4d4de230309d parent: 100341:ed30eac90f60 user: Benjamin Peterson date: Thu Feb 25 22:34:45 2016 -0800 summary: c_encoding can never be NULL, which allows some code simplification files: Python/ast.c | 92 +++++++++++++++++++-------------------- 1 files changed, 44 insertions(+), 48 deletions(-) diff --git a/Python/ast.c b/Python/ast.c --- a/Python/ast.c +++ b/Python/ast.c @@ -4002,55 +4002,52 @@ char *p; const char *end; - if (encoding == NULL) { - u = NULL; - } else { - /* check for integer overflow */ - if (len > PY_SIZE_MAX / 6) - return NULL; - /* "?" (2 bytes) may become "\U000000E4" (10 bytes), or 1:5 - "\?" (3 bytes) may become "\u005c\U000000E4" (16 bytes), or ~1:6 */ - u = PyBytes_FromStringAndSize((char *)NULL, len * 6); - if (u == NULL) - return NULL; - p = buf = PyBytes_AsString(u); - end = s + len; - while (s < end) { - if (*s == '\\') { - *p++ = *s++; - if (*s & 0x80) { - strcpy(p, "u005c"); - p += 5; - } - } - if (*s & 0x80) { /* XXX inefficient */ - PyObject *w; - int kind; - void *data; - Py_ssize_t len, i; - w = decode_utf8(c, &s, end); - if (w == NULL) { - Py_DECREF(u); - return NULL; - } - kind = PyUnicode_KIND(w); - data = PyUnicode_DATA(w); - len = PyUnicode_GET_LENGTH(w); - for (i = 0; i < len; i++) { - Py_UCS4 chr = PyUnicode_READ(kind, data, i); - sprintf(p, "\\U%08x", chr); - p += 10; - } - /* Should be impossible to overflow */ - assert(p - buf <= Py_SIZE(u)); - Py_DECREF(w); - } else { - *p++ = *s++; + /* check for integer overflow */ + if (len > PY_SIZE_MAX / 6) + return NULL; + /* "?" (2 bytes) may become "\U000000E4" (10 bytes), or 1:5 + "\?" (3 bytes) may become "\u005c\U000000E4" (16 bytes), or ~1:6 */ + u = PyBytes_FromStringAndSize((char *)NULL, len * 6); + if (u == NULL) + return NULL; + p = buf = PyBytes_AsString(u); + end = s + len; + while (s < end) { + if (*s == '\\') { + *p++ = *s++; + if (*s & 0x80) { + strcpy(p, "u005c"); + p += 5; } } - len = p - buf; - s = buf; + if (*s & 0x80) { /* XXX inefficient */ + PyObject *w; + int kind; + void *data; + Py_ssize_t len, i; + w = decode_utf8(c, &s, end); + if (w == NULL) { + Py_DECREF(u); + return NULL; + } + kind = PyUnicode_KIND(w); + data = PyUnicode_DATA(w); + len = PyUnicode_GET_LENGTH(w); + for (i = 0; i < len; i++) { + Py_UCS4 chr = PyUnicode_READ(kind, data, i); + sprintf(p, "\\U%08x", chr); + p += 10; + } + /* Should be impossible to overflow */ + assert(p - buf <= Py_SIZE(u)); + Py_DECREF(w); + } else { + *p++ = *s++; + } } + len = p - buf; + s = buf; + v = PyUnicode_DecodeUnicodeEscape(s, len, NULL); Py_XDECREF(u); return v; @@ -4994,8 +4991,7 @@ } } } - need_encoding = (!*bytesmode && c->c_encoding != NULL && - strcmp(c->c_encoding, "utf-8") != 0); + need_encoding = !*bytesmode && strcmp(c->c_encoding, "utf-8") != 0; if (rawmode || strchr(s, '\\') == NULL) { if (need_encoding) { PyObject *v, *u = PyUnicode_DecodeUTF8(s, len, NULL); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Feb 26 02:13:59 2016 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 26 Feb 2016 07:13:59 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_rewrite_parsestr=28=29_so_?= =?utf-8?q?it=27s_comprehensible=3B_remove_dead_code?= Message-ID: <20160226071358.83569.73579@psf.io> https://hg.python.org/cpython/rev/92fd950ee748 changeset: 100344:92fd950ee748 user: Benjamin Peterson date: Thu Feb 25 23:13:53 2016 -0800 summary: rewrite parsestr() so it's comprehensible; remove dead code files: Python/ast.c | 38 +++++++++++++------------------------- 1 files changed, 13 insertions(+), 25 deletions(-) diff --git a/Python/ast.c b/Python/ast.c --- a/Python/ast.c +++ b/Python/ast.c @@ -3995,7 +3995,7 @@ } static PyObject * -decode_unicode(struct compiling *c, const char *s, size_t len, const char *encoding) +decode_unicode_with_escapes(struct compiling *c, const char *s, size_t len) { PyObject *v, *u; char *buf; @@ -4921,7 +4921,6 @@ const char *s = STR(n); int quote = Py_CHARMASK(*s); int rawmode = 0; - int need_encoding; if (Py_ISALPHA(quote)) { while (!*bytesmode || !rawmode) { if (quote == 'b' || quote == 'B') { @@ -4977,11 +4976,10 @@ return NULL; } } - if (!*bytesmode && !rawmode) { - return decode_unicode(c, s, len, c->c_encoding); - } + /* Avoid invoking escape decoding routines if possible. */ + rawmode = rawmode || strchr(s, '\\') == NULL; if (*bytesmode) { - /* Disallow non-ascii characters (but not escapes) */ + /* Disallow non-ASCII characters. */ const char *ch; for (ch = s; *ch; ch++) { if (Py_CHARMASK(*ch) >= 0x80) { @@ -4990,26 +4988,16 @@ return NULL; } } + if (rawmode) + return PyBytes_FromStringAndSize(s, len); + else + return PyBytes_DecodeEscape(s, len, NULL, /* ignored */ 0, NULL); + } else { + if (rawmode) + return PyUnicode_DecodeUTF8Stateful(s, len, NULL, NULL); + else + return decode_unicode_with_escapes(c, s, len); } - need_encoding = !*bytesmode && strcmp(c->c_encoding, "utf-8") != 0; - if (rawmode || strchr(s, '\\') == NULL) { - if (need_encoding) { - PyObject *v, *u = PyUnicode_DecodeUTF8(s, len, NULL); - if (u == NULL || !*bytesmode) - return u; - v = PyUnicode_AsEncodedString(u, c->c_encoding, NULL); - Py_DECREF(u); - return v; - } else if (*bytesmode) { - return PyBytes_FromStringAndSize(s, len); - } else if (strcmp(c->c_encoding, "utf-8") == 0) { - return PyUnicode_FromStringAndSize(s, len); - } else { - return PyUnicode_DecodeLatin1(s, len, NULL); - } - } - return PyBytes_DecodeEscape(s, len, NULL, 1, - need_encoding ? c->c_encoding : NULL); } /* Accepts a STRING+ atom, and produces an expr_ty node. Run through -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Feb 26 02:35:00 2016 From: python-checkins at python.org (benjamin.peterson) Date: Fri, 26 Feb 2016 07:35:00 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_remove_unused_c=5Fencoding?= =?utf-8?q?_struct_member?= Message-ID: <20160226073500.1987.13569@psf.io> https://hg.python.org/cpython/rev/e4deabbfc1b2 changeset: 100345:e4deabbfc1b2 user: Benjamin Peterson date: Thu Feb 25 23:25:14 2016 -0800 summary: remove unused c_encoding struct member files: Python/ast.c | 21 ++++----------------- 1 files changed, 4 insertions(+), 17 deletions(-) diff --git a/Python/ast.c b/Python/ast.c --- a/Python/ast.c +++ b/Python/ast.c @@ -574,7 +574,6 @@ /* Data structure used internally */ struct compiling { - char *c_encoding; /* source encoding */ PyArena *c_arena; /* Arena for allocating memory. */ PyObject *c_filename; /* filename */ PyObject *c_normalize; /* Normalization function from unicodedata. */ @@ -761,23 +760,11 @@ c.c_arena = arena; /* borrowed reference */ c.c_filename = filename; - c.c_normalize = c.c_normalize_args = NULL; - if (flags && flags->cf_flags & PyCF_SOURCE_IS_UTF8) { - c.c_encoding = "utf-8"; - if (TYPE(n) == encoding_decl) { -#if 0 - ast_error(c, n, "encoding declaration in Unicode string"); - goto out; -#endif - n = CHILD(n, 0); - } - } else if (TYPE(n) == encoding_decl) { - c.c_encoding = STR(n); + c.c_normalize = NULL; + c.c_normalize_args = NULL; + + if (TYPE(n) == encoding_decl) n = CHILD(n, 0); - } else { - /* PEP 3120 */ - c.c_encoding = "utf-8"; - } k = 0; switch (TYPE(n)) { -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Fri Feb 26 04:47:00 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Fri, 26 Feb 2016 09:47:00 +0000 Subject: [Python-checkins] Daily reference leaks (ed30eac90f60): sum=4 Message-ID: <20160226094653.96716.19987@psf.io> results for ed30eac90f60 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogLFt0ZQ', '--timeout', '7200'] From lp_benchmark_robot at intel.com Fri Feb 26 10:00:04 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Fri, 26 Feb 2016 15:00:04 +0000 Subject: [Python-checkins] NEUTRAL Benchmark Results for Python Default 2016-02-26 Message-ID: Results for project Python default, build date 2016-02-26 03:09:10 +0000 commit: ed30eac90f60 previous commit: 2c4448bbed1f revision date: 2016-02-26 00:42:33 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.21% 0.16% 10.56% 11.39% :-| pybench 0.20% -0.12% 0.26% 5.43% :-( regex_v8 2.60% 0.19% -4.55% 4.16% :-| nbody 0.08% -0.10% -1.53% 9.43% :-| json_dump_v2 0.18% -0.05% -0.23% 10.67% :-| normal_startup 0.69% 0.14% 0.64% 5.15% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/neutral-benchmark-results-for-python-default-2016-02-26/ Note: Benchmark results are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Fri Feb 26 10:01:49 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Fri, 26 Feb 2016 15:01:49 +0000 Subject: [Python-checkins] NEUTRAL Benchmark Results for Python 2.7 2016-02-26 Message-ID: <79b0d202-b85a-45f8-a720-71ae194cdd76@irsmsx106.ger.corp.intel.com> Results for project Python 2.7, build date 2016-02-26 04:00:36 +0000 commit: 157eb9d40bf9 previous commit: c62526580ff0 revision date: 2016-02-03 05:19:44 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dc from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.20% -0.91% 5.56% 6.68% :-) pybench 0.09% 0.16% 6.31% 4.57% :-( regex_v8 0.79% 0.04% -2.81% 11.54% :-) nbody 0.11% 0.55% 7.65% 1.55% :-) json_dump_v2 0.21% 0.96% 4.82% 10.81% :-( normal_startup 1.74% 0.42% -5.55% 2.34% :-| ssbench 0.11% -0.17% 1.87% 1.74% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/neutral-benchmark-results-for-python-2-7-2016-02-26/ Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From python-checkins at python.org Fri Feb 26 13:15:05 2016 From: python-checkins at python.org (georg.brandl) Date: Fri, 26 Feb 2016 18:15:05 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogQ2xvc2VzICMyNjQ0?= =?utf-8?q?4=3A_typo_fixes=2E?= Message-ID: <20160226181501.83593.67653@psf.io> https://hg.python.org/cpython/rev/29beb1554dec changeset: 100346:29beb1554dec branch: 3.5 parent: 100339:a99580157968 user: Georg Brandl date: Fri Feb 26 19:13:47 2016 +0100 summary: Closes #26444: typo fixes. files: Doc/library/xml.etree.elementtree.rst | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Doc/library/xml.etree.elementtree.rst b/Doc/library/xml.etree.elementtree.rst --- a/Doc/library/xml.etree.elementtree.rst +++ b/Doc/library/xml.etree.elementtree.rst @@ -1044,16 +1044,16 @@ This class is the low-level building block of the module. It uses :mod:`xml.parsers.expat` for efficient, event-based parsing of XML. It can - be fed XML data incrementall with the :meth:`feed` method, and parsing events - are translated to a push API - by invoking callbacks on the *target* object. - If *target* is omitted, the standard :class:`TreeBuilder` is used. The - *html* argument was historically used for backwards compatibility and is now - deprecated. If *encoding* [1]_ is given, the value overrides the encoding - specified in the XML file. + be fed XML data incrementally with the :meth:`feed` method, and parsing + events are translated to a push API - by invoking callbacks on the *target* + object. If *target* is omitted, the standard :class:`TreeBuilder` is used. + The *html* argument was historically used for backwards compatibility and is + now deprecated. If *encoding* [1]_ is given, the value overrides the + encoding specified in the XML file. .. deprecated:: 3.4 The *html* argument. The remaining arguments should be passed via - keywword to prepare for the removal of the *html* argument. + keyword to prepare for the removal of the *html* argument. .. method:: close() -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Feb 26 13:15:07 2016 From: python-checkins at python.org (georg.brandl) Date: Fri, 26 Feb 2016 18:15:07 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_merge_with_3=2E5?= Message-ID: <20160226181501.83581.8558@psf.io> https://hg.python.org/cpython/rev/732e46d081b5 changeset: 100347:732e46d081b5 parent: 100345:e4deabbfc1b2 parent: 100346:29beb1554dec user: Georg Brandl date: Fri Feb 26 19:14:56 2016 +0100 summary: merge with 3.5 files: Doc/library/xml.etree.elementtree.rst | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Doc/library/xml.etree.elementtree.rst b/Doc/library/xml.etree.elementtree.rst --- a/Doc/library/xml.etree.elementtree.rst +++ b/Doc/library/xml.etree.elementtree.rst @@ -1044,16 +1044,16 @@ This class is the low-level building block of the module. It uses :mod:`xml.parsers.expat` for efficient, event-based parsing of XML. It can - be fed XML data incrementall with the :meth:`feed` method, and parsing events - are translated to a push API - by invoking callbacks on the *target* object. - If *target* is omitted, the standard :class:`TreeBuilder` is used. The - *html* argument was historically used for backwards compatibility and is now - deprecated. If *encoding* [1]_ is given, the value overrides the encoding - specified in the XML file. + be fed XML data incrementally with the :meth:`feed` method, and parsing + events are translated to a push API - by invoking callbacks on the *target* + object. If *target* is omitted, the standard :class:`TreeBuilder` is used. + The *html* argument was historically used for backwards compatibility and is + now deprecated. If *encoding* [1]_ is given, the value overrides the + encoding specified in the XML file. .. deprecated:: 3.4 The *html* argument. The remaining arguments should be passed via - keywword to prepare for the removal of the *html* argument. + keyword to prepare for the removal of the *html* argument. .. method:: close() -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Feb 26 13:16:52 2016 From: python-checkins at python.org (georg.brandl) Date: Fri, 26 Feb 2016 18:16:52 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_merge_with_3=2E5?= Message-ID: <20160226181648.96730.71937@psf.io> https://hg.python.org/cpython/rev/c964cd3f9858 changeset: 100349:c964cd3f9858 parent: 100347:732e46d081b5 parent: 100348:9b240ec2bd42 user: Georg Brandl date: Fri Feb 26 19:16:43 2016 +0100 summary: merge with 3.5 files: Doc/library/xmlrpc.server.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/library/xmlrpc.server.rst b/Doc/library/xmlrpc.server.rst --- a/Doc/library/xmlrpc.server.rst +++ b/Doc/library/xmlrpc.server.rst @@ -18,7 +18,7 @@ .. warning:: - The :mod:`xmlrpc.client` module is not secure against maliciously + The :mod:`xmlrpc.server` module is not secure against maliciously constructed data. If you need to parse untrusted or unauthenticated data see :ref:`xml-vulnerabilities`. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Feb 26 13:17:06 2016 From: python-checkins at python.org (georg.brandl) Date: Fri, 26 Feb 2016 18:17:06 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogQ2xvc2VzICMyNjQ0?= =?utf-8?q?2=3A_fix_copy-paste=2E?= Message-ID: <20160226181648.6252.52420@psf.io> https://hg.python.org/cpython/rev/9b240ec2bd42 changeset: 100348:9b240ec2bd42 branch: 3.5 parent: 100346:29beb1554dec user: Georg Brandl date: Fri Feb 26 19:16:40 2016 +0100 summary: Closes #26442: fix copy-paste. files: Doc/library/xmlrpc.server.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/library/xmlrpc.server.rst b/Doc/library/xmlrpc.server.rst --- a/Doc/library/xmlrpc.server.rst +++ b/Doc/library/xmlrpc.server.rst @@ -18,7 +18,7 @@ .. warning:: - The :mod:`xmlrpc.client` module is not secure against maliciously + The :mod:`xmlrpc.server` module is not secure against maliciously constructed data. If you need to parse untrusted or unauthenticated data see :ref:`xml-vulnerabilities`. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Feb 26 13:18:10 2016 From: python-checkins at python.org (georg.brandl) Date: Fri, 26 Feb 2016 18:18:10 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_merge_with_3=2E5?= Message-ID: <20160226181809.1997.1187@psf.io> https://hg.python.org/cpython/rev/06001e079072 changeset: 100351:06001e079072 parent: 100349:c964cd3f9858 parent: 100350:fdcc3c0e7c6c user: Georg Brandl date: Fri Feb 26 19:18:05 2016 +0100 summary: merge with 3.5 files: Doc/using/mac.rst | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/using/mac.rst b/Doc/using/mac.rst --- a/Doc/using/mac.rst +++ b/Doc/using/mac.rst @@ -25,7 +25,7 @@ What you get after installing is a number of things: -* A :file:`MacPython 3.4` folder in your :file:`Applications` folder. In here +* A :file:`MacPython 3.6` folder in your :file:`Applications` folder. In here you find IDLE, the development environment that is a standard part of official Python distributions; PythonLauncher, which handles double-clicking Python scripts from the Finder; and the "Build Applet" tool, which allows you to @@ -93,7 +93,7 @@ anything that has a GUI) need to be run in a special way. Use :program:`pythonw` instead of :program:`python` to start such scripts. -With Python 3.4, you can use either :program:`python` or :program:`pythonw`. +With Python 3.6, you can use either :program:`python` or :program:`pythonw`. Configuration @@ -159,7 +159,7 @@ Distributing Python Applications on the Mac =========================================== -The "Build Applet" tool that is placed in the MacPython 3.4 folder is fine for +The "Build Applet" tool that is placed in the MacPython 3.6 folder is fine for packaging small Python scripts on your own machine to run as a standard Mac application. This tool, however, is not robust enough to distribute Python applications to other users. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Feb 26 13:18:10 2016 From: python-checkins at python.org (georg.brandl) Date: Fri, 26 Feb 2016 18:18:10 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogRml4IHZlcnNpb24u?= Message-ID: <20160226181809.1973.28246@psf.io> https://hg.python.org/cpython/rev/fdcc3c0e7c6c changeset: 100350:fdcc3c0e7c6c branch: 3.5 parent: 100348:9b240ec2bd42 user: Georg Brandl date: Fri Feb 26 19:17:39 2016 +0100 summary: Fix version. files: Doc/using/mac.rst | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/using/mac.rst b/Doc/using/mac.rst --- a/Doc/using/mac.rst +++ b/Doc/using/mac.rst @@ -25,7 +25,7 @@ What you get after installing is a number of things: -* A :file:`MacPython 3.4` folder in your :file:`Applications` folder. In here +* A :file:`MacPython 3.5` folder in your :file:`Applications` folder. In here you find IDLE, the development environment that is a standard part of official Python distributions; PythonLauncher, which handles double-clicking Python scripts from the Finder; and the "Build Applet" tool, which allows you to @@ -93,7 +93,7 @@ anything that has a GUI) need to be run in a special way. Use :program:`pythonw` instead of :program:`python` to start such scripts. -With Python 3.4, you can use either :program:`python` or :program:`pythonw`. +With Python 3.5, you can use either :program:`python` or :program:`pythonw`. Configuration @@ -159,7 +159,7 @@ Distributing Python Applications on the Mac =========================================== -The "Build Applet" tool that is placed in the MacPython 3.4 folder is fine for +The "Build Applet" tool that is placed in the MacPython 3.5 folder is fine for packaging small Python scripts on your own machine to run as a standard Mac application. This tool, however, is not robust enough to distribute Python applications to other users. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Feb 26 13:38:02 2016 From: python-checkins at python.org (georg.brandl) Date: Fri, 26 Feb 2016 18:38:02 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogQ2xvc2VzICMyNTkx?= =?utf-8?q?0=3A_fix_dead_and_permanently_redirected_links_in_the_docs=2E_T?= =?utf-8?q?hanks_to?= Message-ID: <20160226183801.1980.13253@psf.io> https://hg.python.org/cpython/rev/ce5ef48b5140 changeset: 100352:ce5ef48b5140 branch: 3.5 parent: 100350:fdcc3c0e7c6c user: Georg Brandl date: Fri Feb 26 19:37:12 2016 +0100 summary: Closes #25910: fix dead and permanently redirected links in the docs. Thanks to SilentGhost for the patch. files: Doc/distributing/index.rst | 16 +- Doc/distutils/apiref.rst | 2 +- Doc/extending/extending.rst | 2 +- Doc/extending/index.rst | 2 +- Doc/faq/design.rst | 2 +- Doc/faq/extending.rst | 4 +- Doc/faq/general.rst | 12 +- Doc/faq/gui.rst | 12 +- Doc/faq/library.rst | 2 +- Doc/faq/programming.rst | 2 +- Doc/howto/curses.rst | 2 +- Doc/howto/functional.rst | 12 +- Doc/howto/logging-cookbook.rst | 2 +- Doc/howto/logging.rst | 2 +- Doc/howto/sorting.rst | 6 +- Doc/howto/unicode.rst | 6 +- Doc/howto/webservers.rst | 34 +++--- Doc/installing/index.rst | 18 +- Doc/library/asyncio-eventloops.rst | 6 +- Doc/library/asyncio-subprocess.rst | 4 +- Doc/library/collections.rst | 6 +- Doc/library/dbm.rst | 2 +- Doc/library/decimal.rst | 3 - Doc/library/email.generator.rst | 4 +- Doc/library/functions.rst | 2 +- Doc/library/functools.rst | 6 +- Doc/library/heapq.rst | 4 +- Doc/library/http.client.rst | 2 +- Doc/library/itertools.rst | 4 +- Doc/library/json.rst | 2 +- Doc/library/logging.rst | 2 +- Doc/library/mailbox.rst | 4 +- Doc/library/math.rst | 16 +- Doc/library/msilib.rst | 64 +++++++------- Doc/library/os.rst | 6 +- Doc/library/othergui.rst | 14 +- Doc/library/random.rst | 2 +- Doc/library/re.rst | 2 +- Doc/library/shelve.rst | 4 +- Doc/library/socket.rst | 2 +- Doc/library/ssl.rst | 26 ++-- Doc/library/stat.rst | 2 +- Doc/library/subprocess.rst | 8 +- Doc/library/test.rst | 2 +- Doc/library/tkinter.rst | 4 +- Doc/library/unittest.mock-examples.rst | 6 +- Doc/library/urllib.request.rst | 2 +- Doc/library/winreg.rst | 12 +- Doc/library/wsgiref.rst | 4 +- Doc/library/xml.rst | 10 +- Doc/library/xmlrpc.client.rst | 2 +- Doc/library/zipfile.rst | 10 +- Doc/library/zipimport.rst | 2 +- Doc/using/mac.rst | 2 +- Doc/using/unix.rst | 8 +- Doc/using/windows.rst | 28 +++--- Doc/whatsnew/2.0.rst | 4 +- Doc/whatsnew/2.1.rst | 2 +- Doc/whatsnew/2.3.rst | 8 +- Doc/whatsnew/2.4.rst | 6 +- Doc/whatsnew/2.5.rst | 6 +- Doc/whatsnew/2.6.rst | 10 +- Doc/whatsnew/2.7.rst | 4 +- Doc/whatsnew/3.0.rst | 2 +- Doc/whatsnew/3.2.rst | 22 ++-- Doc/whatsnew/3.3.rst | 6 +- Doc/whatsnew/3.4.rst | 8 +- Doc/whatsnew/3.5.rst | 2 +- Misc/NEWS | 2 +- 69 files changed, 253 insertions(+), 256 deletions(-) diff --git a/Doc/distributing/index.rst b/Doc/distributing/index.rst --- a/Doc/distributing/index.rst +++ b/Doc/distributing/index.rst @@ -35,7 +35,7 @@ repository of open source licensed packages made available for use by other Python users * the `Python Packaging Authority - `__ are the group of + `__ are the group of developers and documentation authors responsible for the maintenance and evolution of the standard packaging tools and the associated metadata and file format standards. They maintain a variety of tools, documentation @@ -62,7 +62,7 @@ locally. .. _setuptools: https://setuptools.pypa.io/en/latest/setuptools.html -.. _wheel: http://wheel.readthedocs.org +.. _wheel: https://wheel.readthedocs.org Open source licensing and collaboration ======================================= @@ -111,7 +111,7 @@ The Python Packaging User Guide includes more details on the `currently recommended tools`_. -.. _currently recommended tools: https://packaging.python.org/en/latest/current.html#packaging-tool-recommendations +.. _currently recommended tools: https://packaging.python.org/en/latest/current/#packaging-tool-recommendations Reading the guide ================= @@ -124,11 +124,11 @@ * `Uploading the project to the Python Packaging Index`_ .. _Project structure: \ - https://packaging.python.org/en/latest/distributing.html#creating-your-own-project + https://packaging.python.org/en/latest/distributing/ .. _Building and packaging the project: \ - https://packaging.python.org/en/latest/distributing.html#packaging-your-project + https://packaging.python.org/en/latest/distributing/#packaging-your-project .. _Uploading the project to the Python Packaging Index: \ - https://packaging.python.org/en/latest/distributing.html#uploading-your-project-to-pypi + https://packaging.python.org/en/latest/distributing/#uploading-your-project-to-pypi How do I...? @@ -160,11 +160,11 @@ .. seealso:: `Python Packaging User Guide: Binary Extensions - `__ + `__ .. other topics: Once the Development & Deployment part of PPUG is fleshed out, some of those sections should be linked from new questions here (most notably, we should have a question about avoiding depending on PyPI that links to - https://packaging.python.org/en/latest/deployment.html#pypi-mirrors-and-caches) + https://packaging.python.org/en/latest/mirrors/) diff --git a/Doc/distutils/apiref.rst b/Doc/distutils/apiref.rst --- a/Doc/distutils/apiref.rst +++ b/Doc/distutils/apiref.rst @@ -1822,7 +1822,7 @@ Builds a `Windows Installer`_ (.msi) binary package. - .. _Windows Installer: http://msdn.microsoft.com/en-us/library/cc185688(VS.85).aspx + .. _Windows Installer: https://msdn.microsoft.com/en-us/library/cc185688(VS.85).aspx In most cases, the ``bdist_msi`` installer is a better choice than the ``bdist_wininst`` installer, because it provides better support for diff --git a/Doc/extending/extending.rst b/Doc/extending/extending.rst --- a/Doc/extending/extending.rst +++ b/Doc/extending/extending.rst @@ -27,7 +27,7 @@ avoid writing C extensions and preserve portability to other implementations. For example, if your use case is calling C library functions or system calls, you should consider using the :mod:`ctypes` module or the `cffi - `_ library rather than writing custom C code. + `_ library rather than writing custom C code. These modules let you write Python code to interface with C code and are more portable between implementations of Python than writing and compiling a C extension module. diff --git a/Doc/extending/index.rst b/Doc/extending/index.rst --- a/Doc/extending/index.rst +++ b/Doc/extending/index.rst @@ -32,7 +32,7 @@ .. seealso:: - `Python Packaging User Guide: Binary Extensions `_ + `Python Packaging User Guide: Binary Extensions `_ The Python Packaging User Guide not only covers several available tools that simplify the creation of binary extensions, but also discusses the various reasons why creating an extension module may be diff --git a/Doc/faq/design.rst b/Doc/faq/design.rst --- a/Doc/faq/design.rst +++ b/Doc/faq/design.rst @@ -370,7 +370,7 @@ `Cython `_ and `Pyrex `_ compile a modified version of Python with optional annotations into C -extensions. `Weave `_ makes it easy to +extensions. `Weave `_ makes it easy to intermingle Python and C code in various ways to increase performance. `Nuitka `_ is an up-and-coming compiler of Python into C++ code, aiming to support the full Python language. diff --git a/Doc/faq/extending.rst b/Doc/faq/extending.rst --- a/Doc/faq/extending.rst +++ b/Doc/faq/extending.rst @@ -50,10 +50,10 @@ If you need to interface to some C or C++ library for which no Python extension currently exists, you can try wrapping the library's data types and functions with a tool such as `SWIG `_. `SIP -`__, `CXX +`__, `CXX `_ `Boost `_, or `Weave -`_ are also +`_ are also alternatives for wrapping C++ libraries. diff --git a/Doc/faq/general.rst b/Doc/faq/general.rst --- a/Doc/faq/general.rst +++ b/Doc/faq/general.rst @@ -159,7 +159,7 @@ -------------------------------------------- The latest Python source distribution is always available from python.org, at -https://www.python.org/download/. The latest development sources can be obtained +https://www.python.org/downloads/. The latest development sources can be obtained via anonymous Mercurial access at https://hg.python.org/cpython. The source distribution is a gzipped tar file containing the complete C source, @@ -218,7 +218,7 @@ How do I get a beta test version of Python? ------------------------------------------- -Alpha and beta releases are available from https://www.python.org/download/. All +Alpha and beta releases are available from https://www.python.org/downloads/. All releases are announced on the comp.lang.python and comp.lang.python.announce newsgroups and on the Python home page at https://www.python.org/; an RSS feed of news is available. @@ -273,7 +273,7 @@ `www.python.org `_ is graciously hosted by `Rackspace `_, with CDN caching provided by `Fastly `_. `Upfront Systems -`_ hosts `bugs.python.org +`_ hosts `bugs.python.org `_. Many other Python services like `the Wiki `_ are hosted by `Oregon State University Open Source Lab `_. @@ -284,7 +284,7 @@ When he began implementing Python, Guido van Rossum was also reading the published scripts from `"Monty Python's Flying Circus" -`__, a BBC comedy series from the 1970s. Van Rossum +`__, a BBC comedy series from the 1970s. Van Rossum thought he needed a name that was short, unique, and slightly mysterious, so he decided to call the language Python. @@ -313,7 +313,7 @@ releases. The latest stable releases can always be found on the `Python download page -`_. There are two recommended production-ready +`_. There are two recommended production-ready versions at this point in time, because at the moment there are two branches of stable releases: 2.x and 3.x. Python 3.x may be less useful than 2.x, since currently there is more third party software available for Python 2 than for @@ -345,7 +345,7 @@ High-profile Python projects include `the Mailman mailing list manager `_ and `the Zope application server `_. Several Linux distributions, most notably `Red Hat -`_, have written part or all of their installer and +`_, have written part or all of their installer and system administration software in Python. Companies that use Python internally include Google, Yahoo, and Lucasfilm Ltd. diff --git a/Doc/faq/gui.rst b/Doc/faq/gui.rst --- a/Doc/faq/gui.rst +++ b/Doc/faq/gui.rst @@ -29,7 +29,7 @@ Standard builds of Python include an object-oriented interface to the Tcl/Tk widget set, called :ref:`tkinter `. This is probably the easiest to install (since it comes included with most -`binary distributions `_ of Python) and use. +`binary distributions `_ of Python) and use. For more info about Tk, including pointers to the source, see the `Tcl/Tk home page `_. Tcl/Tk is fully portable to the Mac OS X, Windows, and Unix platforms. @@ -58,19 +58,19 @@ --- There are bindings available for the Qt toolkit (using either `PyQt -`_ or `PySide -`_) and for KDE (`PyKDE `__). +`_ or `PySide +`_) and for KDE (`PyKDE `__). PyQt is currently more mature than PySide, but you must buy a PyQt license from -`Riverbank Computing `_ +`Riverbank Computing `_ if you want to write proprietary applications. PySide is free for all applications. Qt 4.5 upwards is licensed under the LGPL license; also, commercial licenses -are available from `The Qt Company `_. +are available from `The Qt Company `_. Gtk+ ---- -The `GObject introspection bindings `_ +The `GObject introspection bindings `_ for Python allow you to write GTK+ 3 applications. There is also a `Python GTK+ 3 Tutorial `_. diff --git a/Doc/faq/library.rst b/Doc/faq/library.rst --- a/Doc/faq/library.rst +++ b/Doc/faq/library.rst @@ -619,7 +619,7 @@ For Unix, see a Usenet post by Mitch Chapman: - http://groups.google.com/groups?selm=34A04430.CF9 at ohioee.com + https://groups.google.com/groups?selm=34A04430.CF9 at ohioee.com Why doesn't closing sys.stdout (stdin, stderr) really close it? diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -63,7 +63,7 @@ warns about code complexity and style. You can get PyChecker from http://pychecker.sourceforge.net/. -`Pylint `_ is another tool that checks +`Pylint `_ is another tool that checks if a module satisfies a coding standard, and also makes it possible to write plug-ins to add a custom feature. In addition to the bug checking that PyChecker performs, Pylint offers some additional features such as checking line diff --git a/Doc/howto/curses.rst b/Doc/howto/curses.rst --- a/Doc/howto/curses.rst +++ b/Doc/howto/curses.rst @@ -545,7 +545,7 @@ a lengthy tutorial for C programmers. * `The ncurses man page `_ * `The ncurses FAQ `_ -* `"Use curses... don't swear" `_: +* `"Use curses... don't swear" `_: video of a PyCon 2013 talk on controlling terminals using curses or Urwid. * `"Console Applications with Urwid" `_: video of a PyCon CA 2012 talk demonstrating some applications written using diff --git a/Doc/howto/functional.rst b/Doc/howto/functional.rst --- a/Doc/howto/functional.rst +++ b/Doc/howto/functional.rst @@ -332,7 +332,7 @@ List comprehensions and generator expressions (short form: "listcomps" and "genexps") are a concise notation for such operations, borrowed from the -functional programming language Haskell (http://www.haskell.org/). You can strip +functional programming language Haskell (https://www.haskell.org/). You can strip all the whitespace from a stream of strings with the following code:: line_list = [' line 1\n', 'line 2 \n', ...] @@ -716,7 +716,7 @@ It doesn't construct an in-memory list and exhaust all the input iterators before returning; instead tuples are constructed and returned only if they're requested. (The technical term for this behaviour is `lazy evaluation -`__.) +`__.) This iterator is intended to be used with iterables that are all of the same length. If the iterables are of different lengths, the resulting stream will be @@ -1199,7 +1199,7 @@ **Structure and Interpretation of Computer Programs**, by Harold Abelson and Gerald Jay Sussman with Julie Sussman. Full text at -http://mitpress.mit.edu/sicp/. In this classic textbook of computer science, +https://mitpress.mit.edu/sicp/. In this classic textbook of computer science, chapters 2 and 3 discuss the use of sequences and streams to organize the data flow inside a program. The book uses Scheme for its examples, but many of the design approaches described in these chapters are applicable to functional-style @@ -1208,12 +1208,12 @@ http://www.defmacro.org/ramblings/fp.html: A general introduction to functional programming that uses Java examples and has a lengthy historical introduction. -http://en.wikipedia.org/wiki/Functional_programming: General Wikipedia entry +https://en.wikipedia.org/wiki/Functional_programming: General Wikipedia entry describing functional programming. -http://en.wikipedia.org/wiki/Coroutine: Entry for coroutines. +https://en.wikipedia.org/wiki/Coroutine: Entry for coroutines. -http://en.wikipedia.org/wiki/Currying: Entry for the concept of currying. +https://en.wikipedia.org/wiki/Currying: Entry for the concept of currying. Python-specific --------------- diff --git a/Doc/howto/logging-cookbook.rst b/Doc/howto/logging-cookbook.rst --- a/Doc/howto/logging-cookbook.rst +++ b/Doc/howto/logging-cookbook.rst @@ -1316,7 +1316,7 @@ ----------------------------------------- Below is an example of a logging configuration dictionary - it's taken from -the `documentation on the Django project `_. +the `documentation on the Django project `_. This dictionary is passed to :func:`~config.dictConfig` to put the configuration into effect:: LOGGING = { diff --git a/Doc/howto/logging.rst b/Doc/howto/logging.rst --- a/Doc/howto/logging.rst +++ b/Doc/howto/logging.rst @@ -310,7 +310,7 @@ If your logging needs are simple, then use the above examples to incorporate logging into your own scripts, and if you run into problems or don't understand something, please post a question on the comp.lang.python Usenet -group (available at http://groups.google.com/group/comp.lang.python) and you +group (available at https://groups.google.com/group/comp.lang.python) and you should receive help before too long. Still here? You can carry on reading the next few sections, which provide a diff --git a/Doc/howto/sorting.rst b/Doc/howto/sorting.rst --- a/Doc/howto/sorting.rst +++ b/Doc/howto/sorting.rst @@ -127,7 +127,7 @@ ================================ Sorts are guaranteed to be `stable -`_\. That means that +`_\. That means that when multiple records have the same key, their original order is preserved. >>> data = [('red', 1), ('blue', 1), ('red', 2), ('blue', 2)] @@ -145,7 +145,7 @@ >>> sorted(s, key=attrgetter('grade'), reverse=True) # now sort on primary key, descending [('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)] -The `Timsort `_ algorithm used in Python +The `Timsort `_ algorithm used in Python does multiple sorts efficiently because it can take advantage of any ordering already present in a dataset. @@ -184,7 +184,7 @@ directly. Another name for this idiom is -`Schwartzian transform `_\, +`Schwartzian transform `_\, after Randal L. Schwartz, who popularized it among Perl programmers. Now that Python sorting provides key-functions, this technique is not often needed. diff --git a/Doc/howto/unicode.rst b/Doc/howto/unicode.rst --- a/Doc/howto/unicode.rst +++ b/Doc/howto/unicode.rst @@ -73,7 +73,7 @@ precise historical details aren't necessary for understanding how to use Unicode effectively, but if you're curious, consult the Unicode consortium site listed in the References or -the `Wikipedia entry for Unicode `_ +the `Wikipedia entry for Unicode `_ for more information.) @@ -223,8 +223,8 @@ reading this alternate article before continuing. Wikipedia entries are often helpful; see the entries for "`character encoding -`_" and `UTF-8 -`_, for example. +`_" and `UTF-8 +`_, for example. Python's Unicode Support diff --git a/Doc/howto/webservers.rst b/Doc/howto/webservers.rst --- a/Doc/howto/webservers.rst +++ b/Doc/howto/webservers.rst @@ -267,7 +267,7 @@ Each web server requires a specific module. * Apache has both `mod_fastcgi `_ and `mod_fcgid - `_. ``mod_fastcgi`` is the original one, but it + `_. ``mod_fastcgi`` is the original one, but it has some licensing issues, which is why it is sometimes considered non-free. ``mod_fcgid`` is a smaller, compatible alternative. One of these modules needs to be loaded by Apache. @@ -277,7 +277,7 @@ `SCGI module `_. * `nginx `_ also supports `FastCGI - `_. + `_. Once you have installed and configured the module, you can test it with the following WSGI-application:: @@ -307,8 +307,8 @@ .. seealso:: - There is some documentation on `setting up Django with FastCGI - `_, most of + There is some documentation on `setting up Django with WSGI + `_, most of which can be reused for other WSGI-compliant frameworks and libraries. Only the ``manage.py`` part has to be changed, the example used here can be used instead. Django does more or less the exact same thing. @@ -358,7 +358,7 @@ A really great WSGI feature is middleware. Middleware is a layer around your program which can add various functionality to it. There is quite a bit of -`middleware `_ already +`middleware `_ already available. For example, instead of writing your own session management (HTTP is a stateless protocol, so to associate multiple HTTP requests with a single user your application must create and manage such state via a session), you can @@ -379,7 +379,7 @@ The code that is used to connect to various low level gateways like CGI or mod_python is called a *WSGI server*. One of these servers is ``flup``, which supports FastCGI and SCGI, as well as `AJP -`_. Some of these servers +`_. Some of these servers are written in Python, as ``flup`` is, but there also exist others which are written in C and can be used as drop-in replacements. @@ -390,8 +390,8 @@ .. seealso:: A good overview of WSGI-related code can be found in the `WSGI homepage - `_, which contains an extensive list of `WSGI servers - `_ which can be used by *any* application + `_, which contains an extensive list of `WSGI servers + `_ which can be used by *any* application supporting WSGI. You might be interested in some WSGI-supporting modules already contained in @@ -408,7 +408,7 @@ Python without using WSGI. One of the most widely used wiki software packages is `MoinMoin -`_. It was created in 2000, so it predates WSGI by about +`_. It was created in 2000, so it predates WSGI by about three years. Older versions needed separate code to run on CGI, mod_python, FastCGI and standalone. @@ -460,7 +460,7 @@ .. seealso:: The English Wikipedia has an article about the `Model-View-Controller pattern - `_. It includes a long + `_. It includes a long list of web frameworks for various programming languages. @@ -543,10 +543,10 @@ smaller sites SQLite is just enough. Relational databases are *queried* using a language called `SQL -`_. Python programmers in general do not +`_. Python programmers in general do not like SQL too much, as they prefer to work with objects. It is possible to save Python objects into a database using a technology called `ORM -`_ (Object Relational +`_ (Object Relational Mapping). ORM translates all object-oriented access into SQL code under the hood, so the developer does not need to think about it. Most `frameworks`_ use ORMs, and it works quite well. @@ -579,13 +579,13 @@ helps with choosing a method for saving data * `SQLAlchemy `_, the most powerful OR-Mapper - for Python, and `Elixir `_, which makes + for Python, and `Elixir `_, which makes SQLAlchemy easier to use * `SQLObject `_, another popular OR-Mapper * `ZODB `_ and `Durus - `_, two object oriented + `_, two object oriented databases @@ -671,10 +671,10 @@ example the ORM and template engine can be changed to use packages different from those used by default. -The documentation can be found in the `TurboGears wiki -`_, where links to screencasts can be found. +The documentation can be found in the `TurboGears documentation +`_, where links to screencasts can be found. TurboGears has also an active user community which can respond to most related -questions. There is also a `TurboGears book `_ +questions. There is also a `TurboGears book `_ published, which is a good starting point. The newest version of TurboGears, version 2.0, moves even further in direction diff --git a/Doc/installing/index.rst b/Doc/installing/index.rst --- a/Doc/installing/index.rst +++ b/Doc/installing/index.rst @@ -48,7 +48,7 @@ repository of open source licensed packages made available for use by other Python users * the `Python Packaging Authority - `__ are the group of + `__ are the group of developers and documentation authors responsible for the maintenance and evolution of the standard packaging tools and the associated metadata and file format standards. They maintain a variety of tools, documentation @@ -106,7 +106,7 @@ .. seealso:: `Python Packaging User Guide: Installing Python Distribution Packages - `__ + `__ How do I ...? @@ -123,8 +123,8 @@ .. seealso:: - `Python Packaging User Guide: Setup for Installing Distribution Packages - `__ + `Python Packaging User Guide: Requirements for Installing Packages + `__ .. installing-per-user-installation: @@ -143,13 +143,13 @@ aren't currently easy to install using ``pip`` directly. At this point in time, it will often be easier for users to install these packages by `other means -`__ +`__ rather than attempting to install them with ``pip``. .. seealso:: `Python Packaging User Guide: Installing Scientific Packages - `__ + `__ ... work with multiple versions of Python installed in parallel? @@ -179,7 +179,7 @@ Once the Development & Deployment part of PPUG is fleshed out, some of those sections should be linked from new questions here (most notably, we should have a question about avoiding depending on PyPI that links to - https://packaging.python.org/en/latest/deployment.html#pypi-mirrors-and-caches) + https://packaging.python.org/en/latest/mirrors/) Common installation issues @@ -212,11 +212,11 @@ than needing to build them themselves. Some of the solutions for installing `scientific software -`__ +`__ that is not yet available as pre-built ``wheel`` files may also help with obtaining other binary extensions without needing to build them locally. .. seealso:: `Python Packaging User Guide: Binary Extensions - `__ + `__ diff --git a/Doc/library/asyncio-eventloops.rst b/Doc/library/asyncio-eventloops.rst --- a/Doc/library/asyncio-eventloops.rst +++ b/Doc/library/asyncio-eventloops.rst @@ -41,7 +41,7 @@ On Windows, only sockets are supported (ex: pipes are not supported): see the `MSDN documentation of select - `_. + `_. .. class:: ProactorEventLoop @@ -53,7 +53,7 @@ .. seealso:: `MSDN documentation on I/O Completion Ports - `_. + `_. Example to use a :class:`ProactorEventLoop` on Windows:: @@ -107,7 +107,7 @@ The resolution of the monotonic clock on Windows is usually around 15.6 msec. The best resolution is 0.5 msec. The resolution depends on the hardware (availability of `HPET -`_) and on the Windows +`_) and on the Windows configuration. See :ref:`asyncio delayed calls `. .. versionchanged:: 3.5 diff --git a/Doc/library/asyncio-subprocess.rst b/Doc/library/asyncio-subprocess.rst --- a/Doc/library/asyncio-subprocess.rst +++ b/Doc/library/asyncio-subprocess.rst @@ -51,7 +51,7 @@ It is the application's responsibility to ensure that all whitespace and metacharacters are quoted appropriately to avoid `shell injection - `_ + `_ vulnerabilities. The :func:`shlex.quote` function can be used to properly escape whitespace and shell metacharacters in strings that are going to be used to construct shell commands. @@ -134,7 +134,7 @@ It is the application's responsibility to ensure that all whitespace and metacharacters are quoted appropriately to avoid `shell injection - `_ + `_ vulnerabilities. The :func:`shlex.quote` function can be used to properly escape whitespace and shell metacharacters in strings that are going to be used to construct shell commands. diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst --- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -374,12 +374,12 @@ .. seealso:: - * `Bag class `_ + * `Bag class `_ in Smalltalk. - * Wikipedia entry for `Multisets `_. + * Wikipedia entry for `Multisets `_. - * `C++ multisets `_ + * `C++ multisets `_ tutorial with examples. * For mathematical operations on multisets and their use cases, see diff --git a/Doc/library/dbm.rst b/Doc/library/dbm.rst --- a/Doc/library/dbm.rst +++ b/Doc/library/dbm.rst @@ -7,7 +7,7 @@ :mod:`dbm` is a generic interface to variants of the DBM database --- :mod:`dbm.gnu` or :mod:`dbm.ndbm`. If none of these modules is installed, the slow-but-simple implementation in module :mod:`dbm.dumb` will be used. There -is a `third party interface `_ to +is a `third party interface `_ to the Oracle Berkeley DB. diff --git a/Doc/library/decimal.rst b/Doc/library/decimal.rst --- a/Doc/library/decimal.rst +++ b/Doc/library/decimal.rst @@ -109,9 +109,6 @@ * IBM's General Decimal Arithmetic Specification, `The General Decimal Arithmetic Specification `_. - * IEEE standard 854-1987, `Unofficial IEEE 854 Text - `_. - .. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/Doc/library/email.generator.rst b/Doc/library/email.generator.rst --- a/Doc/library/email.generator.rst +++ b/Doc/library/email.generator.rst @@ -43,7 +43,7 @@ followed by a space at the beginning of the line. This is the only guaranteed portable way to avoid having such lines be mistaken for a Unix mailbox format envelope header separator (see `WHY THE CONTENT-LENGTH FORMAT IS BAD - `_ for details). *mangle_from_* + `_ for details). *mangle_from_* defaults to ``True``, but you might want to set this to ``False`` if you are not writing Unix mailbox format files. @@ -123,7 +123,7 @@ i.e. ``From`` followed by a space at the beginning of the line. This is the only guaranteed portable way to avoid having such lines be mistaken for a Unix mailbox format envelope header separator (see `WHY THE CONTENT-LENGTH - FORMAT IS BAD `_ for details). + FORMAT IS BAD `_ for details). *mangle_from_* defaults to ``True``, but you might want to set this to ``False`` if you are not writing Unix mailbox format files. diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -1418,7 +1418,7 @@ For practical suggestions on how to design cooperative classes using :func:`super`, see `guide to using super() - `_. + `_. .. _func-tuple: diff --git a/Doc/library/functools.rst b/Doc/library/functools.rst --- a/Doc/library/functools.rst +++ b/Doc/library/functools.rst @@ -73,7 +73,7 @@ bypassing the cache, or for rewrapping the function with a different cache. An `LRU (least recently used) cache - `_ works + `_ works best when the most recent calls are the best predictors of upcoming calls (for example, the most popular articles on a news server tend to change each day). The cache's size limit assures that the cache does not grow without bound on @@ -99,9 +99,9 @@ CacheInfo(hits=3, misses=8, maxsize=32, currsize=8) Example of efficiently computing - `Fibonacci numbers `_ + `Fibonacci numbers `_ using a cache to implement a - `dynamic programming `_ + `dynamic programming `_ technique:: @lru_cache(maxsize=None) diff --git a/Doc/library/heapq.rst b/Doc/library/heapq.rst --- a/Doc/library/heapq.rst +++ b/Doc/library/heapq.rst @@ -132,7 +132,7 @@ Basic Examples -------------- -A `heapsort `_ can be implemented by +A `heapsort `_ can be implemented by pushing all values onto a heap and then popping off the smallest values one at a time:: @@ -163,7 +163,7 @@ Priority Queue Implementation Notes ----------------------------------- -A `priority queue `_ is common use +A `priority queue `_ is common use for a heap, and it presents several implementation challenges: * Sort stability: how do you get two tasks with equal priorities to be returned diff --git a/Doc/library/http.client.rst b/Doc/library/http.client.rst --- a/Doc/library/http.client.rst +++ b/Doc/library/http.client.rst @@ -21,7 +21,7 @@ .. seealso:: - The `Requests package `_ + The `Requests package `_ is recommended for a higher-level http client interface. .. note:: diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst --- a/Doc/library/itertools.rst +++ b/Doc/library/itertools.rst @@ -117,7 +117,7 @@ :func:`min` for a running minimum, :func:`max` for a running maximum, or :func:`operator.mul` for a running product. Amortization tables can be built by accumulating interest and applying payments. First-order - `recurrence relations `_ + `recurrence relations `_ can be modeled by supplying the initial value in the iterable and using only the accumulated total in *func* argument:: @@ -132,7 +132,7 @@ >>> list(accumulate(cashflows, lambda bal, pmt: bal*1.05 + pmt)) [1000, 960.0, 918.0, 873.9000000000001, 827.5950000000001] - # Chaotic recurrence relation http://en.wikipedia.org/wiki/Logistic_map + # Chaotic recurrence relation https://en.wikipedia.org/wiki/Logistic_map >>> logistic_map = lambda x, _: r * x * (1 - x) >>> r = 3.8 >>> x0 = 0.4 diff --git a/Doc/library/json.rst b/Doc/library/json.rst --- a/Doc/library/json.rst +++ b/Doc/library/json.rst @@ -10,7 +10,7 @@ :rfc:`7159` (which obsoletes :rfc:`4627`) and by `ECMA-404 `_, is a lightweight data interchange format inspired by -`JavaScript `_ object literal syntax +`JavaScript `_ object literal syntax (although it is not a strict subset of JavaScript [#rfc-errata]_ ). :mod:`json` exposes an API familiar to users of the standard library diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst --- a/Doc/library/logging.rst +++ b/Doc/library/logging.rst @@ -1246,7 +1246,7 @@ The proposal which described this feature for inclusion in the Python standard library. - `Original Python logging package `_ + `Original Python logging package `_ This is the original source for the :mod:`logging` package. The version of the package available from this site is suitable for use with Python 1.5.2, 2.1.x and 2.2.x, which do not include the :mod:`logging` package in the standard diff --git a/Doc/library/mailbox.rst b/Doc/library/mailbox.rst --- a/Doc/library/mailbox.rst +++ b/Doc/library/mailbox.rst @@ -484,7 +484,7 @@ `mbox man page from tin `_ Another specification of the format, with details on locking. - `Configuring Netscape Mail on Unix: Why The Content-Length Format is Bad `_ + `Configuring Netscape Mail on Unix: Why The Content-Length Format is Bad `_ An argument for using the original mbox format rather than a variation. `"mbox" is a family of several mutually incompatible mailbox formats `_ @@ -744,7 +744,7 @@ `mmdf man page from tin `_ A specification of MMDF format from the documentation of tin, a newsreader. - `MMDF `_ + `MMDF `_ A Wikipedia article describing the Multichannel Memorandum Distribution Facility. diff --git a/Doc/library/math.rst b/Doc/library/math.rst --- a/Doc/library/math.rst +++ b/Doc/library/math.rst @@ -97,7 +97,7 @@ For further discussion and two alternative approaches, see the `ASPN cookbook recipes for accurate floating point summation - `_\. + `_\. .. function:: gcd(a, b) @@ -204,7 +204,7 @@ Return ``e**x - 1``. For small floats *x*, the subtraction in ``exp(x) - 1`` can result in a `significant loss of precision - `_\; the :func:`expm1` + `_\; the :func:`expm1` function provides a way to compute this quantity to full precision:: >>> from math import exp, expm1 @@ -332,7 +332,7 @@ Hyperbolic functions -------------------- -`Hyperbolic functions `_ +`Hyperbolic functions `_ are analogs of trigonometric functions that are based on hyperbolas instead of circles. @@ -371,12 +371,12 @@ .. function:: erf(x) - Return the `error function `_ at + Return the `error function `_ at *x*. The :func:`erf` function can be used to compute traditional statistical functions such as the `cumulative standard normal distribution - `_:: + `_:: def phi(x): 'Cumulative distribution function for the standard normal distribution' @@ -388,17 +388,17 @@ .. function:: erfc(x) Return the complementary error function at *x*. The `complementary error - function `_ is defined as + function `_ is defined as ``1.0 - erf(x)``. It is used for large values of *x* where a subtraction from one would cause a `loss of significance - `_\. + `_\. .. versionadded:: 3.2 .. function:: gamma(x) - Return the `Gamma function `_ at + Return the `Gamma function `_ at *x*. .. versionadded:: 3.2 diff --git a/Doc/library/msilib.rst b/Doc/library/msilib.rst --- a/Doc/library/msilib.rst +++ b/Doc/library/msilib.rst @@ -120,9 +120,9 @@ .. seealso:: - `FCICreateFile `_ - `UuidCreate `_ - `UuidToString `_ + `FCICreateFile `_ + `UuidCreate `_ + `UuidToString `_ .. _database-objects: @@ -151,9 +151,9 @@ .. seealso:: - `MSIDatabaseOpenView `_ - `MSIDatabaseCommit `_ - `MSIGetSummaryInformation `_ + `MSIDatabaseOpenView `_ + `MSIDatabaseCommit `_ + `MSIGetSummaryInformation `_ .. _view-objects: @@ -199,11 +199,11 @@ .. seealso:: - `MsiViewExecute `_ - `MSIViewGetColumnInfo `_ - `MsiViewFetch `_ - `MsiViewModify `_ - `MsiViewClose `_ + `MsiViewExecute `_ + `MSIViewGetColumnInfo `_ + `MsiViewFetch `_ + `MsiViewModify `_ + `MsiViewClose `_ .. _summary-objects: @@ -243,10 +243,10 @@ .. seealso:: - `MsiSummaryInfoGetProperty `_ - `MsiSummaryInfoGetPropertyCount `_ - `MsiSummaryInfoSetProperty `_ - `MsiSummaryInfoPersist `_ + `MsiSummaryInfoGetProperty `_ + `MsiSummaryInfoGetPropertyCount `_ + `MsiSummaryInfoSetProperty `_ + `MsiSummaryInfoPersist `_ .. _record-objects: @@ -297,11 +297,11 @@ .. seealso:: - `MsiRecordGetFieldCount `_ - `MsiRecordSetString `_ - `MsiRecordSetStream `_ - `MsiRecordSetInteger `_ - `MsiRecordClear `_ + `MsiRecordGetFieldCount `_ + `MsiRecordSetString `_ + `MsiRecordSetStream `_ + `MsiRecordSetInteger `_ + `MsiRecordClear `_ .. _msi-errors: @@ -393,10 +393,10 @@ .. seealso:: - `Directory Table `_ - `File Table `_ - `Component Table `_ - `FeatureComponents Table `_ + `Directory Table `_ + `File Table `_ + `Component Table `_ + `FeatureComponents Table `_ .. _features: @@ -421,7 +421,7 @@ .. seealso:: - `Feature Table `_ + `Feature Table `_ .. _msi-gui: @@ -516,13 +516,13 @@ .. seealso:: - `Dialog Table `_ - `Control Table `_ - `Control Types `_ - `ControlCondition Table `_ - `ControlEvent Table `_ - `EventMapping Table `_ - `RadioButton Table `_ + `Dialog Table `_ + `Control Table `_ + `Control Types `_ + `ControlCondition Table `_ + `ControlEvent Table `_ + `EventMapping Table `_ + `RadioButton Table `_ .. _msi-tables: diff --git a/Doc/library/os.rst b/Doc/library/os.rst --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -894,7 +894,7 @@ :func:`~os.open` function. They can be combined using the bitwise OR operator ``|``. Some of them are not available on all platforms. For descriptions of their availability and use, consult the :manpage:`open(2)` manual page on Unix -or `the MSDN `_ on Windows. +or `the MSDN `_ on Windows. .. data:: O_RDONLY @@ -1907,9 +1907,9 @@ and `readdir() `_ functions. On Windows, it uses the Win32 - `FindFirstFileW `_ + `FindFirstFileW `_ and - `FindNextFileW `_ + `FindNextFileW `_ functions. .. versionadded:: 3.5 diff --git a/Doc/library/othergui.rst b/Doc/library/othergui.rst --- a/Doc/library/othergui.rst +++ b/Doc/library/othergui.rst @@ -8,33 +8,33 @@ .. seealso:: - `PyGObject `_ + `PyGObject `_ provides introspection bindings for C libraries using `GObject `_. One of these libraries is the `GTK+ 3 `_ widget set. GTK+ comes with many more widgets than Tkinter provides. An online - `Python GTK+ 3 Tutorial `_ + `Python GTK+ 3 Tutorial `_ is available. `PyGTK `_ provides bindings for an older version of the library, GTK+ 2. It provides an object oriented interface that is slightly higher level than the C one. There are also bindings to - `GNOME `_. An online `tutorial + `GNOME `_. An online `tutorial `_ is available. - `PyQt `_ + `PyQt `_ PyQt is a :program:`sip`\ -wrapped binding to the Qt toolkit. Qt is an extensive C++ GUI application development framework that is available for Unix, Windows and Mac OS X. :program:`sip` is a tool for generating bindings for C++ libraries as Python classes, and is specifically designed for Python. The *PyQt3* bindings have a book, `GUI Programming with Python: QT Edition - `_ by Boudewijn + `_ by Boudewijn Rempt. The *PyQt4* bindings also have a book, `Rapid GUI Programming with Python and Qt `_, by Mark Summerfield. - `PySide `_ + `PySide `_ is a newer binding to the Qt toolkit, provided by Nokia. Compared to PyQt, its licensing scheme is friendlier to non-open source applications. @@ -50,7 +50,7 @@ low-level device context drawing, drag and drop, system clipboard access, an XML-based resource format and more, including an ever growing library of user-contributed modules. wxPython has a book, `wxPython in Action - `_, by Noel Rappin and + `_, by Noel Rappin and Robin Dunn. PyGTK, PyQt, and wxPython, all have a modern look and feel and more diff --git a/Doc/library/random.rst b/Doc/library/random.rst --- a/Doc/library/random.rst +++ b/Doc/library/random.rst @@ -267,7 +267,7 @@ `Complementary-Multiply-with-Carry recipe - `_ for a compatible alternative + `_ for a compatible alternative random number generator with a long period and comparatively simple update operations. diff --git a/Doc/library/re.rst b/Doc/library/re.rst --- a/Doc/library/re.rst +++ b/Doc/library/re.rst @@ -1389,7 +1389,7 @@ Writing a Tokenizer ^^^^^^^^^^^^^^^^^^^ -A `tokenizer or scanner `_ +A `tokenizer or scanner `_ analyzes a string to categorize groups of characters. This is a useful first step in writing a compiler or interpreter. diff --git a/Doc/library/shelve.rst b/Doc/library/shelve.rst --- a/Doc/library/shelve.rst +++ b/Doc/library/shelve.rst @@ -76,7 +76,7 @@ .. seealso:: - `Persistent dictionary recipe `_ + `Persistent dictionary recipe `_ with widely supported storage formats and having the speed of native dictionaries. @@ -137,7 +137,7 @@ A subclass of :class:`Shelf` which exposes :meth:`first`, :meth:`!next`, :meth:`previous`, :meth:`last` and :meth:`set_location` which are available in the third-party :mod:`bsddb` module from `pybsddb - `_ but not in other database + `_ but not in other database modules. The *dict* object passed to the constructor must support those methods. This is generally accomplished by calling one of :func:`bsddb.hashopen`, :func:`bsddb.btopen` or :func:`bsddb.rnopen`. The diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -983,7 +983,7 @@ The :meth:`ioctl` method is a limited interface to the WSAIoctl system interface. Please refer to the `Win32 documentation - `_ for more + `_ for more information. On other platforms, the generic :func:`fcntl.fcntl` and :func:`fcntl.ioctl` diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst --- a/Doc/library/ssl.rst +++ b/Doc/library/ssl.rst @@ -206,7 +206,7 @@ The *ciphers* parameter sets the available ciphers for this SSL object. It should be a string in the `OpenSSL cipher list format - `_. + `_. The parameter ``do_handshake_on_connect`` specifies whether to do the SSL handshake automatically after doing a :meth:`socket.connect`, or whether the @@ -296,7 +296,7 @@ Read the Wikipedia article, `Cryptographically secure pseudorandom number generator (CSPRNG) - `_, + `_, to get the requirements of a cryptographically generator. .. versionadded:: 3.3 @@ -721,7 +721,7 @@ Whether the OpenSSL library has built-in support for *Next Protocol Negotiation* as described in the `NPN draft specification - `_. When true, + `_. When true, you can use the :meth:`SSLContext.set_npn_protocols` method to advertise which protocols you want to support. @@ -1212,7 +1212,7 @@ Set the available ciphers for sockets created with this context. It should be a string in the `OpenSSL cipher list format - `_. + `_. If no cipher can be selected (because compile-time options or other configuration forbids use of all the specified ciphers), an :class:`SSLError` will be raised. @@ -1241,7 +1241,7 @@ handshake. It should be a list of strings, like ``['http/1.1', 'spdy/2']``, ordered by preference. The selection of a protocol will happen during the handshake, and will play out according to the `NPN draft specification - `_. After a + `_. After a successful handshake, the :meth:`SSLSocket.selected_npn_protocol` method will return the agreed-upon protocol. @@ -2019,7 +2019,7 @@ :meth:`SSLContext.set_ciphers` method. Starting from Python 3.2.3, the ssl module disables certain weak ciphers by default, but you may want to further restrict the cipher choice. Be sure to read OpenSSL's documentation -about the `cipher list format `_. +about the `cipher list format `_. If you want to check which ciphers are enabled by a given cipher list, use the ``openssl ciphers`` command on your system. @@ -2040,25 +2040,25 @@ Class :class:`socket.socket` Documentation of underlying :mod:`socket` class - `SSL/TLS Strong Encryption: An Introduction `_ + `SSL/TLS Strong Encryption: An Introduction `_ Intro from the Apache webserver documentation - `RFC 1422: Privacy Enhancement for Internet Electronic Mail: Part II: Certificate-Based Key Management `_ + `RFC 1422: Privacy Enhancement for Internet Electronic Mail: Part II: Certificate-Based Key Management `_ Steve Kent - `RFC 1750: Randomness Recommendations for Security `_ + `RFC 1750: Randomness Recommendations for Security `_ D. Eastlake et. al. - `RFC 3280: Internet X.509 Public Key Infrastructure Certificate and CRL Profile `_ + `RFC 3280: Internet X.509 Public Key Infrastructure Certificate and CRL Profile `_ Housley et. al. - `RFC 4366: Transport Layer Security (TLS) Extensions `_ + `RFC 4366: Transport Layer Security (TLS) Extensions `_ Blake-Wilson et. al. - `RFC 5246: The Transport Layer Security (TLS) Protocol Version 1.2 `_ + `RFC 5246: The Transport Layer Security (TLS) Protocol Version 1.2 `_ T. Dierks et. al. - `RFC 6066: Transport Layer Security (TLS) Extensions `_ + `RFC 6066: Transport Layer Security (TLS) Extensions `_ D. Eastlake `IANA TLS: Transport Layer Security (TLS) Parameters `_ diff --git a/Doc/library/stat.rst b/Doc/library/stat.rst --- a/Doc/library/stat.rst +++ b/Doc/library/stat.rst @@ -403,7 +403,7 @@ On Windows, the following file attribute constants are available for use when testing bits in the ``st_file_attributes`` member returned by :func:`os.stat`. See the `Windows API documentation -`_ +`_ for more detail on the meaning of these constants. .. data:: FILE_ATTRIBUTE_ARCHIVE diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst --- a/Doc/library/subprocess.rst +++ b/Doc/library/subprocess.rst @@ -475,7 +475,7 @@ execute. On Windows, in order to run a `side-by-side assembly`_ the specified *env* **must** include a valid :envvar:`SystemRoot`. - .. _side-by-side assembly: http://en.wikipedia.org/wiki/Side-by-Side_Assembly + .. _side-by-side assembly: https://en.wikipedia.org/wiki/Side-by-Side_Assembly If *universal_newlines* is ``True``, the file objects *stdin*, *stdout* and *stderr* are opened as text streams in universal newlines mode, as @@ -536,7 +536,7 @@ If the shell is invoked explicitly, via ``shell=True``, it is the application's responsibility to ensure that all whitespace and metacharacters are quoted appropriately to avoid -`shell injection `_ +`shell injection `_ vulnerabilities. When using ``shell=True``, the :func:`shlex.quote` function can be @@ -721,7 +721,7 @@ .. class:: STARTUPINFO() Partial support of the Windows - `STARTUPINFO `__ + `STARTUPINFO `__ structure is used for :class:`Popen` creation. .. attribute:: dwFlags @@ -757,7 +757,7 @@ If :attr:`dwFlags` specifies :data:`STARTF_USESHOWWINDOW`, this attribute can be any of the values that can be specified in the ``nCmdShow`` parameter for the - `ShowWindow `__ + `ShowWindow `__ function, except for ``SW_SHOWDEFAULT``. Otherwise, this attribute is ignored. diff --git a/Doc/library/test.rst b/Doc/library/test.rst --- a/Doc/library/test.rst +++ b/Doc/library/test.rst @@ -619,7 +619,7 @@ are expected to crash a subprocess. On Windows, it disables Windows Error Reporting dialogs using - `SetErrorMode `_. + `SetErrorMode `_. On UNIX, :func:`resource.setrlimit` is used to set :attr:`resource.RLIMIT_CORE`'s soft limit to 0 to prevent coredump file diff --git a/Doc/library/tkinter.rst b/Doc/library/tkinter.rst --- a/Doc/library/tkinter.rst +++ b/Doc/library/tkinter.rst @@ -31,13 +31,13 @@ `Tcl/Tk manual `_ Official manual for the latest tcl/tk version. - `Programming Python `_ + `Programming Python `_ Book by Mark Lutz, has excellent coverage of Tkinter. `Modern Tkinter for Busy Python Developers `_ Book by Mark Rozerman about building attractive and modern graphical user interfaces with Python and Tkinter. - `Python and Tkinter Programming `_ + `Python and Tkinter Programming `_ The book by John Grayson (ISBN 1-884777-81-3). diff --git a/Doc/library/unittest.mock-examples.rst b/Doc/library/unittest.mock-examples.rst --- a/Doc/library/unittest.mock-examples.rst +++ b/Doc/library/unittest.mock-examples.rst @@ -549,7 +549,7 @@ An alternative way of dealing with mocking dates, or other builtin classes, is discussed in `this blog entry -`_. +`_. Mocking a Generator Method @@ -1251,7 +1251,7 @@ :exc:`AssertionError` directly and provide a more useful failure message. As of version 1.5, the Python testing library `PyHamcrest -`_ provides similar functionality, +`_ provides similar functionality, that may be useful here, in the form of its equality matcher (`hamcrest.library.integration.match_equality -`_). +`_). diff --git a/Doc/library/urllib.request.rst b/Doc/library/urllib.request.rst --- a/Doc/library/urllib.request.rst +++ b/Doc/library/urllib.request.rst @@ -14,7 +14,7 @@ .. seealso:: - The `Requests package `_ + The `Requests package `_ is recommended for a higher-level http client interface. diff --git a/Doc/library/winreg.rst b/Doc/library/winreg.rst --- a/Doc/library/winreg.rst +++ b/Doc/library/winreg.rst @@ -134,7 +134,7 @@ The :func:`DeleteKeyEx` function is implemented with the RegDeleteKeyEx Windows API function, which is specific to 64-bit versions of Windows. See the `RegDeleteKeyEx documentation - `__. + `__. *key* is an already open key, or one of the predefined :ref:`HKEY_* constants `. @@ -268,7 +268,7 @@ A call to :func:`LoadKey` fails if the calling process does not have the :const:`SE_RESTORE_PRIVILEGE` privilege. Note that privileges are different from permissions -- see the `RegLoadKey documentation - `__ for + `__ for more details. If *key* is a handle returned by :func:`ConnectRegistry`, then the path @@ -383,7 +383,7 @@ possess the :const:`SeBackupPrivilege` security privilege. Note that privileges are different than permissions -- see the `Conflicts Between User Rights and Permissions documentation - `__ + `__ for more details. This function passes NULL for *security_attributes* to the API. @@ -547,7 +547,7 @@ +++++++++++++ For more information, see `Registry Key Security and Access -`__. +`__. .. data:: KEY_ALL_ACCESS @@ -602,7 +602,7 @@ *************** For more information, see `Accessing an Alternate Registry View -`__. +`__. .. data:: KEY_WOW64_64KEY @@ -621,7 +621,7 @@ +++++++++++ For more information, see `Registry Value Types -`__. +`__. .. data:: REG_BINARY diff --git a/Doc/library/wsgiref.rst b/Doc/library/wsgiref.rst --- a/Doc/library/wsgiref.rst +++ b/Doc/library/wsgiref.rst @@ -24,8 +24,8 @@ and a validation tool that checks WSGI servers and applications for conformance to the WSGI specification (:pep:`3333`). -See http://www.wsgi.org for more information about WSGI, and links to tutorials -and other resources. +See https://wsgi.readthedocs.org/ for more information about WSGI, and links to +tutorials and other resources. .. XXX If you're just trying to write a web application... diff --git a/Doc/library/xml.rst b/Doc/library/xml.rst --- a/Doc/library/xml.rst +++ b/Doc/library/xml.rst @@ -62,7 +62,7 @@ billion laughs **Yes** **Yes** **Yes** **Yes** **Yes** quadratic blowup **Yes** **Yes** **Yes** **Yes** **Yes** external entity expansion **Yes** No (1) No (2) **Yes** No (3) -DTD retrieval **Yes** No No **Yes** No +`DTD`_ retrieval **Yes** No No **Yes** No decompression bomb No No No No **Yes** ========================= ======== ========= ========= ======== ========= @@ -92,7 +92,7 @@ also point to external resources or local files. The XML parser accesses the resource and embeds the content into the XML document. -DTD retrieval +`DTD`_ retrieval Some XML libraries like Python's :mod:`xml.dom.pulldom` retrieve document type definitions from remote or local locations. The feature has similar implications as the external entity expansion issue. @@ -128,6 +128,6 @@ .. _defusedxml: https://pypi.python.org/pypi/defusedxml/ .. _defusedexpat: https://pypi.python.org/pypi/defusedexpat/ -.. _Billion Laughs: http://en.wikipedia.org/wiki/Billion_laughs -.. _ZIP bomb: http://en.wikipedia.org/wiki/Zip_bomb -.. _DTD: http://en.wikipedia.org/wiki/Document_Type_Definition +.. _Billion Laughs: https://en.wikipedia.org/wiki/Billion_laughs +.. _ZIP bomb: https://en.wikipedia.org/wiki/Zip_bomb +.. _DTD: https://en.wikipedia.org/wiki/Document_type_definition diff --git a/Doc/library/xmlrpc.client.rst b/Doc/library/xmlrpc.client.rst --- a/Doc/library/xmlrpc.client.rst +++ b/Doc/library/xmlrpc.client.rst @@ -142,7 +142,7 @@ `XML-RPC Introspection `_ Describes the XML-RPC protocol extension for introspection. - `XML-RPC Specification `_ + `XML-RPC Specification `_ The official specification. `Unofficial XML-RPC Errata `_ diff --git a/Doc/library/zipfile.rst b/Doc/library/zipfile.rst --- a/Doc/library/zipfile.rst +++ b/Doc/library/zipfile.rst @@ -13,8 +13,7 @@ The ZIP file format is a common archive and compression standard. This module provides tools to create, read, write, append, and list a ZIP file. Any advanced use of this module will require an understanding of the format, as -defined in `PKZIP Application Note -`_. +defined in `PKZIP Application Note`_. This module does not currently handle multi-disk ZIP files. It can handle ZIP files that use the ZIP64 extensions @@ -115,7 +114,7 @@ .. seealso:: - `PKZIP Application Note `_ + `PKZIP Application Note`_ Documentation on the ZIP file format by Phil Katz, the creator of the format and algorithms used. @@ -511,8 +510,7 @@ .. attribute:: ZipInfo.extra - Expansion field data. The `PKZIP Application Note - `_ contains + Expansion field data. The `PKZIP Application Note`_ contains some comments on the internal structure of the data contained in this string. @@ -574,3 +572,5 @@ .. attribute:: ZipInfo.file_size Size of the uncompressed file. + +.. _PKZIP Application Note: https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT diff --git a/Doc/library/zipimport.rst b/Doc/library/zipimport.rst --- a/Doc/library/zipimport.rst +++ b/Doc/library/zipimport.rst @@ -30,7 +30,7 @@ .. seealso:: - `PKZIP Application Note `_ + `PKZIP Application Note `_ Documentation on the ZIP file format by Phil Katz, the creator of the format and algorithms used. diff --git a/Doc/using/mac.rst b/Doc/using/mac.rst --- a/Doc/using/mac.rst +++ b/Doc/using/mac.rst @@ -153,7 +153,7 @@ *PyQt* is another popular cross-platform GUI toolkit that runs natively on Mac OS X. More information can be found at -http://www.riverbankcomputing.co.uk/software/pyqt/intro. +https://riverbankcomputing.com/software/pyqt/intro. Distributing Python Applications on the Mac diff --git a/Doc/using/unix.rst b/Doc/using/unix.rst --- a/Doc/using/unix.rst +++ b/Doc/using/unix.rst @@ -26,11 +26,11 @@ .. seealso:: - http://www.debian.org/doc/manuals/maint-guide/first.en.html + https://www.debian.org/doc/manuals/maint-guide/first.en.html for Debian users - http://en.opensuse.org/Portal:Packaging + https://en.opensuse.org/Portal:Packaging for OpenSuse users - http://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch-creating-rpms.html + https://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch-creating-rpms.html for Fedora users http://www.slackbook.org/html/package-management-making-packages.html for Slackware users @@ -65,7 +65,7 @@ =============== If you want to compile CPython yourself, first thing you should do is get the -`source `_. You can download either the +`source `_. You can download either the latest release's source or just grab a fresh `clone `_. (If you want to contribute patches, you will need a clone.) diff --git a/Doc/using/windows.rst b/Doc/using/windows.rst --- a/Doc/using/windows.rst +++ b/Doc/using/windows.rst @@ -251,12 +251,12 @@ release/python>`_, `Maintainer releases `_) -See `Python for Windows `_ +See `Python for Windows `_ for detailed information about platforms with pre-compiled installers. .. seealso:: - `Python on XP `_ + `Python on XP `_ "7 Minutes to "Hello World!"" by Richard Dooling, 2006 @@ -279,10 +279,10 @@ additional functionality. The following is a list of popular versions and their key features: -`ActivePython `_ +`ActivePython `_ Installer with multi-platform compatibility, documentation, PyWin32 -`Anaconda `_ +`Anaconda `_ Popular scientific modules (such as numpy, scipy and pandas) and the ``conda`` package manager. @@ -352,16 +352,16 @@ .. seealso:: - http://support.microsoft.com/kb/100843 + https://support.microsoft.com/kb/100843 Environment variables in Windows NT - http://technet.microsoft.com/en-us/library/cc754250.aspx + https://technet.microsoft.com/en-us/library/cc754250.aspx The SET command, for temporarily modifying environment variables - http://technet.microsoft.com/en-us/library/cc755104.aspx + https://technet.microsoft.com/en-us/library/cc755104.aspx The SETX command, for permanently modifying environment variables - http://support.microsoft.com/kb/310519 + https://support.microsoft.com/kb/310519 How To Manage Environment Variables in Windows XP http://www.chem.gla.ac.uk/~louis/software/faq/q1.html @@ -781,18 +781,18 @@ PyWin32 ------- -The `PyWin32 `_ module by Mark Hammond +The `PyWin32 `_ module by Mark Hammond is a collection of modules for advanced Windows-specific support. This includes utilities for: -* `Component Object Model `_ (COM) +* `Component Object Model `_ (COM) * Win32 API calls * Registry * Event log -* `Microsoft Foundation Classes `_ (MFC) +* `Microsoft Foundation Classes `_ (MFC) user interfaces -`PythonWin `_ is a sample MFC application shipped with PyWin32. It is an embeddable IDE with a built-in debugger. @@ -831,7 +831,7 @@ =========================== If you want to compile CPython yourself, first thing you should do is get the -`source `_. You can download either the +`source `_. You can download either the latest release's source or just grab a fresh `checkout `_. @@ -874,7 +874,7 @@ .. note:: The embedded distribution does not include the `Microsoft C Runtime - `_ and it is + `_ and it is the responsibility of the application installer to provide this. The runtime may have already been installed on a user's system previously or automatically via Windows Update, and can be detected by finding diff --git a/Doc/whatsnew/2.0.rst b/Doc/whatsnew/2.0.rst --- a/Doc/whatsnew/2.0.rst +++ b/Doc/whatsnew/2.0.rst @@ -130,7 +130,7 @@ Read the rest of PEP 1 for the details of the PEP editorial process, style, and format. PEPs are kept in the Python CVS tree on SourceForge, though they're not part of the Python 2.0 distribution, and are also available in HTML form from -https://www.python.org/peps/. As of September 2000, there are 25 PEPS, ranging +https://www.python.org/dev/peps/. As of September 2000, there are 25 PEPS, ranging from PEP 201, "Lockstep Iteration", to PEP 225, "Elementwise/Objectwise Operators". @@ -337,7 +337,7 @@ [ (x,y) for x in seq1 for y in seq2] The idea of list comprehensions originally comes from the functional programming -language Haskell (http://www.haskell.org). Greg Ewing argued most effectively +language Haskell (https://www.haskell.org). Greg Ewing argued most effectively for adding them to Python and wrote the initial list comprehension patch, which was then discussed for a seemingly endless time on the python-dev mailing list and kept up-to-date by Skip Montanaro. diff --git a/Doc/whatsnew/2.1.rst b/Doc/whatsnew/2.1.rst --- a/Doc/whatsnew/2.1.rst +++ b/Doc/whatsnew/2.1.rst @@ -562,7 +562,7 @@ using Python 2.1, since a new release of the Distutils will be made for users of earlier Python versions. Version 1.0.2 of the Distutils includes the changes described in PEP 241, as well as various bugfixes and enhancements. It will be -available from the Distutils SIG at https://www.python.org/sigs/distutils-sig/. +available from the Distutils SIG at https://www.python.org/community/sigs/current/distutils-sig/. .. seealso:: diff --git a/Doc/whatsnew/2.3.rst b/Doc/whatsnew/2.3.rst --- a/Doc/whatsnew/2.3.rst +++ b/Doc/whatsnew/2.3.rst @@ -1080,9 +1080,9 @@ hierarchy. Classic classes are unaffected by this change. Python 2.2 originally used a topological sort of a class's ancestors, but 2.3 now uses the C3 algorithm as described in the paper `"A Monotonic Superclass Linearization - for Dylan" `_. To + for Dylan" `_. To understand the motivation for this change, read Michele Simionato's article - `"Python 2.3 Method Resolution Order" `_, or + `"Python 2.3 Method Resolution Order" `_, or read the thread on python-dev starting with the message at https://mail.python.org/pipermail/python-dev/2002-October/029035.html. Samuele Pedroni first pointed out the problem and also implemented the fix by coding the @@ -1306,7 +1306,7 @@ partially sorted order such that, for every index *k*, ``heap[k] <= heap[2*k+1]`` and ``heap[k] <= heap[2*k+2]``. This makes it quick to remove the smallest item, and inserting a new item while maintaining the heap property is - O(lg n). (See http://www.nist.gov/dads/HTML/priorityque.html for more + O(lg n). (See https://xlinux.nist.gov/dads//HTML/priorityque.html for more information about the priority queue data structure.) The :mod:`heapq` module provides :func:`heappush` and :func:`heappop` functions @@ -1949,7 +1949,7 @@ source distribution, were updated for 2.3. (Contributed by Sean Reifschneider.) Other new platforms now supported by Python include AtheOS -(http://www.atheos.cx/), GNU/Hurd, and OpenVMS. +(http://atheos.cx/), GNU/Hurd, and OpenVMS. .. ====================================================================== diff --git a/Doc/whatsnew/2.4.rst b/Doc/whatsnew/2.4.rst --- a/Doc/whatsnew/2.4.rst +++ b/Doc/whatsnew/2.4.rst @@ -337,7 +337,7 @@ wrote patches implementing function decorators, but the one that was actually checked in was patch #979728, written by Mark Russell. - https://www.python.org/moin/PythonDecoratorLibrary + https://wiki.python.org/moin/PythonDecoratorLibrary This Wiki page contains several examples of decorators. .. ====================================================================== @@ -687,7 +687,7 @@ The article uses Fortran code to illustrate many of the problems that floating- point inaccuracy can cause. - http://www2.hursley.ibm.com/decimal/ + http://speleotrove.com/decimal/ A description of a decimal-based representation. This representation is being proposed as a standard, and underlies the new Python decimal type. Much of this material was written by Mike Cowlishaw, designer of the Rexx language. @@ -756,7 +756,7 @@ :c:type:`double` to an ASCII string. The code for these functions came from the GLib library -(http://library.gnome.org/devel/glib/stable/), whose developers kindly +(https://developer.gnome.org/glib/stable/), whose developers kindly relicensed the relevant functions and donated them to the Python Software Foundation. The :mod:`locale` module can now change the numeric locale, letting extensions such as GTK+ produce the correct results. diff --git a/Doc/whatsnew/2.5.rst b/Doc/whatsnew/2.5.rst --- a/Doc/whatsnew/2.5.rst +++ b/Doc/whatsnew/2.5.rst @@ -330,7 +330,7 @@ :pep:`328` - Imports: Multi-Line and Absolute/Relative PEP written by Aahz; implemented by Thomas Wouters. - http://codespeak.net/py/current/doc/index.html + https://pylib.readthedocs.org/ The py library by Holger Krekel, which contains the :mod:`py.std` package. .. ====================================================================== @@ -547,7 +547,7 @@ Earlier versions of these features were proposed in :pep:`288` by Raymond Hettinger and :pep:`325` by Samuele Pedroni. - http://en.wikipedia.org/wiki/Coroutine + https://en.wikipedia.org/wiki/Coroutine The Wikipedia entry for coroutines. http://www.sidhe.org/~dan/blog/archives/000178.html @@ -2088,7 +2088,7 @@ provided the results of their examination of the Python source code. The analysis found about 60 bugs that were quickly fixed. Many of the bugs were refcounting problems, often occurring in error-handling code. See - http://scan.coverity.com for the statistics. + https://scan.coverity.com for the statistics. * The largest change to the C API came from :pep:`353`, which modifies the interpreter to use a :c:type:`Py_ssize_t` type definition instead of diff --git a/Doc/whatsnew/2.6.rst b/Doc/whatsnew/2.6.rst --- a/Doc/whatsnew/2.6.rst +++ b/Doc/whatsnew/2.6.rst @@ -153,8 +153,8 @@ therefore posted a call for issue trackers, asking volunteers to set up different products and import some of the bugs and patches from SourceForge. Four different trackers were examined: `Jira -`__, -`Launchpad `__, +`__, +`Launchpad `__, `Roundup `__, and `Trac `__. The committee eventually settled on Jira @@ -217,7 +217,7 @@ During the 2.6 development cycle, Georg Brandl put a lot of effort into building a new toolchain for processing the documentation. The resulting package is called Sphinx, and is available from -http://sphinx.pocoo.org/. +http://sphinx-doc.org/. Sphinx concentrates on HTML output, producing attractively styled and modern HTML; printed output is still supported through conversion to @@ -1796,7 +1796,7 @@ * The :mod:`bsddb` module also has a new maintainer, Jes?s Cea Avi?n, and the package is now available as a standalone package. The web page for the package is `www.jcea.es/programacion/pybsddb.htm - `__. + `__. The plan is to remove the package from the standard library in Python 3.0, because its pace of releases is much more frequent than Python's. @@ -1926,7 +1926,7 @@ the left to six places. (Contributed by Skip Montanaro; :issue:`1158`.) * The :mod:`decimal` module was updated to version 1.66 of - `the General Decimal Specification `__. New features + `the General Decimal Specification `__. New features include some methods for some basic mathematical functions such as :meth:`exp` and :meth:`log10`:: diff --git a/Doc/whatsnew/2.7.rst b/Doc/whatsnew/2.7.rst --- a/Doc/whatsnew/2.7.rst +++ b/Doc/whatsnew/2.7.rst @@ -1029,7 +1029,7 @@ * Updated module: the :mod:`bsddb` module has been updated from 4.7.2devel9 to version 4.8.4 of - `the pybsddb package `__. + `the pybsddb package `__. The new version features better Python 3.x compatibility, various bug fixes, and adds several new BerkeleyDB flags and methods. (Updated by Jes?s Cea Avi?n; :issue:`8156`. The pybsddb @@ -1513,7 +1513,7 @@ (Contributed by Kristj?n Valur J?nsson; :issue:`6192` and :issue:`6267`.) * Updated module: the :mod:`sqlite3` module has been updated to - version 2.6.0 of the `pysqlite package `__. Version 2.6.0 includes a number of bugfixes, and adds + version 2.6.0 of the `pysqlite package `__. Version 2.6.0 includes a number of bugfixes, and adds the ability to load SQLite extensions from shared libraries. Call the ``enable_load_extension(True)`` method to enable extensions, and then call :meth:`~sqlite3.Connection.load_extension` to load a particular shared library. diff --git a/Doc/whatsnew/3.0.rst b/Doc/whatsnew/3.0.rst --- a/Doc/whatsnew/3.0.rst +++ b/Doc/whatsnew/3.0.rst @@ -565,7 +565,7 @@ core standard library has proved over time to be a particular burden for the core developers due to testing instability and Berkeley DB's release schedule. However, the package is alive and well, - externally maintained at http://www.jcea.es/programacion/pybsddb.htm. + externally maintained at https://www.jcea.es/programacion/pybsddb.htm. * Some modules were renamed because their old name disobeyed :pep:`0008`, or for various other reasons. Here's the list: diff --git a/Doc/whatsnew/3.2.rst b/Doc/whatsnew/3.2.rst --- a/Doc/whatsnew/3.2.rst +++ b/Doc/whatsnew/3.2.rst @@ -845,9 +845,9 @@ * The :class:`collections.Counter` class now has two forms of in-place subtraction, the existing *-=* operator for `saturating subtraction - `_ and the new + `_ and the new :meth:`~collections.Counter.subtract` method for regular subtraction. The - former is suitable for `multisets `_ + former is suitable for `multisets `_ which only have positive counts, and the latter is more suitable for use cases that allow negative counts: @@ -906,7 +906,7 @@ complete. Barriers can work with an arbitrary number of threads. This is a generalization -of a `Rendezvous `_ which +of a `Rendezvous `_ which is defined for only two threads. Implemented as a two-phase cyclic barrier, :class:`~threading.Barrier` objects @@ -1043,7 +1043,7 @@ 0.013765762467652909 The :func:`~math.erf` function computes a probability integral or `Gaussian -error function `_. The +error function `_. The complementary error function, :func:`~math.erfc`, is ``1 - erf(x)``: >>> erf(1.0/sqrt(2.0)) # portion of normal distribution within 1 standard deviation @@ -1054,7 +1054,7 @@ 1.0 The :func:`~math.gamma` function is a continuous extension of the factorial -function. See http://en.wikipedia.org/wiki/Gamma_function for details. Because +function. See https://en.wikipedia.org/wiki/Gamma_function for details. Because the function is related to factorials, it grows large even for small values of *x*, so there is also a :func:`~math.lgamma` function for computing the natural logarithm of the gamma function: @@ -2180,7 +2180,7 @@ A number of usability improvements were made for the :mod:`urllib.parse` module. The :func:`~urllib.parse.urlparse` function now supports `IPv6 -`_ addresses as described in :rfc:`2732`: +`_ addresses as described in :rfc:`2732`: >>> import urllib.parse >>> urllib.parse.urlparse('http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]/foo/') @@ -2328,7 +2328,7 @@ (Contributed by Alexandre Vassalotti, Antoine Pitrou and the Unladen Swallow team in :issue:`9410` and :issue:`3873`.) -* The `Timsort algorithm `_ used in +* The `Timsort algorithm `_ used in :meth:`list.sort` and :func:`sorted` now runs faster and uses less memory when called with a :term:`key function`. Previously, every element of a list was wrapped with a temporary object that remembered the key value @@ -2380,7 +2380,7 @@ Python has been updated to `Unicode 6.0.0 `_. The update to the standard adds -over 2,000 new characters including `emoji `_ +over 2,000 new characters including `emoji `_ symbols which are important for mobile phones. In addition, the updated standard has altered the character properties for two @@ -2432,7 +2432,7 @@ **Source code** :source:`Lib/functools.py`. (Contributed by Raymond Hettinger; see - `rationale `_.) + `rationale `_.) * The docs now contain more examples and recipes. In particular, :mod:`re` module has an extensive section, :ref:`re-examples`. Likewise, the @@ -2468,7 +2468,7 @@ =============== In addition to the existing Subversion code repository at http://svn.python.org -there is now a `Mercurial `_ repository at +there is now a `Mercurial `_ repository at https://hg.python.org/\ . After the 3.2 release, there are plans to switch to Mercurial as the primary @@ -2478,7 +2478,7 @@ To learn to use the new version control system, see the `tutorial by Joel Spolsky `_ or the `Guide to Mercurial Workflows -`_. +`_. Build and C API Changes diff --git a/Doc/whatsnew/3.3.rst b/Doc/whatsnew/3.3.rst --- a/Doc/whatsnew/3.3.rst +++ b/Doc/whatsnew/3.3.rst @@ -1884,13 +1884,13 @@ Heiko Wundram) * The :class:`~socket.socket` class now supports the PF_CAN protocol family - (http://en.wikipedia.org/wiki/Socketcan), on Linux - (http://lwn.net/Articles/253425). + (https://en.wikipedia.org/wiki/Socketcan), on Linux + (https://lwn.net/Articles/253425). (Contributed by Matthias Fuchs, updated by Tiago Gon?alves in :issue:`10141`.) * The :class:`~socket.socket` class now supports the PF_RDS protocol family - (http://en.wikipedia.org/wiki/Reliable_Datagram_Sockets and + (https://en.wikipedia.org/wiki/Reliable_Datagram_Sockets and https://oss.oracle.com/projects/rds/). * The :class:`~socket.socket` class now supports the ``PF_SYSTEM`` protocol diff --git a/Doc/whatsnew/3.4.rst b/Doc/whatsnew/3.4.rst --- a/Doc/whatsnew/3.4.rst +++ b/Doc/whatsnew/3.4.rst @@ -144,7 +144,7 @@ all of the parent's inheritable handles, only the necessary ones. * A new :func:`hashlib.pbkdf2_hmac` function provides the `PKCS#5 password-based key derivation function 2 - `_. + `_. * :ref:`TLSv1.1 and TLSv1.2 support ` for :mod:`ssl`. * :ref:`Retrieving certificates from the Windows system cert store support ` for :mod:`ssl`. @@ -902,7 +902,7 @@ A new :func:`hashlib.pbkdf2_hmac` function provides the `PKCS#5 password-based key derivation function 2 -`_. (Contributed by Christian +`_. (Contributed by Christian Heimes in :issue:`18582`.) The :attr:`~hashlib.hash.name` attribute of :mod:`hashlib` hash objects is now @@ -1917,8 +1917,8 @@ :issue:`18596`.) * The Windows build now uses `Address Space Layout Randomization - `_ and `Data Execution Prevention - `_. (Contributed by + `_ and `Data Execution Prevention + `_. (Contributed by Christian Heimes in :issue:`16632`.) * New function :c:func:`PyObject_LengthHint` is the C API equivalent diff --git a/Doc/whatsnew/3.5.rst b/Doc/whatsnew/3.5.rst --- a/Doc/whatsnew/3.5.rst +++ b/Doc/whatsnew/3.5.rst @@ -2169,7 +2169,7 @@ The :c:member:`PyTypeObject.tp_finalize` slot is now part of the stable ABI. Windows builds now require Microsoft Visual C++ 14.0, which -is available as part of `Visual Studio 2015 `_. +is available as part of `Visual Studio 2015 `_. Extension modules now include a platform information tag in their filename on some platforms (the tag is optional, and CPython will import extensions without diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -7411,7 +7411,7 @@ - Issue #16245: Fix the value of a few entities in html.entities.html5. -- Issue #16301: Fix the localhost verification in urllib/request.py for file:// +- Issue #16301: Fix the localhost verification in urllib/request.py for ``file://`` urls. - Issue #16250: Fix the invocations of URLError which had misplaced filename -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Feb 26 13:38:21 2016 From: python-checkins at python.org (georg.brandl) Date: Fri, 26 Feb 2016 18:38:21 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_merge_with_3=2E5?= Message-ID: <20160226183802.83587.93515@psf.io> https://hg.python.org/cpython/rev/3cf014d67908 changeset: 100353:3cf014d67908 parent: 100351:06001e079072 parent: 100352:ce5ef48b5140 user: Georg Brandl date: Fri Feb 26 19:37:52 2016 +0100 summary: merge with 3.5 files: Doc/distributing/index.rst | 16 +- Doc/distutils/apiref.rst | 2 +- Doc/extending/extending.rst | 2 +- Doc/extending/index.rst | 2 +- Doc/faq/design.rst | 2 +- Doc/faq/extending.rst | 4 +- Doc/faq/general.rst | 12 +- Doc/faq/gui.rst | 12 +- Doc/faq/library.rst | 2 +- Doc/faq/programming.rst | 2 +- Doc/howto/curses.rst | 2 +- Doc/howto/functional.rst | 12 +- Doc/howto/logging-cookbook.rst | 2 +- Doc/howto/logging.rst | 2 +- Doc/howto/sorting.rst | 6 +- Doc/howto/unicode.rst | 6 +- Doc/howto/webservers.rst | 34 +++--- Doc/installing/index.rst | 18 +- Doc/library/asyncio-eventloops.rst | 6 +- Doc/library/asyncio-subprocess.rst | 4 +- Doc/library/collections.rst | 6 +- Doc/library/dbm.rst | 2 +- Doc/library/decimal.rst | 3 - Doc/library/email.generator.rst | 4 +- Doc/library/functions.rst | 2 +- Doc/library/functools.rst | 6 +- Doc/library/heapq.rst | 4 +- Doc/library/http.client.rst | 2 +- Doc/library/itertools.rst | 4 +- Doc/library/json.rst | 2 +- Doc/library/logging.rst | 2 +- Doc/library/mailbox.rst | 4 +- Doc/library/math.rst | 16 +- Doc/library/msilib.rst | 64 +++++++------- Doc/library/os.rst | 6 +- Doc/library/othergui.rst | 14 +- Doc/library/random.rst | 2 +- Doc/library/re.rst | 2 +- Doc/library/shelve.rst | 4 +- Doc/library/socket.rst | 2 +- Doc/library/ssl.rst | 26 ++-- Doc/library/stat.rst | 2 +- Doc/library/subprocess.rst | 8 +- Doc/library/test.rst | 2 +- Doc/library/tkinter.rst | 4 +- Doc/library/unittest.mock-examples.rst | 6 +- Doc/library/urllib.request.rst | 2 +- Doc/library/winreg.rst | 12 +- Doc/library/wsgiref.rst | 4 +- Doc/library/xml.rst | 10 +- Doc/library/xmlrpc.client.rst | 2 +- Doc/library/zipfile.rst | 15 +-- Doc/library/zipimport.rst | 2 +- Doc/using/mac.rst | 2 +- Doc/using/unix.rst | 8 +- Doc/using/windows.rst | 28 +++--- Doc/whatsnew/2.0.rst | 4 +- Doc/whatsnew/2.1.rst | 2 +- Doc/whatsnew/2.3.rst | 8 +- Doc/whatsnew/2.4.rst | 6 +- Doc/whatsnew/2.5.rst | 6 +- Doc/whatsnew/2.6.rst | 10 +- Doc/whatsnew/2.7.rst | 4 +- Doc/whatsnew/3.0.rst | 2 +- Doc/whatsnew/3.2.rst | 22 ++-- Doc/whatsnew/3.3.rst | 6 +- Doc/whatsnew/3.4.rst | 8 +- Doc/whatsnew/3.5.rst | 2 +- Misc/NEWS | 2 +- 69 files changed, 252 insertions(+), 262 deletions(-) diff --git a/Doc/distributing/index.rst b/Doc/distributing/index.rst --- a/Doc/distributing/index.rst +++ b/Doc/distributing/index.rst @@ -35,7 +35,7 @@ repository of open source licensed packages made available for use by other Python users * the `Python Packaging Authority - `__ are the group of + `__ are the group of developers and documentation authors responsible for the maintenance and evolution of the standard packaging tools and the associated metadata and file format standards. They maintain a variety of tools, documentation @@ -62,7 +62,7 @@ locally. .. _setuptools: https://setuptools.pypa.io/en/latest/setuptools.html -.. _wheel: http://wheel.readthedocs.org +.. _wheel: https://wheel.readthedocs.org Open source licensing and collaboration ======================================= @@ -111,7 +111,7 @@ The Python Packaging User Guide includes more details on the `currently recommended tools`_. -.. _currently recommended tools: https://packaging.python.org/en/latest/current.html#packaging-tool-recommendations +.. _currently recommended tools: https://packaging.python.org/en/latest/current/#packaging-tool-recommendations Reading the guide ================= @@ -124,11 +124,11 @@ * `Uploading the project to the Python Packaging Index`_ .. _Project structure: \ - https://packaging.python.org/en/latest/distributing.html#creating-your-own-project + https://packaging.python.org/en/latest/distributing/ .. _Building and packaging the project: \ - https://packaging.python.org/en/latest/distributing.html#packaging-your-project + https://packaging.python.org/en/latest/distributing/#packaging-your-project .. _Uploading the project to the Python Packaging Index: \ - https://packaging.python.org/en/latest/distributing.html#uploading-your-project-to-pypi + https://packaging.python.org/en/latest/distributing/#uploading-your-project-to-pypi How do I...? @@ -160,11 +160,11 @@ .. seealso:: `Python Packaging User Guide: Binary Extensions - `__ + `__ .. other topics: Once the Development & Deployment part of PPUG is fleshed out, some of those sections should be linked from new questions here (most notably, we should have a question about avoiding depending on PyPI that links to - https://packaging.python.org/en/latest/deployment.html#pypi-mirrors-and-caches) + https://packaging.python.org/en/latest/mirrors/) diff --git a/Doc/distutils/apiref.rst b/Doc/distutils/apiref.rst --- a/Doc/distutils/apiref.rst +++ b/Doc/distutils/apiref.rst @@ -1822,7 +1822,7 @@ Builds a `Windows Installer`_ (.msi) binary package. - .. _Windows Installer: http://msdn.microsoft.com/en-us/library/cc185688(VS.85).aspx + .. _Windows Installer: https://msdn.microsoft.com/en-us/library/cc185688(VS.85).aspx In most cases, the ``bdist_msi`` installer is a better choice than the ``bdist_wininst`` installer, because it provides better support for diff --git a/Doc/extending/extending.rst b/Doc/extending/extending.rst --- a/Doc/extending/extending.rst +++ b/Doc/extending/extending.rst @@ -27,7 +27,7 @@ avoid writing C extensions and preserve portability to other implementations. For example, if your use case is calling C library functions or system calls, you should consider using the :mod:`ctypes` module or the `cffi - `_ library rather than writing custom C code. + `_ library rather than writing custom C code. These modules let you write Python code to interface with C code and are more portable between implementations of Python than writing and compiling a C extension module. diff --git a/Doc/extending/index.rst b/Doc/extending/index.rst --- a/Doc/extending/index.rst +++ b/Doc/extending/index.rst @@ -32,7 +32,7 @@ .. seealso:: - `Python Packaging User Guide: Binary Extensions `_ + `Python Packaging User Guide: Binary Extensions `_ The Python Packaging User Guide not only covers several available tools that simplify the creation of binary extensions, but also discusses the various reasons why creating an extension module may be diff --git a/Doc/faq/design.rst b/Doc/faq/design.rst --- a/Doc/faq/design.rst +++ b/Doc/faq/design.rst @@ -370,7 +370,7 @@ `Cython `_ and `Pyrex `_ compile a modified version of Python with optional annotations into C -extensions. `Weave `_ makes it easy to +extensions. `Weave `_ makes it easy to intermingle Python and C code in various ways to increase performance. `Nuitka `_ is an up-and-coming compiler of Python into C++ code, aiming to support the full Python language. diff --git a/Doc/faq/extending.rst b/Doc/faq/extending.rst --- a/Doc/faq/extending.rst +++ b/Doc/faq/extending.rst @@ -50,10 +50,10 @@ If you need to interface to some C or C++ library for which no Python extension currently exists, you can try wrapping the library's data types and functions with a tool such as `SWIG `_. `SIP -`__, `CXX +`__, `CXX `_ `Boost `_, or `Weave -`_ are also +`_ are also alternatives for wrapping C++ libraries. diff --git a/Doc/faq/general.rst b/Doc/faq/general.rst --- a/Doc/faq/general.rst +++ b/Doc/faq/general.rst @@ -159,7 +159,7 @@ -------------------------------------------- The latest Python source distribution is always available from python.org, at -https://www.python.org/download/. The latest development sources can be obtained +https://www.python.org/downloads/. The latest development sources can be obtained via anonymous Mercurial access at https://hg.python.org/cpython. The source distribution is a gzipped tar file containing the complete C source, @@ -218,7 +218,7 @@ How do I get a beta test version of Python? ------------------------------------------- -Alpha and beta releases are available from https://www.python.org/download/. All +Alpha and beta releases are available from https://www.python.org/downloads/. All releases are announced on the comp.lang.python and comp.lang.python.announce newsgroups and on the Python home page at https://www.python.org/; an RSS feed of news is available. @@ -273,7 +273,7 @@ `www.python.org `_ is graciously hosted by `Rackspace `_, with CDN caching provided by `Fastly `_. `Upfront Systems -`_ hosts `bugs.python.org +`_ hosts `bugs.python.org `_. Many other Python services like `the Wiki `_ are hosted by `Oregon State University Open Source Lab `_. @@ -284,7 +284,7 @@ When he began implementing Python, Guido van Rossum was also reading the published scripts from `"Monty Python's Flying Circus" -`__, a BBC comedy series from the 1970s. Van Rossum +`__, a BBC comedy series from the 1970s. Van Rossum thought he needed a name that was short, unique, and slightly mysterious, so he decided to call the language Python. @@ -313,7 +313,7 @@ releases. The latest stable releases can always be found on the `Python download page -`_. There are two recommended production-ready +`_. There are two recommended production-ready versions at this point in time, because at the moment there are two branches of stable releases: 2.x and 3.x. Python 3.x may be less useful than 2.x, since currently there is more third party software available for Python 2 than for @@ -345,7 +345,7 @@ High-profile Python projects include `the Mailman mailing list manager `_ and `the Zope application server `_. Several Linux distributions, most notably `Red Hat -`_, have written part or all of their installer and +`_, have written part or all of their installer and system administration software in Python. Companies that use Python internally include Google, Yahoo, and Lucasfilm Ltd. diff --git a/Doc/faq/gui.rst b/Doc/faq/gui.rst --- a/Doc/faq/gui.rst +++ b/Doc/faq/gui.rst @@ -29,7 +29,7 @@ Standard builds of Python include an object-oriented interface to the Tcl/Tk widget set, called :ref:`tkinter `. This is probably the easiest to install (since it comes included with most -`binary distributions `_ of Python) and use. +`binary distributions `_ of Python) and use. For more info about Tk, including pointers to the source, see the `Tcl/Tk home page `_. Tcl/Tk is fully portable to the Mac OS X, Windows, and Unix platforms. @@ -58,19 +58,19 @@ --- There are bindings available for the Qt toolkit (using either `PyQt -`_ or `PySide -`_) and for KDE (`PyKDE `__). +`_ or `PySide +`_) and for KDE (`PyKDE `__). PyQt is currently more mature than PySide, but you must buy a PyQt license from -`Riverbank Computing `_ +`Riverbank Computing `_ if you want to write proprietary applications. PySide is free for all applications. Qt 4.5 upwards is licensed under the LGPL license; also, commercial licenses -are available from `The Qt Company `_. +are available from `The Qt Company `_. Gtk+ ---- -The `GObject introspection bindings `_ +The `GObject introspection bindings `_ for Python allow you to write GTK+ 3 applications. There is also a `Python GTK+ 3 Tutorial `_. diff --git a/Doc/faq/library.rst b/Doc/faq/library.rst --- a/Doc/faq/library.rst +++ b/Doc/faq/library.rst @@ -619,7 +619,7 @@ For Unix, see a Usenet post by Mitch Chapman: - http://groups.google.com/groups?selm=34A04430.CF9 at ohioee.com + https://groups.google.com/groups?selm=34A04430.CF9 at ohioee.com Why doesn't closing sys.stdout (stdin, stderr) really close it? diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -63,7 +63,7 @@ warns about code complexity and style. You can get PyChecker from http://pychecker.sourceforge.net/. -`Pylint `_ is another tool that checks +`Pylint `_ is another tool that checks if a module satisfies a coding standard, and also makes it possible to write plug-ins to add a custom feature. In addition to the bug checking that PyChecker performs, Pylint offers some additional features such as checking line diff --git a/Doc/howto/curses.rst b/Doc/howto/curses.rst --- a/Doc/howto/curses.rst +++ b/Doc/howto/curses.rst @@ -545,7 +545,7 @@ a lengthy tutorial for C programmers. * `The ncurses man page `_ * `The ncurses FAQ `_ -* `"Use curses... don't swear" `_: +* `"Use curses... don't swear" `_: video of a PyCon 2013 talk on controlling terminals using curses or Urwid. * `"Console Applications with Urwid" `_: video of a PyCon CA 2012 talk demonstrating some applications written using diff --git a/Doc/howto/functional.rst b/Doc/howto/functional.rst --- a/Doc/howto/functional.rst +++ b/Doc/howto/functional.rst @@ -332,7 +332,7 @@ List comprehensions and generator expressions (short form: "listcomps" and "genexps") are a concise notation for such operations, borrowed from the -functional programming language Haskell (http://www.haskell.org/). You can strip +functional programming language Haskell (https://www.haskell.org/). You can strip all the whitespace from a stream of strings with the following code:: line_list = [' line 1\n', 'line 2 \n', ...] @@ -716,7 +716,7 @@ It doesn't construct an in-memory list and exhaust all the input iterators before returning; instead tuples are constructed and returned only if they're requested. (The technical term for this behaviour is `lazy evaluation -`__.) +`__.) This iterator is intended to be used with iterables that are all of the same length. If the iterables are of different lengths, the resulting stream will be @@ -1199,7 +1199,7 @@ **Structure and Interpretation of Computer Programs**, by Harold Abelson and Gerald Jay Sussman with Julie Sussman. Full text at -http://mitpress.mit.edu/sicp/. In this classic textbook of computer science, +https://mitpress.mit.edu/sicp/. In this classic textbook of computer science, chapters 2 and 3 discuss the use of sequences and streams to organize the data flow inside a program. The book uses Scheme for its examples, but many of the design approaches described in these chapters are applicable to functional-style @@ -1208,12 +1208,12 @@ http://www.defmacro.org/ramblings/fp.html: A general introduction to functional programming that uses Java examples and has a lengthy historical introduction. -http://en.wikipedia.org/wiki/Functional_programming: General Wikipedia entry +https://en.wikipedia.org/wiki/Functional_programming: General Wikipedia entry describing functional programming. -http://en.wikipedia.org/wiki/Coroutine: Entry for coroutines. +https://en.wikipedia.org/wiki/Coroutine: Entry for coroutines. -http://en.wikipedia.org/wiki/Currying: Entry for the concept of currying. +https://en.wikipedia.org/wiki/Currying: Entry for the concept of currying. Python-specific --------------- diff --git a/Doc/howto/logging-cookbook.rst b/Doc/howto/logging-cookbook.rst --- a/Doc/howto/logging-cookbook.rst +++ b/Doc/howto/logging-cookbook.rst @@ -1316,7 +1316,7 @@ ----------------------------------------- Below is an example of a logging configuration dictionary - it's taken from -the `documentation on the Django project `_. +the `documentation on the Django project `_. This dictionary is passed to :func:`~config.dictConfig` to put the configuration into effect:: LOGGING = { diff --git a/Doc/howto/logging.rst b/Doc/howto/logging.rst --- a/Doc/howto/logging.rst +++ b/Doc/howto/logging.rst @@ -310,7 +310,7 @@ If your logging needs are simple, then use the above examples to incorporate logging into your own scripts, and if you run into problems or don't understand something, please post a question on the comp.lang.python Usenet -group (available at http://groups.google.com/group/comp.lang.python) and you +group (available at https://groups.google.com/group/comp.lang.python) and you should receive help before too long. Still here? You can carry on reading the next few sections, which provide a diff --git a/Doc/howto/sorting.rst b/Doc/howto/sorting.rst --- a/Doc/howto/sorting.rst +++ b/Doc/howto/sorting.rst @@ -127,7 +127,7 @@ ================================ Sorts are guaranteed to be `stable -`_\. That means that +`_\. That means that when multiple records have the same key, their original order is preserved. >>> data = [('red', 1), ('blue', 1), ('red', 2), ('blue', 2)] @@ -145,7 +145,7 @@ >>> sorted(s, key=attrgetter('grade'), reverse=True) # now sort on primary key, descending [('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)] -The `Timsort `_ algorithm used in Python +The `Timsort `_ algorithm used in Python does multiple sorts efficiently because it can take advantage of any ordering already present in a dataset. @@ -184,7 +184,7 @@ directly. Another name for this idiom is -`Schwartzian transform `_\, +`Schwartzian transform `_\, after Randal L. Schwartz, who popularized it among Perl programmers. Now that Python sorting provides key-functions, this technique is not often needed. diff --git a/Doc/howto/unicode.rst b/Doc/howto/unicode.rst --- a/Doc/howto/unicode.rst +++ b/Doc/howto/unicode.rst @@ -73,7 +73,7 @@ precise historical details aren't necessary for understanding how to use Unicode effectively, but if you're curious, consult the Unicode consortium site listed in the References or -the `Wikipedia entry for Unicode `_ +the `Wikipedia entry for Unicode `_ for more information.) @@ -223,8 +223,8 @@ reading this alternate article before continuing. Wikipedia entries are often helpful; see the entries for "`character encoding -`_" and `UTF-8 -`_, for example. +`_" and `UTF-8 +`_, for example. Python's Unicode Support diff --git a/Doc/howto/webservers.rst b/Doc/howto/webservers.rst --- a/Doc/howto/webservers.rst +++ b/Doc/howto/webservers.rst @@ -267,7 +267,7 @@ Each web server requires a specific module. * Apache has both `mod_fastcgi `_ and `mod_fcgid - `_. ``mod_fastcgi`` is the original one, but it + `_. ``mod_fastcgi`` is the original one, but it has some licensing issues, which is why it is sometimes considered non-free. ``mod_fcgid`` is a smaller, compatible alternative. One of these modules needs to be loaded by Apache. @@ -277,7 +277,7 @@ `SCGI module `_. * `nginx `_ also supports `FastCGI - `_. + `_. Once you have installed and configured the module, you can test it with the following WSGI-application:: @@ -307,8 +307,8 @@ .. seealso:: - There is some documentation on `setting up Django with FastCGI - `_, most of + There is some documentation on `setting up Django with WSGI + `_, most of which can be reused for other WSGI-compliant frameworks and libraries. Only the ``manage.py`` part has to be changed, the example used here can be used instead. Django does more or less the exact same thing. @@ -358,7 +358,7 @@ A really great WSGI feature is middleware. Middleware is a layer around your program which can add various functionality to it. There is quite a bit of -`middleware `_ already +`middleware `_ already available. For example, instead of writing your own session management (HTTP is a stateless protocol, so to associate multiple HTTP requests with a single user your application must create and manage such state via a session), you can @@ -379,7 +379,7 @@ The code that is used to connect to various low level gateways like CGI or mod_python is called a *WSGI server*. One of these servers is ``flup``, which supports FastCGI and SCGI, as well as `AJP -`_. Some of these servers +`_. Some of these servers are written in Python, as ``flup`` is, but there also exist others which are written in C and can be used as drop-in replacements. @@ -390,8 +390,8 @@ .. seealso:: A good overview of WSGI-related code can be found in the `WSGI homepage - `_, which contains an extensive list of `WSGI servers - `_ which can be used by *any* application + `_, which contains an extensive list of `WSGI servers + `_ which can be used by *any* application supporting WSGI. You might be interested in some WSGI-supporting modules already contained in @@ -408,7 +408,7 @@ Python without using WSGI. One of the most widely used wiki software packages is `MoinMoin -`_. It was created in 2000, so it predates WSGI by about +`_. It was created in 2000, so it predates WSGI by about three years. Older versions needed separate code to run on CGI, mod_python, FastCGI and standalone. @@ -460,7 +460,7 @@ .. seealso:: The English Wikipedia has an article about the `Model-View-Controller pattern - `_. It includes a long + `_. It includes a long list of web frameworks for various programming languages. @@ -543,10 +543,10 @@ smaller sites SQLite is just enough. Relational databases are *queried* using a language called `SQL -`_. Python programmers in general do not +`_. Python programmers in general do not like SQL too much, as they prefer to work with objects. It is possible to save Python objects into a database using a technology called `ORM -`_ (Object Relational +`_ (Object Relational Mapping). ORM translates all object-oriented access into SQL code under the hood, so the developer does not need to think about it. Most `frameworks`_ use ORMs, and it works quite well. @@ -579,13 +579,13 @@ helps with choosing a method for saving data * `SQLAlchemy `_, the most powerful OR-Mapper - for Python, and `Elixir `_, which makes + for Python, and `Elixir `_, which makes SQLAlchemy easier to use * `SQLObject `_, another popular OR-Mapper * `ZODB `_ and `Durus - `_, two object oriented + `_, two object oriented databases @@ -671,10 +671,10 @@ example the ORM and template engine can be changed to use packages different from those used by default. -The documentation can be found in the `TurboGears wiki -`_, where links to screencasts can be found. +The documentation can be found in the `TurboGears documentation +`_, where links to screencasts can be found. TurboGears has also an active user community which can respond to most related -questions. There is also a `TurboGears book `_ +questions. There is also a `TurboGears book `_ published, which is a good starting point. The newest version of TurboGears, version 2.0, moves even further in direction diff --git a/Doc/installing/index.rst b/Doc/installing/index.rst --- a/Doc/installing/index.rst +++ b/Doc/installing/index.rst @@ -48,7 +48,7 @@ repository of open source licensed packages made available for use by other Python users * the `Python Packaging Authority - `__ are the group of + `__ are the group of developers and documentation authors responsible for the maintenance and evolution of the standard packaging tools and the associated metadata and file format standards. They maintain a variety of tools, documentation @@ -106,7 +106,7 @@ .. seealso:: `Python Packaging User Guide: Installing Python Distribution Packages - `__ + `__ How do I ...? @@ -123,8 +123,8 @@ .. seealso:: - `Python Packaging User Guide: Setup for Installing Distribution Packages - `__ + `Python Packaging User Guide: Requirements for Installing Packages + `__ .. installing-per-user-installation: @@ -143,13 +143,13 @@ aren't currently easy to install using ``pip`` directly. At this point in time, it will often be easier for users to install these packages by `other means -`__ +`__ rather than attempting to install them with ``pip``. .. seealso:: `Python Packaging User Guide: Installing Scientific Packages - `__ + `__ ... work with multiple versions of Python installed in parallel? @@ -179,7 +179,7 @@ Once the Development & Deployment part of PPUG is fleshed out, some of those sections should be linked from new questions here (most notably, we should have a question about avoiding depending on PyPI that links to - https://packaging.python.org/en/latest/deployment.html#pypi-mirrors-and-caches) + https://packaging.python.org/en/latest/mirrors/) Common installation issues @@ -212,11 +212,11 @@ than needing to build them themselves. Some of the solutions for installing `scientific software -`__ +`__ that is not yet available as pre-built ``wheel`` files may also help with obtaining other binary extensions without needing to build them locally. .. seealso:: `Python Packaging User Guide: Binary Extensions - `__ + `__ diff --git a/Doc/library/asyncio-eventloops.rst b/Doc/library/asyncio-eventloops.rst --- a/Doc/library/asyncio-eventloops.rst +++ b/Doc/library/asyncio-eventloops.rst @@ -41,7 +41,7 @@ On Windows, only sockets are supported (ex: pipes are not supported): see the `MSDN documentation of select - `_. + `_. .. class:: ProactorEventLoop @@ -53,7 +53,7 @@ .. seealso:: `MSDN documentation on I/O Completion Ports - `_. + `_. Example to use a :class:`ProactorEventLoop` on Windows:: @@ -107,7 +107,7 @@ The resolution of the monotonic clock on Windows is usually around 15.6 msec. The best resolution is 0.5 msec. The resolution depends on the hardware (availability of `HPET -`_) and on the Windows +`_) and on the Windows configuration. See :ref:`asyncio delayed calls `. .. versionchanged:: 3.5 diff --git a/Doc/library/asyncio-subprocess.rst b/Doc/library/asyncio-subprocess.rst --- a/Doc/library/asyncio-subprocess.rst +++ b/Doc/library/asyncio-subprocess.rst @@ -51,7 +51,7 @@ It is the application's responsibility to ensure that all whitespace and metacharacters are quoted appropriately to avoid `shell injection - `_ + `_ vulnerabilities. The :func:`shlex.quote` function can be used to properly escape whitespace and shell metacharacters in strings that are going to be used to construct shell commands. @@ -134,7 +134,7 @@ It is the application's responsibility to ensure that all whitespace and metacharacters are quoted appropriately to avoid `shell injection - `_ + `_ vulnerabilities. The :func:`shlex.quote` function can be used to properly escape whitespace and shell metacharacters in strings that are going to be used to construct shell commands. diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst --- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -374,12 +374,12 @@ .. seealso:: - * `Bag class `_ + * `Bag class `_ in Smalltalk. - * Wikipedia entry for `Multisets `_. + * Wikipedia entry for `Multisets `_. - * `C++ multisets `_ + * `C++ multisets `_ tutorial with examples. * For mathematical operations on multisets and their use cases, see diff --git a/Doc/library/dbm.rst b/Doc/library/dbm.rst --- a/Doc/library/dbm.rst +++ b/Doc/library/dbm.rst @@ -7,7 +7,7 @@ :mod:`dbm` is a generic interface to variants of the DBM database --- :mod:`dbm.gnu` or :mod:`dbm.ndbm`. If none of these modules is installed, the slow-but-simple implementation in module :mod:`dbm.dumb` will be used. There -is a `third party interface `_ to +is a `third party interface `_ to the Oracle Berkeley DB. diff --git a/Doc/library/decimal.rst b/Doc/library/decimal.rst --- a/Doc/library/decimal.rst +++ b/Doc/library/decimal.rst @@ -109,9 +109,6 @@ * IBM's General Decimal Arithmetic Specification, `The General Decimal Arithmetic Specification `_. - * IEEE standard 854-1987, `Unofficial IEEE 854 Text - `_. - .. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/Doc/library/email.generator.rst b/Doc/library/email.generator.rst --- a/Doc/library/email.generator.rst +++ b/Doc/library/email.generator.rst @@ -43,7 +43,7 @@ followed by a space at the beginning of the line. This is the only guaranteed portable way to avoid having such lines be mistaken for a Unix mailbox format envelope header separator (see `WHY THE CONTENT-LENGTH FORMAT IS BAD - `_ for details). *mangle_from_* + `_ for details). *mangle_from_* defaults to ``True``, but you might want to set this to ``False`` if you are not writing Unix mailbox format files. @@ -123,7 +123,7 @@ i.e. ``From`` followed by a space at the beginning of the line. This is the only guaranteed portable way to avoid having such lines be mistaken for a Unix mailbox format envelope header separator (see `WHY THE CONTENT-LENGTH - FORMAT IS BAD `_ for details). + FORMAT IS BAD `_ for details). *mangle_from_* defaults to ``True``, but you might want to set this to ``False`` if you are not writing Unix mailbox format files. diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -1418,7 +1418,7 @@ For practical suggestions on how to design cooperative classes using :func:`super`, see `guide to using super() - `_. + `_. .. _func-tuple: diff --git a/Doc/library/functools.rst b/Doc/library/functools.rst --- a/Doc/library/functools.rst +++ b/Doc/library/functools.rst @@ -73,7 +73,7 @@ bypassing the cache, or for rewrapping the function with a different cache. An `LRU (least recently used) cache - `_ works + `_ works best when the most recent calls are the best predictors of upcoming calls (for example, the most popular articles on a news server tend to change each day). The cache's size limit assures that the cache does not grow without bound on @@ -99,9 +99,9 @@ CacheInfo(hits=3, misses=8, maxsize=32, currsize=8) Example of efficiently computing - `Fibonacci numbers `_ + `Fibonacci numbers `_ using a cache to implement a - `dynamic programming `_ + `dynamic programming `_ technique:: @lru_cache(maxsize=None) diff --git a/Doc/library/heapq.rst b/Doc/library/heapq.rst --- a/Doc/library/heapq.rst +++ b/Doc/library/heapq.rst @@ -132,7 +132,7 @@ Basic Examples -------------- -A `heapsort `_ can be implemented by +A `heapsort `_ can be implemented by pushing all values onto a heap and then popping off the smallest values one at a time:: @@ -163,7 +163,7 @@ Priority Queue Implementation Notes ----------------------------------- -A `priority queue `_ is common use +A `priority queue `_ is common use for a heap, and it presents several implementation challenges: * Sort stability: how do you get two tasks with equal priorities to be returned diff --git a/Doc/library/http.client.rst b/Doc/library/http.client.rst --- a/Doc/library/http.client.rst +++ b/Doc/library/http.client.rst @@ -21,7 +21,7 @@ .. seealso:: - The `Requests package `_ + The `Requests package `_ is recommended for a higher-level http client interface. .. note:: diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst --- a/Doc/library/itertools.rst +++ b/Doc/library/itertools.rst @@ -117,7 +117,7 @@ :func:`min` for a running minimum, :func:`max` for a running maximum, or :func:`operator.mul` for a running product. Amortization tables can be built by accumulating interest and applying payments. First-order - `recurrence relations `_ + `recurrence relations `_ can be modeled by supplying the initial value in the iterable and using only the accumulated total in *func* argument:: @@ -132,7 +132,7 @@ >>> list(accumulate(cashflows, lambda bal, pmt: bal*1.05 + pmt)) [1000, 960.0, 918.0, 873.9000000000001, 827.5950000000001] - # Chaotic recurrence relation http://en.wikipedia.org/wiki/Logistic_map + # Chaotic recurrence relation https://en.wikipedia.org/wiki/Logistic_map >>> logistic_map = lambda x, _: r * x * (1 - x) >>> r = 3.8 >>> x0 = 0.4 diff --git a/Doc/library/json.rst b/Doc/library/json.rst --- a/Doc/library/json.rst +++ b/Doc/library/json.rst @@ -10,7 +10,7 @@ :rfc:`7159` (which obsoletes :rfc:`4627`) and by `ECMA-404 `_, is a lightweight data interchange format inspired by -`JavaScript `_ object literal syntax +`JavaScript `_ object literal syntax (although it is not a strict subset of JavaScript [#rfc-errata]_ ). :mod:`json` exposes an API familiar to users of the standard library diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst --- a/Doc/library/logging.rst +++ b/Doc/library/logging.rst @@ -1246,7 +1246,7 @@ The proposal which described this feature for inclusion in the Python standard library. - `Original Python logging package `_ + `Original Python logging package `_ This is the original source for the :mod:`logging` package. The version of the package available from this site is suitable for use with Python 1.5.2, 2.1.x and 2.2.x, which do not include the :mod:`logging` package in the standard diff --git a/Doc/library/mailbox.rst b/Doc/library/mailbox.rst --- a/Doc/library/mailbox.rst +++ b/Doc/library/mailbox.rst @@ -484,7 +484,7 @@ `mbox man page from tin `_ Another specification of the format, with details on locking. - `Configuring Netscape Mail on Unix: Why The Content-Length Format is Bad `_ + `Configuring Netscape Mail on Unix: Why The Content-Length Format is Bad `_ An argument for using the original mbox format rather than a variation. `"mbox" is a family of several mutually incompatible mailbox formats `_ @@ -744,7 +744,7 @@ `mmdf man page from tin `_ A specification of MMDF format from the documentation of tin, a newsreader. - `MMDF `_ + `MMDF `_ A Wikipedia article describing the Multichannel Memorandum Distribution Facility. diff --git a/Doc/library/math.rst b/Doc/library/math.rst --- a/Doc/library/math.rst +++ b/Doc/library/math.rst @@ -97,7 +97,7 @@ For further discussion and two alternative approaches, see the `ASPN cookbook recipes for accurate floating point summation - `_\. + `_\. .. function:: gcd(a, b) @@ -204,7 +204,7 @@ Return ``e**x - 1``. For small floats *x*, the subtraction in ``exp(x) - 1`` can result in a `significant loss of precision - `_\; the :func:`expm1` + `_\; the :func:`expm1` function provides a way to compute this quantity to full precision:: >>> from math import exp, expm1 @@ -332,7 +332,7 @@ Hyperbolic functions -------------------- -`Hyperbolic functions `_ +`Hyperbolic functions `_ are analogs of trigonometric functions that are based on hyperbolas instead of circles. @@ -371,12 +371,12 @@ .. function:: erf(x) - Return the `error function `_ at + Return the `error function `_ at *x*. The :func:`erf` function can be used to compute traditional statistical functions such as the `cumulative standard normal distribution - `_:: + `_:: def phi(x): 'Cumulative distribution function for the standard normal distribution' @@ -388,17 +388,17 @@ .. function:: erfc(x) Return the complementary error function at *x*. The `complementary error - function `_ is defined as + function `_ is defined as ``1.0 - erf(x)``. It is used for large values of *x* where a subtraction from one would cause a `loss of significance - `_\. + `_\. .. versionadded:: 3.2 .. function:: gamma(x) - Return the `Gamma function `_ at + Return the `Gamma function `_ at *x*. .. versionadded:: 3.2 diff --git a/Doc/library/msilib.rst b/Doc/library/msilib.rst --- a/Doc/library/msilib.rst +++ b/Doc/library/msilib.rst @@ -120,9 +120,9 @@ .. seealso:: - `FCICreateFile `_ - `UuidCreate `_ - `UuidToString `_ + `FCICreateFile `_ + `UuidCreate `_ + `UuidToString `_ .. _database-objects: @@ -151,9 +151,9 @@ .. seealso:: - `MSIDatabaseOpenView `_ - `MSIDatabaseCommit `_ - `MSIGetSummaryInformation `_ + `MSIDatabaseOpenView `_ + `MSIDatabaseCommit `_ + `MSIGetSummaryInformation `_ .. _view-objects: @@ -199,11 +199,11 @@ .. seealso:: - `MsiViewExecute `_ - `MSIViewGetColumnInfo `_ - `MsiViewFetch `_ - `MsiViewModify `_ - `MsiViewClose `_ + `MsiViewExecute `_ + `MSIViewGetColumnInfo `_ + `MsiViewFetch `_ + `MsiViewModify `_ + `MsiViewClose `_ .. _summary-objects: @@ -243,10 +243,10 @@ .. seealso:: - `MsiSummaryInfoGetProperty `_ - `MsiSummaryInfoGetPropertyCount `_ - `MsiSummaryInfoSetProperty `_ - `MsiSummaryInfoPersist `_ + `MsiSummaryInfoGetProperty `_ + `MsiSummaryInfoGetPropertyCount `_ + `MsiSummaryInfoSetProperty `_ + `MsiSummaryInfoPersist `_ .. _record-objects: @@ -297,11 +297,11 @@ .. seealso:: - `MsiRecordGetFieldCount `_ - `MsiRecordSetString `_ - `MsiRecordSetStream `_ - `MsiRecordSetInteger `_ - `MsiRecordClear `_ + `MsiRecordGetFieldCount `_ + `MsiRecordSetString `_ + `MsiRecordSetStream `_ + `MsiRecordSetInteger `_ + `MsiRecordClear `_ .. _msi-errors: @@ -393,10 +393,10 @@ .. seealso:: - `Directory Table `_ - `File Table `_ - `Component Table `_ - `FeatureComponents Table `_ + `Directory Table `_ + `File Table `_ + `Component Table `_ + `FeatureComponents Table `_ .. _features: @@ -421,7 +421,7 @@ .. seealso:: - `Feature Table `_ + `Feature Table `_ .. _msi-gui: @@ -516,13 +516,13 @@ .. seealso:: - `Dialog Table `_ - `Control Table `_ - `Control Types `_ - `ControlCondition Table `_ - `ControlEvent Table `_ - `EventMapping Table `_ - `RadioButton Table `_ + `Dialog Table `_ + `Control Table `_ + `Control Types `_ + `ControlCondition Table `_ + `ControlEvent Table `_ + `EventMapping Table `_ + `RadioButton Table `_ .. _msi-tables: diff --git a/Doc/library/os.rst b/Doc/library/os.rst --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -894,7 +894,7 @@ :func:`~os.open` function. They can be combined using the bitwise OR operator ``|``. Some of them are not available on all platforms. For descriptions of their availability and use, consult the :manpage:`open(2)` manual page on Unix -or `the MSDN `_ on Windows. +or `the MSDN `_ on Windows. .. data:: O_RDONLY @@ -1922,9 +1922,9 @@ and `readdir() `_ functions. On Windows, it uses the Win32 - `FindFirstFileW `_ + `FindFirstFileW `_ and - `FindNextFileW `_ + `FindNextFileW `_ functions. .. versionadded:: 3.5 diff --git a/Doc/library/othergui.rst b/Doc/library/othergui.rst --- a/Doc/library/othergui.rst +++ b/Doc/library/othergui.rst @@ -8,33 +8,33 @@ .. seealso:: - `PyGObject `_ + `PyGObject `_ provides introspection bindings for C libraries using `GObject `_. One of these libraries is the `GTK+ 3 `_ widget set. GTK+ comes with many more widgets than Tkinter provides. An online - `Python GTK+ 3 Tutorial `_ + `Python GTK+ 3 Tutorial `_ is available. `PyGTK `_ provides bindings for an older version of the library, GTK+ 2. It provides an object oriented interface that is slightly higher level than the C one. There are also bindings to - `GNOME `_. An online `tutorial + `GNOME `_. An online `tutorial `_ is available. - `PyQt `_ + `PyQt `_ PyQt is a :program:`sip`\ -wrapped binding to the Qt toolkit. Qt is an extensive C++ GUI application development framework that is available for Unix, Windows and Mac OS X. :program:`sip` is a tool for generating bindings for C++ libraries as Python classes, and is specifically designed for Python. The *PyQt3* bindings have a book, `GUI Programming with Python: QT Edition - `_ by Boudewijn + `_ by Boudewijn Rempt. The *PyQt4* bindings also have a book, `Rapid GUI Programming with Python and Qt `_, by Mark Summerfield. - `PySide `_ + `PySide `_ is a newer binding to the Qt toolkit, provided by Nokia. Compared to PyQt, its licensing scheme is friendlier to non-open source applications. @@ -50,7 +50,7 @@ low-level device context drawing, drag and drop, system clipboard access, an XML-based resource format and more, including an ever growing library of user-contributed modules. wxPython has a book, `wxPython in Action - `_, by Noel Rappin and + `_, by Noel Rappin and Robin Dunn. PyGTK, PyQt, and wxPython, all have a modern look and feel and more diff --git a/Doc/library/random.rst b/Doc/library/random.rst --- a/Doc/library/random.rst +++ b/Doc/library/random.rst @@ -267,7 +267,7 @@ `Complementary-Multiply-with-Carry recipe - `_ for a compatible alternative + `_ for a compatible alternative random number generator with a long period and comparatively simple update operations. diff --git a/Doc/library/re.rst b/Doc/library/re.rst --- a/Doc/library/re.rst +++ b/Doc/library/re.rst @@ -1389,7 +1389,7 @@ Writing a Tokenizer ^^^^^^^^^^^^^^^^^^^ -A `tokenizer or scanner `_ +A `tokenizer or scanner `_ analyzes a string to categorize groups of characters. This is a useful first step in writing a compiler or interpreter. diff --git a/Doc/library/shelve.rst b/Doc/library/shelve.rst --- a/Doc/library/shelve.rst +++ b/Doc/library/shelve.rst @@ -76,7 +76,7 @@ .. seealso:: - `Persistent dictionary recipe `_ + `Persistent dictionary recipe `_ with widely supported storage formats and having the speed of native dictionaries. @@ -137,7 +137,7 @@ A subclass of :class:`Shelf` which exposes :meth:`first`, :meth:`!next`, :meth:`previous`, :meth:`last` and :meth:`set_location` which are available in the third-party :mod:`bsddb` module from `pybsddb - `_ but not in other database + `_ but not in other database modules. The *dict* object passed to the constructor must support those methods. This is generally accomplished by calling one of :func:`bsddb.hashopen`, :func:`bsddb.btopen` or :func:`bsddb.rnopen`. The diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -983,7 +983,7 @@ The :meth:`ioctl` method is a limited interface to the WSAIoctl system interface. Please refer to the `Win32 documentation - `_ for more + `_ for more information. On other platforms, the generic :func:`fcntl.fcntl` and :func:`fcntl.ioctl` diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst --- a/Doc/library/ssl.rst +++ b/Doc/library/ssl.rst @@ -206,7 +206,7 @@ The *ciphers* parameter sets the available ciphers for this SSL object. It should be a string in the `OpenSSL cipher list format - `_. + `_. The parameter ``do_handshake_on_connect`` specifies whether to do the SSL handshake automatically after doing a :meth:`socket.connect`, or whether the @@ -296,7 +296,7 @@ Read the Wikipedia article, `Cryptographically secure pseudorandom number generator (CSPRNG) - `_, + `_, to get the requirements of a cryptographically generator. .. versionadded:: 3.3 @@ -721,7 +721,7 @@ Whether the OpenSSL library has built-in support for *Next Protocol Negotiation* as described in the `NPN draft specification - `_. When true, + `_. When true, you can use the :meth:`SSLContext.set_npn_protocols` method to advertise which protocols you want to support. @@ -1212,7 +1212,7 @@ Set the available ciphers for sockets created with this context. It should be a string in the `OpenSSL cipher list format - `_. + `_. If no cipher can be selected (because compile-time options or other configuration forbids use of all the specified ciphers), an :class:`SSLError` will be raised. @@ -1241,7 +1241,7 @@ handshake. It should be a list of strings, like ``['http/1.1', 'spdy/2']``, ordered by preference. The selection of a protocol will happen during the handshake, and will play out according to the `NPN draft specification - `_. After a + `_. After a successful handshake, the :meth:`SSLSocket.selected_npn_protocol` method will return the agreed-upon protocol. @@ -2019,7 +2019,7 @@ :meth:`SSLContext.set_ciphers` method. Starting from Python 3.2.3, the ssl module disables certain weak ciphers by default, but you may want to further restrict the cipher choice. Be sure to read OpenSSL's documentation -about the `cipher list format `_. +about the `cipher list format `_. If you want to check which ciphers are enabled by a given cipher list, use the ``openssl ciphers`` command on your system. @@ -2040,25 +2040,25 @@ Class :class:`socket.socket` Documentation of underlying :mod:`socket` class - `SSL/TLS Strong Encryption: An Introduction `_ + `SSL/TLS Strong Encryption: An Introduction `_ Intro from the Apache webserver documentation - `RFC 1422: Privacy Enhancement for Internet Electronic Mail: Part II: Certificate-Based Key Management `_ + `RFC 1422: Privacy Enhancement for Internet Electronic Mail: Part II: Certificate-Based Key Management `_ Steve Kent - `RFC 1750: Randomness Recommendations for Security `_ + `RFC 1750: Randomness Recommendations for Security `_ D. Eastlake et. al. - `RFC 3280: Internet X.509 Public Key Infrastructure Certificate and CRL Profile `_ + `RFC 3280: Internet X.509 Public Key Infrastructure Certificate and CRL Profile `_ Housley et. al. - `RFC 4366: Transport Layer Security (TLS) Extensions `_ + `RFC 4366: Transport Layer Security (TLS) Extensions `_ Blake-Wilson et. al. - `RFC 5246: The Transport Layer Security (TLS) Protocol Version 1.2 `_ + `RFC 5246: The Transport Layer Security (TLS) Protocol Version 1.2 `_ T. Dierks et. al. - `RFC 6066: Transport Layer Security (TLS) Extensions `_ + `RFC 6066: Transport Layer Security (TLS) Extensions `_ D. Eastlake `IANA TLS: Transport Layer Security (TLS) Parameters `_ diff --git a/Doc/library/stat.rst b/Doc/library/stat.rst --- a/Doc/library/stat.rst +++ b/Doc/library/stat.rst @@ -403,7 +403,7 @@ On Windows, the following file attribute constants are available for use when testing bits in the ``st_file_attributes`` member returned by :func:`os.stat`. See the `Windows API documentation -`_ +`_ for more detail on the meaning of these constants. .. data:: FILE_ATTRIBUTE_ARCHIVE diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst --- a/Doc/library/subprocess.rst +++ b/Doc/library/subprocess.rst @@ -475,7 +475,7 @@ execute. On Windows, in order to run a `side-by-side assembly`_ the specified *env* **must** include a valid :envvar:`SystemRoot`. - .. _side-by-side assembly: http://en.wikipedia.org/wiki/Side-by-Side_Assembly + .. _side-by-side assembly: https://en.wikipedia.org/wiki/Side-by-Side_Assembly If *universal_newlines* is ``True``, the file objects *stdin*, *stdout* and *stderr* are opened as text streams in universal newlines mode, as @@ -536,7 +536,7 @@ If the shell is invoked explicitly, via ``shell=True``, it is the application's responsibility to ensure that all whitespace and metacharacters are quoted appropriately to avoid -`shell injection `_ +`shell injection `_ vulnerabilities. When using ``shell=True``, the :func:`shlex.quote` function can be @@ -721,7 +721,7 @@ .. class:: STARTUPINFO() Partial support of the Windows - `STARTUPINFO `__ + `STARTUPINFO `__ structure is used for :class:`Popen` creation. .. attribute:: dwFlags @@ -757,7 +757,7 @@ If :attr:`dwFlags` specifies :data:`STARTF_USESHOWWINDOW`, this attribute can be any of the values that can be specified in the ``nCmdShow`` parameter for the - `ShowWindow `__ + `ShowWindow `__ function, except for ``SW_SHOWDEFAULT``. Otherwise, this attribute is ignored. diff --git a/Doc/library/test.rst b/Doc/library/test.rst --- a/Doc/library/test.rst +++ b/Doc/library/test.rst @@ -661,7 +661,7 @@ are expected to crash a subprocess. On Windows, it disables Windows Error Reporting dialogs using - `SetErrorMode `_. + `SetErrorMode `_. On UNIX, :func:`resource.setrlimit` is used to set :attr:`resource.RLIMIT_CORE`'s soft limit to 0 to prevent coredump file diff --git a/Doc/library/tkinter.rst b/Doc/library/tkinter.rst --- a/Doc/library/tkinter.rst +++ b/Doc/library/tkinter.rst @@ -31,13 +31,13 @@ `Tcl/Tk manual `_ Official manual for the latest tcl/tk version. - `Programming Python `_ + `Programming Python `_ Book by Mark Lutz, has excellent coverage of Tkinter. `Modern Tkinter for Busy Python Developers `_ Book by Mark Rozerman about building attractive and modern graphical user interfaces with Python and Tkinter. - `Python and Tkinter Programming `_ + `Python and Tkinter Programming `_ The book by John Grayson (ISBN 1-884777-81-3). diff --git a/Doc/library/unittest.mock-examples.rst b/Doc/library/unittest.mock-examples.rst --- a/Doc/library/unittest.mock-examples.rst +++ b/Doc/library/unittest.mock-examples.rst @@ -549,7 +549,7 @@ An alternative way of dealing with mocking dates, or other builtin classes, is discussed in `this blog entry -`_. +`_. Mocking a Generator Method @@ -1251,7 +1251,7 @@ :exc:`AssertionError` directly and provide a more useful failure message. As of version 1.5, the Python testing library `PyHamcrest -`_ provides similar functionality, +`_ provides similar functionality, that may be useful here, in the form of its equality matcher (`hamcrest.library.integration.match_equality -`_). +`_). diff --git a/Doc/library/urllib.request.rst b/Doc/library/urllib.request.rst --- a/Doc/library/urllib.request.rst +++ b/Doc/library/urllib.request.rst @@ -14,7 +14,7 @@ .. seealso:: - The `Requests package `_ + The `Requests package `_ is recommended for a higher-level http client interface. diff --git a/Doc/library/winreg.rst b/Doc/library/winreg.rst --- a/Doc/library/winreg.rst +++ b/Doc/library/winreg.rst @@ -134,7 +134,7 @@ The :func:`DeleteKeyEx` function is implemented with the RegDeleteKeyEx Windows API function, which is specific to 64-bit versions of Windows. See the `RegDeleteKeyEx documentation - `__. + `__. *key* is an already open key, or one of the predefined :ref:`HKEY_* constants `. @@ -268,7 +268,7 @@ A call to :func:`LoadKey` fails if the calling process does not have the :const:`SE_RESTORE_PRIVILEGE` privilege. Note that privileges are different from permissions -- see the `RegLoadKey documentation - `__ for + `__ for more details. If *key* is a handle returned by :func:`ConnectRegistry`, then the path @@ -383,7 +383,7 @@ possess the :const:`SeBackupPrivilege` security privilege. Note that privileges are different than permissions -- see the `Conflicts Between User Rights and Permissions documentation - `__ + `__ for more details. This function passes NULL for *security_attributes* to the API. @@ -547,7 +547,7 @@ +++++++++++++ For more information, see `Registry Key Security and Access -`__. +`__. .. data:: KEY_ALL_ACCESS @@ -602,7 +602,7 @@ *************** For more information, see `Accessing an Alternate Registry View -`__. +`__. .. data:: KEY_WOW64_64KEY @@ -621,7 +621,7 @@ +++++++++++ For more information, see `Registry Value Types -`__. +`__. .. data:: REG_BINARY diff --git a/Doc/library/wsgiref.rst b/Doc/library/wsgiref.rst --- a/Doc/library/wsgiref.rst +++ b/Doc/library/wsgiref.rst @@ -24,8 +24,8 @@ and a validation tool that checks WSGI servers and applications for conformance to the WSGI specification (:pep:`3333`). -See http://www.wsgi.org for more information about WSGI, and links to tutorials -and other resources. +See https://wsgi.readthedocs.org/ for more information about WSGI, and links to +tutorials and other resources. .. XXX If you're just trying to write a web application... diff --git a/Doc/library/xml.rst b/Doc/library/xml.rst --- a/Doc/library/xml.rst +++ b/Doc/library/xml.rst @@ -62,7 +62,7 @@ billion laughs **Yes** **Yes** **Yes** **Yes** **Yes** quadratic blowup **Yes** **Yes** **Yes** **Yes** **Yes** external entity expansion **Yes** No (1) No (2) **Yes** No (3) -DTD retrieval **Yes** No No **Yes** No +`DTD`_ retrieval **Yes** No No **Yes** No decompression bomb No No No No **Yes** ========================= ======== ========= ========= ======== ========= @@ -92,7 +92,7 @@ also point to external resources or local files. The XML parser accesses the resource and embeds the content into the XML document. -DTD retrieval +`DTD`_ retrieval Some XML libraries like Python's :mod:`xml.dom.pulldom` retrieve document type definitions from remote or local locations. The feature has similar implications as the external entity expansion issue. @@ -128,6 +128,6 @@ .. _defusedxml: https://pypi.python.org/pypi/defusedxml/ .. _defusedexpat: https://pypi.python.org/pypi/defusedexpat/ -.. _Billion Laughs: http://en.wikipedia.org/wiki/Billion_laughs -.. _ZIP bomb: http://en.wikipedia.org/wiki/Zip_bomb -.. _DTD: http://en.wikipedia.org/wiki/Document_Type_Definition +.. _Billion Laughs: https://en.wikipedia.org/wiki/Billion_laughs +.. _ZIP bomb: https://en.wikipedia.org/wiki/Zip_bomb +.. _DTD: https://en.wikipedia.org/wiki/Document_type_definition diff --git a/Doc/library/xmlrpc.client.rst b/Doc/library/xmlrpc.client.rst --- a/Doc/library/xmlrpc.client.rst +++ b/Doc/library/xmlrpc.client.rst @@ -142,7 +142,7 @@ `XML-RPC Introspection `_ Describes the XML-RPC protocol extension for introspection. - `XML-RPC Specification `_ + `XML-RPC Specification `_ The official specification. `Unofficial XML-RPC Errata `_ diff --git a/Doc/library/zipfile.rst b/Doc/library/zipfile.rst --- a/Doc/library/zipfile.rst +++ b/Doc/library/zipfile.rst @@ -13,8 +13,7 @@ The ZIP file format is a common archive and compression standard. This module provides tools to create, read, write, append, and list a ZIP file. Any advanced use of this module will require an understanding of the format, as -defined in `PKZIP Application Note -`_. +defined in `PKZIP Application Note`_. This module does not currently handle multi-disk ZIP files. It can handle ZIP files that use the ZIP64 extensions @@ -115,7 +114,7 @@ .. seealso:: - `PKZIP Application Note `_ + `PKZIP Application Note`_ Documentation on the ZIP file format by Phil Katz, the creator of the format and algorithms used. @@ -527,8 +526,7 @@ .. attribute:: ZipInfo.extra - Expansion field data. The `PKZIP Application Note - `_ contains + Expansion field data. The `PKZIP Application Note`_ contains some comments on the internal structure of the data contained in this string. @@ -591,10 +589,5 @@ Size of the uncompressed file. -There is one method: -.. method:: ZipInfo.is_dir() - - Return ``True`` if the ZipInfo represents a directory. - - .. versionadded:: 3.6 +.. _PKZIP Application Note: https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT diff --git a/Doc/library/zipimport.rst b/Doc/library/zipimport.rst --- a/Doc/library/zipimport.rst +++ b/Doc/library/zipimport.rst @@ -30,7 +30,7 @@ .. seealso:: - `PKZIP Application Note `_ + `PKZIP Application Note `_ Documentation on the ZIP file format by Phil Katz, the creator of the format and algorithms used. diff --git a/Doc/using/mac.rst b/Doc/using/mac.rst --- a/Doc/using/mac.rst +++ b/Doc/using/mac.rst @@ -153,7 +153,7 @@ *PyQt* is another popular cross-platform GUI toolkit that runs natively on Mac OS X. More information can be found at -http://www.riverbankcomputing.co.uk/software/pyqt/intro. +https://riverbankcomputing.com/software/pyqt/intro. Distributing Python Applications on the Mac diff --git a/Doc/using/unix.rst b/Doc/using/unix.rst --- a/Doc/using/unix.rst +++ b/Doc/using/unix.rst @@ -26,11 +26,11 @@ .. seealso:: - http://www.debian.org/doc/manuals/maint-guide/first.en.html + https://www.debian.org/doc/manuals/maint-guide/first.en.html for Debian users - http://en.opensuse.org/Portal:Packaging + https://en.opensuse.org/Portal:Packaging for OpenSuse users - http://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch-creating-rpms.html + https://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch-creating-rpms.html for Fedora users http://www.slackbook.org/html/package-management-making-packages.html for Slackware users @@ -65,7 +65,7 @@ =============== If you want to compile CPython yourself, first thing you should do is get the -`source `_. You can download either the +`source `_. You can download either the latest release's source or just grab a fresh `clone `_. (If you want to contribute patches, you will need a clone.) diff --git a/Doc/using/windows.rst b/Doc/using/windows.rst --- a/Doc/using/windows.rst +++ b/Doc/using/windows.rst @@ -251,12 +251,12 @@ release/python>`_, `Maintainer releases `_) -See `Python for Windows `_ +See `Python for Windows `_ for detailed information about platforms with pre-compiled installers. .. seealso:: - `Python on XP `_ + `Python on XP `_ "7 Minutes to "Hello World!"" by Richard Dooling, 2006 @@ -279,10 +279,10 @@ additional functionality. The following is a list of popular versions and their key features: -`ActivePython `_ +`ActivePython `_ Installer with multi-platform compatibility, documentation, PyWin32 -`Anaconda `_ +`Anaconda `_ Popular scientific modules (such as numpy, scipy and pandas) and the ``conda`` package manager. @@ -352,16 +352,16 @@ .. seealso:: - http://support.microsoft.com/kb/100843 + https://support.microsoft.com/kb/100843 Environment variables in Windows NT - http://technet.microsoft.com/en-us/library/cc754250.aspx + https://technet.microsoft.com/en-us/library/cc754250.aspx The SET command, for temporarily modifying environment variables - http://technet.microsoft.com/en-us/library/cc755104.aspx + https://technet.microsoft.com/en-us/library/cc755104.aspx The SETX command, for permanently modifying environment variables - http://support.microsoft.com/kb/310519 + https://support.microsoft.com/kb/310519 How To Manage Environment Variables in Windows XP http://www.chem.gla.ac.uk/~louis/software/faq/q1.html @@ -781,18 +781,18 @@ PyWin32 ------- -The `PyWin32 `_ module by Mark Hammond +The `PyWin32 `_ module by Mark Hammond is a collection of modules for advanced Windows-specific support. This includes utilities for: -* `Component Object Model `_ (COM) +* `Component Object Model `_ (COM) * Win32 API calls * Registry * Event log -* `Microsoft Foundation Classes `_ (MFC) +* `Microsoft Foundation Classes `_ (MFC) user interfaces -`PythonWin `_ is a sample MFC application shipped with PyWin32. It is an embeddable IDE with a built-in debugger. @@ -831,7 +831,7 @@ =========================== If you want to compile CPython yourself, first thing you should do is get the -`source `_. You can download either the +`source `_. You can download either the latest release's source or just grab a fresh `checkout `_. @@ -874,7 +874,7 @@ .. note:: The embedded distribution does not include the `Microsoft C Runtime - `_ and it is + `_ and it is the responsibility of the application installer to provide this. The runtime may have already been installed on a user's system previously or automatically via Windows Update, and can be detected by finding diff --git a/Doc/whatsnew/2.0.rst b/Doc/whatsnew/2.0.rst --- a/Doc/whatsnew/2.0.rst +++ b/Doc/whatsnew/2.0.rst @@ -130,7 +130,7 @@ Read the rest of PEP 1 for the details of the PEP editorial process, style, and format. PEPs are kept in the Python CVS tree on SourceForge, though they're not part of the Python 2.0 distribution, and are also available in HTML form from -https://www.python.org/peps/. As of September 2000, there are 25 PEPS, ranging +https://www.python.org/dev/peps/. As of September 2000, there are 25 PEPS, ranging from PEP 201, "Lockstep Iteration", to PEP 225, "Elementwise/Objectwise Operators". @@ -337,7 +337,7 @@ [ (x,y) for x in seq1 for y in seq2] The idea of list comprehensions originally comes from the functional programming -language Haskell (http://www.haskell.org). Greg Ewing argued most effectively +language Haskell (https://www.haskell.org). Greg Ewing argued most effectively for adding them to Python and wrote the initial list comprehension patch, which was then discussed for a seemingly endless time on the python-dev mailing list and kept up-to-date by Skip Montanaro. diff --git a/Doc/whatsnew/2.1.rst b/Doc/whatsnew/2.1.rst --- a/Doc/whatsnew/2.1.rst +++ b/Doc/whatsnew/2.1.rst @@ -562,7 +562,7 @@ using Python 2.1, since a new release of the Distutils will be made for users of earlier Python versions. Version 1.0.2 of the Distutils includes the changes described in PEP 241, as well as various bugfixes and enhancements. It will be -available from the Distutils SIG at https://www.python.org/sigs/distutils-sig/. +available from the Distutils SIG at https://www.python.org/community/sigs/current/distutils-sig/. .. seealso:: diff --git a/Doc/whatsnew/2.3.rst b/Doc/whatsnew/2.3.rst --- a/Doc/whatsnew/2.3.rst +++ b/Doc/whatsnew/2.3.rst @@ -1080,9 +1080,9 @@ hierarchy. Classic classes are unaffected by this change. Python 2.2 originally used a topological sort of a class's ancestors, but 2.3 now uses the C3 algorithm as described in the paper `"A Monotonic Superclass Linearization - for Dylan" `_. To + for Dylan" `_. To understand the motivation for this change, read Michele Simionato's article - `"Python 2.3 Method Resolution Order" `_, or + `"Python 2.3 Method Resolution Order" `_, or read the thread on python-dev starting with the message at https://mail.python.org/pipermail/python-dev/2002-October/029035.html. Samuele Pedroni first pointed out the problem and also implemented the fix by coding the @@ -1306,7 +1306,7 @@ partially sorted order such that, for every index *k*, ``heap[k] <= heap[2*k+1]`` and ``heap[k] <= heap[2*k+2]``. This makes it quick to remove the smallest item, and inserting a new item while maintaining the heap property is - O(lg n). (See http://www.nist.gov/dads/HTML/priorityque.html for more + O(lg n). (See https://xlinux.nist.gov/dads//HTML/priorityque.html for more information about the priority queue data structure.) The :mod:`heapq` module provides :func:`heappush` and :func:`heappop` functions @@ -1949,7 +1949,7 @@ source distribution, were updated for 2.3. (Contributed by Sean Reifschneider.) Other new platforms now supported by Python include AtheOS -(http://www.atheos.cx/), GNU/Hurd, and OpenVMS. +(http://atheos.cx/), GNU/Hurd, and OpenVMS. .. ====================================================================== diff --git a/Doc/whatsnew/2.4.rst b/Doc/whatsnew/2.4.rst --- a/Doc/whatsnew/2.4.rst +++ b/Doc/whatsnew/2.4.rst @@ -337,7 +337,7 @@ wrote patches implementing function decorators, but the one that was actually checked in was patch #979728, written by Mark Russell. - https://www.python.org/moin/PythonDecoratorLibrary + https://wiki.python.org/moin/PythonDecoratorLibrary This Wiki page contains several examples of decorators. .. ====================================================================== @@ -687,7 +687,7 @@ The article uses Fortran code to illustrate many of the problems that floating- point inaccuracy can cause. - http://www2.hursley.ibm.com/decimal/ + http://speleotrove.com/decimal/ A description of a decimal-based representation. This representation is being proposed as a standard, and underlies the new Python decimal type. Much of this material was written by Mike Cowlishaw, designer of the Rexx language. @@ -756,7 +756,7 @@ :c:type:`double` to an ASCII string. The code for these functions came from the GLib library -(http://library.gnome.org/devel/glib/stable/), whose developers kindly +(https://developer.gnome.org/glib/stable/), whose developers kindly relicensed the relevant functions and donated them to the Python Software Foundation. The :mod:`locale` module can now change the numeric locale, letting extensions such as GTK+ produce the correct results. diff --git a/Doc/whatsnew/2.5.rst b/Doc/whatsnew/2.5.rst --- a/Doc/whatsnew/2.5.rst +++ b/Doc/whatsnew/2.5.rst @@ -330,7 +330,7 @@ :pep:`328` - Imports: Multi-Line and Absolute/Relative PEP written by Aahz; implemented by Thomas Wouters. - http://codespeak.net/py/current/doc/index.html + https://pylib.readthedocs.org/ The py library by Holger Krekel, which contains the :mod:`py.std` package. .. ====================================================================== @@ -547,7 +547,7 @@ Earlier versions of these features were proposed in :pep:`288` by Raymond Hettinger and :pep:`325` by Samuele Pedroni. - http://en.wikipedia.org/wiki/Coroutine + https://en.wikipedia.org/wiki/Coroutine The Wikipedia entry for coroutines. http://www.sidhe.org/~dan/blog/archives/000178.html @@ -2088,7 +2088,7 @@ provided the results of their examination of the Python source code. The analysis found about 60 bugs that were quickly fixed. Many of the bugs were refcounting problems, often occurring in error-handling code. See - http://scan.coverity.com for the statistics. + https://scan.coverity.com for the statistics. * The largest change to the C API came from :pep:`353`, which modifies the interpreter to use a :c:type:`Py_ssize_t` type definition instead of diff --git a/Doc/whatsnew/2.6.rst b/Doc/whatsnew/2.6.rst --- a/Doc/whatsnew/2.6.rst +++ b/Doc/whatsnew/2.6.rst @@ -153,8 +153,8 @@ therefore posted a call for issue trackers, asking volunteers to set up different products and import some of the bugs and patches from SourceForge. Four different trackers were examined: `Jira -`__, -`Launchpad `__, +`__, +`Launchpad `__, `Roundup `__, and `Trac `__. The committee eventually settled on Jira @@ -217,7 +217,7 @@ During the 2.6 development cycle, Georg Brandl put a lot of effort into building a new toolchain for processing the documentation. The resulting package is called Sphinx, and is available from -http://sphinx.pocoo.org/. +http://sphinx-doc.org/. Sphinx concentrates on HTML output, producing attractively styled and modern HTML; printed output is still supported through conversion to @@ -1796,7 +1796,7 @@ * The :mod:`bsddb` module also has a new maintainer, Jes?s Cea Avi?n, and the package is now available as a standalone package. The web page for the package is `www.jcea.es/programacion/pybsddb.htm - `__. + `__. The plan is to remove the package from the standard library in Python 3.0, because its pace of releases is much more frequent than Python's. @@ -1926,7 +1926,7 @@ the left to six places. (Contributed by Skip Montanaro; :issue:`1158`.) * The :mod:`decimal` module was updated to version 1.66 of - `the General Decimal Specification `__. New features + `the General Decimal Specification `__. New features include some methods for some basic mathematical functions such as :meth:`exp` and :meth:`log10`:: diff --git a/Doc/whatsnew/2.7.rst b/Doc/whatsnew/2.7.rst --- a/Doc/whatsnew/2.7.rst +++ b/Doc/whatsnew/2.7.rst @@ -1029,7 +1029,7 @@ * Updated module: the :mod:`bsddb` module has been updated from 4.7.2devel9 to version 4.8.4 of - `the pybsddb package `__. + `the pybsddb package `__. The new version features better Python 3.x compatibility, various bug fixes, and adds several new BerkeleyDB flags and methods. (Updated by Jes?s Cea Avi?n; :issue:`8156`. The pybsddb @@ -1513,7 +1513,7 @@ (Contributed by Kristj?n Valur J?nsson; :issue:`6192` and :issue:`6267`.) * Updated module: the :mod:`sqlite3` module has been updated to - version 2.6.0 of the `pysqlite package `__. Version 2.6.0 includes a number of bugfixes, and adds + version 2.6.0 of the `pysqlite package `__. Version 2.6.0 includes a number of bugfixes, and adds the ability to load SQLite extensions from shared libraries. Call the ``enable_load_extension(True)`` method to enable extensions, and then call :meth:`~sqlite3.Connection.load_extension` to load a particular shared library. diff --git a/Doc/whatsnew/3.0.rst b/Doc/whatsnew/3.0.rst --- a/Doc/whatsnew/3.0.rst +++ b/Doc/whatsnew/3.0.rst @@ -565,7 +565,7 @@ core standard library has proved over time to be a particular burden for the core developers due to testing instability and Berkeley DB's release schedule. However, the package is alive and well, - externally maintained at http://www.jcea.es/programacion/pybsddb.htm. + externally maintained at https://www.jcea.es/programacion/pybsddb.htm. * Some modules were renamed because their old name disobeyed :pep:`0008`, or for various other reasons. Here's the list: diff --git a/Doc/whatsnew/3.2.rst b/Doc/whatsnew/3.2.rst --- a/Doc/whatsnew/3.2.rst +++ b/Doc/whatsnew/3.2.rst @@ -845,9 +845,9 @@ * The :class:`collections.Counter` class now has two forms of in-place subtraction, the existing *-=* operator for `saturating subtraction - `_ and the new + `_ and the new :meth:`~collections.Counter.subtract` method for regular subtraction. The - former is suitable for `multisets `_ + former is suitable for `multisets `_ which only have positive counts, and the latter is more suitable for use cases that allow negative counts: @@ -906,7 +906,7 @@ complete. Barriers can work with an arbitrary number of threads. This is a generalization -of a `Rendezvous `_ which +of a `Rendezvous `_ which is defined for only two threads. Implemented as a two-phase cyclic barrier, :class:`~threading.Barrier` objects @@ -1043,7 +1043,7 @@ 0.013765762467652909 The :func:`~math.erf` function computes a probability integral or `Gaussian -error function `_. The +error function `_. The complementary error function, :func:`~math.erfc`, is ``1 - erf(x)``: >>> erf(1.0/sqrt(2.0)) # portion of normal distribution within 1 standard deviation @@ -1054,7 +1054,7 @@ 1.0 The :func:`~math.gamma` function is a continuous extension of the factorial -function. See http://en.wikipedia.org/wiki/Gamma_function for details. Because +function. See https://en.wikipedia.org/wiki/Gamma_function for details. Because the function is related to factorials, it grows large even for small values of *x*, so there is also a :func:`~math.lgamma` function for computing the natural logarithm of the gamma function: @@ -2180,7 +2180,7 @@ A number of usability improvements were made for the :mod:`urllib.parse` module. The :func:`~urllib.parse.urlparse` function now supports `IPv6 -`_ addresses as described in :rfc:`2732`: +`_ addresses as described in :rfc:`2732`: >>> import urllib.parse >>> urllib.parse.urlparse('http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]/foo/') @@ -2328,7 +2328,7 @@ (Contributed by Alexandre Vassalotti, Antoine Pitrou and the Unladen Swallow team in :issue:`9410` and :issue:`3873`.) -* The `Timsort algorithm `_ used in +* The `Timsort algorithm `_ used in :meth:`list.sort` and :func:`sorted` now runs faster and uses less memory when called with a :term:`key function`. Previously, every element of a list was wrapped with a temporary object that remembered the key value @@ -2380,7 +2380,7 @@ Python has been updated to `Unicode 6.0.0 `_. The update to the standard adds -over 2,000 new characters including `emoji `_ +over 2,000 new characters including `emoji `_ symbols which are important for mobile phones. In addition, the updated standard has altered the character properties for two @@ -2432,7 +2432,7 @@ **Source code** :source:`Lib/functools.py`. (Contributed by Raymond Hettinger; see - `rationale `_.) + `rationale `_.) * The docs now contain more examples and recipes. In particular, :mod:`re` module has an extensive section, :ref:`re-examples`. Likewise, the @@ -2468,7 +2468,7 @@ =============== In addition to the existing Subversion code repository at http://svn.python.org -there is now a `Mercurial `_ repository at +there is now a `Mercurial `_ repository at https://hg.python.org/\ . After the 3.2 release, there are plans to switch to Mercurial as the primary @@ -2478,7 +2478,7 @@ To learn to use the new version control system, see the `tutorial by Joel Spolsky `_ or the `Guide to Mercurial Workflows -`_. +`_. Build and C API Changes diff --git a/Doc/whatsnew/3.3.rst b/Doc/whatsnew/3.3.rst --- a/Doc/whatsnew/3.3.rst +++ b/Doc/whatsnew/3.3.rst @@ -1884,13 +1884,13 @@ Heiko Wundram) * The :class:`~socket.socket` class now supports the PF_CAN protocol family - (http://en.wikipedia.org/wiki/Socketcan), on Linux - (http://lwn.net/Articles/253425). + (https://en.wikipedia.org/wiki/Socketcan), on Linux + (https://lwn.net/Articles/253425). (Contributed by Matthias Fuchs, updated by Tiago Gon?alves in :issue:`10141`.) * The :class:`~socket.socket` class now supports the PF_RDS protocol family - (http://en.wikipedia.org/wiki/Reliable_Datagram_Sockets and + (https://en.wikipedia.org/wiki/Reliable_Datagram_Sockets and https://oss.oracle.com/projects/rds/). * The :class:`~socket.socket` class now supports the ``PF_SYSTEM`` protocol diff --git a/Doc/whatsnew/3.4.rst b/Doc/whatsnew/3.4.rst --- a/Doc/whatsnew/3.4.rst +++ b/Doc/whatsnew/3.4.rst @@ -144,7 +144,7 @@ all of the parent's inheritable handles, only the necessary ones. * A new :func:`hashlib.pbkdf2_hmac` function provides the `PKCS#5 password-based key derivation function 2 - `_. + `_. * :ref:`TLSv1.1 and TLSv1.2 support ` for :mod:`ssl`. * :ref:`Retrieving certificates from the Windows system cert store support ` for :mod:`ssl`. @@ -902,7 +902,7 @@ A new :func:`hashlib.pbkdf2_hmac` function provides the `PKCS#5 password-based key derivation function 2 -`_. (Contributed by Christian +`_. (Contributed by Christian Heimes in :issue:`18582`.) The :attr:`~hashlib.hash.name` attribute of :mod:`hashlib` hash objects is now @@ -1917,8 +1917,8 @@ :issue:`18596`.) * The Windows build now uses `Address Space Layout Randomization - `_ and `Data Execution Prevention - `_. (Contributed by + `_ and `Data Execution Prevention + `_. (Contributed by Christian Heimes in :issue:`16632`.) * New function :c:func:`PyObject_LengthHint` is the C API equivalent diff --git a/Doc/whatsnew/3.5.rst b/Doc/whatsnew/3.5.rst --- a/Doc/whatsnew/3.5.rst +++ b/Doc/whatsnew/3.5.rst @@ -2169,7 +2169,7 @@ The :c:member:`PyTypeObject.tp_finalize` slot is now part of the stable ABI. Windows builds now require Microsoft Visual C++ 14.0, which -is available as part of `Visual Studio 2015 `_. +is available as part of `Visual Studio 2015 `_. Extension modules now include a platform information tag in their filename on some platforms (the tag is optional, and CPython will import extensions without diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -7917,7 +7917,7 @@ - Issue #16245: Fix the value of a few entities in html.entities.html5. -- Issue #16301: Fix the localhost verification in urllib/request.py for file:// +- Issue #16301: Fix the localhost verification in urllib/request.py for ``file://`` urls. - Issue #16250: Fix the invocations of URLError which had misplaced filename -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri Feb 26 20:26:23 2016 From: python-checkins at python.org (victor.stinner) Date: Sat, 27 Feb 2016 01:26:23 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_compile=2Ec=3A_inline_comp?= =?utf-8?b?aWxlcl91c2VfbmV3X2Jsb2NrKCk=?= Message-ID: <20160227012623.17784.94709@psf.io> https://hg.python.org/cpython/rev/b9e5be743d15 changeset: 100354:b9e5be743d15 user: Victor Stinner date: Sat Feb 27 02:19:22 2016 +0100 summary: compile.c: inline compiler_use_new_block() * Inline compiler_use_new_block() function into its only callee, compiler_enter_scope() * Remove unused NEW_BLOCK() macro files: Python/compile.c | 37 +++++++++-------------------------- 1 files changed, 10 insertions(+), 27 deletions(-) diff --git a/Python/compile.c b/Python/compile.c --- a/Python/compile.c +++ b/Python/compile.c @@ -171,7 +171,6 @@ static int compiler_addop_o(struct compiler *, int, PyObject *, PyObject *); static int compiler_addop_i(struct compiler *, int, Py_ssize_t); static int compiler_addop_j(struct compiler *, int, basicblock *, int); -static basicblock *compiler_use_new_block(struct compiler *); static int compiler_error(struct compiler *, const char *); static int compiler_nameop(struct compiler *, identifier, expr_context_ty); @@ -523,6 +522,7 @@ int scope_type, void *key, int lineno) { struct compiler_unit *u; + basicblock *block; u = (struct compiler_unit *)PyObject_Malloc(sizeof( struct compiler_unit)); @@ -620,8 +620,11 @@ c->u = u; c->c_nestlevel++; - if (compiler_use_new_block(c) == NULL) + + block = compiler_new_block(c); + if (block == NULL) return 0; + c->u->u_curblock = block; if (u->u_scope_type != COMPILER_SCOPE_MODULE) { if (!compiler_set_qualname(c)) @@ -756,16 +759,6 @@ } static basicblock * -compiler_use_new_block(struct compiler *c) -{ - basicblock *block = compiler_new_block(c); - if (block == NULL) - return NULL; - c->u->u_curblock = block; - return block; -} - -static basicblock * compiler_next_block(struct compiler *c) { basicblock *block = compiler_new_block(c); @@ -1208,22 +1201,12 @@ return 1; } -/* The distinction between NEW_BLOCK and NEXT_BLOCK is subtle. (I'd - like to find better names.) NEW_BLOCK() creates a new block and sets - it as the current block. NEXT_BLOCK() also creates an implicit jump - from the current block to the new block. +/* NEXT_BLOCK() creates an implicit jump from the current block + to the new block. + + The returns inside this macro make it impossible to decref objects + created in the local function. Local objects should use the arena. */ - -/* The returns inside these macros make it impossible to decref objects - created in the local function. Local objects should use the arena. -*/ - - -#define NEW_BLOCK(C) { \ - if (compiler_use_new_block((C)) == NULL) \ - return 0; \ -} - #define NEXT_BLOCK(C) { \ if (compiler_next_block((C)) == NULL) \ return 0; \ -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Feb 27 01:46:41 2016 From: python-checkins at python.org (ezio.melotti) Date: Sat, 27 Feb 2016 06:46:41 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogIzI2MjQ2OiB1cGRh?= =?utf-8?q?te_copybutton=2Ejs_after_JQuery_update=2E__Patch_by_Liang-Bo_Wa?= =?utf-8?b?bmcu?= Message-ID: <20160227064641.30282.78825@psf.io> https://hg.python.org/cpython/rev/20b5d153b894 changeset: 100358:20b5d153b894 branch: 2.7 parent: 100342:d4190ed586a4 user: Ezio Melotti date: Sat Feb 27 08:39:36 2016 +0200 summary: #26246: update copybutton.js after JQuery update. Patch by Liang-Bo Wang. files: Doc/tools/static/copybutton.js | 18 +++++++++++------- Misc/ACKS | 1 + 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Doc/tools/static/copybutton.js b/Doc/tools/static/copybutton.js --- a/Doc/tools/static/copybutton.js +++ b/Doc/tools/static/copybutton.js @@ -37,20 +37,24 @@ }); // define the behavior of the button when it's clicked - $('.copybutton').toggle( - function() { - var button = $(this); + $('.copybutton').click(function(e){ + e.preventDefault(); + var button = $(this); + if (button.data('hidden') === 'false') { + // hide the code output button.parent().find('.go, .gp, .gt').hide(); button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'hidden'); button.css('text-decoration', 'line-through'); button.attr('title', show_text); - }, - function() { - var button = $(this); + button.data('hidden', 'true'); + } else { + // show the code output button.parent().find('.go, .gp, .gt').show(); button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'visible'); button.css('text-decoration', 'none'); button.attr('title', hide_text); - }); + button.data('hidden', 'false'); + } + }); }); diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1449,6 +1449,7 @@ Rodrigo Steinmuller Wanderley Dingyuan Wang Ke Wang +Liang-Bo Wang Greg Ward Tom Wardill Zachary Ware -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Feb 27 01:46:41 2016 From: python-checkins at python.org (ezio.melotti) Date: Sat, 27 Feb 2016 06:46:41 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy40KTogIzI2MjQ2OiB1cGRh?= =?utf-8?q?te_copybutton=2Ejs_after_JQuery_update=2E__Patch_by_Liang-Bo_Wa?= =?utf-8?b?bmcu?= Message-ID: <20160227064641.25999.68910@psf.io> https://hg.python.org/cpython/rev/f0e20d942760 changeset: 100355:f0e20d942760 branch: 3.4 parent: 100251:9f29cf9ad17f user: Ezio Melotti date: Sat Feb 27 08:39:36 2016 +0200 summary: #26246: update copybutton.js after JQuery update. Patch by Liang-Bo Wang. files: Doc/tools/static/copybutton.js | 18 +++++++++++------- Misc/ACKS | 1 + 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Doc/tools/static/copybutton.js b/Doc/tools/static/copybutton.js --- a/Doc/tools/static/copybutton.js +++ b/Doc/tools/static/copybutton.js @@ -38,20 +38,24 @@ }); // define the behavior of the button when it's clicked - $('.copybutton').toggle( - function() { - var button = $(this); + $('.copybutton').click(function(e){ + e.preventDefault(); + var button = $(this); + if (button.data('hidden') === 'false') { + // hide the code output button.parent().find('.go, .gp, .gt').hide(); button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'hidden'); button.css('text-decoration', 'line-through'); button.attr('title', show_text); - }, - function() { - var button = $(this); + button.data('hidden', 'true'); + } else { + // show the code output button.parent().find('.go, .gp, .gt').show(); button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'visible'); button.css('text-decoration', 'none'); button.attr('title', hide_text); - }); + button.data('hidden', 'false'); + } + }); }); diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1478,6 +1478,7 @@ Rodrigo Steinmuller Wanderley Dingyuan Wang Ke Wang +Liang-Bo Wang Greg Ward Tom Wardill Zachary Ware -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Feb 27 01:46:41 2016 From: python-checkins at python.org (ezio.melotti) Date: Sat, 27 Feb 2016 06:46:41 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_=2326246=3A_merge_with_3=2E4=2E?= Message-ID: <20160227064641.30280.17618@psf.io> https://hg.python.org/cpython/rev/ac175a7af60b changeset: 100356:ac175a7af60b branch: 3.5 parent: 100352:ce5ef48b5140 parent: 100355:f0e20d942760 user: Ezio Melotti date: Sat Feb 27 08:41:16 2016 +0200 summary: #26246: merge with 3.4. files: Doc/tools/static/copybutton.js | 18 +++++++++++------- Misc/ACKS | 1 + 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Doc/tools/static/copybutton.js b/Doc/tools/static/copybutton.js --- a/Doc/tools/static/copybutton.js +++ b/Doc/tools/static/copybutton.js @@ -38,20 +38,24 @@ }); // define the behavior of the button when it's clicked - $('.copybutton').toggle( - function() { - var button = $(this); + $('.copybutton').click(function(e){ + e.preventDefault(); + var button = $(this); + if (button.data('hidden') === 'false') { + // hide the code output button.parent().find('.go, .gp, .gt').hide(); button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'hidden'); button.css('text-decoration', 'line-through'); button.attr('title', show_text); - }, - function() { - var button = $(this); + button.data('hidden', 'true'); + } else { + // show the code output button.parent().find('.go, .gp, .gt').show(); button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'visible'); button.css('text-decoration', 'none'); button.attr('title', hide_text); - }); + button.data('hidden', 'false'); + } + }); }); diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1533,6 +1533,7 @@ Rodrigo Steinmuller Wanderley Dingyuan Wang Ke Wang +Liang-Bo Wang Greg Ward Tom Wardill Zachary Ware -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Feb 27 01:46:42 2016 From: python-checkins at python.org (ezio.melotti) Date: Sat, 27 Feb 2016 06:46:42 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?b?KTogIzI2MjQ2OiBtZXJnZSB3aXRoIDMuNS4=?= Message-ID: <20160227064641.125907.96727@psf.io> https://hg.python.org/cpython/rev/8c0761260d22 changeset: 100357:8c0761260d22 parent: 100354:b9e5be743d15 parent: 100356:ac175a7af60b user: Ezio Melotti date: Sat Feb 27 08:42:14 2016 +0200 summary: #26246: merge with 3.5. files: Doc/tools/static/copybutton.js | 18 +++++++++++------- Misc/ACKS | 1 + 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Doc/tools/static/copybutton.js b/Doc/tools/static/copybutton.js --- a/Doc/tools/static/copybutton.js +++ b/Doc/tools/static/copybutton.js @@ -38,20 +38,24 @@ }); // define the behavior of the button when it's clicked - $('.copybutton').toggle( - function() { - var button = $(this); + $('.copybutton').click(function(e){ + e.preventDefault(); + var button = $(this); + if (button.data('hidden') === 'false') { + // hide the code output button.parent().find('.go, .gp, .gt').hide(); button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'hidden'); button.css('text-decoration', 'line-through'); button.attr('title', show_text); - }, - function() { - var button = $(this); + button.data('hidden', 'true'); + } else { + // show the code output button.parent().find('.go, .gp, .gt').show(); button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'visible'); button.css('text-decoration', 'none'); button.attr('title', hide_text); - }); + button.data('hidden', 'false'); + } + }); }); diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1540,6 +1540,7 @@ Rodrigo Steinmuller Wanderley Dingyuan Wang Ke Wang +Liang-Bo Wang Greg Ward Tom Wardill Zachary Ware -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Sat Feb 27 04:44:53 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Sat, 27 Feb 2016 09:44:53 +0000 Subject: [Python-checkins] Daily reference leaks (b9e5be743d15): sum=4 Message-ID: <20160227094453.76452.66438@psf.io> results for b9e5be743d15 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogf7QH9L', '--timeout', '7200'] From python-checkins at python.org Sat Feb 27 20:19:33 2016 From: python-checkins at python.org (martin.panter) Date: Sun, 28 Feb 2016 01:19:33 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzIyODM2?= =?utf-8?q?=3A_Keep_exception_reports_sensible_despite_errors?= Message-ID: <20160228011933.9027.93258@psf.io> https://hg.python.org/cpython/rev/fca9f02e10e5 changeset: 100359:fca9f02e10e5 branch: 2.7 user: Martin Panter date: Sun Feb 28 00:18:43 2016 +0000 summary: Issue #22836: Keep exception reports sensible despite errors files: Doc/c-api/exceptions.rst | 4 +- Lib/test/test_exceptions.py | 69 +++++++++++++++++++++++- Misc/NEWS | 5 + Python/errors.c | 10 ++- Python/pythonrun.c | 8 ++- 5 files changed, 87 insertions(+), 9 deletions(-) diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst --- a/Doc/c-api/exceptions.rst +++ b/Doc/c-api/exceptions.rst @@ -404,8 +404,8 @@ :meth:`__del__` method. The function is called with a single argument *obj* that identifies the context - in which the unraisable exception occurred. The repr of *obj* will be printed in - the warning message. + in which the unraisable exception occurred. If possible, + the repr of *obj* will be printed in the warning message. .. _unicodeexceptions: diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -5,10 +5,15 @@ import unittest import pickle, cPickle -from test.test_support import (TESTFN, unlink, run_unittest, captured_output, +from test.test_support import (TESTFN, unlink, run_unittest, captured_stderr, check_warnings, cpython_only) from test.test_pep352 import ignore_deprecation_warnings +class BrokenStrException(Exception): + def __str__(self): + raise Exception("str() is broken") + __repr__ = __str__ # Python 2's PyErr_WriteUnraisable() uses repr() + # XXX This is not really enough, each *operation* should be tested! class ExceptionTests(unittest.TestCase): @@ -375,7 +380,7 @@ # The test prints an unraisable recursion error when # doing "except ValueError", this is because subclass # checking has recursion checking too. - with captured_output("stderr"): + with captured_stderr(): try: g() except RuntimeError: @@ -448,7 +453,7 @@ __metaclass__ = Meta pass - with captured_output("stderr") as stderr: + with captured_stderr() as stderr: try: raise KeyError() except MyException, e: @@ -460,7 +465,7 @@ else: self.fail("Should have raised KeyError") - with captured_output("stderr") as stderr: + with captured_stderr() as stderr: def g(): try: return g() @@ -644,6 +649,62 @@ self.assertEqual(error5.a, 1) self.assertEqual(error5.__doc__, "") + def test_unraisable(self): + # Issue #22836: PyErr_WriteUnraisable() should give sensible reports + class BrokenDel: + def __del__(self): + exc = ValueError("del is broken") + # In Python 3, the following line would be in the report: + raise exc + + class BrokenRepr(BrokenDel): + def __repr__(self): + raise AttributeError("repr() is broken") + + class BrokenExceptionDel: + def __del__(self): + exc = BrokenStrException() + # In Python 3, the following line would be in the report: + raise exc + + for test_class in (BrokenDel, BrokenRepr, BrokenExceptionDel): + obj = test_class() + with captured_stderr() as stderr: + del obj + report = stderr.getvalue() + self.assertRegexpMatches(report, "Exception.* ignored") + if test_class is BrokenRepr: + self.assertIn("", report) + else: + self.assertIn("__del__", report) + if test_class is BrokenExceptionDel: + self.assertIn("BrokenStrException", report) + self.assertIn("", report) + else: + self.assertIn("ValueError", report) + self.assertIn("del is broken", report) + self.assertTrue(report.endswith("\n")) + + def test_unhandled(self): + # Check for sensible reporting of unhandled exceptions + for exc_type in (ValueError, BrokenStrException): + try: + exc = exc_type("test message") + # The following line is included in the traceback report: + raise exc + except exc_type: + with captured_stderr() as stderr: + sys.__excepthook__(*sys.exc_info()) + report = stderr.getvalue() + self.assertIn("test_exceptions.py", report) + self.assertIn("raise exc", report) + self.assertIn(exc_type.__name__, report) + if exc_type is BrokenStrException: + self.assertIn("", report) + else: + self.assertIn("test message", report) + self.assertTrue(report.endswith("\n")) + def test_main(): run_unittest(ExceptionTests, TestSameStrAndUnicodeMsg) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,11 @@ Core and Builtins ----------------- +- Issue #22836: Ensure exception reports from PyErr_Display() and + PyErr_WriteUnraisable() are sensible even when formatting them produces + secondary errors. This affects the reports produced by + sys.__excepthook__() and when __del__() raises an exception. + - Issue #22847: Improve method cache efficiency. - Issue #25843: When compiling code, don't merge constants if they are equal diff --git a/Python/errors.c b/Python/errors.c --- a/Python/errors.c +++ b/Python/errors.c @@ -696,12 +696,18 @@ PyFile_WriteString(className, f); if (v && v != Py_None) { PyFile_WriteString(": ", f); - PyFile_WriteObject(v, f, 0); + if (PyFile_WriteObject(v, f, 0) < 0) { + PyErr_Clear(); + PyFile_WriteString("", f); + } } Py_XDECREF(moduleName); } PyFile_WriteString(" in ", f); - PyFile_WriteObject(obj, f, 0); + if (PyFile_WriteObject(obj, f, 0) < 0) { + PyErr_Clear(); + PyFile_WriteString("", f); + } PyFile_WriteString(" ignored\n", f); PyErr_Clear(); /* Just in case */ } diff --git a/Python/pythonrun.c b/Python/pythonrun.c --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1299,8 +1299,11 @@ /* only print colon if the str() of the object is not the empty string */ - if (s == NULL) + if (s == NULL) { + PyErr_Clear(); err = -1; + PyFile_WriteString(": ", f); + } else if (!PyString_Check(s) || PyString_GET_SIZE(s) != 0) err = PyFile_WriteString(": ", f); @@ -1309,6 +1312,9 @@ Py_XDECREF(s); } /* try to write a newline in any case */ + if (err < 0) { + PyErr_Clear(); + } err += PyFile_WriteString("\n", f); } Py_DECREF(value); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Feb 27 22:45:01 2016 From: python-checkins at python.org (martin.panter) Date: Sun, 28 Feb 2016 03:45:01 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2322836=3A_Merge_exception_reporting_from_3=2E5?= Message-ID: <20160228034501.30270.52382@psf.io> https://hg.python.org/cpython/rev/2b597e03f7f4 changeset: 100361:2b597e03f7f4 parent: 100357:8c0761260d22 parent: 100360:cf70b1204e44 user: Martin Panter date: Sun Feb 28 03:29:51 2016 +0000 summary: Issue #22836: Merge exception reporting from 3.5 files: Doc/c-api/exceptions.rst | 4 +- Lib/test/test_exceptions.py | 68 ++++++++++++++++++++++++- Misc/NEWS | 5 + Python/errors.c | 16 ++++- Python/pythonrun.c | 8 ++- 5 files changed, 92 insertions(+), 9 deletions(-) diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst --- a/Doc/c-api/exceptions.rst +++ b/Doc/c-api/exceptions.rst @@ -74,8 +74,8 @@ :meth:`__del__` method. The function is called with a single argument *obj* that identifies the context - in which the unraisable exception occurred. The repr of *obj* will be printed in - the warning message. + in which the unraisable exception occurred. If possible, + the repr of *obj* will be printed in the warning message. Raising exceptions diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -7,7 +7,7 @@ import weakref import errno -from test.support import (TESTFN, captured_output, check_impl_detail, +from test.support import (TESTFN, captured_stderr, check_impl_detail, check_warnings, cpython_only, gc_collect, run_unittest, no_tracing, unlink, import_module) @@ -20,6 +20,10 @@ def __init__(self, x): self.x = x +class BrokenStrException(Exception): + def __str__(self): + raise Exception("str() is broken") + # XXX This is not really enough, each *operation* should be tested! class ExceptionTests(unittest.TestCase): @@ -882,7 +886,7 @@ class MyException(Exception, metaclass=Meta): pass - with captured_output("stderr") as stderr: + with captured_stderr() as stderr: try: raise KeyError() except MyException as e: @@ -1011,6 +1015,66 @@ os.listdir(__file__) self.assertEqual(cm.exception.errno, errno.ENOTDIR, cm.exception) + def test_unraisable(self): + # Issue #22836: PyErr_WriteUnraisable() should give sensible reports + class BrokenDel: + def __del__(self): + exc = ValueError("del is broken") + # The following line is included in the traceback report: + raise exc + + class BrokenRepr(BrokenDel): + def __repr__(self): + raise AttributeError("repr() is broken") + + class BrokenExceptionDel: + def __del__(self): + exc = BrokenStrException() + # The following line is included in the traceback report: + raise exc + + for test_class in (BrokenDel, BrokenRepr, BrokenExceptionDel): + with self.subTest(test_class): + obj = test_class() + with captured_stderr() as stderr: + del obj + report = stderr.getvalue() + self.assertIn("Exception ignored", report) + if test_class is BrokenRepr: + self.assertIn("", report) + else: + self.assertIn(test_class.__del__.__qualname__, report) + self.assertIn("test_exceptions.py", report) + self.assertIn("raise exc", report) + if test_class is BrokenExceptionDel: + self.assertIn("BrokenStrException", report) + self.assertIn("", report) + else: + self.assertIn("ValueError", report) + self.assertIn("del is broken", report) + self.assertTrue(report.endswith("\n")) + + def test_unhandled(self): + # Check for sensible reporting of unhandled exceptions + for exc_type in (ValueError, BrokenStrException): + with self.subTest(exc_type): + try: + exc = exc_type("test message") + # The following line is included in the traceback report: + raise exc + except exc_type: + with captured_stderr() as stderr: + sys.__excepthook__(*sys.exc_info()) + report = stderr.getvalue() + self.assertIn("test_exceptions.py", report) + self.assertIn("raise exc", report) + self.assertIn(exc_type.__name__, report) + if exc_type is BrokenStrException: + self.assertIn("", report) + else: + self.assertIn("test message", report) + self.assertTrue(report.endswith("\n")) + class ImportErrorTests(unittest.TestCase): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,11 @@ Core and Builtins ----------------- +- Issue #22836: Ensure exception reports from PyErr_Display() and + PyErr_WriteUnraisable() are sensible even when formatting them produces + secondary errors. This affects the reports produced by + sys.__excepthook__() and when __del__() raises an exception. + - Issue #26302: Correct behavior to reject comma as a legal character for cookie names. diff --git a/Python/errors.c b/Python/errors.c --- a/Python/errors.c +++ b/Python/errors.c @@ -900,8 +900,12 @@ if (obj) { if (PyFile_WriteString("Exception ignored in: ", f) < 0) goto done; - if (PyFile_WriteObject(obj, f, 0) < 0) - goto done; + if (PyFile_WriteObject(obj, f, 0) < 0) { + PyErr_Clear(); + if (PyFile_WriteString("", f) < 0) { + goto done; + } + } if (PyFile_WriteString("\n", f) < 0) goto done; } @@ -946,8 +950,12 @@ if (v && v != Py_None) { if (PyFile_WriteString(": ", f) < 0) goto done; - if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0) - goto done; + if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0) { + PyErr_Clear(); + if (PyFile_WriteString("", f) < 0) { + goto done; + } + } } if (PyFile_WriteString("\n", f) < 0) goto done; diff --git a/Python/pythonrun.c b/Python/pythonrun.c --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -766,8 +766,11 @@ /* only print colon if the str() of the object is not the empty string */ - if (s == NULL) + if (s == NULL) { + PyErr_Clear(); err = -1; + PyFile_WriteString(": ", f); + } else if (!PyUnicode_Check(s) || PyUnicode_GetLength(s) != 0) err = PyFile_WriteString(": ", f); @@ -776,6 +779,9 @@ Py_XDECREF(s); } /* try to write a newline in any case */ + if (err < 0) { + PyErr_Clear(); + } err += PyFile_WriteString("\n", f); Py_XDECREF(tb); Py_DECREF(value); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat Feb 27 22:45:01 2016 From: python-checkins at python.org (martin.panter) Date: Sun, 28 Feb 2016 03:45:01 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzIyODM2?= =?utf-8?q?=3A_Keep_exception_reports_sensible_despite_errors?= Message-ID: <20160228034501.125903.79724@psf.io> https://hg.python.org/cpython/rev/cf70b1204e44 changeset: 100360:cf70b1204e44 branch: 3.5 parent: 100356:ac175a7af60b user: Martin Panter date: Sun Feb 28 03:16:11 2016 +0000 summary: Issue #22836: Keep exception reports sensible despite errors files: Doc/c-api/exceptions.rst | 4 +- Lib/test/test_exceptions.py | 68 ++++++++++++++++++++++++- Misc/NEWS | 5 + Python/errors.c | 16 ++++- Python/pythonrun.c | 8 ++- 5 files changed, 92 insertions(+), 9 deletions(-) diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst --- a/Doc/c-api/exceptions.rst +++ b/Doc/c-api/exceptions.rst @@ -74,8 +74,8 @@ :meth:`__del__` method. The function is called with a single argument *obj* that identifies the context - in which the unraisable exception occurred. The repr of *obj* will be printed in - the warning message. + in which the unraisable exception occurred. If possible, + the repr of *obj* will be printed in the warning message. Raising exceptions diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -7,7 +7,7 @@ import weakref import errno -from test.support import (TESTFN, captured_output, check_impl_detail, +from test.support import (TESTFN, captured_stderr, check_impl_detail, check_warnings, cpython_only, gc_collect, run_unittest, no_tracing, unlink, import_module) @@ -20,6 +20,10 @@ def __init__(self, x): self.x = x +class BrokenStrException(Exception): + def __str__(self): + raise Exception("str() is broken") + # XXX This is not really enough, each *operation* should be tested! class ExceptionTests(unittest.TestCase): @@ -882,7 +886,7 @@ class MyException(Exception, metaclass=Meta): pass - with captured_output("stderr") as stderr: + with captured_stderr() as stderr: try: raise KeyError() except MyException as e: @@ -1011,6 +1015,66 @@ os.listdir(__file__) self.assertEqual(cm.exception.errno, errno.ENOTDIR, cm.exception) + def test_unraisable(self): + # Issue #22836: PyErr_WriteUnraisable() should give sensible reports + class BrokenDel: + def __del__(self): + exc = ValueError("del is broken") + # The following line is included in the traceback report: + raise exc + + class BrokenRepr(BrokenDel): + def __repr__(self): + raise AttributeError("repr() is broken") + + class BrokenExceptionDel: + def __del__(self): + exc = BrokenStrException() + # The following line is included in the traceback report: + raise exc + + for test_class in (BrokenDel, BrokenRepr, BrokenExceptionDel): + with self.subTest(test_class): + obj = test_class() + with captured_stderr() as stderr: + del obj + report = stderr.getvalue() + self.assertIn("Exception ignored", report) + if test_class is BrokenRepr: + self.assertIn("", report) + else: + self.assertIn(test_class.__del__.__qualname__, report) + self.assertIn("test_exceptions.py", report) + self.assertIn("raise exc", report) + if test_class is BrokenExceptionDel: + self.assertIn("BrokenStrException", report) + self.assertIn("", report) + else: + self.assertIn("ValueError", report) + self.assertIn("del is broken", report) + self.assertTrue(report.endswith("\n")) + + def test_unhandled(self): + # Check for sensible reporting of unhandled exceptions + for exc_type in (ValueError, BrokenStrException): + with self.subTest(exc_type): + try: + exc = exc_type("test message") + # The following line is included in the traceback report: + raise exc + except exc_type: + with captured_stderr() as stderr: + sys.__excepthook__(*sys.exc_info()) + report = stderr.getvalue() + self.assertIn("test_exceptions.py", report) + self.assertIn("raise exc", report) + self.assertIn(exc_type.__name__, report) + if exc_type is BrokenStrException: + self.assertIn("", report) + else: + self.assertIn("test message", report) + self.assertTrue(report.endswith("\n")) + class ImportErrorTests(unittest.TestCase): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,11 @@ Core and Builtins ----------------- +- Issue #22836: Ensure exception reports from PyErr_Display() and + PyErr_WriteUnraisable() are sensible even when formatting them produces + secondary errors. This affects the reports produced by + sys.__excepthook__() and when __del__() raises an exception. + - Issue #26302: Correct behavior to reject comma as a legal character for cookie names. diff --git a/Python/errors.c b/Python/errors.c --- a/Python/errors.c +++ b/Python/errors.c @@ -900,8 +900,12 @@ if (obj) { if (PyFile_WriteString("Exception ignored in: ", f) < 0) goto done; - if (PyFile_WriteObject(obj, f, 0) < 0) - goto done; + if (PyFile_WriteObject(obj, f, 0) < 0) { + PyErr_Clear(); + if (PyFile_WriteString("", f) < 0) { + goto done; + } + } if (PyFile_WriteString("\n", f) < 0) goto done; } @@ -946,8 +950,12 @@ if (v && v != Py_None) { if (PyFile_WriteString(": ", f) < 0) goto done; - if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0) - goto done; + if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0) { + PyErr_Clear(); + if (PyFile_WriteString("", f) < 0) { + goto done; + } + } } if (PyFile_WriteString("\n", f) < 0) goto done; diff --git a/Python/pythonrun.c b/Python/pythonrun.c --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -766,8 +766,11 @@ /* only print colon if the str() of the object is not the empty string */ - if (s == NULL) + if (s == NULL) { + PyErr_Clear(); err = -1; + PyFile_WriteString(": ", f); + } else if (!PyUnicode_Check(s) || PyUnicode_GetLength(s) != 0) err = PyFile_WriteString(": ", f); @@ -776,6 +779,9 @@ Py_XDECREF(s); } /* try to write a newline in any case */ + if (err < 0) { + PyErr_Clear(); + } err += PyFile_WriteString("\n", f); Py_XDECREF(tb); Py_DECREF(value); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Feb 28 02:35:01 2016 From: python-checkins at python.org (raymond.hettinger) Date: Sun, 28 Feb 2016 07:35:01 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgMTM1NzM6?= =?utf-8?q?_Document_that_csv=2Ewriter_uses_str=28=29_for_floats_instead_o?= =?utf-8?b?ZiByZXByKCku?= Message-ID: <20160228073501.6211.51788@psf.io> https://hg.python.org/cpython/rev/d3ac0214b7b8 changeset: 100362:d3ac0214b7b8 branch: 2.7 parent: 100359:fca9f02e10e5 user: Raymond Hettinger date: Sat Feb 27 23:34:54 2016 -0800 summary: Issue 13573: Document that csv.writer uses str() for floats instead of repr(). files: Doc/library/csv.rst | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/Doc/library/csv.rst b/Doc/library/csv.rst --- a/Doc/library/csv.rst +++ b/Doc/library/csv.rst @@ -112,6 +112,7 @@ value :const:`None` is written as the empty string. While this isn't a reversible transformation, it makes it easier to dump SQL NULL data values to CSV files without preprocessing the data returned from a ``cursor.fetch*`` call. + Floats are stringified with :func:`repr` before being written. All other non-string data are stringified with :func:`str` before being written. A short usage example:: -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Sun Feb 28 04:44:46 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Sun, 28 Feb 2016 09:44:46 +0000 Subject: [Python-checkins] Daily reference leaks (2b597e03f7f4): sum=4 Message-ID: <20160228094442.115629.51121@psf.io> results for 2b597e03f7f4 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogObxp2y', '--timeout', '7200'] From python-checkins at python.org Sun Feb 28 15:09:59 2016 From: python-checkins at python.org (georg.brandl) Date: Sun, 28 Feb 2016 20:09:59 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogRml4IHR5cG8u?= Message-ID: <20160228200958.76436.28185@psf.io> https://hg.python.org/cpython/rev/ce714476ee21 changeset: 100363:ce714476ee21 branch: 3.5 parent: 100360:cf70b1204e44 user: Georg Brandl date: Sun Feb 28 21:09:36 2016 +0100 summary: Fix typo. files: Doc/howto/argparse.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/howto/argparse.rst b/Doc/howto/argparse.rst --- a/Doc/howto/argparse.rst +++ b/Doc/howto/argparse.rst @@ -511,7 +511,7 @@ * Sadly, our help output isn't very informative on the new ability our script has acquired, but that can always be fixed by improving the documentation for - out script (e.g. via the ``help`` keyword argument). + our script (e.g. via the ``help`` keyword argument). * That last output exposes a bug in our program. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Feb 28 15:09:58 2016 From: python-checkins at python.org (georg.brandl) Date: Sun, 28 Feb 2016 20:09:58 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogRml4IHR5cG8u?= Message-ID: <20160228200958.14762.5574@psf.io> https://hg.python.org/cpython/rev/408891646a37 changeset: 100365:408891646a37 branch: 2.7 parent: 100362:d3ac0214b7b8 user: Georg Brandl date: Sun Feb 28 21:09:36 2016 +0100 summary: Fix typo. files: Doc/howto/argparse.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/howto/argparse.rst b/Doc/howto/argparse.rst --- a/Doc/howto/argparse.rst +++ b/Doc/howto/argparse.rst @@ -513,7 +513,7 @@ * Sadly, our help output isn't very informative on the new ability our script has acquired, but that can always be fixed by improving the documentation for - out script (e.g. via the ``help`` keyword argument). + our script (e.g. via the ``help`` keyword argument). * That last output exposes a bug in our program. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Feb 28 15:09:59 2016 From: python-checkins at python.org (georg.brandl) Date: Sun, 28 Feb 2016 20:09:59 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_merge_with_3=2E5?= Message-ID: <20160228200958.125903.21942@psf.io> https://hg.python.org/cpython/rev/6ee2e1bacf2d changeset: 100364:6ee2e1bacf2d parent: 100361:2b597e03f7f4 parent: 100363:ce714476ee21 user: Georg Brandl date: Sun Feb 28 21:09:45 2016 +0100 summary: merge with 3.5 files: Doc/howto/argparse.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/howto/argparse.rst b/Doc/howto/argparse.rst --- a/Doc/howto/argparse.rst +++ b/Doc/howto/argparse.rst @@ -511,7 +511,7 @@ * Sadly, our help output isn't very informative on the new ability our script has acquired, but that can always be fixed by improving the documentation for - out script (e.g. via the ``help`` keyword argument). + our script (e.g. via the ``help`` keyword argument). * That last output exposes a bug in our program. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Feb 28 15:13:49 2016 From: python-checkins at python.org (georg.brandl) Date: Sun, 28 Feb 2016 20:13:49 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_merge_with_3=2E5?= Message-ID: <20160228201349.26003.2332@psf.io> https://hg.python.org/cpython/rev/83814cdca928 changeset: 100367:83814cdca928 parent: 100364:6ee2e1bacf2d parent: 100366:8f8e86ea3abb user: Georg Brandl date: Sun Feb 28 21:13:44 2016 +0100 summary: merge with 3.5 files: Doc/tools/susp-ignored.csv | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/tools/susp-ignored.csv b/Doc/tools/susp-ignored.csv --- a/Doc/tools/susp-ignored.csv +++ b/Doc/tools/susp-ignored.csv @@ -237,7 +237,7 @@ using/cmdline,,:line,file:line: category: message using/cmdline,,:message,action:message:category:module:line using/cmdline,,:module,action:message:category:module:line -using/unix,,:Packaging,http://en.opensuse.org/Portal:Packaging +using/unix,,:Packaging,https://en.opensuse.org/Portal:Packaging whatsnew/2.0,418,:len, whatsnew/2.3,,::, whatsnew/2.3,,:config, -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun Feb 28 15:13:50 2016 From: python-checkins at python.org (georg.brandl) Date: Sun, 28 Feb 2016 20:13:50 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Update_susp-ig?= =?utf-8?q?nore_file_=28=2325910=29=2E?= Message-ID: <20160228201349.76454.34778@psf.io> https://hg.python.org/cpython/rev/8f8e86ea3abb changeset: 100366:8f8e86ea3abb branch: 3.5 parent: 100363:ce714476ee21 user: Georg Brandl date: Sun Feb 28 21:13:23 2016 +0100 summary: Update susp-ignore file (#25910). files: Doc/tools/susp-ignored.csv | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/tools/susp-ignored.csv b/Doc/tools/susp-ignored.csv --- a/Doc/tools/susp-ignored.csv +++ b/Doc/tools/susp-ignored.csv @@ -237,7 +237,7 @@ using/cmdline,,:line,file:line: category: message using/cmdline,,:message,action:message:category:module:line using/cmdline,,:module,action:message:category:module:line -using/unix,,:Packaging,http://en.opensuse.org/Portal:Packaging +using/unix,,:Packaging,https://en.opensuse.org/Portal:Packaging whatsnew/2.0,418,:len, whatsnew/2.3,,::, whatsnew/2.3,,:config, -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Mon Feb 29 04:45:04 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Mon, 29 Feb 2016 09:45:04 +0000 Subject: [Python-checkins] Daily reference leaks (83814cdca928): sum=4 Message-ID: <20160229094458.47187.24696@psf.io> results for 83814cdca928 on branch "default" -------------------------------------------- test_functools leaked [0, 2, 2] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/refloguBCP2e', '--timeout', '7200'] From python-checkins at python.org Mon Feb 29 06:28:34 2016 From: python-checkins at python.org (martin.panter) Date: Mon, 29 Feb 2016 11:28:34 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI2Mzg1?= =?utf-8?q?=3A_Cleanup_NamedTemporaryFile_if_fdopen=28=29_fails=2C_by_Sile?= =?utf-8?q?ntGhost?= Message-ID: <20160229112834.14790.15517@psf.io> https://hg.python.org/cpython/rev/5bfb4147405e changeset: 100368:5bfb4147405e branch: 2.7 parent: 100365:408891646a37 user: Martin Panter date: Mon Feb 29 00:31:38 2016 +0000 summary: Issue #26385: Cleanup NamedTemporaryFile if fdopen() fails, by SilentGhost files: Lib/tempfile.py | 3 ++- Lib/test/test_tempfile.py | 7 +++++++ Misc/NEWS | 3 +++ 3 files changed, 12 insertions(+), 1 deletions(-) diff --git a/Lib/tempfile.py b/Lib/tempfile.py --- a/Lib/tempfile.py +++ b/Lib/tempfile.py @@ -476,7 +476,8 @@ try: file = _os.fdopen(fd, mode, bufsize) return _TemporaryFileWrapper(file, name, delete) - except: + except BaseException: + _os.unlink(name) _os.close(fd) raise diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py --- a/Lib/test/test_tempfile.py +++ b/Lib/test/test_tempfile.py @@ -827,6 +827,13 @@ os.close = old_close os.fdopen = old_fdopen + def test_bad_mode(self): + dir = tempfile.mkdtemp() + self.addCleanup(support.rmtree, dir) + with self.assertRaises(TypeError): + tempfile.NamedTemporaryFile(mode=(), dir=dir) + self.assertEqual(os.listdir(dir), []) + # How to test the mode and bufsize parameters? test_classes.append(test_NamedTemporaryFile) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -55,6 +55,9 @@ Library ------- +- Issue #26385: Remove the file if the internal fdopen() call in + NamedTemporaryFile() fails. Based on patch by Silent Ghost. + - Issue #26309: In the "socketserver" module, shut down the request (closing the connected socket) when verify_request() returns false. Based on patch by Aviv Palivoda. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 29 06:28:35 2016 From: python-checkins at python.org (martin.panter) Date: Mon, 29 Feb 2016 11:28:35 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326385=3A_Merge_NamedTemporaryFile_fix_from_3=2E?= =?utf-8?q?5?= Message-ID: <20160229112835.14772.51168@psf.io> https://hg.python.org/cpython/rev/865cf8eba51a changeset: 100370:865cf8eba51a parent: 100367:83814cdca928 parent: 100369:a1c125f21db4 user: Martin Panter date: Mon Feb 29 11:25:09 2016 +0000 summary: Issue #26385: Merge NamedTemporaryFile fix from 3.5 files: Lib/tempfile.py | 3 ++- Lib/test/test_tempfile.py | 10 +++++++++- Misc/NEWS | 3 +++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Lib/tempfile.py b/Lib/tempfile.py --- a/Lib/tempfile.py +++ b/Lib/tempfile.py @@ -552,7 +552,8 @@ newline=newline, encoding=encoding) return _TemporaryFileWrapper(file, name, delete) - except Exception: + except BaseException: + _os.unlink(name) _os.close(fd) raise diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py --- a/Lib/test/test_tempfile.py +++ b/Lib/test/test_tempfile.py @@ -948,9 +948,17 @@ self.assertRaises(ValueError, tempfile.NamedTemporaryFile) self.assertEqual(len(closed), 1) + def test_bad_mode(self): + dir = tempfile.mkdtemp() + self.addCleanup(support.rmtree, dir) + with self.assertRaises(ValueError): + tempfile.NamedTemporaryFile(mode='wr', dir=dir) + with self.assertRaises(TypeError): + tempfile.NamedTemporaryFile(mode=2, dir=dir) + self.assertEqual(os.listdir(dir), []) + # How to test the mode and bufsize parameters? - class TestSpooledTemporaryFile(BaseTestCase): """Test SpooledTemporaryFile().""" diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -194,6 +194,9 @@ Library ------- +- Issue #26385: Remove the file if the internal open() call in + NamedTemporaryFile() fails. Patch by Silent Ghost. + - Issue #26402: Fix XML-RPC client to retry when the server shuts down a persistent connection. This was a regression related to the new http.client.RemoteDisconnected exception in 3.5.0a4. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 29 06:28:35 2016 From: python-checkins at python.org (martin.panter) Date: Mon, 29 Feb 2016 11:28:35 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2Mzg1?= =?utf-8?q?=3A_Cleanup_NamedTemporaryFile_if_open=28=29_fails=2C_by_Silent?= =?utf-8?q?Ghost?= Message-ID: <20160229112834.47165.38802@psf.io> https://hg.python.org/cpython/rev/a1c125f21db4 changeset: 100369:a1c125f21db4 branch: 3.5 parent: 100366:8f8e86ea3abb user: Martin Panter date: Sun Feb 28 05:22:20 2016 +0000 summary: Issue #26385: Cleanup NamedTemporaryFile if open() fails, by SilentGhost files: Lib/tempfile.py | 3 ++- Lib/test/test_tempfile.py | 10 +++++++++- Misc/NEWS | 3 +++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Lib/tempfile.py b/Lib/tempfile.py --- a/Lib/tempfile.py +++ b/Lib/tempfile.py @@ -552,7 +552,8 @@ newline=newline, encoding=encoding) return _TemporaryFileWrapper(file, name, delete) - except Exception: + except BaseException: + _os.unlink(name) _os.close(fd) raise diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py --- a/Lib/test/test_tempfile.py +++ b/Lib/test/test_tempfile.py @@ -948,9 +948,17 @@ self.assertRaises(ValueError, tempfile.NamedTemporaryFile) self.assertEqual(len(closed), 1) + def test_bad_mode(self): + dir = tempfile.mkdtemp() + self.addCleanup(support.rmtree, dir) + with self.assertRaises(ValueError): + tempfile.NamedTemporaryFile(mode='wr', dir=dir) + with self.assertRaises(TypeError): + tempfile.NamedTemporaryFile(mode=2, dir=dir) + self.assertEqual(os.listdir(dir), []) + # How to test the mode and bufsize parameters? - class TestSpooledTemporaryFile(BaseTestCase): """Test SpooledTemporaryFile().""" diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -84,6 +84,9 @@ Library ------- +- Issue #26385: Remove the file if the internal open() call in + NamedTemporaryFile() fails. Patch by Silent Ghost. + - Issue #26402: Fix XML-RPC client to retry when the server shuts down a persistent connection. This was a regression related to the new http.client.RemoteDisconnected exception in 3.5.0a4. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon Feb 29 09:53:06 2016 From: python-checkins at python.org (victor.stinner) Date: Mon, 29 Feb 2016 14:53:06 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_PEP_511=3A_link_python-ideas_?= =?utf-8?q?discussion?= Message-ID: <20160229145253.125913.32567@psf.io> https://hg.python.org/peps/rev/0c6dfd81f08c changeset: 6247:0c6dfd81f08c user: Victor Stinner date: Mon Feb 29 15:52:38 2016 +0100 summary: PEP 511: link python-ideas discussion files: pep-0511.txt | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/pep-0511.txt b/pep-0511.txt --- a/pep-0511.txt +++ b/pep-0511.txt @@ -541,6 +541,9 @@ Discussion ========== +* `[Python-ideas] PEP 511: API for code transformers + `_ + (January 2016) * `[Python-Dev] AST optimizer implemented in Python `_ (August 2012) -- Repository URL: https://hg.python.org/peps From lp_benchmark_robot at intel.com Mon Feb 29 13:30:05 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Mon, 29 Feb 2016 18:30:05 +0000 Subject: [Python-checkins] BAD Benchmark Results for Python Default 2016-02-29 Message-ID: <50fbda50-362b-459f-b57b-7fe3eb722e23@irsmsx153.ger.corp.intel.com> Results for project Python default, build date 2016-02-29 03:08:49 +0000 commit: 83814cdca928 previous commit: ed30eac90f60 revision date: 2016-02-28 20:13:44 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v3.4.3, with hash b4cbecbc0781 from 2015-02-25 12:15:33+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.30% -2.38% 8.43% 13.60% :-| pybench 0.16% 0.26% 0.52% 5.88% :-( regex_v8 3.06% -0.78% -5.37% 5.20% :-| nbody 0.08% -0.20% -1.74% 10.47% :-| json_dump_v2 0.26% -1.34% -1.58% 11.44% :-| normal_startup 0.81% -0.40% 1.71% 5.46% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/bad-benchmark-results-for-python-default-2016-02-29/ Note: Benchmark results are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From lp_benchmark_robot at intel.com Mon Feb 29 13:32:00 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Mon, 29 Feb 2016 18:32:00 +0000 Subject: [Python-checkins] GOOD Benchmark Results for Python 2.7 2016-02-29 Message-ID: <62468ecc-d993-4776-9453-a50fe0ff7de0@irsmsx153.ger.corp.intel.com> Results for project Python 2.7, build date 2016-02-29 04:00:17 +0000 commit: 408891646a37 previous commit: 157eb9d40bf9 revision date: 2016-02-28 20:09:36 +0000 environment: Haswell-EP cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB mem: 128 GB os: CentOS 7.1 kernel: Linux 3.10.0-229.4.2.el7.x86_64 Baseline results were generated using release v2.7.10, with hash 15c95b7d81dc from 2015-05-23 16:02:14+00:00 ---------------------------------------------------------------------------------- benchmark relative change since change since current rev run std_dev* last run baseline with PGO ---------------------------------------------------------------------------------- :-) django_v2 0.14% -0.87% 4.73% 6.03% :-) pybench 0.10% 0.06% 6.38% 2.91% :-( regex_v8 0.77% 0.13% -2.68% 10.72% :-) nbody 0.11% 1.08% 8.65% -0.24% :-) json_dump_v2 0.20% -0.04% 4.78% 11.42% :-( normal_startup 1.80% -0.08% -5.63% 1.79% :-) ssbench 0.18% 0.43% 2.31% 1.58% ---------------------------------------------------------------------------------- * Relative Standard Deviation (Standard Deviation/Average) If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/good-benchmark-results-for-python-2-7-2016-02-29/ Note: Benchmark results for ssbench are measured in requests/second while all other are measured in seconds. Subject Label Legend: Attributes are determined based on the performance evolution of the workloads compared to the previous measurement iteration. NEUTRAL: performance did not change by more than 1% for any workload GOOD: performance improved by more than 1% for at least one workload and there is no regression greater than 1% BAD: performance dropped by more than 1% for at least one workload and there is no improvement greater than 1% UGLY: performance improved by more than 1% for at least one workload and also dropped by more than 1% for at least one workload Our lab does a nightly source pull and build of the Python project and measures performance changes against the previous stable version and the previous nightly measurement. This is provided as a service to the community so that quality issues with current hardware can be identified quickly. Intel technologies' features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. From david.c.stewart at intel.com Mon Feb 29 18:45:37 2016 From: david.c.stewart at intel.com (Stewart, David C) Date: Mon, 29 Feb 2016 23:45:37 +0000 Subject: [Python-checkins] BAD Benchmark Results for Python Default 2016-02-29 In-Reply-To: <50fbda50-362b-459f-b57b-7fe3eb722e23@irsmsx153.ger.corp.intel.com> References: <50fbda50-362b-459f-b57b-7fe3eb722e23@irsmsx153.ger.corp.intel.com> Message-ID: Does anybody know why django declined so much? On 2/29/16, 10:30 AM, "lp_benchmark_robot" wrote: >Results for project Python default, build date 2016-02-29 03:08:49 +0000 >commit: 83814cdca928 >previous commit: ed30eac90f60 >revision date: 2016-02-28 20:13:44 +0000 >environment: Haswell-EP > cpu: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz 2x18 cores, stepping 2, LLC 45 MB > mem: 128 GB > os: CentOS 7.1 > kernel: Linux 3.10.0-229.4.2.el7.x86_64 > >Baseline results were generated using release v3.4.3, with hash b4cbecbc0781 >from 2015-02-25 12:15:33+00:00 > >---------------------------------------------------------------------------------- > benchmark relative change since change since current rev run > std_dev* last run baseline with PGO >---------------------------------------------------------------------------------- >:-) django_v2 0.30% -2.38% 8.43% 13.60% >:-| pybench 0.16% 0.26% 0.52% 5.88% >:-( regex_v8 3.06% -0.78% -5.37% 5.20% >:-| nbody 0.08% -0.20% -1.74% 10.47% >:-| json_dump_v2 0.26% -1.34% -1.58% 11.44% >:-| normal_startup 0.81% -0.40% 1.71% 5.46% >---------------------------------------------------------------------------------- >* Relative Standard Deviation (Standard Deviation/Average) > >If this is not displayed properly please visit our results page here: http://languagesperformance.intel.com/bad-benchmark-results-for-python-default-2016-02-29/ > >Note: Benchmark results are measured in seconds. > >Subject Label Legend: >Attributes are determined based on the performance evolution of the workloads >compared to the previous measurement iteration. >NEUTRAL: performance did not change by more than 1% for any workload >GOOD: performance improved by more than 1% for at least one workload and there >is no regression greater than 1% >BAD: performance dropped by more than 1% for at least one workload and there is >no improvement greater than 1% >UGLY: performance improved by more than 1% for at least one workload and also >dropped by more than 1% for at least one workload > > >Our lab does a nightly source pull and build of the Python project and measures >performance changes against the previous stable version and the previous nightly >measurement. This is provided as a service to the community so that quality >issues with current hardware can be identified quickly. > >Intel technologies' features and benefits depend on system configuration and may >require enabled hardware, software or service activation. Performance varies >depending on system configuration.