From python-checkins at python.org Sun May 1 02:07:01 2016 From: python-checkins at python.org (berker.peksag) Date: Sun, 01 May 2016 06:07:01 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2323960=3A_Cleanup_args_and_kwargs_on_error_in_Py?= =?utf-8?q?Err=5FSetImportError?= Message-ID: <20160501060701.14942.13385.C25A3AB7@psf.io> https://hg.python.org/cpython/rev/94471357db08 changeset: 101196:94471357db08 parent: 101194:5b5fbce1db9c parent: 101195:5871b48f4c2e user: Berker Peksag date: Sun May 01 09:06:57 2016 +0300 summary: Issue #23960: Cleanup args and kwargs on error in PyErr_SetImportError Patch by Ofer Schwarz. files: Python/errors.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Python/errors.c b/Python/errors.c --- a/Python/errors.c +++ b/Python/errors.c @@ -727,9 +727,9 @@ PyTuple_SET_ITEM(args, 0, msg); if (PyDict_SetItemString(kwargs, "name", name) < 0) - return NULL; + goto done; if (PyDict_SetItemString(kwargs, "path", path) < 0) - return NULL; + goto done; error = PyObject_Call(PyExc_ImportError, args, kwargs); if (error != NULL) { @@ -737,9 +737,9 @@ Py_DECREF(error); } +done: Py_DECREF(args); Py_DECREF(kwargs); - return NULL; } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 1 02:07:04 2016 From: python-checkins at python.org (berker.peksag) Date: Sun, 01 May 2016 06:07:04 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzIzOTYw?= =?utf-8?q?=3A_Cleanup_args_and_kwargs_on_error_in_PyErr=5FSetImportError?= Message-ID: <20160501060701.21691.83082.F47DB1AB@psf.io> https://hg.python.org/cpython/rev/5871b48f4c2e changeset: 101195:5871b48f4c2e branch: 3.5 parent: 101193:db5baad7ad69 user: Berker Peksag date: Sun May 01 09:06:36 2016 +0300 summary: Issue #23960: Cleanup args and kwargs on error in PyErr_SetImportError Patch by Ofer Schwarz. files: Python/errors.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Python/errors.c b/Python/errors.c --- a/Python/errors.c +++ b/Python/errors.c @@ -727,9 +727,9 @@ PyTuple_SET_ITEM(args, 0, msg); if (PyDict_SetItemString(kwargs, "name", name) < 0) - return NULL; + goto done; if (PyDict_SetItemString(kwargs, "path", path) < 0) - return NULL; + goto done; error = PyObject_Call(PyExc_ImportError, args, kwargs); if (error != NULL) { @@ -737,9 +737,9 @@ Py_DECREF(error); } +done: Py_DECREF(args); Py_DECREF(kwargs); - return NULL; } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 1 04:28:40 2016 From: python-checkins at python.org (berker.peksag) Date: Sun, 01 May 2016 08:28:40 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326898=3A_Fix_typo_in_math=2Eisclose=28=29_docst?= =?utf-8?q?ring?= Message-ID: <20160501082840.1506.37715.86254514@psf.io> https://hg.python.org/cpython/rev/634764b4675c changeset: 101198:634764b4675c parent: 101196:94471357db08 parent: 101197:469bc90e8922 user: Berker Peksag date: Sun May 01 11:27:59 2016 +0300 summary: Issue #26898: Fix typo in math.isclose() docstring Patch by Marco Buttu. files: Modules/mathmodule.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -2046,7 +2046,7 @@ } PyDoc_STRVAR(math_isclose_doc, -"is_close(a, b, *, rel_tol=1e-09, abs_tol=0.0) -> bool\n" +"isclose(a, b, *, rel_tol=1e-09, abs_tol=0.0) -> bool\n" "\n" "Determine whether two floating point numbers are close in value.\n" "\n" -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 1 04:28:41 2016 From: python-checkins at python.org (berker.peksag) Date: Sun, 01 May 2016 08:28:41 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2ODk4?= =?utf-8?q?=3A_Fix_typo_in_math=2Eisclose=28=29_docstring?= Message-ID: <20160501082840.39170.58519.9779D29D@psf.io> https://hg.python.org/cpython/rev/469bc90e8922 changeset: 101197:469bc90e8922 branch: 3.5 parent: 101195:5871b48f4c2e user: Berker Peksag date: Sun May 01 11:27:37 2016 +0300 summary: Issue #26898: Fix typo in math.isclose() docstring Patch by Marco Buttu. files: Modules/mathmodule.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -2046,7 +2046,7 @@ } PyDoc_STRVAR(math_isclose_doc, -"is_close(a, b, *, rel_tol=1e-09, abs_tol=0.0) -> bool\n" +"isclose(a, b, *, rel_tol=1e-09, abs_tol=0.0) -> bool\n" "\n" "Determine whether two floating point numbers are close in value.\n" "\n" -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Sun May 1 04:52:34 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Sun, 01 May 2016 08:52:34 +0000 Subject: [Python-checkins] Daily reference leaks (5b5fbce1db9c): sum=11 Message-ID: <20160501085233.39162.80946.D2513FC8@psf.io> results for 5b5fbce1db9c on branch "default" -------------------------------------------- test_asyncio leaked [0, 3, 0] memory blocks, sum=3 test_collections leaked [4, -4, 0] memory blocks, sum=0 test_functools leaked [0, 3, 1] memory blocks, sum=4 test_multiprocessing_forkserver leaked [3, 0, 1] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflog5AqhRW', '--timeout', '7200'] From python-checkins at python.org Sun May 1 06:07:33 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 01 May 2016 10:07:33 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Fixed_declarations_of_=5FPy=5FDumpTraceback=28=29_and_?= =?utf-8?b?X1B5X0R1bXBUcmFjZWJhY2tUaHJlYWRzKCku?= Message-ID: <20160501100733.1536.7618.AC5068A4@psf.io> https://hg.python.org/cpython/rev/5b2edc905db4 changeset: 101200:5b2edc905db4 parent: 101198:634764b4675c parent: 101199:4f5e4155c259 user: Serhiy Storchaka date: Sun May 01 13:07:14 2016 +0300 summary: Fixed declarations of _Py_DumpTraceback() and _Py_DumpTracebackThreads(). files: Include/traceback.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Include/traceback.h b/Include/traceback.h --- a/Include/traceback.h +++ b/Include/traceback.h @@ -48,7 +48,7 @@ This function is signal safe. */ -PyAPI_DATA(void) _Py_DumpTraceback( +PyAPI_FUNC(void) _Py_DumpTraceback( int fd, PyThreadState *tstate); @@ -75,7 +75,7 @@ This function is signal safe. */ -PyAPI_DATA(const char*) _Py_DumpTracebackThreads( +PyAPI_FUNC(const char*) _Py_DumpTracebackThreads( int fd, PyInterpreterState *interp, PyThreadState *current_tstate); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 1 06:07:34 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 01 May 2016 10:07:34 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Fixed_declarat?= =?utf-8?q?ions_of_=5FPy=5FDumpTraceback=28=29_and_=5FPy=5FDumpTracebackTh?= =?utf-8?b?cmVhZHMoKS4=?= Message-ID: <20160501100733.84492.49195.05A1DC16@psf.io> https://hg.python.org/cpython/rev/4f5e4155c259 changeset: 101199:4f5e4155c259 branch: 3.5 parent: 101197:469bc90e8922 user: Serhiy Storchaka date: Sun May 01 13:06:43 2016 +0300 summary: Fixed declarations of _Py_DumpTraceback() and _Py_DumpTracebackThreads(). files: Include/traceback.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Include/traceback.h b/Include/traceback.h --- a/Include/traceback.h +++ b/Include/traceback.h @@ -48,7 +48,7 @@ This function is signal safe. */ -PyAPI_DATA(void) _Py_DumpTraceback( +PyAPI_FUNC(void) _Py_DumpTraceback( int fd, PyThreadState *tstate); @@ -62,7 +62,7 @@ This function is signal safe. */ -PyAPI_DATA(const char*) _Py_DumpTracebackThreads( +PyAPI_FUNC(const char*) _Py_DumpTracebackThreads( int fd, PyInterpreterState *interp, PyThreadState *current_thread); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 1 06:37:07 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 01 May 2016 10:37:07 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326711=3A_Fixed_the_comparison_of_plistlib=2EDat?= =?utf-8?q?a_with_other_types=2E?= Message-ID: <20160501103706.21671.69089.BBF20239@psf.io> https://hg.python.org/cpython/rev/dbdd5bc4df99 changeset: 101202:dbdd5bc4df99 parent: 101200:5b2edc905db4 parent: 101201:41afb83cffac user: Serhiy Storchaka date: Sun May 01 13:36:42 2016 +0300 summary: Issue #26711: Fixed the comparison of plistlib.Data with other types. files: Lib/plistlib.py | 4 ++-- Lib/test/test_plistlib.py | 6 +++--- Misc/NEWS | 2 ++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Lib/plistlib.py b/Lib/plistlib.py --- a/Lib/plistlib.py +++ b/Lib/plistlib.py @@ -225,10 +225,10 @@ def __eq__(self, other): if isinstance(other, self.__class__): return self.data == other.data - elif isinstance(other, str): + elif isinstance(other, bytes): return self.data == other else: - return id(self) == id(other) + return NotImplemented def __repr__(self): return "%s(%s)" % (self.__class__.__name__, repr(self.data)) diff --git a/Lib/test/test_plistlib.py b/Lib/test/test_plistlib.py --- a/Lib/test/test_plistlib.py +++ b/Lib/test/test_plistlib.py @@ -514,15 +514,15 @@ cur = plistlib.loads(buf) self.assertEqual(cur, out_data) - self.assertNotEqual(cur, in_data) + self.assertEqual(cur, in_data) cur = plistlib.loads(buf, use_builtin_types=False) - self.assertNotEqual(cur, out_data) + self.assertEqual(cur, out_data) self.assertEqual(cur, in_data) with self.assertWarns(DeprecationWarning): cur = plistlib.readPlistFromBytes(buf) - self.assertNotEqual(cur, out_data) + self.assertEqual(cur, out_data) self.assertEqual(cur, in_data) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -256,6 +256,8 @@ Library ------- +- Issue #26711: Fixed the comparison of plistlib.Data with other types. + - Issue #24114: Fix an uninitialized variable in `ctypes.util`. The bug only occurs on SunOS when the ctypes implementation searches -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 1 06:37:07 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 01 May 2016 10:37:07 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2NzEx?= =?utf-8?q?=3A_Fixed_the_comparison_of_plistlib=2EData_with_other_types=2E?= Message-ID: <20160501103706.84508.83350.4D3EECCF@psf.io> https://hg.python.org/cpython/rev/41afb83cffac changeset: 101201:41afb83cffac branch: 3.5 parent: 101199:4f5e4155c259 user: Serhiy Storchaka date: Sun May 01 13:36:16 2016 +0300 summary: Issue #26711: Fixed the comparison of plistlib.Data with other types. files: Lib/plistlib.py | 4 ++-- Lib/test/test_plistlib.py | 6 +++--- Misc/NEWS | 2 ++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Lib/plistlib.py b/Lib/plistlib.py --- a/Lib/plistlib.py +++ b/Lib/plistlib.py @@ -225,10 +225,10 @@ def __eq__(self, other): if isinstance(other, self.__class__): return self.data == other.data - elif isinstance(other, str): + elif isinstance(other, bytes): return self.data == other else: - return id(self) == id(other) + return NotImplemented def __repr__(self): return "%s(%s)" % (self.__class__.__name__, repr(self.data)) diff --git a/Lib/test/test_plistlib.py b/Lib/test/test_plistlib.py --- a/Lib/test/test_plistlib.py +++ b/Lib/test/test_plistlib.py @@ -515,15 +515,15 @@ cur = plistlib.loads(buf) self.assertEqual(cur, out_data) - self.assertNotEqual(cur, in_data) + self.assertEqual(cur, in_data) cur = plistlib.loads(buf, use_builtin_types=False) - self.assertNotEqual(cur, out_data) + self.assertEqual(cur, out_data) self.assertEqual(cur, in_data) with self.assertWarns(DeprecationWarning): cur = plistlib.readPlistFromBytes(buf) - self.assertNotEqual(cur, out_data) + self.assertEqual(cur, out_data) self.assertEqual(cur, in_data) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -107,6 +107,8 @@ Library ------- +- Issue #26711: Fixed the comparison of plistlib.Data with other types. + - Issue #24114: Fix an uninitialized variable in `ctypes.util`. The bug only occurs on SunOS when the ctypes implementation searches -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 1 13:04:55 2016 From: python-checkins at python.org (ethan.furman) Date: Sun, 01 May 2016 17:04:55 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogaXNzdWUyNjg5Mzog?= =?utf-8?q?use_mro=28=29_to_examine_class_heirarchy?= Message-ID: <20160501170455.12168.30034.EAE16D02@psf.io> https://hg.python.org/cpython/rev/1b6581bae5a1 changeset: 101203:1b6581bae5a1 branch: 3.5 parent: 101201:41afb83cffac user: Ethan Furman date: Sun May 01 10:03:53 2016 -0700 summary: issue26893: use mro() to examine class heirarchy files: Lib/enum.py | 2 +- Lib/test/test_enum.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletions(-) diff --git a/Lib/enum.py b/Lib/enum.py --- a/Lib/enum.py +++ b/Lib/enum.py @@ -118,7 +118,7 @@ # save attributes from super classes so we know if we can take # the shortcut of storing members in the class dict - base_attributes = {a for b in bases for a in b.__dict__} + base_attributes = {a for b in enum_class.mro() for a in b.__dict__} # Reverse value->name map for hashable values. enum_class._value2member_map_ = {} diff --git a/Lib/test/test_enum.py b/Lib/test/test_enum.py --- a/Lib/test/test_enum.py +++ b/Lib/test/test_enum.py @@ -1568,6 +1568,19 @@ triple = 3 turkey = 3 + def test_unique_with_name(self): + @unique + class Silly(Enum): + one = 1 + two = 'dos' + name = 3 + @unique + class Sillier(IntEnum): + single = 1 + name = 2 + triple = 3 + value = 4 + expected_help_output_with_docs = """\ Help on class Color in module %s: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 1 13:05:00 2016 From: python-checkins at python.org (ethan.furman) Date: Sun, 01 May 2016 17:05:00 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_issue26893=3A_use_mro=28=29_to_examine_class_heirarchy?= Message-ID: <20160501170500.7003.43857.B7273176@psf.io> https://hg.python.org/cpython/rev/7188de6b50ab changeset: 101204:7188de6b50ab parent: 101202:dbdd5bc4df99 parent: 101203:1b6581bae5a1 user: Ethan Furman date: Sun May 01 10:04:21 2016 -0700 summary: issue26893: use mro() to examine class heirarchy files: Lib/enum.py | 2 +- Lib/test/test_enum.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletions(-) diff --git a/Lib/enum.py b/Lib/enum.py --- a/Lib/enum.py +++ b/Lib/enum.py @@ -124,7 +124,7 @@ # save attributes from super classes so we know if we can take # the shortcut of storing members in the class dict - base_attributes = {a for b in bases for a in b.__dict__} + base_attributes = {a for b in enum_class.mro() for a in b.__dict__} # Reverse value->name map for hashable values. enum_class._value2member_map_ = {} diff --git a/Lib/test/test_enum.py b/Lib/test/test_enum.py --- a/Lib/test/test_enum.py +++ b/Lib/test/test_enum.py @@ -1591,6 +1591,19 @@ triple = 3 turkey = 3 + def test_unique_with_name(self): + @unique + class Silly(Enum): + one = 1 + two = 'dos' + name = 3 + @unique + class Sillier(IntEnum): + single = 1 + name = 2 + triple = 3 + value = 4 + expected_help_output_with_docs = """\ Help on class Color in module %s: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 1 13:34:26 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 01 May 2016 17:34:26 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Regenerate_Argument_Clinic_code_for_issue_=2326874=2E?= Message-ID: <20160501173423.21663.14552.0F6905BD@psf.io> https://hg.python.org/cpython/rev/98678738b7e9 changeset: 101206:98678738b7e9 parent: 101204:7188de6b50ab parent: 101205:84ff79cce41e user: Serhiy Storchaka date: Sun May 01 20:34:00 2016 +0300 summary: Regenerate Argument Clinic code for issue #26874. files: Python/bltinmodule.c | 2 +- Python/clinic/bltinmodule.c.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -801,7 +801,7 @@ static PyObject * builtin_divmod_impl(PyModuleDef *module, PyObject *x, PyObject *y) -/*[clinic end generated code: output=9ad0076120ebf9ac input=7fdb15f8a97a5fe7]*/ +/*[clinic end generated code: output=9ad0076120ebf9ac input=175ad9c84ff41a85]*/ { return PyNumber_Divmod(x, y); } diff --git a/Python/clinic/bltinmodule.c.h b/Python/clinic/bltinmodule.c.h --- a/Python/clinic/bltinmodule.c.h +++ b/Python/clinic/bltinmodule.c.h @@ -179,7 +179,7 @@ "divmod($module, x, y, /)\n" "--\n" "\n" -"Return the tuple ((x-x%y)/y, x%y). Invariant: div*y + mod == x."); +"Return the tuple (x//y, x%y). Invariant: div*y + mod == x."); #define BUILTIN_DIVMOD_METHODDEF \ {"divmod", (PyCFunction)builtin_divmod, METH_VARARGS, builtin_divmod__doc__}, @@ -660,4 +660,4 @@ exit: return return_value; } -/*[clinic end generated code: output=bec3399c0aee98d7 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=4bef16b6aa432879 input=a9049054013a1b77]*/ -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 1 13:34:27 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 01 May 2016 17:34:27 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Regenerate_Arg?= =?utf-8?q?ument_Clinic_code_for_issue_=2326874=2E?= Message-ID: <20160501173423.84500.68049.5ADC9D12@psf.io> https://hg.python.org/cpython/rev/84ff79cce41e changeset: 101205:84ff79cce41e branch: 3.5 parent: 101203:1b6581bae5a1 user: Serhiy Storchaka date: Sun May 01 20:33:24 2016 +0300 summary: Regenerate Argument Clinic code for issue #26874. files: Python/bltinmodule.c | 2 +- Python/clinic/bltinmodule.c.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -801,7 +801,7 @@ static PyObject * builtin_divmod_impl(PyModuleDef *module, PyObject *x, PyObject *y) -/*[clinic end generated code: output=9ad0076120ebf9ac input=7fdb15f8a97a5fe7]*/ +/*[clinic end generated code: output=9ad0076120ebf9ac input=175ad9c84ff41a85]*/ { return PyNumber_Divmod(x, y); } diff --git a/Python/clinic/bltinmodule.c.h b/Python/clinic/bltinmodule.c.h --- a/Python/clinic/bltinmodule.c.h +++ b/Python/clinic/bltinmodule.c.h @@ -179,7 +179,7 @@ "divmod($module, x, y, /)\n" "--\n" "\n" -"Return the tuple ((x-x%y)/y, x%y). Invariant: div*y + mod == x."); +"Return the tuple (x//y, x%y). Invariant: div*y + mod == x."); #define BUILTIN_DIVMOD_METHODDEF \ {"divmod", (PyCFunction)builtin_divmod, METH_VARARGS, builtin_divmod__doc__}, @@ -660,4 +660,4 @@ exit: return return_value; } -/*[clinic end generated code: output=bec3399c0aee98d7 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=4bef16b6aa432879 input=a9049054013a1b77]*/ -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Mon May 2 04:53:05 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Mon, 02 May 2016 08:53:05 +0000 Subject: [Python-checkins] Daily reference leaks (98678738b7e9): sum=12 Message-ID: <20160502085305.12119.54889.E588D31B@psf.io> results for 98678738b7e9 on branch "default" -------------------------------------------- test_asyncio leaked [3, 0, 0] memory blocks, sum=3 test_collections leaked [4, -4, 4] memory blocks, sum=4 test_functools leaked [0, 3, 1] memory blocks, sum=4 test_multiprocessing_forkserver leaked [1, -2, 2] memory blocks, sum=1 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogV64n_H', '--timeout', '7200'] From python-checkins at python.org Mon May 2 05:25:59 2016 From: python-checkins at python.org (berker.peksag) Date: Mon, 02 May 2016 09:25:59 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2318916=3A_Update_thread_module_docstrings?= Message-ID: <20160502092558.34499.89889.45690B7B@psf.io> https://hg.python.org/cpython/rev/57a475e0e378 changeset: 101208:57a475e0e378 parent: 101206:98678738b7e9 parent: 101207:203c9c4ccb2a user: Berker Peksag date: Mon May 02 12:26:00 2016 +0300 summary: Issue #18916: Update thread module docstrings * Fix acquire() signature * Remove outdated help(LockType) reference * Replace PyThread_allocate_lock() with threading.Lock() Patch by Christopher Welborn. files: Modules/_threadmodule.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c --- a/Modules/_threadmodule.c +++ b/Modules/_threadmodule.c @@ -159,7 +159,7 @@ } PyDoc_STRVAR(acquire_doc, -"acquire([wait]) -> bool\n\ +"acquire(blocking=True, timeout=-1) -> bool\n\ (acquire_lock() is an obsolete synonym)\n\ \n\ Lock the lock. Without argument, this blocks if the lock is already\n\ @@ -1134,7 +1134,8 @@ "allocate_lock() -> lock object\n\ (allocate() is an obsolete synonym)\n\ \n\ -Create a new lock object. See help(LockType) for information about locks."); +Create a new lock object. See help(type(threading.Lock())) for\n\ +information about locks."); static PyObject * thread_get_ident(PyObject *self) @@ -1326,7 +1327,7 @@ PyDoc_STRVAR(lock_doc, "A lock object is a synchronization primitive. To create a lock,\n\ -call the PyThread_allocate_lock() function. Methods are:\n\ +call threading.Lock(). Methods are:\n\ \n\ acquire() -- lock the lock, possibly blocking until it can be obtained\n\ release() -- unlock of the lock\n\ -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon May 2 05:25:59 2016 From: python-checkins at python.org (berker.peksag) Date: Mon, 02 May 2016 09:25:59 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzE4OTE2?= =?utf-8?q?=3A_Update_thread_module_docstrings?= Message-ID: <20160502092557.13121.24151.EC69F2F7@psf.io> https://hg.python.org/cpython/rev/203c9c4ccb2a changeset: 101207:203c9c4ccb2a branch: 3.5 parent: 101205:84ff79cce41e user: Berker Peksag date: Mon May 02 12:25:35 2016 +0300 summary: Issue #18916: Update thread module docstrings * Fix acquire() signature * Remove outdated help(LockType) reference * Replace PyThread_allocate_lock() with threading.Lock() Patch by Christopher Welborn. files: Modules/_threadmodule.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c --- a/Modules/_threadmodule.c +++ b/Modules/_threadmodule.c @@ -159,7 +159,7 @@ } PyDoc_STRVAR(acquire_doc, -"acquire([wait]) -> bool\n\ +"acquire(blocking=True, timeout=-1) -> bool\n\ (acquire_lock() is an obsolete synonym)\n\ \n\ Lock the lock. Without argument, this blocks if the lock is already\n\ @@ -1134,7 +1134,8 @@ "allocate_lock() -> lock object\n\ (allocate() is an obsolete synonym)\n\ \n\ -Create a new lock object. See help(LockType) for information about locks."); +Create a new lock object. See help(type(threading.Lock())) for\n\ +information about locks."); static PyObject * thread_get_ident(PyObject *self) @@ -1326,7 +1327,7 @@ PyDoc_STRVAR(lock_doc, "A lock object is a synchronization primitive. To create a lock,\n\ -call the PyThread_allocate_lock() function. Methods are:\n\ +call threading.Lock(). Methods are:\n\ \n\ acquire() -- lock the lock, possibly blocking until it can be obtained\n\ release() -- unlock of the lock\n\ -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon May 2 06:46:07 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Mon, 02 May 2016 10:46:07 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Got_rid_of_redundand_=22se?= =?utf-8?q?lf=22_parameter_declarations=2E?= Message-ID: <20160502104537.100800.51794.1522B293@psf.io> https://hg.python.org/cpython/rev/c5729c10ce65 changeset: 101209:c5729c10ce65 user: Serhiy Storchaka date: Mon May 02 13:45:20 2016 +0300 summary: Got rid of redundand "self" parameter declarations. Argument Clinic is now able to infer all needed information. files: Modules/_bz2module.c | 3 +- Modules/_lzmamodule.c | 14 +---- Modules/_tkinter.c | 17 ++----- Objects/bytearrayobject.c | 47 ++++++--------------- Objects/bytesobject.c | 46 +++++++++------------ Objects/clinic/bytesobject.c.h | 22 +++++----- Python/bltinmodule.c | 5 +- 7 files changed, 57 insertions(+), 97 deletions(-) diff --git a/Modules/_bz2module.c b/Modules/_bz2module.c --- a/Modules/_bz2module.c +++ b/Modules/_bz2module.c @@ -592,7 +592,6 @@ /*[clinic input] _bz2.BZ2Decompressor.decompress - self: self(type="BZ2Decompressor *") data: Py_buffer max_length: Py_ssize_t=-1 @@ -615,7 +614,7 @@ static PyObject * _bz2_BZ2Decompressor_decompress_impl(BZ2Decompressor *self, Py_buffer *data, Py_ssize_t max_length) -/*[clinic end generated code: output=23e41045deb240a3 input=9558b424c8b00516]*/ +/*[clinic end generated code: output=23e41045deb240a3 input=52e1ffc66a8ea624]*/ { PyObject *result = NULL; diff --git a/Modules/_lzmamodule.c b/Modules/_lzmamodule.c --- a/Modules/_lzmamodule.c +++ b/Modules/_lzmamodule.c @@ -553,7 +553,6 @@ /*[clinic input] _lzma.LZMACompressor.compress - self: self(type="Compressor *") data: Py_buffer / @@ -567,7 +566,7 @@ static PyObject * _lzma_LZMACompressor_compress_impl(Compressor *self, Py_buffer *data) -/*[clinic end generated code: output=31f615136963e00f input=8b60cb13e0ce6420]*/ +/*[clinic end generated code: output=31f615136963e00f input=64019eac7f2cc8d0]*/ { PyObject *result = NULL; @@ -583,8 +582,6 @@ /*[clinic input] _lzma.LZMACompressor.flush - self: self(type="Compressor *") - Finish the compression process. Returns the compressed data left in internal buffers. @@ -594,7 +591,7 @@ static PyObject * _lzma_LZMACompressor_flush_impl(Compressor *self) -/*[clinic end generated code: output=fec21f3e22504f50 input=3060fb26f9b4042c]*/ +/*[clinic end generated code: output=fec21f3e22504f50 input=6b369303f67ad0a8]*/ { PyObject *result = NULL; @@ -698,7 +695,6 @@ /*[-clinic input] _lzma.LZMACompressor.__init__ - self: self(type="Compressor *") format: int(c_default="FORMAT_XZ") = FORMAT_XZ The container format to use for the output. This can be FORMAT_XZ (default), FORMAT_ALONE, or FORMAT_RAW. @@ -1063,7 +1059,6 @@ /*[clinic input] _lzma.LZMADecompressor.decompress - self: self(type="Decompressor *") data: Py_buffer max_length: Py_ssize_t=-1 @@ -1086,7 +1081,7 @@ static PyObject * _lzma_LZMADecompressor_decompress_impl(Decompressor *self, Py_buffer *data, Py_ssize_t max_length) -/*[clinic end generated code: output=ef4e20ec7122241d input=f2bb902cc1caf203]*/ +/*[clinic end generated code: output=ef4e20ec7122241d input=60c1f135820e309d]*/ { PyObject *result = NULL; @@ -1126,7 +1121,6 @@ /*[clinic input] _lzma.LZMADecompressor.__init__ - self: self(type="Decompressor *") format: int(c_default="FORMAT_AUTO") = FORMAT_AUTO Specifies the container format of the input stream. If this is FORMAT_AUTO (the default), the decompressor will automatically detect @@ -1152,7 +1146,7 @@ static int _lzma_LZMADecompressor___init___impl(Decompressor *self, int format, PyObject *memlimit, PyObject *filters) -/*[clinic end generated code: output=3e1821f8aa36564c input=458ca6132ef29801]*/ +/*[clinic end generated code: output=3e1821f8aa36564c input=81fe684a6c2f8a27]*/ { const uint32_t decoder_flags = LZMA_TELL_ANY_CHECK | LZMA_TELL_NO_CHECK; uint64_t memlimit_ = UINT64_MAX; diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -2485,7 +2485,6 @@ /*[clinic input] _tkinter.tkapp.createcommand - self: self(type="TkappObject *") name: str func: object / @@ -2495,7 +2494,7 @@ static PyObject * _tkinter_tkapp_createcommand_impl(TkappObject *self, const char *name, PyObject *func) -/*[clinic end generated code: output=2a1c79a4ee2af410 input=2bc2c046a0914234]*/ +/*[clinic end generated code: output=2a1c79a4ee2af410 input=255785cb70edc6a0]*/ { PythonCmd_ClientData *data; int err; @@ -2561,7 +2560,6 @@ /*[clinic input] _tkinter.tkapp.deletecommand - self: self(type="TkappObject *") name: str / @@ -2569,7 +2567,7 @@ static PyObject * _tkinter_tkapp_deletecommand_impl(TkappObject *self, const char *name) -/*[clinic end generated code: output=a67e8cb5845e0d2d input=b6306468f10b219c]*/ +/*[clinic end generated code: output=a67e8cb5845e0d2d input=53e9952eae1f85f5]*/ { int err; @@ -2762,13 +2760,11 @@ /*[clinic input] _tkinter.tktimertoken.deletetimerhandler - self: self(type="TkttObject *") - [clinic start generated code]*/ static PyObject * _tkinter_tktimertoken_deletetimerhandler_impl(TkttObject *self) -/*[clinic end generated code: output=bd7fe17f328cfa55 input=25ba5dd594e52084]*/ +/*[clinic end generated code: output=bd7fe17f328cfa55 input=40bd070ff85f5cf3]*/ { TkttObject *v = self; PyObject *func = v->func; @@ -2894,7 +2890,6 @@ /*[clinic input] _tkinter.tkapp.mainloop - self: self(type="TkappObject *") threshold: int = 0 / @@ -2902,7 +2897,7 @@ static PyObject * _tkinter_tkapp_mainloop_impl(TkappObject *self, int threshold) -/*[clinic end generated code: output=0ba8eabbe57841b0 input=ad57c9c1dd2b9470]*/ +/*[clinic end generated code: output=0ba8eabbe57841b0 input=036bcdcf03d5eca0]*/ { #ifdef WITH_THREAD PyThreadState *tstate = PyThreadState_Get(); @@ -3072,13 +3067,11 @@ /*[clinic input] _tkinter.tkapp.willdispatch - self: self(type="TkappObject *") - [clinic start generated code]*/ static PyObject * _tkinter_tkapp_willdispatch_impl(TkappObject *self) -/*[clinic end generated code: output=0e3f46d244642155 input=2630699767808970]*/ +/*[clinic end generated code: output=0e3f46d244642155 input=d88f5970843d6dab]*/ { self->dispatching = 1; diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -1243,14 +1243,12 @@ /*[clinic input] bytearray.clear - self: self(type="PyByteArrayObject *") - Remove all items from the bytearray. [clinic start generated code]*/ static PyObject * bytearray_clear_impl(PyByteArrayObject *self) -/*[clinic end generated code: output=85c2fe6aede0956c input=e524fd330abcdc18]*/ +/*[clinic end generated code: output=85c2fe6aede0956c input=ed6edae9de447ac4]*/ { if (PyByteArray_Resize((PyObject *)self, 0) < 0) return NULL; @@ -1260,14 +1258,12 @@ /*[clinic input] bytearray.copy - self: self(type="PyByteArrayObject *") - Return a copy of B. [clinic start generated code]*/ static PyObject * bytearray_copy_impl(PyByteArrayObject *self) -/*[clinic end generated code: output=68cfbcfed484c132 input=6d5d2975aa0f33f3]*/ +/*[clinic end generated code: output=68cfbcfed484c132 input=6597b0c01bccaa9e]*/ { return PyByteArray_FromStringAndSize(PyByteArray_AS_STRING((PyObject *)self), PyByteArray_GET_SIZE(self)); @@ -1489,7 +1485,6 @@ /*[clinic input] bytearray.translate - self: self(type="PyByteArrayObject *") table: object Translation table, which must be a bytes object of length 256. [ @@ -1506,7 +1501,7 @@ static PyObject * bytearray_translate_impl(PyByteArrayObject *self, PyObject *table, int group_right_1, PyObject *deletechars) -/*[clinic end generated code: output=2bebc86a9a1ff083 input=b749ad85f4860824]*/ +/*[clinic end generated code: output=2bebc86a9a1ff083 input=846a01671bccc1c5]*/ { char *input, *output; const char *table_chars; @@ -2187,7 +2182,6 @@ /*[clinic input] bytearray.partition - self: self(type="PyByteArrayObject *") sep: object / @@ -2203,7 +2197,7 @@ static PyObject * bytearray_partition(PyByteArrayObject *self, PyObject *sep) -/*[clinic end generated code: output=45d2525ddd35f957 input=7d7fe37b1696d506]*/ +/*[clinic end generated code: output=45d2525ddd35f957 input=86f89223892b70b5]*/ { PyObject *bytesep, *result; @@ -2225,7 +2219,6 @@ /*[clinic input] bytearray.rpartition - self: self(type="PyByteArrayObject *") sep: object / @@ -2241,7 +2234,7 @@ static PyObject * bytearray_rpartition(PyByteArrayObject *self, PyObject *sep) -/*[clinic end generated code: output=440de3c9426115e8 input=9b8cd540c1b75853]*/ +/*[clinic end generated code: output=440de3c9426115e8 input=5f4094f2de87c8f3]*/ { PyObject *bytesep, *result; @@ -2299,14 +2292,12 @@ /*[clinic input] bytearray.reverse - self: self(type="PyByteArrayObject *") - Reverse the order of the values in B in place. [clinic start generated code]*/ static PyObject * bytearray_reverse_impl(PyByteArrayObject *self) -/*[clinic end generated code: output=9f7616f29ab309d3 input=7933a499b8597bd1]*/ +/*[clinic end generated code: output=9f7616f29ab309d3 input=543356319fc78557]*/ { char swap, *head, *tail; Py_ssize_t i, j, n = Py_SIZE(self); @@ -2335,7 +2326,6 @@ /*[clinic input] bytearray.insert - self: self(type="PyByteArrayObject *") index: Py_ssize_t The index where the value is to be inserted. item: bytesvalue @@ -2347,7 +2337,7 @@ static PyObject * bytearray_insert_impl(PyByteArrayObject *self, Py_ssize_t index, int item) -/*[clinic end generated code: output=76c775a70e7b07b7 input=833766836ba30e1e]*/ +/*[clinic end generated code: output=76c775a70e7b07b7 input=b2b5d07e9de6c070]*/ { Py_ssize_t n = Py_SIZE(self); char *buf; @@ -2377,7 +2367,6 @@ /*[clinic input] bytearray.append - self: self(type="PyByteArrayObject *") item: bytesvalue The item to be appended. / @@ -2387,7 +2376,7 @@ static PyObject * bytearray_append_impl(PyByteArrayObject *self, int item) -/*[clinic end generated code: output=a154e19ed1886cb6 input=ae56ea87380407cc]*/ +/*[clinic end generated code: output=a154e19ed1886cb6 input=20d6bec3d1340593]*/ { Py_ssize_t n = Py_SIZE(self); @@ -2407,7 +2396,6 @@ /*[clinic input] bytearray.extend - self: self(type="PyByteArrayObject *") iterable_of_ints: object The iterable of items to append. / @@ -2417,7 +2405,7 @@ static PyObject * bytearray_extend(PyByteArrayObject *self, PyObject *iterable_of_ints) -/*[clinic end generated code: output=98155dbe249170b1 input=ce83a5d75b70d850]*/ +/*[clinic end generated code: output=98155dbe249170b1 input=c617b3a93249ba28]*/ { PyObject *it, *item, *bytearray_obj; Py_ssize_t buf_size = 0, len = 0; @@ -2492,7 +2480,6 @@ /*[clinic input] bytearray.pop - self: self(type="PyByteArrayObject *") index: Py_ssize_t = -1 The index from where to remove the item. -1 (the default value) means remove the last item. @@ -2505,7 +2492,7 @@ static PyObject * bytearray_pop_impl(PyByteArrayObject *self, Py_ssize_t index) -/*[clinic end generated code: output=e0ccd401f8021da8 input=0797e6c0ca9d5a85]*/ +/*[clinic end generated code: output=e0ccd401f8021da8 input=3591df2d06c0d237]*/ { int value; Py_ssize_t n = Py_SIZE(self); @@ -2537,7 +2524,6 @@ /*[clinic input] bytearray.remove - self: self(type="PyByteArrayObject *") value: bytesvalue The value to remove. / @@ -2547,7 +2533,7 @@ static PyObject * bytearray_remove_impl(PyByteArrayObject *self, int value) -/*[clinic end generated code: output=d659e37866709c13 input=47560b11fd856c24]*/ +/*[clinic end generated code: output=d659e37866709c13 input=121831240cd51ddf]*/ { Py_ssize_t where, n = Py_SIZE(self); char *buf = PyByteArray_AS_STRING(self); @@ -2858,14 +2844,12 @@ /*[clinic input] bytearray.__reduce__ as bytearray_reduce - self: self(type="PyByteArrayObject *") - Return state information for pickling. [clinic start generated code]*/ static PyObject * bytearray_reduce_impl(PyByteArrayObject *self) -/*[clinic end generated code: output=52bf304086464cab input=fbb07de4d102a03a]*/ +/*[clinic end generated code: output=52bf304086464cab input=44b5737ada62dd3f]*/ { return _common_reduce(self, 2); } @@ -2873,7 +2857,6 @@ /*[clinic input] bytearray.__reduce_ex__ as bytearray_reduce_ex - self: self(type="PyByteArrayObject *") proto: int = 0 / @@ -2882,7 +2865,7 @@ static PyObject * bytearray_reduce_ex_impl(PyByteArrayObject *self, int proto) -/*[clinic end generated code: output=52eac33377197520 input=0e091a42ca6dbd91]*/ +/*[clinic end generated code: output=52eac33377197520 input=f129bc1a1aa151ee]*/ { return _common_reduce(self, proto); } @@ -2890,14 +2873,12 @@ /*[clinic input] bytearray.__sizeof__ as bytearray_sizeof - self: self(type="PyByteArrayObject *") - Returns the size of the bytearray object in memory, in bytes. [clinic start generated code]*/ static PyObject * bytearray_sizeof_impl(PyByteArrayObject *self) -/*[clinic end generated code: output=738abdd17951c427 input=6b23d305362b462b]*/ +/*[clinic end generated code: output=738abdd17951c427 input=e27320fd98a4bc5a]*/ { Py_ssize_t res; diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -9,9 +9,9 @@ #include /*[clinic input] -class bytes "PyBytesObject*" "&PyBytes_Type" +class bytes "PyBytesObject *" "&PyBytes_Type" [clinic start generated code]*/ -/*[clinic end generated code: output=da39a3ee5e6b4b0d input=1a1d9102afc1b00c]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=7a238f965d64892b]*/ #include "clinic/bytesobject.c.h" @@ -1752,8 +1752,8 @@ [clinic start generated code]*/ static PyObject * -bytes_split_impl(PyBytesObject*self, PyObject *sep, Py_ssize_t maxsplit) -/*[clinic end generated code: output=8bde44dacb36ef2e input=8b809b39074abbfa]*/ +bytes_split_impl(PyBytesObject *self, PyObject *sep, Py_ssize_t maxsplit) +/*[clinic end generated code: output=52126b5844c1d8ef input=8b809b39074abbfa]*/ { Py_ssize_t len = PyBytes_GET_SIZE(self), n; const char *s = PyBytes_AS_STRING(self), *sub; @@ -1777,7 +1777,6 @@ /*[clinic input] bytes.partition - self: self(type="PyBytesObject *") sep: Py_buffer / @@ -1793,7 +1792,7 @@ static PyObject * bytes_partition_impl(PyBytesObject *self, Py_buffer *sep) -/*[clinic end generated code: output=f532b392a17ff695 input=bc855dc63ca949de]*/ +/*[clinic end generated code: output=f532b392a17ff695 input=61cca95519406099]*/ { return stringlib_partition( (PyObject*) self, @@ -1805,7 +1804,6 @@ /*[clinic input] bytes.rpartition - self: self(type="PyBytesObject *") sep: Py_buffer / @@ -1821,7 +1819,7 @@ static PyObject * bytes_rpartition_impl(PyBytesObject *self, Py_buffer *sep) -/*[clinic end generated code: output=191b114cbb028e50 input=6588fff262a9170e]*/ +/*[clinic end generated code: output=191b114cbb028e50 input=67f689e63a62d478]*/ { return stringlib_rpartition( (PyObject*) self, @@ -1839,8 +1837,8 @@ [clinic start generated code]*/ static PyObject * -bytes_rsplit_impl(PyBytesObject*self, PyObject *sep, Py_ssize_t maxsplit) -/*[clinic end generated code: output=0b6570b977911d88 input=0f86c9f28f7d7b7b]*/ +bytes_rsplit_impl(PyBytesObject *self, PyObject *sep, Py_ssize_t maxsplit) +/*[clinic end generated code: output=ba698d9ea01e1c8f input=0f86c9f28f7d7b7b]*/ { Py_ssize_t len = PyBytes_GET_SIZE(self), n; const char *s = PyBytes_AS_STRING(self), *sub; @@ -1878,8 +1876,8 @@ [clinic start generated code]*/ static PyObject * -bytes_join(PyBytesObject*self, PyObject *iterable_of_bytes) -/*[clinic end generated code: output=634aff14764ff997 input=7fe377b95bd549d2]*/ +bytes_join(PyBytesObject *self, PyObject *iterable_of_bytes) +/*[clinic end generated code: output=a046f379f626f6f8 input=7fe377b95bd549d2]*/ { return stringlib_bytes_join((PyObject*)self, iterable_of_bytes); } @@ -2129,7 +2127,6 @@ /*[clinic input] bytes.strip - self: self(type="PyBytesObject *") bytes: object = None / @@ -2140,7 +2137,7 @@ static PyObject * bytes_strip_impl(PyBytesObject *self, PyObject *bytes) -/*[clinic end generated code: output=c7c228d3bd104a1b input=37daa5fad1395d95]*/ +/*[clinic end generated code: output=c7c228d3bd104a1b input=8a354640e4e0b3ef]*/ { return do_argstrip(self, BOTHSTRIP, bytes); } @@ -2148,7 +2145,6 @@ /*[clinic input] bytes.lstrip - self: self(type="PyBytesObject *") bytes: object = None / @@ -2159,7 +2155,7 @@ static PyObject * bytes_lstrip_impl(PyBytesObject *self, PyObject *bytes) -/*[clinic end generated code: output=28602e586f524e82 input=88811b09dfbc2988]*/ +/*[clinic end generated code: output=28602e586f524e82 input=9baff4398c3f6857]*/ { return do_argstrip(self, LEFTSTRIP, bytes); } @@ -2167,7 +2163,6 @@ /*[clinic input] bytes.rstrip - self: self(type="PyBytesObject *") bytes: object = None / @@ -2178,7 +2173,7 @@ static PyObject * bytes_rstrip_impl(PyBytesObject *self, PyObject *bytes) -/*[clinic end generated code: output=547e3815c95447da input=8f93c9cd361f0140]*/ +/*[clinic end generated code: output=547e3815c95447da input=b78af445c727e32b]*/ { return do_argstrip(self, RIGHTSTRIP, bytes); } @@ -2235,7 +2230,6 @@ /*[clinic input] bytes.translate - self: self(type="PyBytesObject *") table: object Translation table, which must be a bytes object of length 256. [ @@ -2252,7 +2246,7 @@ static PyObject * bytes_translate_impl(PyBytesObject *self, PyObject *table, int group_right_1, PyObject *deletechars) -/*[clinic end generated code: output=233df850eb50bf8d input=d8fa5519d7cc4be7]*/ +/*[clinic end generated code: output=233df850eb50bf8d input=ca20edf39d780d49]*/ { char *input, *output; Py_buffer table_view = {NULL, NULL}; @@ -2909,9 +2903,9 @@ [clinic start generated code]*/ static PyObject * -bytes_replace_impl(PyBytesObject*self, Py_buffer *old, Py_buffer *new, +bytes_replace_impl(PyBytesObject *self, Py_buffer *old, Py_buffer *new, Py_ssize_t count) -/*[clinic end generated code: output=403dc9d7a83c5a1d input=b2fbbf0bf04de8e5]*/ +/*[clinic end generated code: output=994fa588b6b9c104 input=b2fbbf0bf04de8e5]*/ { return (PyObject *)replace((PyBytesObject *) self, (const char *)old->buf, old->len, @@ -3078,9 +3072,9 @@ [clinic start generated code]*/ static PyObject * -bytes_decode_impl(PyBytesObject*self, const char *encoding, +bytes_decode_impl(PyBytesObject *self, const char *encoding, const char *errors) -/*[clinic end generated code: output=2d2016ff8e0bb176 input=958174769d2a40ca]*/ +/*[clinic end generated code: output=5649a53dde27b314 input=958174769d2a40ca]*/ { return PyUnicode_FromEncodedObject((PyObject*)self, encoding, errors); } @@ -3098,8 +3092,8 @@ [clinic start generated code]*/ static PyObject * -bytes_splitlines_impl(PyBytesObject*self, int keepends) -/*[clinic end generated code: output=995c3598f7833cad input=7f4aac67144f9944]*/ +bytes_splitlines_impl(PyBytesObject *self, int keepends) +/*[clinic end generated code: output=3484149a5d880ffb input=7f4aac67144f9944]*/ { return stringlib_splitlines( (PyObject*) self, PyBytes_AS_STRING(self), diff --git a/Objects/clinic/bytesobject.c.h b/Objects/clinic/bytesobject.c.h --- a/Objects/clinic/bytesobject.c.h +++ b/Objects/clinic/bytesobject.c.h @@ -20,10 +20,10 @@ {"split", (PyCFunction)bytes_split, METH_VARARGS|METH_KEYWORDS, bytes_split__doc__}, static PyObject * -bytes_split_impl(PyBytesObject*self, PyObject *sep, Py_ssize_t maxsplit); +bytes_split_impl(PyBytesObject *self, PyObject *sep, Py_ssize_t maxsplit); static PyObject * -bytes_split(PyBytesObject*self, PyObject *args, PyObject *kwargs) +bytes_split(PyBytesObject *self, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"sep", "maxsplit", NULL}; @@ -133,10 +133,10 @@ {"rsplit", (PyCFunction)bytes_rsplit, METH_VARARGS|METH_KEYWORDS, bytes_rsplit__doc__}, static PyObject * -bytes_rsplit_impl(PyBytesObject*self, PyObject *sep, Py_ssize_t maxsplit); +bytes_rsplit_impl(PyBytesObject *self, PyObject *sep, Py_ssize_t maxsplit); static PyObject * -bytes_rsplit(PyBytesObject*self, PyObject *args, PyObject *kwargs) +bytes_rsplit(PyBytesObject *self, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"sep", "maxsplit", NULL}; @@ -359,11 +359,11 @@ {"replace", (PyCFunction)bytes_replace, METH_VARARGS, bytes_replace__doc__}, static PyObject * -bytes_replace_impl(PyBytesObject*self, Py_buffer *old, Py_buffer *new, +bytes_replace_impl(PyBytesObject *self, Py_buffer *old, Py_buffer *new, Py_ssize_t count); static PyObject * -bytes_replace(PyBytesObject*self, PyObject *args) +bytes_replace(PyBytesObject *self, PyObject *args) { PyObject *return_value = NULL; Py_buffer old = {NULL, NULL}; @@ -405,11 +405,11 @@ {"decode", (PyCFunction)bytes_decode, METH_VARARGS|METH_KEYWORDS, bytes_decode__doc__}, static PyObject * -bytes_decode_impl(PyBytesObject*self, const char *encoding, +bytes_decode_impl(PyBytesObject *self, const char *encoding, const char *errors); static PyObject * -bytes_decode(PyBytesObject*self, PyObject *args, PyObject *kwargs) +bytes_decode(PyBytesObject *self, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"encoding", "errors", NULL}; @@ -438,10 +438,10 @@ {"splitlines", (PyCFunction)bytes_splitlines, METH_VARARGS|METH_KEYWORDS, bytes_splitlines__doc__}, static PyObject * -bytes_splitlines_impl(PyBytesObject*self, int keepends); +bytes_splitlines_impl(PyBytesObject *self, int keepends); static PyObject * -bytes_splitlines(PyBytesObject*self, PyObject *args, PyObject *kwargs) +bytes_splitlines(PyBytesObject *self, PyObject *args, PyObject *kwargs) { PyObject *return_value = NULL; static char *_keywords[] = {"keepends", NULL}; @@ -484,4 +484,4 @@ exit: return return_value; } -/*[clinic end generated code: output=bd0ce8f25d7e18f4 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=d0e9f5a1c0682910 input=a9049054013a1b77]*/ diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -1078,7 +1078,6 @@ /*[clinic input] id as builtin_id - self: self(type="PyModuleDef *") obj as v: object / @@ -1089,8 +1088,8 @@ [clinic start generated code]*/ static PyObject * -builtin_id(PyModuleDef *self, PyObject *v) -/*[clinic end generated code: output=0aa640785f697f65 input=5a534136419631f4]*/ +builtin_id(PyModuleDef *module, PyObject *v) +/*[clinic end generated code: output=63635e497e09c2f7 input=57fb4a9aaff96384]*/ { return PyLong_FromVoidPtr(v); } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon May 2 07:02:50 2016 From: python-checkins at python.org (donald.stufft) Date: Mon, 02 May 2016 11:02:50 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Upgrade_ensure?= =?utf-8?q?pip_bundled_setuptools_to_20=2E10=2E1?= Message-ID: <20160502110235.30349.54782.1C48CC12@psf.io> https://hg.python.org/cpython/rev/e407db1cac8b changeset: 101210:e407db1cac8b branch: 2.7 parent: 101192:57bf7a40925f user: Donald Stufft date: Mon May 02 07:02:30 2016 -0400 summary: Upgrade ensurepip bundled setuptools to 20.10.1 files: Lib/ensurepip/__init__.py | 2 +- Lib/ensurepip/_bundled/setuptools-20.10.1-py2.py3-none-any.whl | Bin Lib/ensurepip/_bundled/setuptools-20.3-py2.py3-none-any.whl | Bin 3 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py --- a/Lib/ensurepip/__init__.py +++ b/Lib/ensurepip/__init__.py @@ -12,7 +12,7 @@ __all__ = ["version", "bootstrap"] -_SETUPTOOLS_VERSION = "20.3" +_SETUPTOOLS_VERSION = "20.10.1" _PIP_VERSION = "8.1.1" diff --git a/Lib/ensurepip/_bundled/setuptools-20.10.1-py2.py3-none-any.whl b/Lib/ensurepip/_bundled/setuptools-20.10.1-py2.py3-none-any.whl new file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..9d1319a24aba103fe956ef6298e3649efacc0b93 GIT binary patch [stripped] diff --git a/Lib/ensurepip/_bundled/setuptools-20.3-py2.py3-none-any.whl b/Lib/ensurepip/_bundled/setuptools-20.3-py2.py3-none-any.whl deleted file mode 100644 index 39e67c0b6e3bb3fcb8ed5f42a494f3b1ac3fa9cc..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 GIT binary patch [stripped] -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon May 2 07:03:51 2016 From: python-checkins at python.org (donald.stufft) Date: Mon, 02 May 2016 11:03:51 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E4=29=3A_Upgrade_ensure?= =?utf-8?q?pip_bundled_setuptools_to_20=2E10=2E1?= Message-ID: <20160502110350.12426.47320.E166BA0A@psf.io> https://hg.python.org/cpython/rev/5cf064bf81fd changeset: 101211:5cf064bf81fd branch: 3.4 parent: 100962:772805538caf user: Donald Stufft date: Mon May 02 07:03:46 2016 -0400 summary: Upgrade ensurepip bundled setuptools to 20.10.1 files: Lib/ensurepip/__init__.py | 2 +- Lib/ensurepip/_bundled/setuptools-20.10.1-py2.py3-none-any.whl | Bin Lib/ensurepip/_bundled/setuptools-20.3-py2.py3-none-any.whl | Bin 3 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py --- a/Lib/ensurepip/__init__.py +++ b/Lib/ensurepip/__init__.py @@ -8,7 +8,7 @@ __all__ = ["version", "bootstrap"] -_SETUPTOOLS_VERSION = "20.3" +_SETUPTOOLS_VERSION = "20.10.1" _PIP_VERSION = "8.1.1" diff --git a/Lib/ensurepip/_bundled/setuptools-20.10.1-py2.py3-none-any.whl b/Lib/ensurepip/_bundled/setuptools-20.10.1-py2.py3-none-any.whl new file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..9d1319a24aba103fe956ef6298e3649efacc0b93 GIT binary patch [stripped] diff --git a/Lib/ensurepip/_bundled/setuptools-20.3-py2.py3-none-any.whl b/Lib/ensurepip/_bundled/setuptools-20.3-py2.py3-none-any.whl deleted file mode 100644 index 39e67c0b6e3bb3fcb8ed5f42a494f3b1ac3fa9cc..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 GIT binary patch [stripped] -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon May 2 07:05:04 2016 From: python-checkins at python.org (donald.stufft) Date: Mon, 02 May 2016 11:05:04 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAobWVyZ2UgMy40IC0+IDMuNSk6?= =?utf-8?q?_Upgrade_ensurepip_bundled_setuptools_to_20=2E10=2E1?= Message-ID: <20160502110503.13894.69459.95CCB7C1@psf.io> https://hg.python.org/cpython/rev/538eeb8c3019 changeset: 101212:538eeb8c3019 branch: 3.5 parent: 101207:203c9c4ccb2a parent: 101211:5cf064bf81fd user: Donald Stufft date: Mon May 02 07:04:59 2016 -0400 summary: Upgrade ensurepip bundled setuptools to 20.10.1 files: Lib/ensurepip/__init__.py | 2 +- Lib/ensurepip/_bundled/setuptools-20.10.1-py2.py3-none-any.whl | Bin Lib/ensurepip/_bundled/setuptools-20.3-py2.py3-none-any.whl | Bin 3 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py --- a/Lib/ensurepip/__init__.py +++ b/Lib/ensurepip/__init__.py @@ -8,7 +8,7 @@ __all__ = ["version", "bootstrap"] -_SETUPTOOLS_VERSION = "20.3" +_SETUPTOOLS_VERSION = "20.10.1" _PIP_VERSION = "8.1.1" diff --git a/Lib/ensurepip/_bundled/setuptools-20.10.1-py2.py3-none-any.whl b/Lib/ensurepip/_bundled/setuptools-20.10.1-py2.py3-none-any.whl new file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..9d1319a24aba103fe956ef6298e3649efacc0b93 GIT binary patch [stripped] diff --git a/Lib/ensurepip/_bundled/setuptools-20.3-py2.py3-none-any.whl b/Lib/ensurepip/_bundled/setuptools-20.3-py2.py3-none-any.whl deleted file mode 100644 index 39e67c0b6e3bb3fcb8ed5f42a494f3b1ac3fa9cc..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 GIT binary patch [stripped] -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon May 2 07:05:33 2016 From: python-checkins at python.org (donald.stufft) Date: Mon, 02 May 2016 11:05:33 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Upgrade_ensurepip_bundled_setuptools_to_20=2E10=2E1?= Message-ID: <20160502110532.13918.93958.7A949E12@psf.io> https://hg.python.org/cpython/rev/e324588c2959 changeset: 101213:e324588c2959 parent: 101209:c5729c10ce65 parent: 101212:538eeb8c3019 user: Donald Stufft date: Mon May 02 07:05:29 2016 -0400 summary: Upgrade ensurepip bundled setuptools to 20.10.1 files: Lib/ensurepip/__init__.py | 2 +- Lib/ensurepip/_bundled/setuptools-20.10.1-py2.py3-none-any.whl | Bin Lib/ensurepip/_bundled/setuptools-20.3-py2.py3-none-any.whl | Bin 3 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py --- a/Lib/ensurepip/__init__.py +++ b/Lib/ensurepip/__init__.py @@ -8,7 +8,7 @@ __all__ = ["version", "bootstrap"] -_SETUPTOOLS_VERSION = "20.3" +_SETUPTOOLS_VERSION = "20.10.1" _PIP_VERSION = "8.1.1" diff --git a/Lib/ensurepip/_bundled/setuptools-20.10.1-py2.py3-none-any.whl b/Lib/ensurepip/_bundled/setuptools-20.10.1-py2.py3-none-any.whl new file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..9d1319a24aba103fe956ef6298e3649efacc0b93 GIT binary patch [stripped] diff --git a/Lib/ensurepip/_bundled/setuptools-20.3-py2.py3-none-any.whl b/Lib/ensurepip/_bundled/setuptools-20.3-py2.py3-none-any.whl deleted file mode 100644 index 39e67c0b6e3bb3fcb8ed5f42a494f3b1ac3fa9cc..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 GIT binary patch [stripped] -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon May 2 13:56:42 2016 From: python-checkins at python.org (brett.cannon) Date: Mon, 02 May 2016 17:56:42 +0000 Subject: [Python-checkins] =?utf-8?q?devguide=3A_Ignore_venv?= Message-ID: <20160502175641.13904.46980.B72FE5C8@psf.io> https://hg.python.org/devguide/rev/1df6fcc0578e changeset: 800:1df6fcc0578e user: Brett Cannon date: Mon May 02 10:49:10 2016 -0700 summary: Ignore venv files: .hgignore | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/.hgignore b/.hgignore --- a/.hgignore +++ b/.hgignore @@ -3,3 +3,4 @@ *.swp *~ _build +venv -- Repository URL: https://hg.python.org/devguide From python-checkins at python.org Mon May 2 13:57:10 2016 From: python-checkins at python.org (brett.cannon) Date: Mon, 02 May 2016 17:57:10 +0000 Subject: [Python-checkins] =?utf-8?q?devguide=3A_Document_that_we_now_want?= =?utf-8?q?_your_GitHub_username_as_well?= Message-ID: <20160502175641.39162.87732.AB8E1814@psf.io> https://hg.python.org/devguide/rev/ff3ff9670efb changeset: 801:ff3ff9670efb user: Brett Cannon date: Mon May 02 10:56:37 2016 -0700 summary: Document that we now want your GitHub username as well files: coredev.rst | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/coredev.rst b/coredev.rst --- a/coredev.rst +++ b/coredev.rst @@ -63,8 +63,9 @@ You need to provide an SSH-2 key to be able to commit code. You may have multiple keys if you wish (e.g., for work and home). Using Ed25519 keys is encouraged. Send your key as an attachment in an email to -hgaccounts at python.org. Help in generating an SSH key can be found in the -:ref:`faq`. +hgaccounts at python.org along with your GitHub username so you can be added to +the "Python core" team at https://github.com/python. Help in generating an SSH +key can be found in the :ref:`faq`. Your SSH key will be set to a username in the form of "first_name.last_name". This should match your username on the issue tracker. -- Repository URL: https://hg.python.org/devguide From python-checkins at python.org Mon May 2 18:17:44 2016 From: python-checkins at python.org (terry.reedy) Date: Mon, 02 May 2016 22:17:44 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Clarify_IDLE-c?= =?utf-8?q?onsole_differences_with_respect_to_the_sys_module=2E?= Message-ID: <20160502221732.100796.25750.5800B6EE@psf.io> https://hg.python.org/cpython/rev/21d18f09822b changeset: 101214:21d18f09822b branch: 2.7 parent: 101210:e407db1cac8b user: Terry Jan Reedy date: Mon May 02 18:17:19 2016 -0400 summary: Clarify IDLE-console differences with respect to the sys module. The reload(sys) effect was the crux of a Stackoverflow question. files: Doc/library/idle.rst | 16 +++++++++------- Lib/idlelib/help.html | 20 +++++++++++--------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst --- a/Doc/library/idle.rst +++ b/Doc/library/idle.rst @@ -550,14 +550,16 @@ As much as possible, the result of executing Python code with IDLE is the same as executing the same code in a console window. However, the different -interface and operation occasionally affects results. +interface and operation occasionally affects visible results. For instance, +``sys.modules`` starts with more entries. -For instance, IDLE normally executes user code in a separate process from -the IDLE GUI itself. The IDLE versions of sys.stdin, .stdout, and .stderr in the -execution process get input from and send output to the GUI process, -which keeps control of the keyboard and screen. This is normally transparent, -but code that access these object will see different attribute values. -Also, functions that directly access the keyboard and screen will not work. +IDLE also replaces ``sys.stdin``, ``sys.stdout``, and ``sys.stderr`` with +objects that get input from and send output to the Shell window. +When this window has the focus, it controls the keyboard and screen. +This is normally transparent, but functions that directly access the keyboard +and screen will not work. If ``sys`` is reset with ``reload(sys)``, +IDLE's changes are lost and things like ``input``, ``raw_input``, and +``print`` will not work correctly. With IDLE's Shell, one enters, edits, and recalls complete statements. Some consoles only work with a single physical line at a time. diff --git a/Lib/idlelib/help.html b/Lib/idlelib/help.html --- a/Lib/idlelib/help.html +++ b/Lib/idlelib/help.html @@ -163,7 +163,7 @@
Find Selection
Search for the currently selected string, if there is one.
Find in Files...
-
Open a file search dialog. Put results in an new output window.
+
Open a file search dialog. Put results in a new output window.
Replace...
Open a search-and-replace dialog.
Go to Line
@@ -517,13 +517,15 @@

24.6.3.2. IDLE-console differences?

As much as possible, the result of executing Python code with IDLE is the same as executing the same code in a console window. However, the different -interface and operation occasionally affects results.

-

For instance, IDLE normally executes user code in a separate process from -the IDLE GUI itself. The IDLE versions of sys.stdin, .stdout, and .stderr in the -execution process get input from and send output to the GUI process, -which keeps control of the keyboard and screen. This is normally transparent, -but code that access these object will see different attribute values. -Also, functions that directly access the keyboard and screen will not work.

+interface and operation occasionally affects visible results. For instance, +sys.modules starts with more entries.

+

IDLE also replaces sys.stdin, sys.stdout, and sys.stderr with +objects that get input from and send output to the Shell window. +When this window has the focus, it controls the keyboard and screen. +This is normally transparent, but functions that directly access the keyboard +and screen will not work. If sys is reset with reload(sys), +IDLE’s changes are lost and things like input, raw_input, and +print will not work correctly.

With IDLE’s Shell, one enters, edits, and recalls complete statements. Some consoles only work with a single physical line at a time.

@@ -699,7 +701,7 @@ The Python Software Foundation is a non-profit corporation. Please donate.
- Last updated on Mar 20, 2016. + Last updated on May 02, 2016. Found a bug?
Created using Sphinx 1.3.3. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon May 2 18:30:35 2016 From: python-checkins at python.org (terry.reedy) Date: Mon, 02 May 2016 22:30:35 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Clarify_IDLE-c?= =?utf-8?q?onsole_differences_with_respect_to_the_sys_module=2E?= Message-ID: <20160502223035.27378.574.261EC1E6@psf.io> https://hg.python.org/cpython/rev/5ef3eda91051 changeset: 101215:5ef3eda91051 branch: 3.5 parent: 101212:538eeb8c3019 user: Terry Jan Reedy date: Mon May 02 18:30:02 2016 -0400 summary: Clarify IDLE-console differences with respect to the sys module. The reload(sys) effect was the crux of a Stackoverflow question. files: Doc/library/idle.rst | 16 +++++++++------- Lib/idlelib/help.html | 22 ++++++++++++---------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst --- a/Doc/library/idle.rst +++ b/Doc/library/idle.rst @@ -550,14 +550,16 @@ As much as possible, the result of executing Python code with IDLE is the same as executing the same code in a console window. However, the different -interface and operation occasionally affects results. +interface and operation occasionally affects visible results. For instance, +``sys.modules`` starts with more entries. -For instance, IDLE normally executes user code in a separate process from -the IDLE GUI itself. The IDLE versions of sys.stdin, .stdout, and .stderr in the -execution process get input from and send output to the GUI process, -which keeps control of the keyboard and screen. This is normally transparent, -but code that access these object will see different attribute values. -Also, functions that directly access the keyboard and screen will not work. +IDLE also replaces ``sys.stdin``, ``sys.stdout``, and ``sys.stderr`` with +objects that get input from and send output to the Shell window. +When this window has the focus, it controls the keyboard and screen. +This is normally transparent, but functions that directly access the keyboard +and screen will not work. If ``sys`` is reset with ``importlib.reload(sys)``, +IDLE's changes are lost and things li ke ``input``, ``raw_input``, and +``print`` will not work correctly. With IDLE's Shell, one enters, edits, and recalls complete statements. Some consoles only work with a single physical line at a time. diff --git a/Lib/idlelib/help.html b/Lib/idlelib/help.html --- a/Lib/idlelib/help.html +++ b/Lib/idlelib/help.html @@ -163,7 +163,7 @@
Find Selection
Search for the currently selected string, if there is one.
Find in Files...
-
Open a file search dialog. Put results in an new output window.
+
Open a file search dialog. Put results in a new output window.
Replace...
Open a search-and-replace dialog.
Go to Line
@@ -517,13 +517,15 @@

25.5.3.2. IDLE-console differences?

As much as possible, the result of executing Python code with IDLE is the same as executing the same code in a console window. However, the different -interface and operation occasionally affects results.

-

For instance, IDLE normally executes user code in a separate process from -the IDLE GUI itself. The IDLE versions of sys.stdin, .stdout, and .stderr in the -execution process get input from and send output to the GUI process, -which keeps control of the keyboard and screen. This is normally transparent, -but code that access these object will see different attribute values. -Also, functions that directly access the keyboard and screen will not work.

+interface and operation occasionally affects visible results. For instance, +sys.modules starts with more entries.

+

IDLE also replaces sys.stdin, sys.stdout, and sys.stderr with +objects that get input from and send output to the Shell window. +When this window has the focus, it controls the keyboard and screen. +This is normally transparent, but functions that directly access the keyboard +and screen will not work. If sys is reset with importlib.reload(sys), +IDLE’s changes are lost and things li ke input, raw_input, and +print will not work correctly.

With IDLE’s Shell, one enters, edits, and recalls complete statements. Some consoles only work with a single physical line at a time.

@@ -694,12 +696,12 @@ @@ -694,12 +696,12 @@ ', file=outfile) print('
', file=outfile) -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Tue May 3 03:52:27 2016 From: python-checkins at python.org (georg.brandl) Date: Tue, 03 May 2016 07:52:27 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Fix_lists-in-blockquotes_in_3?= =?utf-8?q?xxx_PEPs=2E_Ref=3A_=2326914?= Message-ID: <20160503075226.14942.3246.E4F5E0DE@psf.io> https://hg.python.org/peps/rev/d420d6fe349f changeset: 6301:d420d6fe349f user: Georg Brandl date: Tue May 03 09:51:54 2016 +0200 summary: Fix lists-in-blockquotes in 3xxx PEPs. Ref: #26914 files: pep-3103.txt | 10 +- pep-3104.txt | 40 ++-- pep-3108.txt | 304 +++++++++++++++++++------------------- pep-3121.txt | 8 +- pep-3127.txt | 76 ++++---- pep-3131.txt | 6 +- pep-3137.txt | 66 ++++---- pep-3147.txt | 4 +- pep-3149.txt | 20 +- pep-3150.txt | 38 ++-- 10 files changed, 284 insertions(+), 288 deletions(-) diff --git a/pep-3103.txt b/pep-3103.txt --- a/pep-3103.txt +++ b/pep-3103.txt @@ -567,11 +567,11 @@ inside a function. There are a few pragmatic choices for how to treat a switch outside a function: - (a) Disallow it. - (b) Translate it into an if/elif chain. - (c) Allow only compile-time constant expressions. - (d) Compute the dispatch dict each time the switch is reached. - (e) Like (b) but tests that all expressions evaluated are hashable. +(a) Disallow it. +(b) Translate it into an if/elif chain. +(c) Allow only compile-time constant expressions. +(d) Compute the dispatch dict each time the switch is reached. +(e) Like (b) but tests that all expressions evaluated are hashable. Of these, (a) seems too restrictive: it's uniformly worse than (c); and (d) has poor performance for little or no benefits compared to diff --git a/pep-3104.txt b/pep-3104.txt --- a/pep-3104.txt +++ b/pep-3104.txt @@ -295,26 +295,26 @@ Many spellings have been suggested for such a declaration: - - ``scoped x`` [1]_ - - ``global x in f`` [3]_ (explicitly specify which scope) - - ``free x`` [5]_ - - ``outer x`` [6]_ - - ``use x`` [9]_ - - ``global x`` [10]_ (change the meaning of ``global``) - - ``nonlocal x`` [11]_ - - ``global x outer`` [18]_ - - ``global in x`` [18]_ - - ``not global x`` [18]_ - - ``extern x`` [20]_ - - ``ref x`` [22]_ - - ``refer x`` [22]_ - - ``share x`` [22]_ - - ``sharing x`` [22]_ - - ``common x`` [22]_ - - ``using x`` [22]_ - - ``borrow x`` [22]_ - - ``reuse x`` [23]_ - - ``scope f x`` [25]_ (explicitly specify which scope) +- ``scoped x`` [1]_ +- ``global x in f`` [3]_ (explicitly specify which scope) +- ``free x`` [5]_ +- ``outer x`` [6]_ +- ``use x`` [9]_ +- ``global x`` [10]_ (change the meaning of ``global``) +- ``nonlocal x`` [11]_ +- ``global x outer`` [18]_ +- ``global in x`` [18]_ +- ``not global x`` [18]_ +- ``extern x`` [20]_ +- ``ref x`` [22]_ +- ``refer x`` [22]_ +- ``share x`` [22]_ +- ``sharing x`` [22]_ +- ``common x`` [22]_ +- ``using x`` [22]_ +- ``borrow x`` [22]_ +- ``reuse x`` [23]_ +- ``scope f x`` [25]_ (explicitly specify which scope) The most commonly discussed choices appear to be ``outer``, ``global``, and ``nonlocal``. ``outer`` is already used as both a diff --git a/pep-3108.txt b/pep-3108.txt --- a/pep-3108.txt +++ b/pep-3108.txt @@ -70,56 +70,56 @@ * cfmfile - + Documented as deprecated since Python 2.4 without an explicit - reason. + + Documented as deprecated since Python 2.4 without an explicit + reason. * cl - + Documented as obsolete since Python 2.0 or earlier. - + Interface to SGI hardware. + + Documented as obsolete since Python 2.0 or earlier. + + Interface to SGI hardware. * md5 - + Supplanted by the ``hashlib`` module. + + Supplanted by the ``hashlib`` module. * mimetools - + Documented as obsolete in a previous version. - + Supplanted by the ``email`` package. + + Documented as obsolete in a previous version. + + Supplanted by the ``email`` package. * MimeWriter - + Supplanted by the ``email`` package. + + Supplanted by the ``email`` package. * mimify - + Supplanted by the ``email`` package. + + Supplanted by the ``email`` package. * multifile - + Supplanted by the ``email`` package. + + Supplanted by the ``email`` package. * posixfile - + Locking is better done by ``fcntl.lockf()``. + + Locking is better done by ``fcntl.lockf()``. * rfc822 - + Supplanted by the ``email`` package. + + Supplanted by the ``email`` package. * sha - + Supplanted by the ``hashlib`` package. + + Supplanted by the ``hashlib`` package. * sv - + Documented as obsolete since Python 2.0 or earlier. - + Interface to obsolete SGI Indigo hardware. + + Documented as obsolete since Python 2.0 or earlier. + + Interface to obsolete SGI Indigo hardware. * timing - + Documented as obsolete since Python 2.0 or earlier. - + ``time.clock()`` gives better time resolution. + + Documented as obsolete since Python 2.0 or earlier. + + ``time.clock()`` gives better time resolution. Platform-specific with minimal use [done] @@ -136,120 +136,121 @@ for the specified platforms will also be removed. IRIX -/////////// +//// + The IRIX operating system is no longer produced [#irix-retirement]_. Removing all modules from the plat-irix[56] directory has been deemed reasonable because of this fact. - + AL/al ++ AL/al - - Provides sound support on Indy and Indigo workstations. - - Both workstations are no longer available. - - Code has not been uniquely edited in three years. + - Provides sound support on Indy and Indigo workstations. + - Both workstations are no longer available. + - Code has not been uniquely edited in three years. - + cd/CD ++ cd/CD - - CD drive control for SGI systems. - - SGI no longer sells machines with IRIX on them. - - Code has not been uniquely edited in 14 years. + - CD drive control for SGI systems. + - SGI no longer sells machines with IRIX on them. + - Code has not been uniquely edited in 14 years. - + cddb ++ cddb - - Undocumented. + - Undocumented. - + cdplayer ++ cdplayer - - Undocumented. + - Undocumented. - + cl/CL/CL_old ++ cl/CL/CL_old - - Compression library for SGI systems. - - SGI no longer sells machines with IRIX on them. - - Code has not been uniquely edited in 14 years. + - Compression library for SGI systems. + - SGI no longer sells machines with IRIX on them. + - Code has not been uniquely edited in 14 years. - + DEVICE/GL/gl/cgen/cgensuport ++ DEVICE/GL/gl/cgen/cgensuport - - GL access, which is the predecessor to OpenGL. - - Has not been edited in at least eight years. - - Third-party libraries provide better support (PyOpenGL [#pyopengl]_). + - GL access, which is the predecessor to OpenGL. + - Has not been edited in at least eight years. + - Third-party libraries provide better support (PyOpenGL [#pyopengl]_). - + ERRNO ++ ERRNO - - Undocumented. + - Undocumented. - + FILE ++ FILE - - Undocumented. + - Undocumented. - + FL/fl/flp ++ FL/fl/flp - - Wrapper for the FORMS library [#irix-forms]_ - - FORMS has not been edited in 12 years. - - Library is not widely used. - - First eight hits on Google are for Python docs for fl. + - Wrapper for the FORMS library [#irix-forms]_ + - FORMS has not been edited in 12 years. + - Library is not widely used. + - First eight hits on Google are for Python docs for fl. - + fm ++ fm - - Wrapper to the IRIS Font Manager library. - - Only available on SGI machines which no longer come with IRIX. + - Wrapper to the IRIS Font Manager library. + - Only available on SGI machines which no longer come with IRIX. - + GET ++ GET - - Undocumented. + - Undocumented. - + GLWS ++ GLWS - - Undocumented. + - Undocumented. - + imgfile ++ imgfile - - Wrapper for SGI libimage library for imglib image files - (``.rgb`` files). - - Python Imaging Library provdes read-only support [#pil]_. - - Not uniquely edited in 13 years. + - Wrapper for SGI libimage library for imglib image files + (``.rgb`` files). + - Python Imaging Library provdes read-only support [#pil]_. + - Not uniquely edited in 13 years. - + IN ++ IN - - Undocumented. + - Undocumented. - + IOCTL ++ IOCTL - - Undocumented. + - Undocumented. - + jpeg ++ jpeg - - Wrapper for JPEG (de)compressor. - - Code not uniquely edited in nine years. - - Third-party libraries provide better support - (Python Imaging Library [#pil]_). + - Wrapper for JPEG (de)compressor. + - Code not uniquely edited in nine years. + - Third-party libraries provide better support + (Python Imaging Library [#pil]_). - + panel ++ panel - - Undocumented. + - Undocumented. - + panelparser ++ panelparser - - Undocumented. + - Undocumented. - + readcd ++ readcd - - Undocumented. + - Undocumented. - + SV ++ SV - - Undocumented. + - Undocumented. - + torgb ++ torgb - - Undocumented. + - Undocumented. - + WAIT ++ WAIT - - Undocumented. + - Undocumented. Mac-specific modules -//////////////////////////// +//////////////////// The Mac-specific modules are not well-maintained (e.g., the bgen tool used to auto-generate many of the modules has never been @@ -261,108 +262,107 @@ * _builtinSuites - - Undocumented. - - Package under lib-scriptpackages. + - Undocumented. + - Package under lib-scriptpackages. * Audio_mac - - Undocumented. + - Undocumented. * aepack - - OSA support is better through third-party modules. + - OSA support is better through third-party modules. - * Appscript [#appscript]_. + * Appscript [#appscript]_. - - Hard-coded endianness which breaks on Intel Macs. - - Might need to rename if Carbon package dependent. + - Hard-coded endianness which breaks on Intel Macs. + - Might need to rename if Carbon package dependent. * aetools - - See aepack. + - See aepack. * aetypes - - See aepack. + - See aepack. * applesingle - - Undocumented. - - AppleSingle is a binary file format for A/UX. - - A/UX no longer distributed. + - Undocumented. + - AppleSingle is a binary file format for A/UX. + - A/UX no longer distributed. * appletrawmain - - Undocumented. + - Undocumented. * appletrunner - - Undocumented. + - Undocumented. * argvemulator - - Undocumented. + - Undocumented. * autoGIL - - Very bad model for using Python with the CFRunLoop. + - Very bad model for using Python with the CFRunLoop. * bgenlocations - - Undocumented. + - Undocumented. * buildtools - - Documented as deprecated since Python 2.3 without an explicit - reason. + - Documented as deprecated since Python 2.3 without an explicit + reason. * bundlebuilder - - Undocumented. + - Undocumented. * Carbon - - Carbon development has stopped. - - Does not support 64-bit systems completely. - - Dependent on bgen which has never been updated to support UCS-4 - Unicode builds of Python. + - Carbon development has stopped. + - Does not support 64-bit systems completely. + - Dependent on bgen which has never been updated to support UCS-4 + Unicode builds of Python. * CodeWarrior - - Undocumented. - - Package under lib-scriptpackages. + - Undocumented. + - Package under lib-scriptpackages. * ColorPicker - - Better to use Cocoa for GUIs. + - Better to use Cocoa for GUIs. * EasyDialogs - - Better to use Cocoa for GUIs. + - Better to use Cocoa for GUIs. * Explorer - - Undocumented. - - Package under lib-scriptpackages. + - Undocumented. + - Package under lib-scriptpackages. * Finder - - Undocumented. - - Package under lib-scriptpackages. - + - Undocumented. + - Package under lib-scriptpackages. * findertools - - No longer useful. + - No longer useful. * FrameWork - - Poorly documented. - - Not updated to support Carbon Events. + - Poorly documented. + - Not updated to support Carbon Events. * gensuitemodule - - See aepack. + - See aepack. * ic @@ -370,85 +370,84 @@ * icopen - - Not needed on OS X. - - Meant to replace 'open' which is usually a bad thing to do. + - Not needed on OS X. + - Meant to replace 'open' which is usually a bad thing to do. * macerrors - - Undocumented. + - Undocumented. * MacOS - - Would also mean the removal of binhex. + - Would also mean the removal of binhex. * macostools * macresource - - Undocumented. + - Undocumented. * MiniAEFrame - - See aepack. + - See aepack. * Nav - - Undocumented. + - Undocumented. * Netscape - - Undocumented. - - Package under lib-scriptpackages. + - Undocumented. + - Package under lib-scriptpackages. * OSATerminology * pimp - - Undocumented. + - Undocumented. * PixMapWrapper - - Undocumented. + - Undocumented. * StdSuites - - Undocumented. - - Package under lib-scriptpackages. + - Undocumented. + - Package under lib-scriptpackages. * SystemEvents - - Undocumented. - - Package under lib-scriptpackages. + - Undocumented. + - Package under lib-scriptpackages. * Terminal - - Undocumented. - - Package under lib-scriptpackages. - + - Undocumented. + - Package under lib-scriptpackages. * terminalcommand - - Undocumented. + - Undocumented. * videoreader - - No longer used. + - No longer used. * W - - No longer distributed with Python. + - No longer distributed with Python. .. _PyObjC: http://pyobjc.sourceforge.net/ Solaris -/////////////// +/////// - + SUNAUDIODEV/sunaudiodev ++ SUNAUDIODEV/sunaudiodev - - Access to the sound card on Sun machines. - - Code not uniquely edited in over eight years. + - Access to the sound card on Sun machines. + - Code not uniquely edited in over eight years. Hardly used [done] @@ -476,7 +475,6 @@ + Only useful with the 'sched' module. + Not thread-safe. - * stringold + Function versions of the methods on string objects. @@ -769,7 +767,7 @@ dbm package -////////////////// +/////////// ================= =============================== Current Name Replacement Name @@ -790,7 +788,7 @@ html package -/////////////////// +//////////// ================== =============================== Current Name Replacement Name @@ -801,7 +799,7 @@ http package -/////////////////// +//////////// ================= =============================== Current Name Replacement Name @@ -819,7 +817,7 @@ tkinter package -////////////////////// +/////////////// ================== =============================== Current Name Replacement Name @@ -850,7 +848,7 @@ urllib package -////////////////////////////////////////////////// +////////////// Originally this new package was to be named ``url``, but because of the common use of the name as a variable, it has been deemed better @@ -873,7 +871,7 @@ xmlrpc package -///////////////////// +////////////// ================== =============================== Current Name Replacement Name @@ -895,10 +893,8 @@ Issues related to this PEP: -* `Issue 2775`_ - Master tracking issue -* `Issue 2828`_ - clean up undoc.rst +* `Issue 2775`_: Master tracking issue +* `Issue 2828`_: clean up undoc.rst .. _Issue 2775: http://bugs.python.org/issue2775 .. _Issue 2828: http://bugs.python.org/issue2828 diff --git a/pep-3121.txt b/pep-3121.txt --- a/pep-3121.txt +++ b/pep-3121.txt @@ -190,13 +190,13 @@ at one point, and lists the following additional hooks which aren't currently supported in this PEP: - * when the module object is deleted from sys.modules +* when the module object is deleted from sys.modules - * when Py_Finalize is called +* when Py_Finalize is called - * when Python exits +* when Python exits - * when the Python DLL is unloaded (Windows only) +* when the Python DLL is unloaded (Windows only) References diff --git a/pep-3127.txt b/pep-3127.txt --- a/pep-3127.txt +++ b/pep-3127.txt @@ -24,14 +24,14 @@ The proposal is that: - a) octal literals must now be specified - with a leading "0o" or "0O" instead of "0"; +a) octal literals must now be specified + with a leading "0o" or "0O" instead of "0"; - b) binary literals are now supported via a - leading "0b" or "0B"; and +b) binary literals are now supported via a + leading "0b" or "0B"; and - c) provision will be made for binary numbers in - string formatting. +c) provision will be made for binary numbers in + string formatting. Motivation @@ -39,15 +39,15 @@ This PEP was motivated by two different issues: - - The default octal representation of integers is silently confusing - to people unfamiliar with C-like languages. It is extremely easy - to inadvertently create an integer object with the wrong value, - because '013' means 'decimal 11', not 'decimal 13', to the Python - language itself, which is not the meaning that most humans would - assign to this literal. +- The default octal representation of integers is silently confusing + to people unfamiliar with C-like languages. It is extremely easy + to inadvertently create an integer object with the wrong value, + because '013' means 'decimal 11', not 'decimal 13', to the Python + language itself, which is not the meaning that most humans would + assign to this literal. - - Some Python users have a strong desire for binary support in - the language. +- Some Python users have a strong desire for binary support in + the language. Specification @@ -175,22 +175,22 @@ Throughout this document, unless otherwise noted, discussions about the string representation of integers relate to these features: - - Literal integer tokens, as used by normal module compilation, - by eval(), and by int(token, 0). (int(token) and int(token, 2-36) - are not modified by this proposal.) +- Literal integer tokens, as used by normal module compilation, + by eval(), and by int(token, 0). (int(token) and int(token, 2-36) + are not modified by this proposal.) - * Under 2.6, long() is treated the same as int() + * Under 2.6, long() is treated the same as int() - - Formatting of integers into strings, either via the % string - operator or the new PEP 3101 advanced string formatting method. +- Formatting of integers into strings, either via the % string + operator or the new PEP 3101 advanced string formatting method. It is presumed that: - - All of these features should have an identical set - of supported radices, for consistency. +- All of these features should have an identical set + of supported radices, for consistency. - - Python source code syntax and int(mystring, 0) should - continue to share identical behavior. +- Python source code syntax and int(mystring, 0) should + continue to share identical behavior. Removal of old octal syntax @@ -239,14 +239,14 @@ occasionally or as a matter of habit, use leading zeros for decimal numbers. Python could either: - a) silently do the wrong thing with his numbers, as it does now; +a) silently do the wrong thing with his numbers, as it does now; - b) immediately disabuse him of the notion that this is viable syntax - (and yes, the SyntaxWarning should be more gentle than it - currently is, but that is a subject for a different PEP); or +b) immediately disabuse him of the notion that this is viable syntax + (and yes, the SyntaxWarning should be more gentle than it + currently is, but that is a subject for a different PEP); or - c) let him continue to think that computers are happy with - multi-digit decimal integers which start with "0". +c) let him continue to think that computers are happy with + multi-digit decimal integers which start with "0". Some people passionately believe that (c) is the correct answer, and they would be absolutely right if we could be sure that new @@ -416,16 +416,16 @@ (sometimes conflicting) requirements and "nice-to-haves" for this syntax: - - It should be as compatible with other languages and - previous versions of Python as is reasonable, both - for the input syntax and for the output (e.g. string - % operator) syntax. +- It should be as compatible with other languages and + previous versions of Python as is reasonable, both + for the input syntax and for the output (e.g. string + % operator) syntax. - - It should be as obvious to the casual observer as - possible. +- It should be as obvious to the casual observer as + possible. - - It should be easy to visually distinguish integers - formatted in the different bases. +- It should be easy to visually distinguish integers + formatted in the different bases. Proposed syntaxes included things like arbitrary radix prefixes, diff --git a/pep-3131.txt b/pep-3131.txt --- a/pep-3131.txt +++ b/pep-3131.txt @@ -144,9 +144,9 @@ It's not clear how that can precisely apply to this PEP; possible consequences are - * warn about characters listed as "restricted" in xidmodifications.txt - * warn about identifiers using mixed scripts - * somehow perform Confusable Detection +* warn about characters listed as "restricted" in xidmodifications.txt +* warn about identifiers using mixed scripts +* somehow perform Confusable Detection In the latter two approaches, it's not clear how precisely the algorithm should work. For mixed scripts, certain kinds of mixing diff --git a/pep-3137.txt b/pep-3137.txt --- a/pep-3137.txt +++ b/pep-3137.txt @@ -58,11 +58,11 @@ I propose the following type names at the Python level: - - ``bytes`` is an immutable array of bytes (PyString) +- ``bytes`` is an immutable array of bytes (PyString) - - ``bytearray`` is a mutable array of bytes (PyBytes) +- ``bytearray`` is a mutable array of bytes (PyBytes) - - ``memoryview`` is a bytes view on another object (PyMemory) +- ``memoryview`` is a bytes view on another object (PyMemory) The old type named ``buffer`` is so similar to the new type ``memoryview``, introduce by PEP 3118, that it is redundant. The rest @@ -116,27 +116,27 @@ There are four forms of constructors, applicable to both bytes and bytearray: - - ``bytes()``, ``bytes()``, ``bytearray()``, - ``bytearray()``: simple copying constructors, with the - note that ``bytes()`` might return its (immutable) - argument, but ``bytearray()`` always makes a copy. +- ``bytes()``, ``bytes()``, ``bytearray()``, + ``bytearray()``: simple copying constructors, with the + note that ``bytes()`` might return its (immutable) + argument, but ``bytearray()`` always makes a copy. - - ``bytes(, [, ])``, ``bytearray(, - [, ])``: encode a text string. Note that the - ``str.encode()`` method returns an *immutable* bytes object. The - argument is mandatory; is optional. - and , if given, must be ``str`` instances. +- ``bytes(, [, ])``, ``bytearray(, + [, ])``: encode a text string. Note that the + ``str.encode()`` method returns an *immutable* bytes object. The + argument is mandatory; is optional. + and , if given, must be ``str`` instances. - - ``bytes()``, ``bytearray()``: construct - a bytes or bytearray object from anything that implements the PEP - 3118 buffer API. +- ``bytes()``, ``bytearray()``: construct + a bytes or bytearray object from anything that implements the PEP + 3118 buffer API. - - ``bytes()``, ``bytearray()``: - construct a bytes or bytearray object from a stream of integers in - range(256). +- ``bytes()``, ``bytearray()``: + construct a bytes or bytearray object from a stream of integers in + range(256). - - ``bytes()``, ``bytearray()``: construct a - zero-initialized bytes or bytearray object of a given length. +- ``bytes()``, ``bytearray()``: construct a + zero-initialized bytes or bytearray object of a given length. Comparisons ----------- @@ -190,26 +190,26 @@ The following operators are implemented by the bytes and bytearray types, except where mentioned: - - ``b1 + b2``: concatenation. With mixed bytes/bytearray operands, - the return type is that of the first argument (this seems arbitrary - until you consider how ``+=`` works). +- ``b1 + b2``: concatenation. With mixed bytes/bytearray operands, + the return type is that of the first argument (this seems arbitrary + until you consider how ``+=`` works). - - ``b1 += b2``: mutates b1 if it is a bytearray object. +- ``b1 += b2``: mutates b1 if it is a bytearray object. - - ``b * n``, ``n * b``: repetition; n must be an integer. +- ``b * n``, ``n * b``: repetition; n must be an integer. - - ``b *= n``: mutates b if it is a bytearray object. +- ``b *= n``: mutates b if it is a bytearray object. - - ``b1 in b2``, ``b1 not in b2``: substring test; b1 can be any - object implementing the PEP 3118 buffer API. +- ``b1 in b2``, ``b1 not in b2``: substring test; b1 can be any + object implementing the PEP 3118 buffer API. - - ``i in b``, ``i not in b``: single-byte membership test; i must - be an integer (if it is a length-1 bytes array, it is considered - to be a substring test, with the same outcome). +- ``i in b``, ``i not in b``: single-byte membership test; i must + be an integer (if it is a length-1 bytes array, it is considered + to be a substring test, with the same outcome). - - ``len(b)``: the number of bytes. +- ``len(b)``: the number of bytes. - - ``hash(b)``: the hash value; only implemented by the bytes type. +- ``hash(b)``: the hash value; only implemented by the bytes type. Note that the % operator is *not* implemented. It does not appear worth the complexity. diff --git a/pep-3147.txt b/pep-3147.txt --- a/pep-3147.txt +++ b/pep-3147.txt @@ -426,8 +426,8 @@ To support this use case, we'll add two new methods to the `imp` package [17]_: - * `imp.cache_from_source(py_path)` -> `pyc_path` - * `imp.source_from_cache(pyc_path)` -> `py_path` +* `imp.cache_from_source(py_path)` -> `pyc_path` +* `imp.source_from_cache(pyc_path)` -> `py_path` Alternative implementations are free to override these functions to return reasonable values based on their own support for this PEP. diff --git a/pep-3149.txt b/pep-3149.txt --- a/pep-3149.txt +++ b/pep-3149.txt @@ -117,9 +117,9 @@ tag as appropriate. For example, on POSIX systems these flags will also contribute to the file name: - * ``--with-pydebug`` (flag: ``d``) - * ``--with-pymalloc`` (flag: ``m``) - * ``--with-wide-unicode`` (flag: ``u``) +* ``--with-pydebug`` (flag: ``d``) +* ``--with-pymalloc`` (flag: ``m``) +* ``--with-wide-unicode`` (flag: ``u``) By default in Python 3.2, ``configure`` enables ``--with-pymalloc`` so shared library file names would appear as ``foo.cpython-32m.so``. @@ -224,13 +224,13 @@ Martin v. L?wis describes his thoughts [7]_ about the applicability of this PEP to PEP 384. In summary: - * ``--with-pydebug`` would not be supported by the stable ABI because - this changes the layout of ``PyObject``, which is an exposed - structure. - * ``--with-pymalloc`` has no bearing on the issue. - * ``--with-wide-unicode`` is trickier, though Martin's inclination is - to force the stable ABI to use a ``Py_UNICODE`` that matches the - platform's ``wchar_t``. +* ``--with-pydebug`` would not be supported by the stable ABI because + this changes the layout of ``PyObject``, which is an exposed + structure. +* ``--with-pymalloc`` has no bearing on the issue. +* ``--with-wide-unicode`` is trickier, though Martin's inclination is + to force the stable ABI to use a ``Py_UNICODE`` that matches the + platform's ``wchar_t``. Alternatives diff --git a/pep-3150.txt b/pep-3150.txt --- a/pep-3150.txt +++ b/pep-3150.txt @@ -60,15 +60,15 @@ current list of simple statements that would be affected by this addition is as follows: - * expression statement - * assignment statement - * augmented assignment statement - * del statement - * return statement - * yield statement - * raise statement - * assert statement - * pass statement +* expression statement +* assignment statement +* augmented assignment statement +* del statement +* return statement +* yield statement +* raise statement +* assert statement +* pass statement The ``given`` clause would allow subexpressions to be referenced by name in the header line, with the actual definitions following in @@ -238,17 +238,17 @@ PEP proposes the following additions for ``given`` statements to the "Programming Conventions" section of PEP 8: - - for code that could reasonably be factored out into a separate function, - but is not currently reused anywhere, consider using a ``given`` clause. - This clearly indicates which variables are being used only to define - subcomponents of another statement rather than to hold algorithm or - application state. This is an especially useful technique when - passing multi-line functions to operations which take callable - arguments. +- for code that could reasonably be factored out into a separate function, + but is not currently reused anywhere, consider using a ``given`` clause. + This clearly indicates which variables are being used only to define + subcomponents of another statement rather than to hold algorithm or + application state. This is an especially useful technique when + passing multi-line functions to operations which take callable + arguments. - - keep ``given`` clauses concise. If they become unwieldy, either break - them up into multiple steps or else move the details into a separate - function. +- keep ``given`` clauses concise. If they become unwieldy, either break + them up into multiple steps or else move the details into a separate + function. Rationale -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Tue May 3 04:35:16 2016 From: python-checkins at python.org (georg.brandl) Date: Tue, 03 May 2016 08:35:16 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Fixup_some_more_lists-in-bloc?= =?utf-8?q?kquotes=2E_Fixes_=2326914=2E?= Message-ID: <20160503083515.1272.6979.799FDEB5@psf.io> https://hg.python.org/peps/rev/e7200e32b220 changeset: 6303:e7200e32b220 user: Georg Brandl date: Tue May 03 10:35:10 2016 +0200 summary: Fixup some more lists-in-blockquotes. Fixes #26914. files: pep-0318.txt | 2 +- pep-0410.txt | 32 ++++++++++++++++---------------- pep-0422.txt | 2 +- pep-0436.txt | 8 ++++---- pep-0446.txt | 24 ++++++++++++------------ pep-0495.txt | 40 ++++++++++++++++++++-------------------- pep-0498.txt | 8 ++++---- pep-3104.txt | 6 +++--- pep-3108.txt | 8 ++++---- pep-3127.txt | 2 +- pep-3141.txt | 26 +++++++++++++------------- pep-3149.txt | 4 ++-- pep-3156.txt | 14 +++++++------- 13 files changed, 88 insertions(+), 88 deletions(-) diff --git a/pep-0318.txt b/pep-0318.txt --- a/pep-0318.txt +++ b/pep-0318.txt @@ -396,7 +396,7 @@ http://mail.python.org/pipermail/python-dev/2004-August/047112.html The next form is that the decorator syntax goes inside the method body at -the start, in the same place that docstrings currently live: +the start, in the same place that docstrings currently live:: def foo(arg1,arg2): @classmethod diff --git a/pep-0410.txt b/pep-0410.txt --- a/pep-0410.txt +++ b/pep-0410.txt @@ -425,7 +425,7 @@ used: type(numerator) / type(denominator). A variant is to use a "converter" callback to create a timestamp. Example -creating a float timestamp: +creating a float timestamp:: def timestamp_to_float(numerator, denominator): return float(numerator) / float(denominator) @@ -520,24 +520,24 @@ Python: - * `Issue #7652: Merge C version of decimal into py3k `_ (cdecimal) - * `Issue #11457: os.stat(): add new fields to get timestamps as Decimal objects with nanosecond resolution `_ - * `Issue #13882: PEP 410: Use decimal.Decimal type for timestamps `_ - * `[Python-Dev] Store timestamps as decimal.Decimal objects `_ +* `Issue #7652: Merge C version of decimal into py3k `_ (cdecimal) +* `Issue #11457: os.stat(): add new fields to get timestamps as Decimal objects with nanosecond resolution `_ +* `Issue #13882: PEP 410: Use decimal.Decimal type for timestamps `_ +* `[Python-Dev] Store timestamps as decimal.Decimal objects `_ Other languages: - * Ruby (1.9.3), the `Time class `_ - supports picosecond (10\ :sup:`-12`) - * .NET framework, `DateTime type `_: - number of 100-nanosecond intervals that have elapsed since 12:00:00 - midnight, January 1, 0001. DateTime.Ticks uses a signed 64-bit integer. - * Java (1.5), `System.nanoTime() `_: - wallclock with an unspecified starting point as a number of nanoseconds, use - a signed 64 bits integer (long). - * Perl, `Time::Hiref module `_: - use float so has the same loss of precision issue with nanosecond resolution - than Python float timestamps +* Ruby (1.9.3), the `Time class `_ + supports picosecond (10\ :sup:`-12`) +* .NET framework, `DateTime type `_: + number of 100-nanosecond intervals that have elapsed since 12:00:00 + midnight, January 1, 0001. DateTime.Ticks uses a signed 64-bit integer. +* Java (1.5), `System.nanoTime() `_: + wallclock with an unspecified starting point as a number of nanoseconds, use + a signed 64 bits integer (long). +* Perl, `Time::Hiref module `_: + use float so has the same loss of precision issue with nanosecond resolution + than Python float timestamps Copyright diff --git a/pep-0422.txt b/pep-0422.txt --- a/pep-0422.txt +++ b/pep-0422.txt @@ -130,7 +130,7 @@ return cls To simplify the cooperative multiple inheritance case, ``object`` will gain -a default implementation of the hook that returns the class unmodified: +a default implementation of the hook that returns the class unmodified:: class object: def __autodecorate__(cls): diff --git a/pep-0436.txt b/pep-0436.txt --- a/pep-0436.txt +++ b/pep-0436.txt @@ -517,10 +517,10 @@ A list of strings representing acceptable Python types for this object. There are also four strings which represent Python protocols: - * "buffer" - * "mapping" - * "number" - * "sequence" + * "buffer" + * "mapping" + * "number" + * "sequence" ``zeroes`` For converters that accept string types. The converted value should diff --git a/pep-0446.txt b/pep-0446.txt --- a/pep-0446.txt +++ b/pep-0446.txt @@ -308,18 +308,18 @@ On UNIX, new flags were added for files and sockets: - * ``O_CLOEXEC``: available on Linux (2.6.23), FreeBSD (8.3), - Mac OS 10.8, OpenBSD 5.0, Solaris 11, QNX, BeOS, next NetBSD release - (6.1?). This flag is part of POSIX.1-2008. - * ``SOCK_CLOEXEC`` flag for ``socket()`` and ``socketpair()``, - available on Linux 2.6.27, OpenBSD 5.2, NetBSD 6.0. - * ``fcntl()``: ``F_DUPFD_CLOEXEC`` flag, available on Linux 2.6.24, - OpenBSD 5.0, FreeBSD 9.1, NetBSD 6.0, Solaris 11. This flag is part - of POSIX.1-2008. - * ``fcntl()``: ``F_DUP2FD_CLOEXEC`` flag, available on FreeBSD 9.1 - and Solaris 11. - * ``recvmsg()``: ``MSG_CMSG_CLOEXEC``, available on Linux 2.6.23, - NetBSD 6.0. +* ``O_CLOEXEC``: available on Linux (2.6.23), FreeBSD (8.3), + Mac OS 10.8, OpenBSD 5.0, Solaris 11, QNX, BeOS, next NetBSD release + (6.1?). This flag is part of POSIX.1-2008. +* ``SOCK_CLOEXEC`` flag for ``socket()`` and ``socketpair()``, + available on Linux 2.6.27, OpenBSD 5.2, NetBSD 6.0. +* ``fcntl()``: ``F_DUPFD_CLOEXEC`` flag, available on Linux 2.6.24, + OpenBSD 5.0, FreeBSD 9.1, NetBSD 6.0, Solaris 11. This flag is part + of POSIX.1-2008. +* ``fcntl()``: ``F_DUP2FD_CLOEXEC`` flag, available on FreeBSD 9.1 + and Solaris 11. +* ``recvmsg()``: ``MSG_CMSG_CLOEXEC``, available on Linux 2.6.23, + NetBSD 6.0. On Linux older than 2.6.23, ``O_CLOEXEC`` flag is simply ignored. So ``fcntl()`` must be called to check if the file descriptor is diff --git a/pep-0495.txt b/pep-0495.txt --- a/pep-0495.txt +++ b/pep-0495.txt @@ -676,29 +676,29 @@ The following alternative names have also been considered: - **later** - A close contender to "fold". One author dislikes it because - it is confusable with equally fitting "latter," but in the age - of auto-completion everywhere this is a small consideration. A - stronger objection may be that in the case of missing time, we - will have ``later=True`` instance converted to an earlier time by - ``.astimezone(timezone.utc)`` that that with ``later=False``. - Yet again, this can be interpreted as a desirable indication that - the original time is invalid. +**later** + A close contender to "fold". One author dislikes it because + it is confusable with equally fitting "latter," but in the age + of auto-completion everywhere this is a small consideration. A + stronger objection may be that in the case of missing time, we + will have ``later=True`` instance converted to an earlier time by + ``.astimezone(timezone.utc)`` that that with ``later=False``. + Yet again, this can be interpreted as a desirable indication that + the original time is invalid. - **which** - The `original`_ placeholder name for the `localtime` function - branch index was `independently proposed`_ for the name of the - disambiguation attribute and received `some support`_. +**which** + The `original`_ placeholder name for the `localtime` function + branch index was `independently proposed`_ for the name of the + disambiguation attribute and received `some support`_. - **repeated** - Did not receive any support on the mailing list. +**repeated** + Did not receive any support on the mailing list. - **ltdf** - (Local Time Disambiguation Flag) - short and no-one will attempt - to guess what it means without reading the docs. (This abbreviation - was used in PEP discussions with the meaning ``ltdf=False`` is the - earlier by those who didn't want to endorse any of the alternatives.) +**ltdf** + (Local Time Disambiguation Flag) - short and no-one will attempt + to guess what it means without reading the docs. (This abbreviation + was used in PEP discussions with the meaning ``ltdf=False`` is the + earlier by those who didn't want to endorse any of the alternatives.) .. _original: https://mail.python.org/pipermail/python-dev/2015-April/139099.html .. _independently proposed: https://mail.python.org/pipermail/datetime-sig/2015-August/000479.html diff --git a/pep-0498.txt b/pep-0498.txt --- a/pep-0498.txt +++ b/pep-0498.txt @@ -616,11 +616,11 @@ recently in PEP 461 [#]_. The discussions of such a feature usually suggest either - - adding a method such as ``__bformat__()`` so an object can control - how it is converted to bytes, or +- adding a method such as ``__bformat__()`` so an object can control + how it is converted to bytes, or - - having ``bytes.format()`` not be as general purpose or extensible - as ``str.format()``. +- having ``bytes.format()`` not be as general purpose or extensible + as ``str.format()``. Both of these remain as options in the future, if such functionality is desired. diff --git a/pep-3104.txt b/pep-3104.txt --- a/pep-3104.txt +++ b/pep-3104.txt @@ -190,9 +190,9 @@ statement similar to JavaScript's ``var``. A few possible keywords have been proposed for this purpose: - - ``scope x`` [4]_ - - ``var x`` [4]_ [9]_ - - ``my x`` [13]_ +- ``scope x`` [4]_ +- ``var x`` [4]_ [9]_ +- ``my x`` [13]_ In all these proposals, a declaration such as ``var x`` in a particular scope S would cause all references to ``x`` in scopes diff --git a/pep-3108.txt b/pep-3108.txt --- a/pep-3108.txt +++ b/pep-3108.txt @@ -431,11 +431,11 @@ * videoreader - - No longer used. + - No longer used. * W - - No longer distributed with Python. + - No longer distributed with Python. .. _PyObjC: http://pyobjc.sourceforge.net/ @@ -1051,7 +1051,7 @@ * audioop/sunau/aifc - + Audio modules where the formats are still used. + + Audio modules where the formats are still used. * base64/quopri/uu @@ -1065,7 +1065,7 @@ * linecache - + Used internally in several places. + + Used internally in several places. * nis diff --git a/pep-3127.txt b/pep-3127.txt --- a/pep-3127.txt +++ b/pep-3127.txt @@ -179,7 +179,7 @@ by eval(), and by int(token, 0). (int(token) and int(token, 2-36) are not modified by this proposal.) - * Under 2.6, long() is treated the same as int() + * Under 2.6, long() is treated the same as int() - Formatting of integers into strings, either via the % string operator or the new PEP 3101 advanced string formatting method. diff --git a/pep-3141.txt b/pep-3141.txt --- a/pep-3141.txt +++ b/pep-3141.txt @@ -467,19 +467,19 @@ instance of ``A``, which is a subtype of ``Complex`` (``a : A <: Complex``), and ``b : B <: Complex``. I'll consider ``a + b``: - 1. If A defines an __add__ which accepts b, all is well. - 2. If A falls back to the boilerplate code, and it were to return - a value from __add__, we'd miss the possibility that B defines - a more intelligent __radd__, so the boilerplate should return - NotImplemented from __add__. (Or A may not implement __add__ at - all.) - 3. Then B's __radd__ gets a chance. If it accepts a, all is well. - 4. If it falls back to the boilerplate, there are no more possible - methods to try, so this is where the default implementation - should live. - 5. If B <: A, Python tries B.__radd__ before A.__add__. This is - ok, because it was implemented with knowledge of A, so it can - handle those instances before delegating to Complex. +1. If A defines an __add__ which accepts b, all is well. +2. If A falls back to the boilerplate code, and it were to return + a value from __add__, we'd miss the possibility that B defines + a more intelligent __radd__, so the boilerplate should return + NotImplemented from __add__. (Or A may not implement __add__ at + all.) +3. Then B's __radd__ gets a chance. If it accepts a, all is well. +4. If it falls back to the boilerplate, there are no more possible + methods to try, so this is where the default implementation + should live. +5. If B <: A, Python tries B.__radd__ before A.__add__. This is + ok, because it was implemented with knowledge of A, so it can + handle those instances before delegating to Complex. If ``A<:Complex`` and ``B<:Real`` without sharing any other knowledge, then the appropriate shared operation is the one involving the built diff --git a/pep-3149.txt b/pep-3149.txt --- a/pep-3149.txt +++ b/pep-3149.txt @@ -107,8 +107,8 @@ The following information *MUST* be included in the shared library file name: - * The Python implementation (e.g. cpython, pypy, jython, etc.) - * The interpreter's major and minor version numbers +* The Python implementation (e.g. cpython, pypy, jython, etc.) +* The interpreter's major and minor version numbers These two fields are separated by a hyphen and no dots are to appear between the major and minor version numbers. E.g. ``cpython-32``. diff --git a/pep-3156.txt b/pep-3156.txt --- a/pep-3156.txt +++ b/pep-3156.txt @@ -1386,10 +1386,10 @@ Here is a table indicating the order and multiplicity of the basic calls: - 1. ``connection_made()`` -- exactly once - 2. ``data_received()`` -- zero or more times - 3. ``eof_received()`` -- at most once - 4. ``connection_lost()`` -- exactly once +1. ``connection_made()`` -- exactly once +2. ``data_received()`` -- zero or more times +3. ``eof_received()`` -- at most once +4. ``connection_lost()`` -- exactly once Calls to ``pause_writing()`` and ``resume_writing()`` occur in pairs and only between #1 and #4. These pairs will not be nested. The @@ -1418,9 +1418,9 @@ Here is a chart indicating the order and multiplicity of calls: - 1. ``connection_made()`` -- exactly once - 2. ``datagram_received()``, ``error_received()`` -- zero or more times - 3. ``connection_lost()`` -- exactly once +1. ``connection_made()`` -- exactly once +2. ``datagram_received()``, ``error_received()`` -- zero or more times +3. ``connection_lost()`` -- exactly once Subprocess Protocol -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Tue May 3 04:35:18 2016 From: python-checkins at python.org (georg.brandl) Date: Tue, 03 May 2016 08:35:18 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Fix_lists-in-blockquotes_in_0?= =?utf-8?q?xxx_PEPs=2E_Ref=3A_=2326914?= Message-ID: <20160503083515.84492.72361.3AAB535B@psf.io> https://hg.python.org/peps/rev/d34c698f63a3 changeset: 6302:d34c698f63a3 user: Georg Brandl date: Tue May 03 10:18:02 2016 +0200 summary: Fix lists-in-blockquotes in 0xxx PEPs. Ref: #26914 files: pep-0302.txt | 144 ++++++------ pep-0327.txt | 12 +- pep-0339.txt | 102 ++++---- pep-0362.txt | 100 ++++---- pep-0364.txt | 26 +- pep-0372.txt | 2 +- pep-0380.txt | 57 ++-- pep-0382.txt | 20 +- pep-0393.txt | 16 +- pep-0400.txt | 170 ++++++++-------- pep-0403.txt | 10 +- pep-0404.txt | 2 +- pep-0410.txt | 114 +++++----- pep-0416.txt | 226 ++++++++++---------- pep-0418.txt | 16 +- pep-0426.txt | 32 +- pep-0432.txt | 70 ++++- pep-0433.txt | 407 ++++++++++++++++++++------------------ pep-0437.txt | 74 +++--- pep-0446.txt | 40 +- pep-0457.txt | 72 +++--- pep-0461.txt | 36 +- pep-0472.txt | 12 +- pep-0488.txt | 12 +- pep-0498.txt | 6 +- pep-0628.txt | 12 +- 26 files changed, 920 insertions(+), 870 deletions(-) diff --git a/pep-0302.txt b/pep-0302.txt --- a/pep-0302.txt +++ b/pep-0302.txt @@ -34,15 +34,15 @@ built-in ``__import__`` function. However, overriding ``__import__`` has many problems. To begin with: - * An ``__import__`` replacement needs to *fully* reimplement the entire - import mechanism, or call the original ``__import__`` before or after the - custom code. +* An ``__import__`` replacement needs to *fully* reimplement the entire + import mechanism, or call the original ``__import__`` before or after the + custom code. - * It has very complex semantics and responsibilities. +* It has very complex semantics and responsibilities. - * ``__import__`` gets called even for modules that are already in - ``sys.modules``, which is almost never what you want, unless you're writing - some sort of monitoring tool. +* ``__import__`` gets called even for modules that are already in + ``sys.modules``, which is almost never what you want, unless you're writing + some sort of monitoring tool. The situation gets worse when you need to extend the import mechanism from C: it's currently impossible, apart from hacking Python's ``import.c`` or @@ -233,61 +233,61 @@ The ``load_module()`` method has a few responsibilities that it must fulfill *before* it runs any code: - * If there is an existing module object named 'fullname' in ``sys.modules``, - the loader must use that existing module. (Otherwise, the ``reload()`` - builtin will not work correctly.) If a module named 'fullname' does not - exist in ``sys.modules``, the loader must create a new module object and - add it to ``sys.modules``. +* If there is an existing module object named 'fullname' in ``sys.modules``, + the loader must use that existing module. (Otherwise, the ``reload()`` + builtin will not work correctly.) If a module named 'fullname' does not + exist in ``sys.modules``, the loader must create a new module object and + add it to ``sys.modules``. - Note that the module object *must* be in ``sys.modules`` before the loader - executes the module code. This is crucial because the module code may - (directly or indirectly) import itself; adding it to ``sys.modules`` - beforehand prevents unbounded recursion in the worst case and multiple - loading in the best. + Note that the module object *must* be in ``sys.modules`` before the loader + executes the module code. This is crucial because the module code may + (directly or indirectly) import itself; adding it to ``sys.modules`` + beforehand prevents unbounded recursion in the worst case and multiple + loading in the best. - If the load fails, the loader needs to remove any module it may have - inserted into ``sys.modules``. If the module was already in ``sys.modules`` - then the loader should leave it alone. + If the load fails, the loader needs to remove any module it may have + inserted into ``sys.modules``. If the module was already in ``sys.modules`` + then the loader should leave it alone. - * The ``__file__`` attribute must be set. This must be a string, but it may - be a dummy value, for example "". The privilege of not having a - ``__file__`` attribute at all is reserved for built-in modules. +* The ``__file__`` attribute must be set. This must be a string, but it may + be a dummy value, for example "". The privilege of not having a + ``__file__`` attribute at all is reserved for built-in modules. - * The ``__name__`` attribute must be set. If one uses ``imp.new_module()`` - then the attribute is set automatically. +* The ``__name__`` attribute must be set. If one uses ``imp.new_module()`` + then the attribute is set automatically. - * If it's a package, the ``__path__`` variable must be set. This must be a - list, but may be empty if ``__path__`` has no further significance to the - importer (more on this later). +* If it's a package, the ``__path__`` variable must be set. This must be a + list, but may be empty if ``__path__`` has no further significance to the + importer (more on this later). - * The ``__loader__`` attribute must be set to the loader object. This is - mostly for introspection and reloading, but can be used for - importer-specific extras, for example getting data associated with an - importer. +* The ``__loader__`` attribute must be set to the loader object. This is + mostly for introspection and reloading, but can be used for + importer-specific extras, for example getting data associated with an + importer. - * The ``__package__`` attribute [8]_ must be set. +* The ``__package__`` attribute [8]_ must be set. - If the module is a Python module (as opposed to a built-in module or a - dynamically loaded extension), it should execute the module's code in the - module's global name space (``module.__dict__``). + If the module is a Python module (as opposed to a built-in module or a + dynamically loaded extension), it should execute the module's code in the + module's global name space (``module.__dict__``). - Here is a minimal pattern for a ``load_module()`` method:: + Here is a minimal pattern for a ``load_module()`` method:: - # Consider using importlib.util.module_for_loader() to handle - # most of these details for you. - def load_module(self, fullname): - code = self.get_code(fullname) - ispkg = self.is_package(fullname) - mod = sys.modules.setdefault(fullname, imp.new_module(fullname)) - mod.__file__ = "<%s>" % self.__class__.__name__ - mod.__loader__ = self - if ispkg: - mod.__path__ = [] - mod.__package__ = fullname - else: - mod.__package__ = fullname.rpartition('.')[0] - exec(code, mod.__dict__) - return mod + # Consider using importlib.util.module_for_loader() to handle + # most of these details for you. + def load_module(self, fullname): + code = self.get_code(fullname) + ispkg = self.is_package(fullname) + mod = sys.modules.setdefault(fullname, imp.new_module(fullname)) + mod.__file__ = "<%s>" % self.__class__.__name__ + mod.__loader__ = self + if ispkg: + mod.__path__ = [] + mod.__package__ = fullname + else: + mod.__package__ = fullname.rpartition('.')[0] + exec(code, mod.__dict__) + return mod Specification part 2: Registering Hooks @@ -326,8 +326,8 @@ Just like ``sys.path`` itself, the new ``sys`` variables must have specific types: - * ``sys.meta_path`` and ``sys.path_hooks`` must be Python lists. - * ``sys.path_importer_cache`` must be a Python dict. +* ``sys.meta_path`` and ``sys.path_hooks`` must be Python lists. +* ``sys.path_importer_cache`` must be a Python dict. Modifying these variables in place is allowed, as is replacing them with new objects. @@ -457,26 +457,26 @@ There are a number of possible ways to address this problem: - * "Don't do that". If a package needs to locate data files via its - ``__path__``, it is not suitable for loading via an import hook. The - package can still be located on a directory in ``sys.path``, as at present, - so this should not be seen as a major issue. +* "Don't do that". If a package needs to locate data files via its + ``__path__``, it is not suitable for loading via an import hook. The + package can still be located on a directory in ``sys.path``, as at present, + so this should not be seen as a major issue. - * Locate data files from a standard location, rather than relative to the - module file. A relatively simple approach (which is supported by - distutils) would be to locate data files based on ``sys.prefix`` (or - ``sys.exec_prefix``). For example, looking in - ``os.path.join(sys.prefix, "data", package_name)``. +* Locate data files from a standard location, rather than relative to the + module file. A relatively simple approach (which is supported by + distutils) would be to locate data files based on ``sys.prefix`` (or + ``sys.exec_prefix``). For example, looking in + ``os.path.join(sys.prefix, "data", package_name)``. - * Import hooks could offer a standard way of getting at data files relative - to the module file. The standard ``zipimport`` object provides a method - ``get_data(name)`` which returns the content of the "file" called ``name``, - as a string. To allow modules to get at the importer object, ``zipimport`` - also adds an attribute ``__loader__`` to the module, containing the - ``zipimport`` object used to load the module. If such an approach is used, - it is important that client code takes care not to break if the - ``get_data()`` method is not available, so it is not clear that this - approach offers a general answer to the problem. +* Import hooks could offer a standard way of getting at data files relative + to the module file. The standard ``zipimport`` object provides a method + ``get_data(name)`` which returns the content of the "file" called ``name``, + as a string. To allow modules to get at the importer object, ``zipimport`` + also adds an attribute ``__loader__`` to the module, containing the + ``zipimport`` object used to load the module. If such an approach is used, + it is important that client code takes care not to break if the + ``get_data()`` method is not available, so it is not clear that this + approach offers a general answer to the problem. It was suggested on python-dev that it would be useful to be able to receive a list of available modules from an importer and/or a list of available data diff --git a/pep-0327.txt b/pep-0327.txt --- a/pep-0327.txt +++ b/pep-0327.txt @@ -499,12 +499,12 @@ The initial discussion on this item was what should happen when passing floating point to the constructor: - 1. ``Decimal(1.1) == Decimal('1.1')`` +1. ``Decimal(1.1) == Decimal('1.1')`` - 2. ``Decimal(1.1) == - Decimal('110000000000000008881784197001252...e-51')`` +2. ``Decimal(1.1) == + Decimal('110000000000000008881784197001252...e-51')`` - 3. an exception is raised +3. an exception is raised Several people alleged that (1) is the better option here, because it's what you expect when writing ``Decimal(1.1)``. And quoting John @@ -1180,14 +1180,14 @@ These are methods that return useful information from the Context: -- ``Etiny()``: Minimum exponent considering precision. +- ``Etiny()``: Minimum exponent considering precision. :: >>> c.Emin -999999999 >>> c.Etiny() -1000000007 -- ``Etop()``: Maximum exponent considering precision. +- ``Etop()``: Maximum exponent considering precision. :: >>> c.Emax 999999999 diff --git a/pep-0339.txt b/pep-0339.txt --- a/pep-0339.txt +++ b/pep-0339.txt @@ -428,12 +428,12 @@ + Parser/ - - Python.asdl - ASDL syntax file + - Python.asdl + ASDL syntax file - - asdl.py - "An implementation of the Zephyr Abstract Syntax Definition - Language." Uses SPARK_ to parse the ASDL files. + - asdl.py + "An implementation of the Zephyr Abstract Syntax Definition + Language." Uses SPARK_ to parse the ASDL files. - asdl_c.py "Generate C code from an ASDL description." Generates @@ -444,86 +444,86 @@ + Python/ - - Python-ast.c - Creates C structs corresponding to the ASDL types. Also + - Python-ast.c + Creates C structs corresponding to the ASDL types. Also contains code for marshaling AST nodes (core ASDL types have marshaling code in asdl.c). "File automatically generated by Parser/asdl_c.py". This file must be committed separately - after every grammar change is committed since the __version__ - value is set to the latest grammar change revision number. + after every grammar change is committed since the __version__ + value is set to the latest grammar change revision number. - - asdl.c - Contains code to handle the ASDL sequence type. Also has code - to handle marshalling the core ASDL types, such as number and - identifier. used by Python-ast.c for marshaling AST nodes. + - asdl.c + Contains code to handle the ASDL sequence type. Also has code + to handle marshalling the core ASDL types, such as number and + identifier. used by Python-ast.c for marshaling AST nodes. - - ast.c - Converts Python's parse tree into the abstract syntax tree. + - ast.c + Converts Python's parse tree into the abstract syntax tree. - - ceval.c - Executes byte code (aka, eval loop). + - ceval.c + Executes byte code (aka, eval loop). - - compile.c - Emits bytecode based on the AST. + - compile.c + Emits bytecode based on the AST. - - symtable.c + - symtable.c Generates a symbol table from AST. - - pyarena.c - Implementation of the arena memory manager. + - pyarena.c + Implementation of the arena memory manager. - - import.c - Home of the magic number (named ``MAGIC``) for bytecode versioning + - import.c + Home of the magic number (named ``MAGIC``) for bytecode versioning + Include/ - - Python-ast.h - Contains the actual definitions of the C structs as generated by - Python/Python-ast.c . - "Automatically generated by Parser/asdl_c.py". + - Python-ast.h + Contains the actual definitions of the C structs as generated by + Python/Python-ast.c . + "Automatically generated by Parser/asdl_c.py". - - asdl.h - Header for the corresponding Python/ast.c . + - asdl.h + Header for the corresponding Python/ast.c . - - ast.h - Declares PyAST_FromNode() external (from Python/ast.c). + - ast.h + Declares PyAST_FromNode() external (from Python/ast.c). - - code.h + - code.h Header file for Objects/codeobject.c; contains definition of PyCodeObject. - - symtable.h + - symtable.h Header for Python/symtable.c . struct symtable and PySTEntryObject are defined here. - - pyarena.h - Header file for the corresponding Python/pyarena.c . + - pyarena.h + Header file for the corresponding Python/pyarena.c . - - opcode.h - Master list of bytecode; if this file is modified you must modify - several other files accordingly (see "`Introducing New Bytecode`_") + - opcode.h + Master list of bytecode; if this file is modified you must modify + several other files accordingly (see "`Introducing New Bytecode`_") + Objects/ - - codeobject.c - Contains PyCodeObject-related code (originally in - Python/compile.c). + - codeobject.c + Contains PyCodeObject-related code (originally in + Python/compile.c). + Lib/ - - opcode.py - One of the files that must be modified if Include/opcode.h is. + - opcode.py + One of the files that must be modified if Include/opcode.h is. - - compiler/ + - compiler/ - * pyassem.py - One of the files that must be modified if Include/opcode.h is - changed. + * pyassem.py + One of the files that must be modified if Include/opcode.h is + changed. - * pycodegen.py - One of the files that must be modified if Include/opcode.h is - changed. + * pycodegen.py + One of the files that must be modified if Include/opcode.h is + changed. Known Compiler-related Experiments diff --git a/pep-0362.txt b/pep-0362.txt --- a/pep-0362.txt +++ b/pep-0362.txt @@ -151,32 +151,32 @@ Describes how argument values are bound to the parameter. Possible values: - * ``Parameter.POSITIONAL_ONLY`` - value must be supplied - as a positional argument. + * ``Parameter.POSITIONAL_ONLY`` - value must be supplied + as a positional argument. - Python has no explicit syntax for defining positional-only - parameters, but many built-in and extension module functions - (especially those that accept only one or two parameters) - accept them. + Python has no explicit syntax for defining positional-only + parameters, but many built-in and extension module functions + (especially those that accept only one or two parameters) + accept them. - * ``Parameter.POSITIONAL_OR_KEYWORD`` - value may be - supplied as either a keyword or positional argument - (this is the standard binding behaviour for functions - implemented in Python.) + * ``Parameter.POSITIONAL_OR_KEYWORD`` - value may be + supplied as either a keyword or positional argument + (this is the standard binding behaviour for functions + implemented in Python.) - * ``Parameter.KEYWORD_ONLY`` - value must be supplied - as a keyword argument. Keyword only parameters are those - which appear after a "*" or "\*args" entry in a Python - function definition. + * ``Parameter.KEYWORD_ONLY`` - value must be supplied + as a keyword argument. Keyword only parameters are those + which appear after a "*" or "\*args" entry in a Python + function definition. - * ``Parameter.VAR_POSITIONAL`` - a tuple of positional - arguments that aren't bound to any other parameter. - This corresponds to a "\*args" parameter in a Python - function definition. + * ``Parameter.VAR_POSITIONAL`` - a tuple of positional + arguments that aren't bound to any other parameter. + This corresponds to a "\*args" parameter in a Python + function definition. - * ``Parameter.VAR_KEYWORD`` - a dict of keyword arguments - that aren't bound to any other parameter. This corresponds - to a "\*\*kwargs" parameter in a Python function definition. + * ``Parameter.VAR_KEYWORD`` - a dict of keyword arguments + that aren't bound to any other parameter. This corresponds + to a "\*\*kwargs" parameter in a Python function definition. Always use ``Parameter.*`` constants for setting and checking value of the ``kind`` attribute. @@ -271,39 +271,39 @@ The function implements the following algorithm: - - If the object is not callable - raise a TypeError +- If the object is not callable - raise a TypeError - - If the object has a ``__signature__`` attribute and if it - is not ``None`` - return it +- If the object has a ``__signature__`` attribute and if it + is not ``None`` - return it - - If it has a ``__wrapped__`` attribute, return - ``signature(object.__wrapped__)`` +- If it has a ``__wrapped__`` attribute, return + ``signature(object.__wrapped__)`` - - If the object is an instance of ``FunctionType``, construct - and return a new ``Signature`` for it +- If the object is an instance of ``FunctionType``, construct + and return a new ``Signature`` for it - - If the object is a bound method, construct and return a new ``Signature`` - object, with its first parameter (usually ``self`` or ``cls``) - removed. (``classmethod`` and ``staticmethod`` are supported - too. Since both are descriptors, the former returns a bound method, - and the latter returns its wrapped function.) +- If the object is a bound method, construct and return a new ``Signature`` + object, with its first parameter (usually ``self`` or ``cls``) + removed. (``classmethod`` and ``staticmethod`` are supported + too. Since both are descriptors, the former returns a bound method, + and the latter returns its wrapped function.) - - If the object is an instance of ``functools.partial``, construct - a new ``Signature`` from its ``partial.func`` attribute, and - account for already bound ``partial.args`` and ``partial.kwargs`` +- If the object is an instance of ``functools.partial``, construct + a new ``Signature`` from its ``partial.func`` attribute, and + account for already bound ``partial.args`` and ``partial.kwargs`` - - If the object is a class or metaclass: +- If the object is a class or metaclass: - - If the object's type has a ``__call__`` method defined in - its MRO, return a Signature for it + - If the object's type has a ``__call__`` method defined in + its MRO, return a Signature for it - - If the object has a ``__new__`` method defined in its MRO, - return a Signature object for it + - If the object has a ``__new__`` method defined in its MRO, + return a Signature object for it - - If the object has a ``__init__`` method defined in its MRO, - return a Signature object for it + - If the object has a ``__init__`` method defined in its MRO, + return a Signature object for it - - Return ``signature(object.__call__)`` +- Return ``signature(object.__call__)`` Note that the ``Signature`` object is created in a lazy manner, and is not automatically cached. However, the user can manually cache a @@ -323,13 +323,13 @@ objects in the ``inspect.signature()`` function. However, this has the following downsides: - * If the ``Signature`` object is cached then any changes to the function - it describes will not be reflected in it. However, If the caching is - needed, it can be always done manually and explicitly +* If the ``Signature`` object is cached then any changes to the function + it describes will not be reflected in it. However, If the caching is + needed, it can be always done manually and explicitly - * It is better to reserve the ``__signature__`` attribute for the cases - when there is a need to explicitly set to a ``Signature`` object that - is different from the actual one +* It is better to reserve the ``__signature__`` attribute for the cases + when there is a need to explicitly set to a ``Signature`` object that + is different from the actual one Some functions may not be introspectable diff --git a/pep-0364.txt b/pep-0364.txt --- a/pep-0364.txt +++ b/pep-0364.txt @@ -206,23 +206,23 @@ Open Issues =========== - - Should there be a command line switch and/or environment variable to - disable all remappings? +- Should there be a command line switch and/or environment variable to + disable all remappings? - - Should remappings occur recursively? +- Should remappings occur recursively? - - Should we automatically parse package directories for .mv files when - the package's __init__.py is loaded? This would allow packages to - easily include .mv files for their own remappings. Compare what the - email package currently has to do if we place its ``.mv`` file in - the email package instead of in the oldlib package:: +- Should we automatically parse package directories for .mv files when + the package's __init__.py is loaded? This would allow packages to + easily include .mv files for their own remappings. Compare what the + email package currently has to do if we place its ``.mv`` file in + the email package instead of in the oldlib package:: - # Expose old names - import os, sys - sys.stdlib_remapper.read_directory_mv_files(os.path.dirname(__file__)) + # Expose old names + import os, sys + sys.stdlib_remapper.read_directory_mv_files(os.path.dirname(__file__)) - I think we should automatically read a package's directory for any - ``.mv`` files it might contain. + I think we should automatically read a package's directory for any + ``.mv`` files it might contain. Reference Implementation diff --git a/pep-0372.txt b/pep-0372.txt --- a/pep-0372.txt +++ b/pep-0372.txt @@ -317,6 +317,7 @@ This document has been placed in the public domain. + .. Local Variables: mode: indented-text @@ -325,4 +326,3 @@ fill-column: 70 coding: utf-8 End: - diff --git a/pep-0380.txt b/pep-0380.txt --- a/pep-0380.txt +++ b/pep-0380.txt @@ -85,35 +85,35 @@ The full semantics of the ``yield from`` expression can be described in terms of the generator protocol as follows: - * Any values that the iterator yields are passed directly to the - caller. +* Any values that the iterator yields are passed directly to the + caller. - * Any values sent to the delegating generator using ``send()`` are - passed directly to the iterator. If the sent value is None, the - iterator's ``__next__()`` method is called. If the sent value - is not None, the iterator's ``send()`` method is called. If the - call raises StopIteration, the delegating generator is resumed. - Any other exception is propagated to the delegating generator. +* Any values sent to the delegating generator using ``send()`` are + passed directly to the iterator. If the sent value is None, the + iterator's ``__next__()`` method is called. If the sent value + is not None, the iterator's ``send()`` method is called. If the + call raises StopIteration, the delegating generator is resumed. + Any other exception is propagated to the delegating generator. - * Exceptions other than GeneratorExit thrown into the delegating - generator are passed to the ``throw()`` method of the iterator. - If the call raises StopIteration, the delegating generator is - resumed. Any other exception is propagated to the delegating - generator. +* Exceptions other than GeneratorExit thrown into the delegating + generator are passed to the ``throw()`` method of the iterator. + If the call raises StopIteration, the delegating generator is + resumed. Any other exception is propagated to the delegating + generator. - * If a GeneratorExit exception is thrown into the delegating - generator, or the ``close()`` method of the delegating generator - is called, then the ``close()`` method of the iterator is called - if it has one. If this call results in an exception, it is - propagated to the delegating generator. Otherwise, - GeneratorExit is raised in the delegating generator. +* If a GeneratorExit exception is thrown into the delegating + generator, or the ``close()`` method of the delegating generator + is called, then the ``close()`` method of the iterator is called + if it has one. If this call results in an exception, it is + propagated to the delegating generator. Otherwise, + GeneratorExit is raised in the delegating generator. - * The value of the ``yield from`` expression is the first argument - to the ``StopIteration`` exception raised by the iterator when - it terminates. +* The value of the ``yield from`` expression is the first argument + to the ``StopIteration`` exception raised by the iterator when + it terminates. - * ``return expr`` in a generator causes ``StopIteration(expr)`` to - be raised upon exit from the generator. +* ``return expr`` in a generator causes ``StopIteration(expr)`` to + be raised upon exit from the generator. Enhancements to StopIteration @@ -133,7 +133,7 @@ RESULT = yield from EXPR -is semantically equivalent to :: + is semantically equivalent to :: _i = iter(EXPR) try: @@ -180,12 +180,12 @@ return value -is semantically equivalent to :: + is semantically equivalent to :: raise StopIteration(value) -except that, as currently, the exception cannot be caught by -``except`` clauses within the returning generator. + except that, as currently, the exception cannot be caught by + ``except`` clauses within the returning generator. 3. The StopIteration exception behaves as though defined thusly:: @@ -469,6 +469,7 @@ This document has been placed in the public domain. + .. Local Variables: mode: indented-text diff --git a/pep-0382.txt b/pep-0382.txt --- a/pep-0382.txt +++ b/pep-0382.txt @@ -117,16 +117,16 @@ encountered. In summary, the process import a package foo works like this: - 1. sys.path is searched for directories foo or foo.pyp, or a file foo.. - If a file is found and no directory, it is treated as a module, and imported. - 2. If a directory foo is found, a check is made whether it contains __init__.py. - If so, the location of the __init__.py is remembered. Otherwise, the directory - is skipped. Once an __init__.py is found, further directories called foo are - skipped. - 3. For both directories foo and foo.pyp, the directories are added to the package's - __path__. - 4. If an __init__ module was found, it is imported, with __path__ - being initialized to the path computed all ``.pyp`` directories. +1. sys.path is searched for directories foo or foo.pyp, or a file foo.. + If a file is found and no directory, it is treated as a module, and imported. +2. If a directory foo is found, a check is made whether it contains __init__.py. + If so, the location of the __init__.py is remembered. Otherwise, the directory + is skipped. Once an __init__.py is found, further directories called foo are + skipped. +3. For both directories foo and foo.pyp, the directories are added to the package's + __path__. +4. If an __init__ module was found, it is imported, with __path__ + being initialized to the path computed all ``.pyp`` directories. Impact on Import Hooks ---------------------- diff --git a/pep-0393.txt b/pep-0393.txt --- a/pep-0393.txt +++ b/pep-0393.txt @@ -110,10 +110,12 @@ - length: number of code points in the string (result of sq_length) - interned: interned-state (SSTATE_*) as in 3.2 - kind: form of string - + 00 => str is not initialized (data are in wstr) - + 01 => 1 byte (Latin-1) - + 10 => 2 byte (UCS-2) - + 11 => 4 byte (UCS-4); + + + 00 => str is not initialized (data are in wstr) + + 01 => 1 byte (Latin-1) + + 10 => 2 byte (UCS-2) + + 11 => 4 byte (UCS-4); + - compact: the object uses one of the compact representations (implies ready) - ascii: the object uses the PyASCIIObject representation @@ -189,9 +191,9 @@ gives the void pointer to the data. Access to individual characters should use PyUnicode_{READ|WRITE}[_CHAR]: - - PyUnicode_READ(kind, data, index) - - PyUnicode_WRITE(kind, data, index, value) - - PyUnicode_READ_CHAR(unicode, index) +- PyUnicode_READ(kind, data, index) +- PyUnicode_WRITE(kind, data, index, value) +- PyUnicode_READ_CHAR(unicode, index) All these macros assume that the string is in canonical form; callers need to ensure this by calling PyUnicode_READY. diff --git a/pep-0400.txt b/pep-0400.txt --- a/pep-0400.txt +++ b/pep-0400.txt @@ -77,72 +77,72 @@ StreamReader and StreamWriter issues '''''''''''''''''''''''''''''''''''' - * StreamReader is unable to translate newlines. - * StreamWriter doesn't support "line buffering" (flush if the input - text contains a newline). - * StreamReader classes of the CJK encodings (e.g. GB18030) only - supports UNIX newlines ('\\n'). - * StreamReader and StreamWriter are stateful codecs but don't expose - functions to control their state (getstate() or setstate()). Each - codec has to handle corner cases, see `Appendix A`_. - * StreamReader and StreamWriter are very similar to IncrementalReader - and IncrementalEncoder, some code is duplicated for stateful codecs - (e.g. UTF-16). - * Each codec has to reimplement its own StreamReader and StreamWriter - class, even if it's trivial (just call the encoder/decoder). - * codecs.open(filename, "r") creates a io.TextIOWrapper object. - * No codec implements an optimized method in StreamReader or - StreamWriter based on the specificities of the codec. +* StreamReader is unable to translate newlines. +* StreamWriter doesn't support "line buffering" (flush if the input + text contains a newline). +* StreamReader classes of the CJK encodings (e.g. GB18030) only + supports UNIX newlines ('\\n'). +* StreamReader and StreamWriter are stateful codecs but don't expose + functions to control their state (getstate() or setstate()). Each + codec has to handle corner cases, see `Appendix A`_. +* StreamReader and StreamWriter are very similar to IncrementalReader + and IncrementalEncoder, some code is duplicated for stateful codecs + (e.g. UTF-16). +* Each codec has to reimplement its own StreamReader and StreamWriter + class, even if it's trivial (just call the encoder/decoder). +* codecs.open(filename, "r") creates a io.TextIOWrapper object. +* No codec implements an optimized method in StreamReader or + StreamWriter based on the specificities of the codec. Issues in the bug tracker: - * `Issue #5445 `_ (2009-03-08): - codecs.StreamWriter.writelines problem when passed generator - * `Issue #7262: `_ (2009-11-04): - codecs.open() + eol (windows) - * `Issue #8260 `_ (2010-03-29): - When I use codecs.open(...) and f.readline() follow up by f.read() - return bad result - * `Issue #8630 `_ (2010-05-05): - Keepends param in codec readline(s) - * `Issue #10344 `_ (2010-11-06): - codecs.readline doesn't care buffering - * `Issue #11461 `_ (2011-03-10): - Reading UTF-16 with codecs.readline() breaks on surrogate pairs - * `Issue #12446 `_ (2011-06-30): - StreamReader Readlines behavior odd - * `Issue #12508 `_ (2011-07-06): - Codecs Anomaly - * `Issue #12512 `_ (2011-07-07): - codecs: StreamWriter issues with stateful codecs after a seek or - with append mode - * `Issue #12513 `_ (2011-07-07): - codec.StreamReaderWriter: issues with interlaced read-write +* `Issue #5445 `_ (2009-03-08): + codecs.StreamWriter.writelines problem when passed generator +* `Issue #7262: `_ (2009-11-04): + codecs.open() + eol (windows) +* `Issue #8260 `_ (2010-03-29): + When I use codecs.open(...) and f.readline() follow up by f.read() + return bad result +* `Issue #8630 `_ (2010-05-05): + Keepends param in codec readline(s) +* `Issue #10344 `_ (2010-11-06): + codecs.readline doesn't care buffering +* `Issue #11461 `_ (2011-03-10): + Reading UTF-16 with codecs.readline() breaks on surrogate pairs +* `Issue #12446 `_ (2011-06-30): + StreamReader Readlines behavior odd +* `Issue #12508 `_ (2011-07-06): + Codecs Anomaly +* `Issue #12512 `_ (2011-07-07): + codecs: StreamWriter issues with stateful codecs after a seek or + with append mode +* `Issue #12513 `_ (2011-07-07): + codec.StreamReaderWriter: issues with interlaced read-write TextIOWrapper features '''''''''''''''''''''' - * TextIOWrapper supports any kind of newline, including translating - newlines (to UNIX newlines), to read and write. - * TextIOWrapper reuses codecs incremental encoders and decoders (no - duplication of code). - * The io module (TextIOWrapper) is faster than the codecs module - (StreamReader). It is implemented in C, whereas codecs is - implemented in Python. - * TextIOWrapper has a readahead algorithm which speeds up small - reads: read character by character or line by line (io is 10x - through 25x faster than codecs on these operations). - * TextIOWrapper has a write buffer. - * TextIOWrapper.tell() is optimized. - * TextIOWrapper supports random access (read+write) using a single - class which permit to optimize interlaced read-write (but no such - optimization is implemented). +* TextIOWrapper supports any kind of newline, including translating + newlines (to UNIX newlines), to read and write. +* TextIOWrapper reuses codecs incremental encoders and decoders (no + duplication of code). +* The io module (TextIOWrapper) is faster than the codecs module + (StreamReader). It is implemented in C, whereas codecs is + implemented in Python. +* TextIOWrapper has a readahead algorithm which speeds up small + reads: read character by character or line by line (io is 10x + through 25x faster than codecs on these operations). +* TextIOWrapper has a write buffer. +* TextIOWrapper.tell() is optimized. +* TextIOWrapper supports random access (read+write) using a single + class which permit to optimize interlaced read-write (but no such + optimization is implemented). TextIOWrapper issues '''''''''''''''''''' - * `Issue #12215 `_ (2011-05-30): - TextIOWrapper: issues with interlaced read-write +* `Issue #12215 `_ (2011-05-30): + TextIOWrapper: issues with interlaced read-write Possible improvements of StreamReader and StreamWriter '''''''''''''''''''''''''''''''''''''''''''''''''''''' @@ -233,29 +233,29 @@ Python supports the following stateful codecs: - * cp932 - * cp949 - * cp950 - * euc_jis_2004 - * euc_jisx2003 - * euc_jp - * euc_kr - * gb18030 - * gbk - * hz - * iso2022_jp - * iso2022_jp_1 - * iso2022_jp_2 - * iso2022_jp_2004 - * iso2022_jp_3 - * iso2022_jp_ext - * iso2022_kr - * shift_jis - * shift_jis_2004 - * shift_jisx0213 - * utf_8_sig - * utf_16 - * utf_32 +* cp932 +* cp949 +* cp950 +* euc_jis_2004 +* euc_jisx2003 +* euc_jp +* euc_kr +* gb18030 +* gbk +* hz +* iso2022_jp +* iso2022_jp_1 +* iso2022_jp_2 +* iso2022_jp_2004 +* iso2022_jp_3 +* iso2022_jp_ext +* iso2022_kr +* shift_jis +* shift_jis_2004 +* shift_jisx0213 +* utf_8_sig +* utf_16 +* utf_32 Read and seek(0) '''''''''''''''' @@ -312,13 +312,13 @@ Links ===== - * `PEP 100: Python Unicode Integration - `_ - * `PEP 3116: New I/O `_ - * `Issue #8796: Deprecate codecs.open() - `_ - * `[python-dev] Deprecate codecs.open() and StreamWriter/StreamReader - `_ +* `PEP 100: Python Unicode Integration + `_ +* `PEP 3116: New I/O `_ +* `Issue #8796: Deprecate codecs.open() + `_ +* `[python-dev] Deprecate codecs.open() and StreamWriter/StreamReader + `_ Copyright diff --git a/pep-0403.txt b/pep-0403.txt --- a/pep-0403.txt +++ b/pep-0403.txt @@ -176,11 +176,11 @@ many constructs Python has where one expression is responsible for the bulk of the heavy lifting: - * comprehensions, generator expressions, map(), filter() - * key arguments to sorted(), min(), max() - * partial function application - * provision of callbacks (e.g. for weak references or aysnchronous IO) - * array broadcast operations in NumPy +* comprehensions, generator expressions, map(), filter() +* key arguments to sorted(), min(), max() +* partial function application +* provision of callbacks (e.g. for weak references or aysnchronous IO) +* array broadcast operations in NumPy However, adopting Ruby's block syntax directly won't work for Python, since the effectiveness of Ruby's blocks relies heavily on various conventions in diff --git a/pep-0404.txt b/pep-0404.txt --- a/pep-0404.txt +++ b/pep-0404.txt @@ -32,7 +32,7 @@ The current un-schedule is: - - 2.8 final Never +- 2.8 final Never Official pronouncement diff --git a/pep-0410.txt b/pep-0410.txt --- a/pep-0410.txt +++ b/pep-0410.txt @@ -32,8 +32,8 @@ os.stat() uses float timestamps by default since Python 2.5. Python 3.3 introduced functions supporting nanosecond resolutions: - * os module: futimens(), utimensat() - * time module: clock_gettime(), clock_getres(), monotonic(), wallclock() +* os module: futimens(), utimensat() +* time module: clock_gettime(), clock_getres(), monotonic(), wallclock() os.stat() reads nanosecond timestamps but returns timestamps as float. @@ -74,24 +74,24 @@ Add an optional *timestamp* argument to: - * os module: fstat(), fstatat(), lstat(), stat() (st_atime, - st_ctime and st_mtime fields of the stat structure), - sched_rr_get_interval(), times(), wait3() and wait4() - * resource module: ru_utime and ru_stime fields of getrusage() - * signal module: getitimer(), setitimer() - * time module: clock(), clock_gettime(), clock_getres(), - monotonic(), time() and wallclock() +* os module: fstat(), fstatat(), lstat(), stat() (st_atime, + st_ctime and st_mtime fields of the stat structure), + sched_rr_get_interval(), times(), wait3() and wait4() +* resource module: ru_utime and ru_stime fields of getrusage() +* signal module: getitimer(), setitimer() +* time module: clock(), clock_gettime(), clock_getres(), + monotonic(), time() and wallclock() The *timestamp* argument value can be float or Decimal, float is still the default for backward compatibility. The following functions support Decimal as input: - * datetime module: date.fromtimestamp(), datetime.fromtimestamp() and - datetime.utcfromtimestamp() - * os module: futimes(), futimesat(), lutimes(), utime() - * select module: epoll.poll(), kqueue.control(), select() - * signal module: setitimer(), sigtimedwait() - * time module: ctime(), gmtime(), localtime(), sleep() +* datetime module: date.fromtimestamp(), datetime.fromtimestamp() and + datetime.utcfromtimestamp() +* os module: futimes(), futimesat(), lutimes(), utime() +* select module: epoll.poll(), kqueue.control(), select() +* signal module: setitimer(), sigtimedwait() +* time module: ctime(), gmtime(), localtime(), sleep() The os.stat_float_times() function is deprecated: use an explicit cast using int() instead. @@ -132,22 +132,22 @@ To support timestamps with an arbitrary or nanosecond resolution, the following types have been considered: - * decimal.Decimal - * number of nanoseconds - * 128-bits float - * datetime.datetime - * datetime.timedelta - * tuple of integers - * timespec structure +* decimal.Decimal +* number of nanoseconds +* 128-bits float +* datetime.datetime +* datetime.timedelta +* tuple of integers +* timespec structure Criteria: - * Doing arithmetic on timestamps must be possible - * Timestamps must be comparable - * An arbitrary resolution, or at least a resolution of one nanosecond without - losing precision - * It should be possible to coerce the new timestamp to float for backward - compatibility +* Doing arithmetic on timestamps must be possible +* Timestamps must be comparable +* An arbitrary resolution, or at least a resolution of one nanosecond without + losing precision +* It should be possible to coerce the new timestamp to float for backward + compatibility A resolution of one nanosecond is enough to support all current C functions. @@ -264,39 +264,39 @@ Different formats have been proposed: - * A: (numerator, denominator) +* A: (numerator, denominator) - * value = numerator / denominator - * resolution = 1 / denominator - * denominator > 0 + * value = numerator / denominator + * resolution = 1 / denominator + * denominator > 0 - * B: (seconds, numerator, denominator) +* B: (seconds, numerator, denominator) - * value = seconds + numerator / denominator - * resolution = 1 / denominator - * 0 <= numerator < denominator - * denominator > 0 + * value = seconds + numerator / denominator + * resolution = 1 / denominator + * 0 <= numerator < denominator + * denominator > 0 - * C: (intpart, floatpart, base, exponent) +* C: (intpart, floatpart, base, exponent) - * value = intpart + floatpart / base\ :sup:`exponent` - * resolution = 1 / base \ :sup:`exponent` - * 0 <= floatpart < base \ :sup:`exponent` - * base > 0 - * exponent >= 0 + * value = intpart + floatpart / base\ :sup:`exponent` + * resolution = 1 / base \ :sup:`exponent` + * 0 <= floatpart < base \ :sup:`exponent` + * base > 0 + * exponent >= 0 - * D: (intpart, floatpart, exponent) +* D: (intpart, floatpart, exponent) - * value = intpart + floatpart / 10\ :sup:`exponent` - * resolution = 1 / 10 \ :sup:`exponent` - * 0 <= floatpart < 10 \ :sup:`exponent` - * exponent >= 0 + * value = intpart + floatpart / 10\ :sup:`exponent` + * resolution = 1 / 10 \ :sup:`exponent` + * 0 <= floatpart < 10 \ :sup:`exponent` + * exponent >= 0 - * E: (sec, nsec) +* E: (sec, nsec) - * value = sec + nsec ? 10\ :sup:`-9` - * resolution = 10 \ :sup:`-9` (nanosecond) - * 0 <= nsec < 10 \ :sup:`9` + * value = sec + nsec ? 10\ :sup:`-9` + * resolution = 10 \ :sup:`-9` (nanosecond) + * 0 <= nsec < 10 \ :sup:`9` All formats support an arbitrary resolution, except of the format (E). @@ -490,11 +490,11 @@ Add new functions for each type, examples: - * time.clock_decimal() - * time.time_decimal() - * os.stat_decimal() - * os.stat_timespec() - * etc. +* time.clock_decimal() +* time.time_decimal() +* os.stat_decimal() +* os.stat_timespec() +* etc. Adding a new function for each function creating timestamps duplicate a lot of code and would be a pain to maintain. diff --git a/pep-0416.txt b/pep-0416.txt --- a/pep-0416.txt +++ b/pep-0416.txt @@ -15,22 +15,22 @@ I'm rejecting this PEP. A number of reasons (not exhaustive): - * According to Raymond Hettinger, use of frozendict is low. Those - that do use it tend to use it as a hint only, such as declaring - global or class-level "constants": they aren't really immutable, - since anyone can still assign to the name. - * There are existing idioms for avoiding mutable default values. - * The potential of optimizing code using frozendict in PyPy is - unsure; a lot of other things would have to change first. The same - holds for compile-time lookups in general. - * Multiple threads can agree by convention not to mutate a shared - dict, there's no great need for enforcement. Multiple processes - can't share dicts. - * Adding a security sandbox written in Python, even with a limited - scope, is frowned upon by many, due to the inherent difficulty with - ever proving that the sandbox is actually secure. Because of this - we won't be adding one to the stdlib any time soon, so this use - case falls outside the scope of a PEP. +* According to Raymond Hettinger, use of frozendict is low. Those + that do use it tend to use it as a hint only, such as declaring + global or class-level "constants": they aren't really immutable, + since anyone can still assign to the name. +* There are existing idioms for avoiding mutable default values. +* The potential of optimizing code using frozendict in PyPy is + unsure; a lot of other things would have to change first. The same + holds for compile-time lookups in general. +* Multiple threads can agree by convention not to mutate a shared + dict, there's no great need for enforcement. Multiple processes + can't share dicts. +* Adding a security sandbox written in Python, even with a limited + scope, is frowned upon by many, due to the inherent difficulty with + ever proving that the sandbox is actually secure. Because of this + we won't be adding one to the stdlib any time soon, so this use + case falls outside the scope of a PEP. On the other hand, exposing the existing read-only dict proxy as a built-in type sounds good to me. (It would need to be changed to @@ -55,46 +55,46 @@ Use cases: - * Immutable global variable like a default configuration. - * Default value of a function parameter. Avoid the issue of mutable default - arguments. - * Implement a cache: frozendict can be used to store function keywords. - frozendict can be used as a key of a mapping or as a member of set. - * frozendict avoids the need of a lock when the frozendict is shared - by multiple threads or processes, especially hashable frozendict. It would - also help to prohibe coroutines (generators + greenlets) to modify the - global state. - * frozendict lookup can be done at compile time instead of runtime because the - mapping is read-only. frozendict can be used instead of a preprocessor to - remove conditional code at compilation, like code specific to a debug build. - * frozendict helps to implement read-only object proxies for security modules. - For example, it would be possible to use frozendict type for __builtins__ - mapping or type.__dict__. This is possible because frozendict is compatible - with the PyDict C API. - * frozendict avoids the need of a read-only proxy in some cases. frozendict is - faster than a proxy because getting an item in a frozendict is a fast lookup - whereas a proxy requires a function call. +* Immutable global variable like a default configuration. +* Default value of a function parameter. Avoid the issue of mutable default + arguments. +* Implement a cache: frozendict can be used to store function keywords. + frozendict can be used as a key of a mapping or as a member of set. +* frozendict avoids the need of a lock when the frozendict is shared + by multiple threads or processes, especially hashable frozendict. It would + also help to prohibe coroutines (generators + greenlets) to modify the + global state. +* frozendict lookup can be done at compile time instead of runtime because the + mapping is read-only. frozendict can be used instead of a preprocessor to + remove conditional code at compilation, like code specific to a debug build. +* frozendict helps to implement read-only object proxies for security modules. + For example, it would be possible to use frozendict type for __builtins__ + mapping or type.__dict__. This is possible because frozendict is compatible + with the PyDict C API. +* frozendict avoids the need of a read-only proxy in some cases. frozendict is + faster than a proxy because getting an item in a frozendict is a fast lookup + whereas a proxy requires a function call. Constraints =========== - * frozendict has to implement the Mapping abstract base class - * frozendict keys and values can be unorderable - * a frozendict is hashable if all keys and values are hashable - * frozendict hash does not depend on the items creation order +* frozendict has to implement the Mapping abstract base class +* frozendict keys and values can be unorderable +* a frozendict is hashable if all keys and values are hashable +* frozendict hash does not depend on the items creation order Implementation ============== - * Add a PyFrozenDictObject structure based on PyDictObject with an extra - "Py_hash_t hash;" field - * frozendict.__hash__() is implemented using hash(frozenset(self.items())) and - caches the result in its private hash attribute - * Register frozendict as a collections.abc.Mapping - * frozendict can be used with PyDict_GetItem(), but PyDict_SetItem() and - PyDict_DelItem() raise a TypeError +* Add a PyFrozenDictObject structure based on PyDictObject with an extra + "Py_hash_t hash;" field +* frozendict.__hash__() is implemented using hash(frozenset(self.items())) and + caches the result in its private hash attribute +* Register frozendict as a collections.abc.Mapping +* frozendict can be used with PyDict_GetItem(), but PyDict_SetItem() and + PyDict_DelItem() raise a TypeError Recipe: hashable dict @@ -161,90 +161,90 @@ Whitelist approach. - * `Implementing an Immutable Dictionary (Python recipe 498072) - `_ by Aristotelis Mikropoulos. - Similar to frozendict except that it is not truly read-only: it is possible - to access to this private internal dict. It does not implement __hash__ and - has an implementation issue: it is possible to call again __init__() to - modify the mapping. - * PyWebmail contains an ImmutableDict type: `webmail.utils.ImmutableDict - `_. - It is hashable if keys and values are hashable. It is not truly read-only: - its internal dict is a public attribute. - * remember project: `remember.dicts.FrozenDict - `_. - It is used to implement a cache: FrozenDict is used to store function callbacks. - FrozenDict may be hashable. It has an extra supply_dict() class method to - create a FrozenDict from a dict without copying the dict: store the dict as - the internal dict. Implementation issue: __init__() can be called to modify - the mapping and the hash may differ depending on item creation order. The - mapping is not truly read-only: the internal dict is accessible in Python. +* `Implementing an Immutable Dictionary (Python recipe 498072) + `_ by Aristotelis Mikropoulos. + Similar to frozendict except that it is not truly read-only: it is possible + to access to this private internal dict. It does not implement __hash__ and + has an implementation issue: it is possible to call again __init__() to + modify the mapping. +* PyWebmail contains an ImmutableDict type: `webmail.utils.ImmutableDict + `_. + It is hashable if keys and values are hashable. It is not truly read-only: + its internal dict is a public attribute. +* remember project: `remember.dicts.FrozenDict + `_. + It is used to implement a cache: FrozenDict is used to store function callbacks. + FrozenDict may be hashable. It has an extra supply_dict() class method to + create a FrozenDict from a dict without copying the dict: store the dict as + the internal dict. Implementation issue: __init__() can be called to modify + the mapping and the hash may differ depending on item creation order. The + mapping is not truly read-only: the internal dict is accessible in Python. Blacklist approach: inherit from dict and override write methods to raise an exception. It is not truly read-only: it is still possible to call dict methods on such "frozen dictionary" to modify it. - * brownie: `brownie.datastructures.ImmuatableDict - `_. - It is hashable if keys and values are hashable. werkzeug project has the - same code: `werkzeug.datastructures.ImmutableDict - `_. - ImmutableDict is used for global constant (configuration options). The Flask - project uses ImmutableDict of werkzeug for its default configuration. - * SQLAchemy project: `sqlachemy.util.immutabledict - `_. - It is not hashable and has an extra method: union(). immutabledict is used - for the default value of parameter of some functions expecting a mapping. - Example: mapper_args=immutabledict() in SqlSoup.map(). - * `Frozen dictionaries (Python recipe 414283) `_ - by Oren Tirosh. It is hashable if keys and values are hashable. Included in - the following projects: +* brownie: `brownie.datastructures.ImmuatableDict + `_. + It is hashable if keys and values are hashable. werkzeug project has the + same code: `werkzeug.datastructures.ImmutableDict + `_. + ImmutableDict is used for global constant (configuration options). The Flask + project uses ImmutableDict of werkzeug for its default configuration. +* SQLAchemy project: `sqlachemy.util.immutabledict + `_. + It is not hashable and has an extra method: union(). immutabledict is used + for the default value of parameter of some functions expecting a mapping. + Example: mapper_args=immutabledict() in SqlSoup.map(). +* `Frozen dictionaries (Python recipe 414283) `_ + by Oren Tirosh. It is hashable if keys and values are hashable. Included in + the following projects: - * lingospot: `frozendict/frozendict.py - `_ - * factor-graphics: frozendict type in `python/fglib/util_ext_frozendict.py - `_ + * lingospot: `frozendict/frozendict.py + `_ + * factor-graphics: frozendict type in `python/fglib/util_ext_frozendict.py + `_ - * The gsakkis-utils project written by George Sakkis includes a frozendict - type: `datastructs.frozendict - `_ - * characters: `scripts/python/frozendict.py - `_. - It is hashable. __init__() sets __init__ to None. - * Old NLTK (1.x): `nltk.util.frozendict - `_. Keys and - values must be hashable. __init__() can be called twice to modify the - mapping. frozendict is used to "freeze" an object. +* The gsakkis-utils project written by George Sakkis includes a frozendict + type: `datastructs.frozendict + `_ +* characters: `scripts/python/frozendict.py + `_. + It is hashable. __init__() sets __init__ to None. +* Old NLTK (1.x): `nltk.util.frozendict + `_. Keys and + values must be hashable. __init__() can be called twice to modify the + mapping. frozendict is used to "freeze" an object. Hashable dict: inherit from dict and just add an __hash__ method. - * `pypy.rpython.lltypesystem.lltype.frozendict - `_. - It is hashable but don't deny modification of the mapping. - * factor-graphics: hashabledict type in `python/fglib/util_ext_frozendict.py - `_ +* `pypy.rpython.lltypesystem.lltype.frozendict + `_. + It is hashable but don't deny modification of the mapping. +* factor-graphics: hashabledict type in `python/fglib/util_ext_frozendict.py + `_ Links ===== - * `Issue #14162: PEP 416: Add a builtin frozendict type - `_ - * PEP 412: Key-Sharing Dictionary - (`issue #13903 `_) - * PEP 351: The freeze protocol - * `The case for immutable dictionaries; and the central misunderstanding of - PEP 351 `_ - * `make dictproxy object via ctypes.pythonapi and type() (Python recipe - 576540) `_ by Ikkei Shimomura. - * Python security modules implementing read-only object proxies using a C - extension: +* `Issue #14162: PEP 416: Add a builtin frozendict type + `_ +* PEP 412: Key-Sharing Dictionary + (`issue #13903 `_) +* PEP 351: The freeze protocol +* `The case for immutable dictionaries; and the central misunderstanding of + PEP 351 `_ +* `make dictproxy object via ctypes.pythonapi and type() (Python recipe + 576540) `_ by Ikkei Shimomura. +* Python security modules implementing read-only object proxies using a C + extension: - * `pysandbox `_ - * `mxProxy `_ - * `zope.proxy `_ - * `zope.security `_ + * `pysandbox `_ + * `mxProxy `_ + * `zope.proxy `_ + * `zope.security `_ Copyright diff --git a/pep-0418.txt b/pep-0418.txt --- a/pep-0418.txt +++ b/pep-0418.txt @@ -116,14 +116,14 @@ Return a ``time.clock_info`` object which has the following attributes: - * ``implementation`` (str): name of the underlying operating system - function. Examples: ``"QueryPerformanceCounter()"``, - ``"clock_gettime(CLOCK_REALTIME)"``. - * ``monotonic`` (bool): True if the clock cannot go backward. - * ``adjustable`` (bool): ``True`` if the clock can be changed automatically - (e.g. by a NTP daemon) or manually by the system administrator, ``False`` - otherwise - * ``resolution`` (float): resolution in seconds of the clock. +* ``implementation`` (str): name of the underlying operating system + function. Examples: ``"QueryPerformanceCounter()"``, + ``"clock_gettime(CLOCK_REALTIME)"``. +* ``monotonic`` (bool): True if the clock cannot go backward. +* ``adjustable`` (bool): ``True`` if the clock can be changed automatically + (e.g. by a NTP daemon) or manually by the system administrator, ``False`` + otherwise +* ``resolution`` (float): resolution in seconds of the clock. time.monotonic() diff --git a/pep-0426.txt b/pep-0426.txt --- a/pep-0426.txt +++ b/pep-0426.txt @@ -868,27 +868,27 @@ * Implied runtime dependencies: + * ``run_requires`` + * ``meta_requires`` + +* Implied build dependencies: + + * ``build_requires`` + * If running the distribution's test suite as part of the build process, + request the ``:run:``, ``:meta:``, and ``:test:`` extras to also + install: + * ``run_requires`` * ``meta_requires`` - -* Implied build dependencies: - - * ``build_requires`` - * If running the distribution's test suite as part of the build process, - request the ``:run:``, ``:meta:``, and ``:test:`` extras to also - install: - - * ``run_requires`` - * ``meta_requires`` - * ``test_requires`` + * ``test_requires`` * Implied development and publication dependencies: - * ``run_requires`` - * ``meta_requires`` - * ``build_requires`` - * ``test_requires`` - * ``dev_requires`` + * ``run_requires`` + * ``meta_requires`` + * ``build_requires`` + * ``test_requires`` + * ``dev_requires`` The notation described in `Extras (optional dependencies)`_ SHOULD be used to determine exactly what gets installed for various operations. diff --git a/pep-0432.txt b/pep-0432.txt --- a/pep-0432.txt +++ b/pep-0432.txt @@ -175,32 +175,50 @@ * Whether or not to enable the import system (required by CPython's build process when freezing the importlib._bootstrap bytecode) * The "Where is Python located?" elements in the ``sys`` module: + * ``sys.executable`` * ``sys.base_exec_prefix`` * ``sys.base_prefix`` * ``sys.exec_prefix`` * ``sys.prefix`` + * The path searched for imports from the filesystem (and other path hooks): + * ``sys.path`` + * The command line arguments seen by the interpeter: + * ``sys.argv`` + * The filesystem encoding used by: + * ``sys.getfsencoding`` * ``os.fsencode`` * ``os.fsdecode`` + * The IO encoding (if any) and the buffering used by: + * ``sys.stdin`` * ``sys.stdout`` * ``sys.stderr`` + * The initial warning system state: + * ``sys.warnoptions`` + * Arbitrary extended options (e.g. to automatically enable ``faulthandler``): + * ``sys._xoptions`` + * Whether or not to implicitly cache bytecode files: + * ``sys.dont_write_bytecode`` + * Whether or not to enforce correct case in filenames on case-insensitive platforms + * ``os.environ["PYTHONCASEOK"]`` + * The other settings exposed to Python code in ``sys.flags``: * ``debug`` (Enable debugging output in the pgen parser) @@ -738,9 +756,9 @@ (typically a zipfile or directory) * otherwise, it will be accurate: - * the script name if running an ordinary script - * ``-c`` if executing a supplied string - * ``-`` or the empty string if running from stdin + * the script name if running an ordinary script + * ``-c`` if executing a supplied string + * ``-`` or the empty string if running from stdin * the metadata in the ``__main__`` module will still indicate it is a builtin module @@ -791,24 +809,26 @@ ``main_code``. * For ``main_path``: - * if the supplied path is recognised as a valid ``sys.path`` entry, it - is inserted as ``sys.path[0]``, ``main_module`` is set - to ``__main__`` and processing continues as for ``main_module`` below. - * otherwise, path is read as a CPython bytecode file - * if that fails, it is read as a Python source file and compiled - * in the latter two cases, the code object is saved to ``main_code`` - and ``__main__.__file__`` is set appropriately + + * if the supplied path is recognised as a valid ``sys.path`` entry, it + is inserted as ``sys.path[0]``, ``main_module`` is set + to ``__main__`` and processing continues as for ``main_module`` below. + * otherwise, path is read as a CPython bytecode file + * if that fails, it is read as a Python source file and compiled + * in the latter two cases, the code object is saved to ``main_code`` + and ``__main__.__file__`` is set appropriately * For ``main_module``: - * any parent package is imported - * the loader for the module is determined - * if the loader indicates the module is a package, add ``.__main__`` to - the end of ``main_module`` and try again (if the final name segment - is already ``.__main__`` then fail immediately) - * once the module source code is located, save the compiled module code - as ``main_code`` and populate the following attributes in ``__main__`` - appropriately: ``__name__``, ``__loader__``, ``__file__``, - ``__cached__``, ``__package__``. + + * any parent package is imported + * the loader for the module is determined + * if the loader indicates the module is a package, add ``.__main__`` to + the end of ``main_module`` and try again (if the final name segment + is already ``.__main__`` then fail immediately) + * once the module source code is located, save the compiled module code + as ``main_code`` and populate the following attributes in ``__main__`` + appropriately: ``__name__``, ``__loader__``, ``__file__``, + ``__cached__``, ``__package__``. (Note: the behaviour described in this section isn't new, it's a write-up @@ -1222,26 +1242,38 @@ * Completely disabling the import system * The initial warning system state: + * ``sys.warnoptions`` * (-W option, PYTHONWARNINGS) + * Arbitrary extended options (e.g. to automatically enable ``faulthandler``): + * ``sys._xoptions`` * (-X option) + * The filesystem encoding used by: + * ``sys.getfsencoding`` * ``os.fsencode`` * ``os.fsdecode`` + * The IO encoding and buffering used by: + * ``sys.stdin`` * ``sys.stdout`` * ``sys.stderr`` * (-u option, PYTHONIOENCODING, PYTHONUNBUFFEREDIO) + * Whether or not to implicitly cache bytecode files: + * ``sys.dont_write_bytecode`` * (-B option, PYTHONDONTWRITEBYTECODE) + * Whether or not to enforce correct case in filenames on case-insensitive platforms + * ``os.environ["PYTHONCASEOK"]`` + * The other settings exposed to Python code in ``sys.flags``: * ``debug`` (Enable debugging output in the pgen parser) diff --git a/pep-0433.txt b/pep-0433.txt --- a/pep-0433.txt +++ b/pep-0433.txt @@ -18,10 +18,10 @@ descriptors, add different ways to change default values of this parameter, and add four new functions: - * ``os.get_cloexec(fd)`` - * ``os.set_cloexec(fd, cloexec=True)`` - * ``sys.getdefaultcloexec()`` - * ``sys.setdefaultcloexec(cloexec)`` +* ``os.get_cloexec(fd)`` +* ``os.set_cloexec(fd, cloexec=True)`` +* ``sys.getdefaultcloexec()`` +* ``sys.setdefaultcloexec(cloexec)`` Rationale @@ -86,14 +86,14 @@ See also the following issues: - * `Issue #2320: Race condition in subprocess using stdin - `_ (2008) - * `Issue #3006: subprocess.Popen causes socket to remain open after - close `_ (2008) - * `Issue #7213: subprocess leaks open file descriptors between Popen - instances causing hangs `_ (2009) - * `Issue #12786: subprocess wait() hangs when stdin is closed - `_ (2011) +* `Issue #2320: Race condition in subprocess using stdin + `_ (2008) +* `Issue #3006: subprocess.Popen causes socket to remain open after + close `_ (2008) +* `Issue #7213: subprocess leaks open file descriptors between Popen + instances causing hangs `_ (2009) +* `Issue #12786: subprocess wait() hangs when stdin is closed + `_ (2011) Security @@ -112,20 +112,20 @@ Example of vulnerabilities: - * `OpenSSH Security Advisory: portable-keysign-rand-helper.adv - `_ - (April 2011) - * `CWE-403: Exposure of File Descriptor to Unintended Control Sphere - `_ (2008) - * `Hijacking Apache https by mod_php - `_ (Dec 2003) +* `OpenSSH Security Advisory: portable-keysign-rand-helper.adv + `_ + (April 2011) +* `CWE-403: Exposure of File Descriptor to Unintended Control Sphere + `_ (2008) +* `Hijacking Apache https by mod_php + `_ (Dec 2003) - * Apache: `Apr should set FD_CLOEXEC if APR_FOPEN_NOCLEANUP is not set - `_ - (fixed in 2009) - * PHP: `system() (and similar) don't cleanup opened handles of Apache - `_ (not fixed in january - 2013) + * Apache: `Apr should set FD_CLOEXEC if APR_FOPEN_NOCLEANUP is not set + `_ + (fixed in 2009) + * PHP: `system() (and similar) don't cleanup opened handles of Apache + `_ (not fixed in january + 2013) Atomicity @@ -189,37 +189,37 @@ Add new functions: - * ``os.get_cloexec(fd:int) -> bool``: get the - close-on-exec flag of a file descriptor. Not available on all - platforms. - * ``os.set_cloexec(fd:int, cloexec:bool=True)``: set or clear the - close-on-exec flag on a file descriptor. Not available on all - platforms. - * ``sys.getdefaultcloexec() -> bool``: get the current default value - of the *cloexec* parameter - * ``sys.setdefaultcloexec(cloexec: bool)``: set the default value - of the *cloexec* parameter +* ``os.get_cloexec(fd:int) -> bool``: get the + close-on-exec flag of a file descriptor. Not available on all + platforms. +* ``os.set_cloexec(fd:int, cloexec:bool=True)``: set or clear the + close-on-exec flag on a file descriptor. Not available on all + platforms. +* ``sys.getdefaultcloexec() -> bool``: get the current default value + of the *cloexec* parameter +* ``sys.setdefaultcloexec(cloexec: bool)``: set the default value + of the *cloexec* parameter Add a new optional *cloexec* parameter to: - * ``asyncore.dispatcher.create_socket()`` - * ``io.FileIO`` - * ``io.open()`` - * ``open()`` - * ``os.dup()`` - * ``os.dup2()`` - * ``os.fdopen()`` - * ``os.open()`` - * ``os.openpty()`` - * ``os.pipe()`` - * ``select.devpoll()`` - * ``select.epoll()`` - * ``select.kqueue()`` - * ``socket.socket()`` - * ``socket.socket.accept()`` - * ``socket.socket.dup()`` - * ``socket.socket.fromfd`` - * ``socket.socketpair()`` +* ``asyncore.dispatcher.create_socket()`` +* ``io.FileIO`` +* ``io.open()`` +* ``open()`` +* ``os.dup()`` +* ``os.dup2()`` +* ``os.fdopen()`` +* ``os.open()`` +* ``os.openpty()`` +* ``os.pipe()`` +* ``select.devpoll()`` +* ``select.epoll()`` +* ``select.kqueue()`` +* ``socket.socket()`` +* ``socket.socket.accept()`` +* ``socket.socket.dup()`` +* ``socket.socket.fromfd`` +* ``socket.socketpair()`` The default value of the *cloexec* parameter is ``sys.getdefaultcloexec()``. @@ -241,13 +241,13 @@ Drawbacks of the proposal: - * It is not more possible to know if the close-on-exec flag will be - set or not on a newly created file descriptor just by reading the - source code. - * If the inheritance of a file descriptor matters, the *cloexec* - parameter must now be specified explicitly, or the library or the - application will not work depending on the default value of the - *cloexec* parameter. +* It is not more possible to know if the close-on-exec flag will be + set or not on a newly created file descriptor just by reading the + source code. +* If the inheritance of a file descriptor matters, the *cloexec* + parameter must now be specified explicitly, or the library or the + application will not work depending on the default value of the + *cloexec* parameter. Alternatives @@ -288,23 +288,23 @@ Advantages of setting close-on-exec flag by default: - * There are far more programs that are bitten by FD inheritance upon - exec (see `Inherited file descriptors issues`_ and `Security`_) - than programs relying on it (see `Applications using inheritance of - file descriptors`_). +* There are far more programs that are bitten by FD inheritance upon + exec (see `Inherited file descriptors issues`_ and `Security`_) + than programs relying on it (see `Applications using inheritance of + file descriptors`_). Drawbacks of setting close-on-exec flag by default: - * It violates the principle of least surprise. Developers using the - os module may expect that Python respects the POSIX standard and so - that close-on-exec flag is not set by default. - * The os module is written as a thin wrapper to system calls (to - functions of the C standard library). If atomic flags to set - close-on-exec flag are not supported (see `Appendix: Operating - system support`_), a single Python function call may call 2 or 3 - system calls (see `Performances`_ section). - * Extra system calls, if any, may slow down Python: see - `Performances`_. +* It violates the principle of least surprise. Developers using the + os module may expect that Python respects the POSIX standard and so + that close-on-exec flag is not set by default. +* The os module is written as a thin wrapper to system calls (to + functions of the C standard library). If atomic flags to set + close-on-exec flag are not supported (see `Appendix: Operating + system support`_), a single Python function call may call 2 or 3 + system calls (see `Performances`_ section). +* Extra system calls, if any, may slow down Python: see + `Performances`_. Backward compatibility: only a few programs rely on inheritance of file descriptors, and they only pass a few file descriptors, usually just @@ -329,20 +329,20 @@ Drawbacks: - * It does not solve the problem on Windows: ``fork()`` does not exist - on Windows - * This alternative does not solve the problem for programs using - ``exec()`` without ``fork()``. - * A third party module may call directly the C function ``fork()`` - which will not call "atfork" callbacks. - * All functions creating file descriptors must be changed to register - a callback and then unregister their callback when the file is - closed. Or a list of *all* open file descriptors must be - maintained. - * The operating system is a better place than Python to close - automatically file descriptors. For example, it is not easy to - avoid a race condition between closing the file and unregistering - the callback closing the file. +* It does not solve the problem on Windows: ``fork()`` does not exist + on Windows +* This alternative does not solve the problem for programs using + ``exec()`` without ``fork()``. +* A third party module may call directly the C function ``fork()`` + which will not call "atfork" callbacks. +* All functions creating file descriptors must be changed to register + a callback and then unregister their callback when the file is + closed. Or a list of *all* open file descriptors must be + maintained. +* The operating system is a better place than Python to close + automatically file descriptors. For example, it is not easy to + avoid a race condition between closing the file and unregistering + the callback closing the file. open(): add "e" flag to mode @@ -363,9 +363,9 @@ Bikeshedding on the name of the new parameter --------------------------------------------- - * ``inherit``, ``inherited``: closer to Windows definition - * ``sensitive`` - * ``sterile``: "Does not produce offspring." +* ``inherit``, ``inherited``: closer to Windows definition +* ``sensitive`` +* ``sterile``: "Does not produce offspring." @@ -400,11 +400,11 @@ Example of programs taking file descriptors from the parent process using a command line option: - * gpg: ``--status-fd ``, ``--logger-fd ``, etc. - * openssl: ``-pass fd:`` - * qemu: ``-add-fd `` - * valgrind: ``--log-fd=``, ``--input-fd=``, etc. - * xterm: ``-S `` +* gpg: ``--status-fd ``, ``--logger-fd ``, etc. +* openssl: ``-pass fd:`` +* qemu: ``-add-fd `` +* valgrind: ``--log-fd=``, ``--input-fd=``, etc. +* xterm: ``-S `` On Linux, it is possible to use ``"/dev/fd/"`` filename to pass a file descriptor to a program expecting a filename. @@ -417,24 +417,24 @@ each creation of new file descriptors. The number of additional system calls depends on the method used to set the flag: - * ``O_NOINHERIT``: no additional system call - * ``O_CLOEXEC``: one additional system call, but only at the creation - of the first file descriptor, to check if the flag is supported. If - the flag is not supported, Python has to fallback to the next method. - * ``ioctl(fd, FIOCLEX)``: one additional system call per file - descriptor - * ``fcntl(fd, F_SETFD, flags)``: two additional system calls per file - descriptor, one to get old flags and one to set new flags +* ``O_NOINHERIT``: no additional system call +* ``O_CLOEXEC``: one additional system call, but only at the creation + of the first file descriptor, to check if the flag is supported. If + the flag is not supported, Python has to fallback to the next method. +* ``ioctl(fd, FIOCLEX)``: one additional system call per file + descriptor +* ``fcntl(fd, F_SETFD, flags)``: two additional system calls per file + descriptor, one to get old flags and one to set new flags On Linux, setting the close-on-flag has a low overhead on performances. Results of `bench_cloexec.py `_ on Linux 3.6: - * close-on-flag not set: 7.8 us - * ``O_CLOEXEC``: 1% slower (7.9 us) - * ``ioctl()``: 3% slower (8.0 us) - * ``fcntl()``: 3% slower (8.0 us) +* close-on-flag not set: 7.8 us +* ``O_CLOEXEC``: 1% slower (7.9 us) +* ``ioctl()``: 3% slower (8.0 us) +* ``fcntl()``: 3% slower (8.0 us) Implementation @@ -522,52 +522,52 @@ open() ------ - * Windows: ``open()`` with ``O_NOINHERIT`` flag [atomic] - * ``open()`` with ``O_CLOEXEC flag`` [atomic] - * ``open()`` + ``os.set_cloexec(fd, True)`` [best-effort] +* Windows: ``open()`` with ``O_NOINHERIT`` flag [atomic] +* ``open()`` with ``O_CLOEXEC flag`` [atomic] +* ``open()`` + ``os.set_cloexec(fd, True)`` [best-effort] os.dup() -------- - * Windows: ``DuplicateHandle()`` [atomic] - * ``fcntl(fd, F_DUPFD_CLOEXEC)`` [atomic] - * ``dup()`` + ``os.set_cloexec(fd, True)`` [best-effort] +* Windows: ``DuplicateHandle()`` [atomic] +* ``fcntl(fd, F_DUPFD_CLOEXEC)`` [atomic] +* ``dup()`` + ``os.set_cloexec(fd, True)`` [best-effort] os.dup2() --------- - * ``fcntl(fd, F_DUP2FD_CLOEXEC, fd2)`` [atomic] - * ``dup3()`` with ``O_CLOEXEC`` flag [atomic] - * ``dup2()`` + ``os.set_cloexec(fd, True)`` [best-effort] +* ``fcntl(fd, F_DUP2FD_CLOEXEC, fd2)`` [atomic] +* ``dup3()`` with ``O_CLOEXEC`` flag [atomic] +* ``dup2()`` + ``os.set_cloexec(fd, True)`` [best-effort] os.pipe() --------- - * Windows: ``CreatePipe()`` with - ``SECURITY_ATTRIBUTES.bInheritHandle=TRUE``, or ``_pipe()`` with - ``O_NOINHERIT`` flag [atomic] - * ``pipe2()`` with ``O_CLOEXEC`` flag [atomic] - * ``pipe()`` + ``os.set_cloexec(fd, True)`` [best-effort] +* Windows: ``CreatePipe()`` with + ``SECURITY_ATTRIBUTES.bInheritHandle=TRUE``, or ``_pipe()`` with + ``O_NOINHERIT`` flag [atomic] +* ``pipe2()`` with ``O_CLOEXEC`` flag [atomic] +* ``pipe()`` + ``os.set_cloexec(fd, True)`` [best-effort] socket.socket() --------------- - * Windows: ``WSASocket()`` with ``WSA_FLAG_NO_HANDLE_INHERIT`` flag - [atomic] - * ``socket()`` with ``SOCK_CLOEXEC`` flag [atomic] - * ``socket()`` + ``os.set_cloexec(fd, True)`` [best-effort] +* Windows: ``WSASocket()`` with ``WSA_FLAG_NO_HANDLE_INHERIT`` flag + [atomic] +* ``socket()`` with ``SOCK_CLOEXEC`` flag [atomic] +* ``socket()`` + ``os.set_cloexec(fd, True)`` [best-effort] socket.socketpair() ------------------- - * ``socketpair()`` with ``SOCK_CLOEXEC`` flag [atomic] - * ``socketpair()`` + ``os.set_cloexec(fd, True)`` [best-effort] +* ``socketpair()`` with ``SOCK_CLOEXEC`` flag [atomic] +* ``socketpair()`` + ``os.set_cloexec(fd, True)`` [best-effort] socket.socket.accept() ---------------------- - * ``accept4()`` with ``SOCK_CLOEXEC`` flag [atomic] - * ``accept()`` + ``os.set_cloexec(fd, True)`` [best-effort] +* ``accept4()`` with ``SOCK_CLOEXEC`` flag [atomic] +* ``accept()`` + ``os.set_cloexec(fd, True)`` [best-effort] Backward compatibility @@ -603,8 +603,8 @@ Functions: - * ``ioctl(fd, FIOCLEX, 0)``: set the close-on-exec flag - * ``ioctl(fd, FIONCLEX, 0)``: clear the close-on-exec flag +* ``ioctl(fd, FIOCLEX, 0)``: set the close-on-exec flag +* ``ioctl(fd, FIONCLEX, 0)``: clear the close-on-exec flag Availability: Linux, Mac OS X, QNX, NetBSD, OpenBSD, FreeBSD. @@ -614,10 +614,10 @@ Functions: - * ``flags = fcntl(fd, F_GETFD); fcntl(fd, F_SETFD, flags | FD_CLOEXEC)``: - set the close-on-exec flag - * ``flags = fcntl(fd, F_GETFD); fcntl(fd, F_SETFD, flags & ~FD_CLOEXEC)``: - clear the close-on-exec flag +* ``flags = fcntl(fd, F_GETFD); fcntl(fd, F_SETFD, flags | FD_CLOEXEC)``: + set the close-on-exec flag +* ``flags = fcntl(fd, F_GETFD); fcntl(fd, F_SETFD, flags & ~FD_CLOEXEC)``: + clear the close-on-exec flag Availability: AIX, Digital UNIX, FreeBSD, HP-UX, IRIX, Linux, Mac OS X, OpenBSD, Solaris, SunOS, Unicos. @@ -628,20 +628,20 @@ New flags: - * ``O_CLOEXEC``: available on Linux (2.6.23), FreeBSD (8.3), - OpenBSD 5.0, Solaris 11, QNX, BeOS, next NetBSD release (6.1?). - This flag is part of POSIX.1-2008. - * ``SOCK_CLOEXEC`` flag for ``socket()`` and ``socketpair()``, - available on Linux 2.6.27, OpenBSD 5.2, NetBSD 6.0. - * ``WSA_FLAG_NO_HANDLE_INHERIT`` flag for ``WSASocket()``: supported - on Windows 7 with SP1, Windows Server 2008 R2 with SP1, and later - * ``fcntl()``: ``F_DUPFD_CLOEXEC`` flag, available on Linux 2.6.24, - OpenBSD 5.0, FreeBSD 9.1, NetBSD 6.0, Solaris 11. This flag is part - of POSIX.1-2008. - * ``fcntl()``: ``F_DUP2FD_CLOEXEC`` flag, available on FreeBSD 9.1 - and Solaris 11. - * ``recvmsg()``: ``MSG_CMSG_CLOEXEC``, available on Linux 2.6.23, - NetBSD 6.0. +* ``O_CLOEXEC``: available on Linux (2.6.23), FreeBSD (8.3), + OpenBSD 5.0, Solaris 11, QNX, BeOS, next NetBSD release (6.1?). + This flag is part of POSIX.1-2008. +* ``SOCK_CLOEXEC`` flag for ``socket()`` and ``socketpair()``, + available on Linux 2.6.27, OpenBSD 5.2, NetBSD 6.0. +* ``WSA_FLAG_NO_HANDLE_INHERIT`` flag for ``WSASocket()``: supported + on Windows 7 with SP1, Windows Server 2008 R2 with SP1, and later +* ``fcntl()``: ``F_DUPFD_CLOEXEC`` flag, available on Linux 2.6.24, + OpenBSD 5.0, FreeBSD 9.1, NetBSD 6.0, Solaris 11. This flag is part + of POSIX.1-2008. +* ``fcntl()``: ``F_DUP2FD_CLOEXEC`` flag, available on FreeBSD 9.1 + and Solaris 11. +* ``recvmsg()``: ``MSG_CMSG_CLOEXEC``, available on Linux 2.6.23, + NetBSD 6.0. On Linux older than 2.6.23, ``O_CLOEXEC`` flag is simply ignored. So we have to check that the flag is supported by calling ``fcntl()``. If @@ -657,9 +657,9 @@ New functions: - * ``dup3()``: available on Linux 2.6.27 (and glibc 2.9) - * ``pipe2()``: available on Linux 2.6.27 (and glibc 2.9) - * ``accept4()``: available on Linux 2.6.28 (and glibc 2.10) +* ``dup3()``: available on Linux 2.6.27 (and glibc 2.9) +* ``pipe2()``: available on Linux 2.6.27 (and glibc 2.9) +* ``accept4()``: available on Linux 2.6.28 (and glibc 2.10) If ``accept4()`` is called on Linux older than 2.6.28, ``accept4()`` returns ``-1`` (fail) and ``errno`` is set to ``ENOSYS``. @@ -670,55 +670,55 @@ Links: - * `Secure File Descriptor Handling - `_ (Ulrich Drepper, - 2008) - * `win32_support.py of the Tornado project - `_: - emulate fcntl(fd, F_SETFD, FD_CLOEXEC) using - ``SetHandleInformation(fd, HANDLE_FLAG_INHERIT, 1)`` - * `LKML: [PATCH] nextfd(2) - `_ +* `Secure File Descriptor Handling + `_ (Ulrich Drepper, + 2008) +* `win32_support.py of the Tornado project + `_: + emulate fcntl(fd, F_SETFD, FD_CLOEXEC) using + ``SetHandleInformation(fd, HANDLE_FLAG_INHERIT, 1)`` +* `LKML: [PATCH] nextfd(2) + `_ Python issues: - * `#10115: Support accept4() for atomic setting of flags at socket - creation `_ - * `#12105: open() does not able to set flags, such as O_CLOEXEC - `_ - * `#12107: TCP listening sockets created without FD_CLOEXEC flag - `_ - * `#16500: Add an atfork module - `_ - * `#16850: Add "e" mode to open(): close-and-exec - (O_CLOEXEC) / O_NOINHERIT `_ - * `#16860: Use O_CLOEXEC in the tempfile module - `_ - * `#17036: Implementation of the PEP 433 - `_ - * `#16946: subprocess: _close_open_fd_range_safe() does not set - close-on-exec flag on Linux < 2.6.23 if O_CLOEXEC is defined - `_ - * `#17070: PEP 433: Use the new cloexec to improve security and avoid - bugs `_ +* `#10115: Support accept4() for atomic setting of flags at socket + creation `_ +* `#12105: open() does not able to set flags, such as O_CLOEXEC + `_ +* `#12107: TCP listening sockets created without FD_CLOEXEC flag + `_ +* `#16500: Add an atfork module + `_ +* `#16850: Add "e" mode to open(): close-and-exec + (O_CLOEXEC) / O_NOINHERIT `_ +* `#16860: Use O_CLOEXEC in the tempfile module + `_ +* `#17036: Implementation of the PEP 433 + `_ +* `#16946: subprocess: _close_open_fd_range_safe() does not set + close-on-exec flag on Linux < 2.6.23 if O_CLOEXEC is defined + `_ +* `#17070: PEP 433: Use the new cloexec to improve security and avoid + bugs `_ Other languages: - * Perl sets the close-on-exec flag on newly created file decriptor if - their number is greater than ``$SYSTEM_FD_MAX`` (``$^F``). - See `$SYSTEM_FD_MAX documentation - `_. Perl does - this since the creation of Perl (it was already present in Perl 1). - * Ruby: `Set FD_CLOEXEC for all fds (except 0, 1, 2) - `_ - * Ruby: `O_CLOEXEC flag missing for Kernel::open - `_: the - `commit was reverted later - `_ - * OCaml: `PR#5256: Processes opened using Unix.open_process* inherit - all opened file descriptors (including sockets) - `_. OCaml has a - ``Unix.set_close_on_exec`` function. +* Perl sets the close-on-exec flag on newly created file decriptor if + their number is greater than ``$SYSTEM_FD_MAX`` (``$^F``). + See `$SYSTEM_FD_MAX documentation + `_. Perl does + this since the creation of Perl (it was already present in Perl 1). +* Ruby: `Set FD_CLOEXEC for all fds (except 0, 1, 2) + `_ +* Ruby: `O_CLOEXEC flag missing for Kernel::open + `_: the + `commit was reverted later + `_ +* OCaml: `PR#5256: Processes opened using Unix.open_process* inherit + all opened file descriptors (including sockets) + `_. OCaml has a + ``Unix.set_close_on_exec`` function. Footnotes @@ -732,3 +732,18 @@ has a descriptor smaller than 3, ``ValueError`` is raised. +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: diff --git a/pep-0437.txt b/pep-0437.txt --- a/pep-0437.txt +++ b/pep-0437.txt @@ -313,28 +313,28 @@ Two tools are available: - * *printsemant* reads a converter header and a .c file and dumps - the semantically checked parse tree to stdout. +* *printsemant* reads a converter header and a .c file and dumps + the semantically checked parse tree to stdout. - * *preprocess* reads a converter header and a .c file and dumps - the preprocessed .c file to stdout. +* *preprocess* reads a converter header and a .c file and dumps + the preprocessed .c file to stdout. Known deficiencies: - * The Python 'test' expression is not semantically checked. The syntax - however is checked since it is part of the grammar. +* The Python 'test' expression is not semantically checked. The syntax + however is checked since it is part of the grammar. - * The lexer does not handle triple quoted strings. +* The lexer does not handle triple quoted strings. - * C declarations are parsed in a primitive way. The final implementation - should utilize 'declarator' and 'init-declarator' from the C grammar. +* C declarations are parsed in a primitive way. The final implementation + should utilize 'declarator' and 'init-declarator' from the C grammar. - * The *preprocess* tool does not emit code for the left-and-right optional - arguments case. The *printsemant* tool can deal with this case. +* The *preprocess* tool does not emit code for the left-and-right optional + arguments case. The *printsemant* tool can deal with this case. - * Since the *preprocess* tool generates the output from the parse - tree, the original indentation of the define block is lost. +* Since the *preprocess* tool generates the output from the parse + tree, the original indentation of the define block is lost. Grammar @@ -350,37 +350,37 @@ The author of this PEP has the following concerns about the DSL proposed in PEP 436: - * The whitespace sensitive configuration file like syntax looks out - of place in a C file. +* The whitespace sensitive configuration file like syntax looks out + of place in a C file. - * The structure of the function definition gets lost in the per-parameter - specifications. Keywords like positional-only, required and keyword-only - are scattered across too many different places. +* The structure of the function definition gets lost in the per-parameter + specifications. Keywords like positional-only, required and keyword-only + are scattered across too many different places. - By contrast, in the alternative DSL the structure of the function - definition can be understood at a single glance. + By contrast, in the alternative DSL the structure of the function + definition can be understood at a single glance. - * The PEP 436 DSL has 14 documented flags and at least one undocumented - (allow_fd) flag. Figuring out which of the 2**15 possible combinations - are valid places an unnecessary burden on the user. +* The PEP 436 DSL has 14 documented flags and at least one undocumented + (allow_fd) flag. Figuring out which of the 2**15 possible combinations + are valid places an unnecessary burden on the user. - Experience with the PEP-3118 buffer flags has shown that sorting out - (and exhaustively testing!) valid combinations is an extremely tedious - task. The PEP-3118 flags are still not well understood by many people. + Experience with the PEP-3118 buffer flags has shown that sorting out + (and exhaustively testing!) valid combinations is an extremely tedious + task. The PEP-3118 flags are still not well understood by many people. - By contrast, the alternative DSL has a central file Include/converters.h - that can be quickly searched for the desired converter. Many of the - converters are already known, perhaps even memorized by people (due - to frequent use). + By contrast, the alternative DSL has a central file Include/converters.h + that can be quickly searched for the desired converter. Many of the + converters are already known, perhaps even memorized by people (due + to frequent use). - * The PEP 436 DSL allows too much freedom. Types can apparently be omitted, - the preprocessor accepts (and ignores) unknown keywords, sometimes adding - white space after a docstring results in an assertion error. +* The PEP 436 DSL allows too much freedom. Types can apparently be omitted, + the preprocessor accepts (and ignores) unknown keywords, sometimes adding + white space after a docstring results in an assertion error. - The alternative DSL on the other hand allows no such freedoms. Omitting - converter or return value annotations is plainly a syntax error. The - LALR(1) grammar is unambiguous and specified for the complete translation - unit. + The alternative DSL on the other hand allows no such freedoms. Omitting + converter or return value annotations is plainly a syntax error. The + LALR(1) grammar is unambiguous and specified for the complete translation + unit. Copyright diff --git a/pep-0446.txt b/pep-0446.txt --- a/pep-0446.txt +++ b/pep-0446.txt @@ -330,9 +330,9 @@ New functions: - * ``dup3()``: available on Linux 2.6.27 (and glibc 2.9) - * ``pipe2()``: available on Linux 2.6.27 (and glibc 2.9) - * ``accept4()``: available on Linux 2.6.28 (and glibc 2.10) +* ``dup3()``: available on Linux 2.6.27 (and glibc 2.9) +* ``pipe2()``: available on Linux 2.6.27 (and glibc 2.9) +* ``accept4()``: available on Linux 2.6.28 (and glibc 2.10) On Linux older than 2.6.28, ``accept4()`` fails with ``errno`` set to ``ENOSYS``. @@ -468,23 +468,23 @@ The following functions are modified to make newly created file descriptors non-inheritable by default: - * ``asyncore.dispatcher.create_socket()`` - * ``io.FileIO`` - * ``io.open()`` - * ``open()`` - * ``os.dup()`` - * ``os.fdopen()`` - * ``os.open()`` - * ``os.openpty()`` - * ``os.pipe()`` - * ``select.devpoll()`` - * ``select.epoll()`` - * ``select.kqueue()`` - * ``socket.socket()`` - * ``socket.socket.accept()`` - * ``socket.socket.dup()`` - * ``socket.socket.fromfd()`` - * ``socket.socketpair()`` +* ``asyncore.dispatcher.create_socket()`` +* ``io.FileIO`` +* ``io.open()`` +* ``open()`` +* ``os.dup()`` +* ``os.fdopen()`` +* ``os.open()`` +* ``os.openpty()`` +* ``os.pipe()`` +* ``select.devpoll()`` +* ``select.epoll()`` +* ``select.kqueue()`` +* ``socket.socket()`` +* ``socket.socket.accept()`` +* ``socket.socket.dup()`` +* ``socket.socket.fromfd()`` +* ``socket.socketpair()`` ``os.dup2()`` still creates inheritable by default, see below. diff --git a/pep-0457.txt b/pep-0457.txt --- a/pep-0457.txt +++ b/pep-0457.txt @@ -62,14 +62,14 @@ In addition, there are some functions with particularly interesting semantics: - * ``range()``, which accepts an optional parameter - to the *left* of its required parameter. [#RANGE]_ +* ``range()``, which accepts an optional parameter + to the *left* of its required parameter. [#RANGE]_ - * ``dict()``, whose mapping/iterator parameter is optional and - semantically must be positional-only. Any externally - visible name for this parameter would occlude - that name going into the ``**kwarg`` keyword variadic - parameter dict! [#DICT]_ +* ``dict()``, whose mapping/iterator parameter is optional and + semantically must be positional-only. Any externally + visible name for this parameter would occlude + that name going into the ``**kwarg`` keyword variadic + parameter dict! [#DICT]_ Obviously one can simulate any of these in pure Python code by accepting ``(*args, **kwargs)`` and parsing the arguments @@ -85,17 +85,17 @@ parameters in Python. The goal of this PEP is simply to define the syntax, so that: - * Documentation can clearly, unambiguously, and - consistently express exactly how the arguments - for a function will be interpreted. +* Documentation can clearly, unambiguously, and + consistently express exactly how the arguments + for a function will be interpreted. - * The syntax is reserved for future use, in case - the community decides someday to add positional-only - parameters to the language. +* The syntax is reserved for future use, in case + the community decides someday to add positional-only + parameters to the language. - * Argument Clinic can use a variant of the syntax - as part of its input when defining - the arguments for built-in functions. +* Argument Clinic can use a variant of the syntax + as part of its input when defining + the arguments for built-in functions. ================================================================= The Current State Of Documentation For Positional-Only Parameters @@ -179,28 +179,28 @@ More semantics of positional-only parameters: - * Although positional-only parameter technically have names, - these names are internal-only; positional-only parameters - are *never* externally addressable by name. (Similarly - to ``*args`` and ``**kwargs``.) +* Although positional-only parameter technically have names, + these names are internal-only; positional-only parameters + are *never* externally addressable by name. (Similarly + to ``*args`` and ``**kwargs``.) - * It's possible to nest option groups. +* It's possible to nest option groups. - * If there are no required parameters, all option groups behave - as if they're to the right of the required parameter group. +* If there are no required parameters, all option groups behave + as if they're to the right of the required parameter group. - * For clarity and consistency, the comma for a parameter always - comes immediately after the parameter name. It's a syntax error - to specify a square bracket between the name of a parameter and - the following comma. (This is far more readable than putting - the comma outside the square bracket, particularly for nested - groups.) +* For clarity and consistency, the comma for a parameter always + comes immediately after the parameter name. It's a syntax error + to specify a square bracket between the name of a parameter and + the following comma. (This is far more readable than putting + the comma outside the square bracket, particularly for nested + groups.) - * If there are arguments after the ``/``, then you must specify - a comma after the ``/``, just as there is a comma - after the ``*`` denoting the shift to keyword-only parameters. +* If there are arguments after the ``/``, then you must specify + a comma after the ``/``, just as there is a comma + after the ``*`` denoting the shift to keyword-only parameters. - * This syntax has no effect on ``*args`` or ``**kwargs``. +* This syntax has no effect on ``*args`` or ``**kwargs``. It's possible to specify a function prototype where the mapping of arguments to parameters is ambiguous. Consider:: @@ -273,9 +273,9 @@ There are three types of parameters in Python: - 1. positional-only parameters, - 2. positional-or-keyword parameters, and - 3. keyword-only parameters. +1. positional-only parameters, +2. positional-or-keyword parameters, and +3. keyword-only parameters. Python allows functions to have both 2 and 3. And some builtins (e.g. range) have both 1 and 3. Does it make diff --git a/pep-0461.txt b/pep-0461.txt --- a/pep-0461.txt +++ b/pep-0461.txt @@ -95,22 +95,22 @@ ``%b`` will insert a series of bytes. These bytes are collected in one of two ways:: - - input type supports ``Py_buffer`` [4]_? - use it to collect the necessary bytes +- input type supports ``Py_buffer`` [4]_? + use it to collect the necessary bytes - - input type is something else? - use its ``__bytes__`` method [5]_ ; if there isn't one, raise a ``TypeError`` +- input type is something else? + use its ``__bytes__`` method [5]_ ; if there isn't one, raise a ``TypeError`` In particular, ``%b`` will not accept numbers nor ``str``. ``str`` is rejected as the string to bytes conversion requires an encoding, and we are refusing to guess; numbers are rejected because: - - what makes a number is fuzzy (float? Decimal? Fraction? some user type?) +- what makes a number is fuzzy (float? Decimal? Fraction? some user type?) - - allowing numbers would lead to ambiguity between numbers and textual - representations of numbers (3.14 vs '3.14') +- allowing numbers would lead to ambiguity between numbers and textual + representations of numbers (3.14 vs '3.14') - - given the nature of wire formats, explicit is definitely better than implicit +- given the nature of wire formats, explicit is definitely better than implicit ``%s`` is included as a synonym for ``%b`` for the sole purpose of making 2/3 code bases easier to maintain. Python 3 only code should use ``%b``. @@ -177,15 +177,15 @@ It has been proposed to automatically use ``.encode('ascii','strict')`` for ``str`` arguments to ``%b``. - - Rejected as this would lead to intermittent failures. Better to have the - operation always fail so the trouble-spot can be correctly fixed. +- Rejected as this would lead to intermittent failures. Better to have the + operation always fail so the trouble-spot can be correctly fixed. It has been proposed to have ``%b`` return the ascii-encoded repr when the value is a ``str`` (b'%b' % 'abc' --> b"'abc'"). - - Rejected as this would lead to hard to debug failures far from the problem - site. Better to have the operation always fail so the trouble-spot can be - easily fixed. +- Rejected as this would lead to hard to debug failures far from the problem + site. Better to have the operation always fail so the trouble-spot can be + easily fixed. Originally this PEP also proposed adding format-style formatting, but it was decided that format and its related machinery were all strictly text (aka @@ -204,12 +204,12 @@ The objections raised against this PEP were mainly variations on two themes: - - the ``bytes`` and ``bytearray`` types are for pure binary data, with no - assumptions about encodings +- the ``bytes`` and ``bytearray`` types are for pure binary data, with no + assumptions about encodings - - offering %-interpolation that assumes an ASCII encoding will be an - attractive nuisance and lead us back to the problems of the Python 2 - ``str``/``unicode`` text model +- offering %-interpolation that assumes an ASCII encoding will be an + attractive nuisance and lead us back to the problems of the Python 2 + ``str``/``unicode`` text model As was seen during the discussion, ``bytes`` and ``bytearray`` are also used for mixed binary data and ASCII-compatible segments: file formats such as diff --git a/pep-0472.txt b/pep-0472.txt --- a/pep-0472.txt +++ b/pep-0472.txt @@ -136,12 +136,12 @@ Traditionally, the full content between square brackets is turned into a single object passed to argument ``idx``: - - When a single element is passed, e.g. ``a[2]``, ``idx`` will be ``2``. - - When multiple elements are passed, they must be separated by commas: ``a[2, 3]``. - In this case, ``idx`` will be a tuple ``(2, 3)``. With ``a[2, 3, "hello", {}]`` - ``idx`` will be ``(2, 3, "hello", {})``. - - A slicing notation e.g. ``a[2:10]`` will produce a slice object, or a tuple - containing slice objects if multiple values were passed. +- When a single element is passed, e.g. ``a[2]``, ``idx`` will be ``2``. +- When multiple elements are passed, they must be separated by commas: ``a[2, 3]``. + In this case, ``idx`` will be a tuple ``(2, 3)``. With ``a[2, 3, "hello", {}]`` + ``idx`` will be ``(2, 3, "hello", {})``. +- A slicing notation e.g. ``a[2:10]`` will produce a slice object, or a tuple + containing slice objects if multiple values were passed. Except for its unique ability to handle slice notation, the indexing operation has similarities to a plain method call: it acts like one when invoked with diff --git a/pep-0488.txt b/pep-0488.txt --- a/pep-0488.txt +++ b/pep-0488.txt @@ -37,9 +37,9 @@ is not true for PYO files. To put this in terms of optimization levels and the file extension: - - 0: ``.pyc`` - - 1 (``-O``): ``.pyo`` - - 2 (``-OO``): ``.pyo`` +- 0: ``.pyc`` +- 1 (``-O``): ``.pyo`` +- 2 (``-OO``): ``.pyo`` The reuse of the ``.pyo`` file extension for both level 1 and 2 optimizations means that there is no clear way to tell what @@ -85,9 +85,9 @@ based on the interpreter's optimization level (none, ``-O``, and ``-OO``): - - 0: ``foo.cpython-35.pyc`` (i.e., no change) - - 1: ``foo.cpython-35.opt-1.pyc`` - - 2: ``foo.cpython-35.opt-2.pyc`` +- 0: ``foo.cpython-35.pyc`` (i.e., no change) +- 1: ``foo.cpython-35.opt-1.pyc`` +- 2: ``foo.cpython-35.opt-2.pyc`` Currently bytecode file names are created by ``importlib.util.cache_from_source()``, approximately using the diff --git a/pep-0498.txt b/pep-0498.txt --- a/pep-0498.txt +++ b/pep-0498.txt @@ -465,9 +465,9 @@ Most of the discussions on python-ideas [#]_ focused on three issues: - - How to denote f-strings, - - How to specify the location of expressions in f-strings, and - - Whether to allow full Python expressions. +- How to denote f-strings, +- How to specify the location of expressions in f-strings, and +- Whether to allow full Python expressions. How to denote f-strings *********************** diff --git a/pep-0628.txt b/pep-0628.txt --- a/pep-0628.txt +++ b/pep-0628.txt @@ -72,12 +72,12 @@ specific examples sufficiently persausive, here are some more resources that may be of interest: - * Michael Hartl is the primary instigator of Tau Day in his `Tau Manifesto`_ - * Bob Palais, the author of the original mathematics journal article - highlighting the problems with ``pi`` has `a page of resources`_ on the - topic - * For those that prefer videos to written text, `Pi is wrong!`_ and - `Pi is (still) wrong`_ are available on YouTube +* Michael Hartl is the primary instigator of Tau Day in his `Tau Manifesto`_ +* Bob Palais, the author of the original mathematics journal article + highlighting the problems with ``pi`` has `a page of resources`_ on the + topic +* For those that prefer videos to written text, `Pi is wrong!`_ and + `Pi is (still) wrong`_ are available on YouTube .. _Tau Manifesto: http://tauday.com/ .. _Pi is (still) wrong: http://www.youtube.com/watch?v=jG7vhMMXagQ -- Repository URL: https://hg.python.org/peps From solipsis at pitrou.net Tue May 3 04:45:45 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Tue, 03 May 2016 08:45:45 +0000 Subject: [Python-checkins] Daily reference leaks (63f4fd1ec636): sum=0 Message-ID: <20160503084542.109944.12546.A3806085@psf.io> results for 63f4fd1ec636 on branch "default" -------------------------------------------- test_collections leaked [-4, 0, 0] memory blocks, sum=-4 test_functools leaked [0, 3, 1] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogtxRZgt', '--timeout', '7200'] From python-checkins at python.org Tue May 3 05:07:10 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 03 May 2016 09:07:10 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Issue_=2326916=3A_Fixed_words?= =?utf-8?q?_duplications=2E?= Message-ID: <20160503090705.3146.4366.B939A15A@psf.io> https://hg.python.org/peps/rev/d0b969132758 changeset: 6304:d0b969132758 user: Serhiy Storchaka date: Tue May 03 12:03:16 2016 +0300 summary: Issue #26916: Fixed words duplications. files: pep-0101.txt | 2 +- pep-0205.txt | 2 +- pep-0208.txt | 2 +- pep-0237.txt | 4 ++-- pep-0253.txt | 4 ++-- pep-0262.txt | 2 +- pep-0287.txt | 2 +- pep-0304.txt | 2 +- pep-0326.txt | 2 +- pep-0344.txt | 2 +- pep-0355.txt | 2 +- pep-0374.txt | 4 ++-- pep-0386.txt | 2 +- pep-0390.txt | 2 +- pep-0405.txt | 2 +- pep-0408.txt | 4 ++-- pep-0411.txt | 2 +- pep-0416.txt | 2 +- pep-0433.txt | 2 +- pep-0436.txt | 2 +- pep-0449.txt | 2 +- pep-0452.txt | 2 +- pep-0454.txt | 2 +- pep-0456.txt | 4 ++-- pep-0458.txt | 2 +- pep-0460.txt | 2 +- pep-0463.txt | 2 +- pep-0465.txt | 4 ++-- pep-0475.txt | 2 +- pep-0484.txt | 2 +- pep-0486.txt | 2 +- pep-0498.txt | 2 +- pep-0505.txt | 4 ++-- pep-0509.txt | 2 +- pep-0510.txt | 2 +- pep-0517.txt | 4 ++-- pep-3104.txt | 2 +- pep-3116.txt | 2 +- pep-3118.txt | 2 +- pep-3119.txt | 2 +- pep-3124.txt | 2 +- pep-3127.txt | 2 +- pep-3134.txt | 2 +- pep-3139.txt | 4 ++-- pep-3144.txt | 2 +- pep-3145.txt | 2 +- pep-3148.txt | 4 ++-- pep-3156.txt | 2 +- 48 files changed, 58 insertions(+), 58 deletions(-) diff --git a/pep-0101.txt b/pep-0101.txt --- a/pep-0101.txt +++ b/pep-0101.txt @@ -258,7 +258,7 @@ ___ Add a new whatsnew/3.x.rst file (with the comment near the top and the toplevel sections copied from the previous file) and - and add it to the toctree in whatsnew/index.rst. + add it to the toctree in whatsnew/index.rst. ___ Update the version number in configure.ac and re-run autoconf. diff --git a/pep-0205.txt b/pep-0205.txt --- a/pep-0205.txt +++ b/pep-0205.txt @@ -364,7 +364,7 @@ An example vref module using this model could include the function "new"; When used as 'MyVref = vref.new(MyObject)', it - returns a new vref object such that that MyVref.object == + returns a new vref object such that MyVref.object == MyObject. MyVref.object would then change to Nothing if MyObject is ever deallocated. diff --git a/pep-0208.txt b/pep-0208.txt --- a/pep-0208.txt +++ b/pep-0208.txt @@ -83,7 +83,7 @@ style operations if the number indicates the availability of these. A new style number is considered by the interpreter as such if and - only it it sets the type flag Py_TPFLAGS_CHECKTYPES. The main + only if it sets the type flag Py_TPFLAGS_CHECKTYPES. The main difference between an old style number and a new style one is that the numeric slot functions can no longer assume to be passed arguments of identical type. New style slots must check all arguments for proper diff --git a/pep-0237.txt b/pep-0237.txt --- a/pep-0237.txt +++ b/pep-0237.txt @@ -140,7 +140,7 @@ inclusive) are "interned" -- whenever a result has such a value, an existing short int with the same value is returned. This is not done for long ints with the same values. This difference - will remain. (Since there is no guarantee of this interning, is + will remain. (Since there is no guarantee of this interning, it is debatable whether this is a semantic difference -- but code may exist that uses 'is' for comparisons of short ints and happens to work because of this interning. Such code may fail @@ -291,7 +291,7 @@ Example If you pass a long int to a C function or built-in operation that - takes an integer, it will be treated the same as as a short int as + takes an integer, it will be treated the same as a short int as long as the value fits (by virtue of how PyArg_ParseTuple() is implemented). If the long value doesn't fit, it will still raise an OverflowError. For example: diff --git a/pep-0253.txt b/pep-0253.txt --- a/pep-0253.txt +++ b/pep-0253.txt @@ -199,7 +199,7 @@ callable. Since type objects are instances of their metatype (PyType_Type), the metatype's tp_call slot (PyType_Type.tp_call) points to a function that is invoked when any type object is - called. Now, since each type has do do something different to + called. Now, since each type has to do something different to create an instance of itself, PyType_Type.tp_call immediately defers to the tp_new slot of the type that is being called. PyType_Type itself is also callable: its tp_new slot creates a new @@ -271,7 +271,7 @@ tp_new() is the type that defined the tp_new() function (in the example, if type == &PyInt_Type), and when the tp_init() slot for this type does nothing. If the type argument differs, the - tp_new() call is initiated by by a derived type's tp_new() to + tp_new() call is initiated by a derived type's tp_new() to create the object and initialize the base type portion of the object; in this case tp_new() should always return a new object (or raise an exception). diff --git a/pep-0262.txt b/pep-0262.txt --- a/pep-0262.txt +++ b/pep-0262.txt @@ -73,7 +73,7 @@ A distribution that uses the Distutils for installation should automatically update the database. Distributions that roll their - own installation will have to use the database's API to to + own installation will have to use the database's API to manually add or update their own entry. System package managers such as RPM or pkgadd can just create the new file in the INSTALLDB directory. diff --git a/pep-0287.txt b/pep-0287.txt --- a/pep-0287.txt +++ b/pep-0287.txt @@ -252,7 +252,7 @@ - SText implementations have been buggy. - - Most STexts have have had no formal specification except for the + - Most STexts have no formal specification except for the implementation itself. A buggy implementation meant a buggy spec, and vice-versa. diff --git a/pep-0304.txt b/pep-0304.txt --- a/pep-0304.txt +++ b/pep-0304.txt @@ -179,7 +179,7 @@ performance penalty is incurred each time a program importing the module is run. [3]_ Warning messages may also be generated in certain circumstances. If the directory is writable, nearly simultaneous -attempts attempts to write the bytecode file by two separate processes +attempts to write the bytecode file by two separate processes may occur, resulting in file corruption. [4]_ In environments with RAM disks available, it may be desirable for diff --git a/pep-0326.txt b/pep-0326.txt --- a/pep-0326.txt +++ b/pep-0326.txt @@ -244,7 +244,7 @@ None itself compares smaller than any other object in the standard distribution. -As an aside, it is not clear to to the author that using Nodes as a +As an aside, it is not clear to the author that using Nodes as a replacement for tuples has increased readability significantly, if at all. diff --git a/pep-0344.txt b/pep-0344.txt --- a/pep-0344.txt +++ b/pep-0344.txt @@ -112,7 +112,7 @@ To keep things simpler, the C API calls for setting an exception will not automatically set the exception's '__context__'. Guido - van Rossum has has expressed concerns with making such changes [8]. + van Rossum has expressed concerns with making such changes [8]. As for other languages, Java and Ruby both discard the original exception when another exception occurs in a 'catch'/'rescue' or diff --git a/pep-0355.txt b/pep-0355.txt --- a/pep-0355.txt +++ b/pep-0355.txt @@ -67,7 +67,7 @@ Currently, Python has a large number of different functions scattered over half a dozen modules for handling paths. This - makes it hard for newbies and experienced developers to to choose + makes it hard for newbies and experienced developers to choose the right method. The Path class provides the following enhancements over the diff --git a/pep-0374.txt b/pep-0374.txt --- a/pep-0374.txt +++ b/pep-0374.txt @@ -495,7 +495,7 @@ ``git diff master > stuff-i-did.patch``, too, but ``git format-patch | git am`` knows some tricks (empty files, renames, etc) that ordinary patch can't handle. git -grabs "Stuff I did" out of the the commit message to create the file +grabs "Stuff I did" out of the commit message to create the file name 0001-Stuff-I-did.patch. See Patch Review below for a description of the git-format-patch format. :: @@ -1322,7 +1322,7 @@ Tests/Impressions ================= -As I (Brett Cannon) am left with the task of of making the final +As I (Brett Cannon) am left with the task of making the final decision of which/any DVCS to go with and not my co-authors, I felt it only fair to write down what tests I ran and my impressions as I evaluate the various tools so as to be as transparent as possible. diff --git a/pep-0386.txt b/pep-0386.txt --- a/pep-0386.txt +++ b/pep-0386.txt @@ -240,7 +240,7 @@ Finally, to handle miscellaneous cases, the strings "pre", "preview", and "rc" are treated as if they were "c", i.e. as though they were release candidates, and therefore are not as new as a version string that does not - contain them, and "dev" is replaced with an '@' so that it sorts lower than + contain them, and "dev" is replaced with an '@' so that it sorts lower than any other pre-release tag. In other words, ``parse_version`` will return a tuple for each version string, diff --git a/pep-0390.txt b/pep-0390.txt --- a/pep-0390.txt +++ b/pep-0390.txt @@ -212,7 +212,7 @@ Compatiblity ============ -This change is is based on a new metadata ``1.2`` format meaning that +This change is based on a new metadata ``1.2`` format meaning that Distutils will be able to distinguish old PKG-INFO files from new ones. The ``setup.cfg`` file change will stay ``ConfigParser``-compatible and diff --git a/pep-0405.txt b/pep-0405.txt --- a/pep-0405.txt +++ b/pep-0405.txt @@ -103,7 +103,7 @@ same value as ``sys.prefix``.) The ``site`` and ``sysconfig`` standard-library modules are modified -such that the standard library and header files are are found relative +such that the standard library and header files are found relative to ``sys.base_prefix`` / ``sys.base_exec_prefix``, while site-package directories ("purelib" and "platlib", in ``sysconfig`` terms) are still found relative to ``sys.prefix`` / ``sys.exec_prefix``. diff --git a/pep-0408.txt b/pep-0408.txt --- a/pep-0408.txt +++ b/pep-0408.txt @@ -83,7 +83,7 @@ whether via ``__preview__`` or directly, must fulfill the acceptance conditions set by PEP 2. -It is important to stress that the aim of of this proposal is not to make the +It is important to stress that the aim of this proposal is not to make the process of adding new modules to the standard library more difficult. On the contrary, it tries to provide a means to add *more* useful libraries. Modules which are obvious candidates for entry can be added as before. Modules which @@ -118,7 +118,7 @@ from __preview__ import example -Assuming the module is then promoted to the the standard library proper in +Assuming the module is then promoted to the standard library proper in release ``3.X+1``, it will be moved to a permanent location in the library:: import example diff --git a/pep-0411.txt b/pep-0411.txt --- a/pep-0411.txt +++ b/pep-0411.txt @@ -23,7 +23,7 @@ "graduating" into a "stable" state. On one hand, this state provides the package with the benefits of being formally part of the Python distribution. On the other hand, the core development team explicitly states that no promises -are made with regards to the the stability of the package's API, which may +are made with regards to the stability of the package's API, which may change for the next release. While it is considered an unlikely outcome, such packages may even be removed from the standard library without a deprecation period if the concerns regarding their API or maintenance prove diff --git a/pep-0416.txt b/pep-0416.txt --- a/pep-0416.txt +++ b/pep-0416.txt @@ -100,7 +100,7 @@ Recipe: hashable dict ====================== -To ensure that a a frozendict is hashable, values can be checked +To ensure that a frozendict is hashable, values can be checked before creating the frozendict:: import itertools diff --git a/pep-0433.txt b/pep-0433.txt --- a/pep-0433.txt +++ b/pep-0433.txt @@ -652,7 +652,7 @@ socket type, ``socket()`` or ``socketpair()`` fail and ``errno`` is set to ``EINVAL``. -On Windows XPS3, ``WSASocket()`` with with ``WSAEPROTOTYPE`` when +On Windows XPS3, ``WSASocket()`` with ``WSAEPROTOTYPE`` when ``WSA_FLAG_NO_HANDLE_INHERIT`` flag is used. New functions: diff --git a/pep-0436.txt b/pep-0436.txt --- a/pep-0436.txt +++ b/pep-0436.txt @@ -315,7 +315,7 @@ Parameter Declaration --------------------- -The full form of the parameter declaration line as as follows:: +The full form of the parameter declaration line as follows:: name: converter [ (parameter=value [, parameter2=value2]) ] [ = default] diff --git a/pep-0449.txt b/pep-0449.txt --- a/pep-0449.txt +++ b/pep-0449.txt @@ -132,7 +132,7 @@ ========================= The mirroring protocol will continue to exist as defined in `PEP381`_ and -people are encouraged to to host public and private mirrors if they so desire. +people are encouraged to host public and private mirrors if they so desire. The recommended mirroring client is `Bandersnatch`_. diff --git a/pep-0452.txt b/pep-0452.txt --- a/pep-0452.txt +++ b/pep-0452.txt @@ -86,7 +86,7 @@ of the hash algorithm in bytes. The block size is used by the HMAC module to pad the secret key to digest_size or to hash the secret key if it is longer than digest_size. If no HMAC - algorithm is standardized for the the hash algorithm, return + algorithm is standardized for the hash algorithm, return ``NotImplemented`` instead. name diff --git a/pep-0454.txt b/pep-0454.txt --- a/pep-0454.txt +++ b/pep-0454.txt @@ -202,7 +202,7 @@ store more frames. The ``tracemalloc`` module must be tracing memory allocations to - take a snapshot, see the the ``start()`` function. + take a snapshot, see the ``start()`` function. See also the ``get_object_traceback()`` function. diff --git a/pep-0456.txt b/pep-0456.txt --- a/pep-0456.txt +++ b/pep-0456.txt @@ -88,7 +88,7 @@ Current implementation with modified FNV ======================================== -CPython currently uses uses a variant of the Fowler-Noll-Vo hash function +CPython currently uses a variant of the Fowler-Noll-Vo hash function [fnv]_. The variant is has been modified to reduce the amount and cost of hash collisions for common strings. The first character of the string is added twice, the first time with a bit shift of 7. The length of the input @@ -595,7 +595,7 @@ 3. Hash maps have a worst case of O(n) for insertion and lookup of keys. This results in a quadratic runtime during a hash collision attack. The - introduction of a new and additional data structure with with O(log n) + introduction of a new and additional data structure with O(log n) worst case behavior would eliminate the root cause. A data structures like red-black-tree or prefix trees (trie [trie]_) would have other benefits, too. Prefix trees with stringed keyed can reduce memory usage as common diff --git a/pep-0458.txt b/pep-0458.txt --- a/pep-0458.txt +++ b/pep-0458.txt @@ -1082,7 +1082,7 @@ helped us to design TUF from its predecessor Thandy of the Tor project. We appreciate the efforts of Konstantin Andrianov, Geremy Condra, Zane Fisher, -Justin Samuel, Tian Tian, Santiago Torres, John Ward, and Yuyu Zheng to to +Justin Samuel, Tian Tian, Santiago Torres, John Ward, and Yuyu Zheng to develop TUF. Vladimir Diaz, Monzur Muhammad and Sai Teja Peddinti helped us to review this diff --git a/pep-0460.txt b/pep-0460.txt --- a/pep-0460.txt +++ b/pep-0460.txt @@ -111,7 +111,7 @@ * In 3.3 encoding to ASCII or latin-1 is as fast as memcpy (but it still creates a separate object). * Developers will have to work around the lack of binary formatting anyway, - if they want to to support Python 3.4 and earlier. + if they want to support Python 3.4 and earlier. * bytes.join() is consistently faster than format to join bytes strings (XXX *is it?*). * Formatting functions could be implemented in a third party module, diff --git a/pep-0463.txt b/pep-0463.txt --- a/pep-0463.txt +++ b/pep-0463.txt @@ -637,7 +637,7 @@ `Tcl`__ has the other half of Lua's xpcall; catch is a function which returns true if an exception was caught, false otherwise, and you get the value out -in other ways. And it's all built around the the implicit quote-and-exec +in other ways. And it's all built around the implicit quote-and-exec that everything in Tcl is based on, making it even harder to describe in Python terms than Lisp macros, but something like diff --git a/pep-0465.txt b/pep-0465.txt --- a/pep-0465.txt +++ b/pep-0465.txt @@ -208,7 +208,7 @@ reverse convention would lead to more special cases.) So that's why matrix multiplication doesn't and can't just use ``*``. -Now, in the the rest of this section, we'll explain why it nonetheless +Now, in the rest of this section, we'll explain why it nonetheless meets the high bar for adding a new operator. @@ -1195,7 +1195,7 @@ test the null hypothesis that :math:`H\beta = r`; a large :math:`S` then indicates that this hypothesis is unlikely to be true. For example, in an analysis of human height, the vector :math:`\beta` - might contain one value which was the the average height of the + might contain one value which was the average height of the measured men, and another value which was the average height of the measured women, and then setting :math:`H = [1, -1], r = 0` would let us test whether men and women are the same height on diff --git a/pep-0475.txt b/pep-0475.txt --- a/pep-0475.txt +++ b/pep-0475.txt @@ -136,7 +136,7 @@ application. There are two options to interrupt an application on only *some* signals: -* Set up a custom signal signal handler which raises an exception, such as +* Set up a custom signal handler which raises an exception, such as ``KeyboardInterrupt`` for ``SIGINT``. * Use a I/O multiplexing function like ``select()`` together with Python's signal wakeup file descriptor: see the function ``signal.set_wakeup_fd()``. diff --git a/pep-0484.txt b/pep-0484.txt --- a/pep-0484.txt +++ b/pep-0484.txt @@ -1414,7 +1414,7 @@ ``NamedTuple(type_name, [(field_name, field_type), ...])`` and equivalent to ``collections.namedtuple(type_name, [field_name, ...])``. - This is useful to declare the types of the fields of a a named tuple + This is useful to declare the types of the fields of a named tuple type. * cast(), described earlier diff --git a/pep-0486.txt b/pep-0486.txt --- a/pep-0486.txt +++ b/pep-0486.txt @@ -57,7 +57,7 @@ pip install pytest py.test -Having to use different commands is is error-prone, and in many cases +Having to use different commands is error-prone, and in many cases the error is difficult to spot immediately. The PEP proposes making the ``py`` command usable with virtual environments, so that the first form of command can be used in all cases. diff --git a/pep-0498.txt b/pep-0498.txt --- a/pep-0498.txt +++ b/pep-0498.txt @@ -296,7 +296,7 @@ f'abc{expr1:spec1}{expr2!r:spec2}def{expr3}ghi' -Might be be evaluated as:: +Might be evaluated as:: 'abc' + format(expr1, spec1) + format(repr(expr2), spec2) + 'def' + format(expr3) + 'ghi' diff --git a/pep-0505.txt b/pep-0505.txt --- a/pep-0505.txt +++ b/pep-0505.txt @@ -302,7 +302,7 @@ Both ``first_seen`` and ``last_seen`` are allowed to be ``null`` in the database, and they are also allowed to be ``null`` in the JSON response. JSON -does not have a native way to represent a ``datetime``, so the the server's +does not have a native way to represent a ``datetime``, so the server's contract states that any non-``null`` date is represented as a ISO-8601 string. Note that this code is invalid by PEP-8 standards: several lines are over the @@ -925,7 +925,7 @@ The ``None``-aware attribute access operator (also called "safe navigation") checks its left operand. If the left operand is ``None``, then the operator -evaluates to ``None``. If the the left operand is not ``None``, then the +evaluates to ``None``. If the left operand is not ``None``, then the operator accesses the attribute named by the right operand. As in the previous section, we continue to use the temporary spelling ``?``:: diff --git a/pep-0509.txt b/pep-0509.txt --- a/pep-0509.txt +++ b/pep-0509.txt @@ -457,7 +457,7 @@ Method cache and type version tag --------------------------------- -In 2007, Armin Rigo wrote a patch to to implement a cache of methods. It +In 2007, Armin Rigo wrote a patch to implement a cache of methods. It was merged into Python 2.6. The patch adds a "type attribute cache version tag" (``tp_version_tag``) and a "valid version tag" flag to types (the ``PyTypeObject`` structure). diff --git a/pep-0510.txt b/pep-0510.txt --- a/pep-0510.txt +++ b/pep-0510.txt @@ -348,7 +348,7 @@ and must not have specialized code. If *code* is a Python function or a code object, a new code object is -created and the code name and first number number of the code object of +created and the code name and first line number of the code object of *func* are copied. The specialized code must have the same cell variables and the same free variables. diff --git a/pep-0517.txt b/pep-0517.txt --- a/pep-0517.txt +++ b/pep-0517.txt @@ -100,7 +100,7 @@ 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 +consists of 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 @@ -560,7 +560,7 @@ 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 +we make it much cheaper to fix bugs in the IPC interface than if fixing bugs requires coordinated agreement and coordinated changes across the ecosystem. diff --git a/pep-3104.txt b/pep-3104.txt --- a/pep-3104.txt +++ b/pep-3104.txt @@ -82,7 +82,7 @@ languages, including JavaScript, Perl, Ruby, Scheme, Smalltalk, C with GNU extensions, and C# 2.0. -It has been argued that that such a feature isn't necessary, because +It has been argued that such a feature isn't necessary, because a rebindable outer variable can be simulated by wrapping it in a mutable object:: diff --git a/pep-3116.txt b/pep-3116.txt --- a/pep-3116.txt +++ b/pep-3116.txt @@ -422,7 +422,7 @@ Unicode encoding/decoding Issues -------------------------------- -We should allow allow changing the encoding and error-handling +We should allow changing the encoding and error-handling setting later. The behavior of Text I/O operations in the face of Unicode problems and ambiguities (e.g. diacritics, surrogates, invalid bytes in an encoding) should be the same as that of the unicode diff --git a/pep-3118.txt b/pep-3118.txt --- a/pep-3118.txt +++ b/pep-3118.txt @@ -551,7 +551,7 @@ readable, writable, or set to update the original buffer if a copy must be made. If buffertype is PyBUF_WRITE and the buffer is not contiguous an error will be raised. In this circumstance, the user -can use PyBUF_UPDATEIFCOPY to ensure that a a writable temporary +can use PyBUF_UPDATEIFCOPY to ensure that a writable temporary contiguous buffer is returned. The contents of this contiguous buffer will be copied back into the original object after the memoryview object is deleted as long as the original object is writable. If this diff --git a/pep-3119.txt b/pep-3119.txt --- a/pep-3119.txt +++ b/pep-3119.txt @@ -250,7 +250,7 @@ ``x.__class__`` are not the same object, e.g. when x is a proxy object.) -These methods are intended to be be called on classes whose metaclass +These methods are intended to be called on classes whose metaclass is (derived from) ``ABCMeta``; for example:: from abc import ABCMeta diff --git a/pep-3124.txt b/pep-3124.txt --- a/pep-3124.txt +++ b/pep-3124.txt @@ -220,7 +220,7 @@ The default predicate implementation is a tuple of types with positional matching to the overloaded function's arguments. However, -an arbitrary number of other kinds of of predicates can be created and +an arbitrary number of other kinds of predicates can be created and registered using the `Extension API`_, and will then be usable with ``@when`` and other decorators created by this module (like ``@before``, ``@after``, and ``@around``). diff --git a/pep-3127.txt b/pep-3127.txt --- a/pep-3127.txt +++ b/pep-3127.txt @@ -402,7 +402,7 @@ Syntax for supported radices ----------------------------- -This proposal is to to use a "0o" prefix with either uppercase +This proposal is to use a "0o" prefix with either uppercase or lowercase "o" for octal, and a "0b" prefix with either uppercase or lowercase "b" for binary. diff --git a/pep-3134.txt b/pep-3134.txt --- a/pep-3134.txt +++ b/pep-3134.txt @@ -112,7 +112,7 @@ To keep things simpler, the C API calls for setting an exception will not automatically set the exception's '__context__'. Guido - van Rossum has has expressed concerns with making such changes [8]. + van Rossum has expressed concerns with making such changes [8]. As for other languages, Java and Ruby both discard the original exception when another exception occurs in a 'catch'/'rescue' or diff --git a/pep-3139.txt b/pep-3139.txt --- a/pep-3139.txt +++ b/pep-3139.txt @@ -78,7 +78,7 @@ causing clutter in sys. Guido has even said he doesn't recognize some of things in it [#bug-1522]_! -Moving these items items off to another module would send a clear message to +Moving these items off to another module would send a clear message to other Python implementations about what functions need and need not be implemented. @@ -119,7 +119,7 @@ =============== Once implemented in 3.x, the interpreter module will be back-ported to 2.6. -Py3k warnings will be added the the sys functions it replaces. +Py3k warnings will be added to the sys functions it replaces. Open Issues diff --git a/pep-3144.txt b/pep-3144.txt --- a/pep-3144.txt +++ b/pep-3144.txt @@ -150,7 +150,7 @@ [1] Appealing to authority is a logical fallacy, but Vint Cerf is an - an authority who can't be ignored. Full text of the email + authority who can't be ignored. Full text of the email follows: """ diff --git a/pep-3145.txt b/pep-3145.txt --- a/pep-3145.txt +++ b/pep-3145.txt @@ -52,7 +52,7 @@ Windows builds of Python. Practically every I/O object in Python has a file-like wrapper of some sort. Sockets already act as such and for strings there is StringIO. Popen can be made to act like a file by simply - using the methods attached the the subprocess.Popen.stderr, stdout and + using the methods attached to the subprocess.Popen.stderr, stdout and stdin file-like objects. But when using the read and write methods of those options, you do not have the benefit of asynchronous I/O. In the proposed solution the wrapper wraps the asynchronous methods to mimic a diff --git a/pep-3148.txt b/pep-3148.txt --- a/pep-3148.txt +++ b/pep-3148.txt @@ -389,11 +389,11 @@ Rationale ========= -The proposed design of this module was heavily influenced by the the +The proposed design of this module was heavily influenced by the Java java.util.concurrent package [1]_. The conceptual basis of the module, as in Java, is the Future class, which represents the progress and result of an asynchronous computation. The Future class makes -little commitment to the evaluation mode being used e.g. it can be be +little commitment to the evaluation mode being used e.g. it can be used to represent lazy or eager evaluation, for evaluation using threads, processes or remote procedure call. diff --git a/pep-3156.txt b/pep-3156.txt --- a/pep-3156.txt +++ b/pep-3156.txt @@ -984,7 +984,7 @@ - ``cancel()``. If the Future is already done (or cancelled), do nothing and return ``False``. Otherwise, this attempts to cancel - the Future and returns ``True``. If the the cancellation attempt is + the Future and returns ``True``. If the cancellation attempt is successful, eventually the Future's state will change to cancelled (so that ``cancelled()`` will return ``True``) and the callbacks will be scheduled. For regular Futures, -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Tue May 3 06:28:15 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 03 May 2016 10:28:15 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Convert_to_Unix_newlines=2E?= Message-ID: <20160503102813.34489.44527.A1A86216@psf.io> https://hg.python.org/peps/rev/8cc3b2c1eb31 changeset: 6305:8cc3b2c1eb31 user: Serhiy Storchaka date: Tue May 03 13:27:59 2016 +0300 summary: Convert to Unix newlines. files: pep-0506.txt | 898 +++++++++++++++++++------------------- pep-0514.txt | 504 ++++++++++---------- 2 files changed, 701 insertions(+), 701 deletions(-) diff --git a/pep-0506.txt b/pep-0506.txt --- a/pep-0506.txt +++ b/pep-0506.txt @@ -1,449 +1,449 @@ -PEP: 506 -Title: Adding A Secrets Module To The Standard Library -Version: $Revision$ -Last-Modified: $Date$ -Author: Steven D'Aprano -Status: Accepted -Type: Standards Track -Content-Type: text/x-rst -Created: 19-Sep-2015 -Python-Version: 3.6 -Post-History: - - -Abstract -======== - -This PEP proposes the addition of a module for common security-related -functions such as generating tokens to the Python standard library. - - -Definitions -=========== - -Some common abbreviations used in this proposal: - -* PRNG: - - Pseudo Random Number Generator. A deterministic algorithm used - to produce random-looking numbers with certain desirable - statistical properties. - -* CSPRNG: - - Cryptographically Strong Pseudo Random Number Generator. An - algorithm used to produce random-looking numbers which are - resistant to prediction. - -* MT: - - Mersenne Twister. An extensively studied PRNG which is currently - used by the ``random`` module as the default. - - -Rationale -========= - -This proposal is motivated by concerns that Python's standard library -makes it too easy for developers to inadvertently make serious security -errors. Theo de Raadt, the founder of OpenBSD, contacted Guido van Rossum -and expressed some concern [#]_ about the use of MT for generating sensitive -information such as passwords, secure tokens, session keys and similar. - -Although the documentation for the ``random`` module explicitly states that -the default is not suitable for security purposes [#]_, it is strongly -believed that this warning may be missed, ignored or misunderstood by -many Python developers. In particular: - -* developers may not have read the documentation and consequently - not seen the warning; - -* they may not realise that their specific use of the module has security - implications; or - -* not realising that there could be a problem, they have copied code - (or learned techniques) from websites which don't offer best - practises. - -The first [#]_ hit when searching for "python how to generate passwords" on -Google is a tutorial that uses the default functions from the ``random`` -module [#]_. Although it is not intended for use in web applications, it is -likely that similar techniques find themselves used in that situation. -The second hit is to a StackOverflow question about generating -passwords [#]_. Most of the answers given, including the accepted one, use -the default functions. When one user warned that the default could be -easily compromised, they were told "I think you worry too much." [#]_ - -This strongly suggests that the existing ``random`` module is an attractive -nuisance when it comes to generating (for example) passwords or secure -tokens. - -Additional motivation (of a more philosophical bent) can be found in the -post which first proposed this idea [#]_. - - -Proposal -======== - -Alternative proposals have focused on the default PRNG in the ``random`` -module, with the aim of providing "secure by default" cryptographically -strong primitives that developers can build upon without thinking about -security. (See Alternatives below.) This proposes a different approach: - -* The standard library already provides cryptographically strong - primitives, but many users don't know they exist or when to use them. - -* Instead of requiring crypto-naive users to write secure code, the - standard library should include a set of ready-to-use "batteries" for - the most common needs, such as generating secure tokens. This code - will both directly satisfy a need ("How do I generate a password reset - token?"), and act as an example of acceptable practises which - developers can learn from [#]_. - -To do this, this PEP proposes that we add a new module to the standard -library, with the suggested name ``secrets``. This module will contain a -set of ready-to-use functions for common activities with security -implications, together with some lower-level primitives. - -The suggestion is that ``secrets`` becomes the go-to module for dealing -with anything which should remain secret (passwords, tokens, etc.) -while the ``random`` module remains backward-compatible. - - -API and Implementation -====================== - -This PEP proposes the following functions for the ``secrets`` module: - -* Functions for generating tokens suitable for use in (e.g.) password - recovery, as session keys, etc., in the following formats: - - - as bytes, ``secrets.token_bytes``; - - as text, using hexadecimal digits, ``secrets.token_hex``; - - as text, using URL-safe base-64 encoding, ``secrets.token_urlsafe``. - -* A limited interface to the system CSPRNG, using either ``os.urandom`` - directly or ``random.SystemRandom``. Unlike the ``random`` module, this - does not need to provide methods for seeding, getting or setting the - state, or any non-uniform distributions. It should provide the - following: - - - A function for choosing items from a sequence, ``secrets.choice``. - - A function for generating a given number of random bits and/or bytes - as an integer, ``secrets.randbits``. - - A function for returning a random integer in the half-open range - 0 to the given upper limit, ``secrets.randbelow`` [#]_. - -* A function for comparing text or bytes digests for equality while being - resistent to timing attacks, ``secrets.compare_digest``. - -The consensus appears to be that there is no need to add a new CSPRNG to -the ``random`` module to support these uses, ``SystemRandom`` will be -sufficient. - -Some illustrative implementations have been given by Nick Coghlan [#]_ -and a minimalist API by Tim Peters [#]_. This idea has also been discussed -on the issue tracker for the "cryptography" module [#]_. The following -pseudo-code should be taken as the starting point for the real -implementation:: - - from random import SystemRandom - from hmac import compare_digest - - _sysrand = SystemRandom() - - randbits = _sysrand.getrandbits - choice = _sysrand.choice - - def randbelow(exclusive_upper_bound): - return _sysrand._randbelow(exclusive_upper_bound) - - DEFAULT_ENTROPY = 32 # bytes - - def token_bytes(nbytes=None): - if nbytes is None: - nbytes = DEFAULT_ENTROPY - return os.urandom(nbytes) - - def token_hex(nbytes=None): - return binascii.hexlify(token_bytes(nbytes)).decode('ascii') - - def token_urlsafe(nbytes=None): - tok = token_bytes(nbytes) - return base64.urlsafe_b64encode(tok).rstrip(b'=').decode('ascii') - - -The ``secrets`` module itself will be pure Python, and other Python -implementations can easily make use of it unchanged, or adapt it as -necessary. An implementation can be found on BitBucket [#]_. - -Default arguments -~~~~~~~~~~~~~~~~~ - -One difficult question is "How many bytes should my token be?". We can -help with this question by providing a default amount of entropy for the -"token_*" functions. If the ``nbytes`` argument is None or not given, the -default entropy will be used. This default value should be large enough -to be expected to be secure for medium-security uses, but is expected to -change in the future, possibly even in a maintenance release [#]_. - -Naming conventions -~~~~~~~~~~~~~~~~~~ - -One question is the naming conventions used in the module [#]_, whether to -use C-like naming conventions such as "randrange" or more Pythonic names -such as "random_range". - -Functions which are simply bound methods of the private ``SystemRandom`` -instance (e.g. ``randrange``), or a thin wrapper around such, should keep -the familiar names. Those which are something new (such as the various -``token_*`` functions) will use more Pythonic names. - -Alternatives -============ - -One alternative is to change the default PRNG provided by the ``random`` -module [#]_. This received considerable scepticism and outright opposition: - -* There is fear that a CSPRNG may be slower than the current PRNG (which - in the case of MT is already quite slow). - -* Some applications (such as scientific simulations, and replaying - gameplay) require the ability to seed the PRNG into a known state, - which a CSPRNG lacks by design. - -* Another major use of the ``random`` module is for simple "guess a number" - games written by beginners, and many people are loath to make any - change to the ``random`` module which may make that harder. - -* Although there is no proposal to remove MT from the ``random`` module, - there was considerable hostility to the idea of having to opt-in to - a non-CSPRNG or any backwards-incompatible changes. - -* Demonstrated attacks against MT are typically against PHP applications. - It is believed that PHP's version of MT is a significantly softer target - than Python's version, due to a poor seeding technique [#]_. Consequently, - without a proven attack against Python applications, many people object - to a backwards-incompatible change. - -Nick Coghlan made an earlier suggestion for a globally configurable PRNG -which uses the system CSPRNG by default [#]_, but has since withdrawn it -in favour of this proposal. - - -Comparison To Other Languages -============================= - -* PHP - - PHP includes a function ``uniqid`` [#]_ which by default returns a - thirteen character string based on the current time in microseconds. - Translated into Python syntax, it has the following signature:: - - def uniqid(prefix='', more_entropy=False)->str - - The PHP documentation warns that this function is not suitable for - security purposes. Nevertheless, various mature, well-known PHP - applications use it for that purpose (citation needed). - - PHP 5.3 and better also includes a function ``openssl_random_pseudo_bytes`` - [#]_. Translated into Python syntax, it has roughly the following - signature:: - - def openssl_random_pseudo_bytes(length:int)->Tuple[str, bool] - - This function returns a pseudo-random string of bytes of the given - length, and an boolean flag giving whether the string is considered - cryptographically strong. The PHP manual suggests that returning - anything but True should be rare except for old or broken platforms. - -* JavaScript - - Based on a rather cursory search [#]_, there do not appear to be any - well-known standard functions for producing strong random values in - JavaScript. ``Math.random`` is often used, despite serious weaknesses - making it unsuitable for cryptographic purposes [#]_. In recent years - the majority of browsers have gained support for ``window.crypto.getRandomValues`` [#]_. - - Node.js offers a rich cryptographic module, ``crypto`` [#]_, most of - which is beyond the scope of this PEP. It does include a single function - for generating random bytes, ``crypto.randomBytes``. - -* Ruby - - The Ruby standard library includes a module ``SecureRandom`` [#]_ - which includes the following methods: - - * base64 - returns a Base64 encoded random string. - - * hex - returns a random hexadecimal string. - - * random_bytes - returns a random byte string. - - * random_number - depending on the argument, returns either a random - integer in the range(0, n), or a random float between 0.0 and 1.0. - - * urlsafe_base64 - returns a random URL-safe Base64 encoded string. - - * uuid - return a version 4 random Universally Unique IDentifier. - - -What Should Be The Name Of The Module? -====================================== - -There was a proposal to add a "random.safe" submodule, quoting the Zen -of Python "Namespaces are one honking great idea" koan. However, the -author of the Zen, Tim Peters, has come out against this idea [#]_, and -recommends a top-level module. - -In discussion on the python-ideas mailing list so far, the name "secrets" -has received some approval, and no strong opposition. - -There is already an existing third-party module with the same name [#]_, -but it appears to be unused and abandoned. - - -Frequently Asked Questions -========================== - -* Q: Is this a real problem? Surely MT is random enough that nobody can - predict its output. - - A: The consensus among security professionals is that MT is not safe - in security contexts. It is not difficult to reconstruct the internal - state of MT [#]_ [#]_ and so predict all past and future values. There - are a number of known, practical attacks on systems using MT for - randomness [#]_. - - While there are currently no known direct attacks on applications - written in Python due to the use of MT, there is widespread agreement - that such usage is unsafe. - -* Q: Is this an alternative to specialise cryptographic software such as SSL? - - A: No. This is a "batteries included" solution, not a full-featured - "nuclear reactor". It is intended to mitigate against some basic - security errors, not be a solution to all security-related issues. To - quote Nick Coghlan referring to his earlier proposal [#]_:: - - "...folks really are better off learning to use things like - cryptography.io for security sensitive software, so this change - is just about harm mitigation given that it's inevitable that a - non-trivial proportion of the millions of current and future - Python developers won't do that." - -* Q: What about a password generator? - - A: The consensus is that the requirements for password generators are too - variable for it to be a good match for the standard library [#]_. No - password generator will be included in the initial release of the - module, instead it will be given in the documentation as a recipe (? la - the recipes in the ``itertools`` module) [#]_. - -* Q: Will ``secrets`` use /dev/random (which blocks) or /dev/urandom (which - doesn't block) on Linux? What about other platforms? - - A: ``secrets`` will be based on ``os.urandom`` and ``random.SystemRandom``, - which are interfaces to your operating system's best source of - cryptographic randomness. On Linux, that may be ``/dev/urandom`` [#]_, - on Windows it may be ``CryptGenRandom()``, but see the documentation - and/or source code for the detailed implementation details. - - -References -========== - -.. [#] https://mail.python.org/pipermail/python-ideas/2015-September/035820.html - -.. [#] https://docs.python.org/3/library/random.html - -.. [#] As of the date of writing. Also, as Google search terms may be - automatically customised for the user without their knowledge, some - readers may see different results. - -.. [#] http://interactivepython.org/runestone/static/everyday/2013/01/3_password.html - -.. [#] http://stackoverflow.com/questions/3854692/generate-password-in-python - -.. [#] http://stackoverflow.com/questions/3854692/generate-password-in-python/3854766#3854766 - -.. [#] https://mail.python.org/pipermail/python-ideas/2015-September/036238.html - -.. [#] At least those who are motivated to read the source code and documentation. - -.. [#] After considerable discussion, Guido ruled that the module need only - provide ``randbelow``, and not similar functions ``randrange`` or - ``randint``. http://code.activestate.com/lists/python-dev/138375/ - -.. [#] https://mail.python.org/pipermail/python-ideas/2015-September/036271.html - -.. [#] https://mail.python.org/pipermail/python-ideas/2015-September/036350.html - -.. [#] https://github.com/pyca/cryptography/issues/2347 - -.. [#] https://bitbucket.org/sdaprano/secrets - -.. [#] https://mail.python.org/pipermail/python-ideas/2015-September/036517.html - https://mail.python.org/pipermail/python-ideas/2015-September/036515.html - -.. [#] https://mail.python.org/pipermail/python-ideas/2015-September/036474.html - -.. [#] Link needed. - -.. [#] By default PHP seeds the MT PRNG with the time (citation needed), - which is exploitable by attackers, while Python seeds the PRNG with - output from the system CSPRNG, which is believed to be much harder to - exploit. - -.. [#] http://legacy.python.org/dev/peps/pep-0504/ - -.. [#] http://php.net/manual/en/function.uniqid.php - -.. [#] http://php.net/manual/en/function.openssl-random-pseudo-bytes.php - -.. [#] Volunteers and patches are welcome. - -.. [#] http://ifsec.blogspot.fr/2012/05/cross-domain-mathrandom-prediction.html - -.. [#] https://developer.mozilla.org/en-US/docs/Web/API/RandomSource/getRandomValues - -.. [#] https://nodejs.org/api/crypto.html - -.. [#] http://ruby-doc.org/stdlib-2.1.2/libdoc/securerandom/rdoc/SecureRandom.html - -.. [#] https://mail.python.org/pipermail/python-ideas/2015-September/036254.html - -.. [#] https://pypi.python.org/pypi/secrets - -.. [#] https://jazzy.id.au/2010/09/22/cracking_random_number_generators_part_3.html - -.. [#] https://mail.python.org/pipermail/python-ideas/2015-September/036077.html - -.. [#] https://media.blackhat.com/bh-us-12/Briefings/Argyros/BH_US_12_Argyros_PRNG_WP.pdf - -.. [#] https://mail.python.org/pipermail/python-ideas/2015-September/036157.html - -.. [#] https://mail.python.org/pipermail/python-ideas/2015-September/036476.html - https://mail.python.org/pipermail/python-ideas/2015-September/036478.html - -.. [#] https://mail.python.org/pipermail/python-ideas/2015-September/036488.html - -.. [#] http://sockpuppet.org/blog/2014/02/25/safely-generate-random-numbers/ - http://www.2uo.de/myths-about-urandom/ - - -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: +PEP: 506 +Title: Adding A Secrets Module To The Standard Library +Version: $Revision$ +Last-Modified: $Date$ +Author: Steven D'Aprano +Status: Accepted +Type: Standards Track +Content-Type: text/x-rst +Created: 19-Sep-2015 +Python-Version: 3.6 +Post-History: + + +Abstract +======== + +This PEP proposes the addition of a module for common security-related +functions such as generating tokens to the Python standard library. + + +Definitions +=========== + +Some common abbreviations used in this proposal: + +* PRNG: + + Pseudo Random Number Generator. A deterministic algorithm used + to produce random-looking numbers with certain desirable + statistical properties. + +* CSPRNG: + + Cryptographically Strong Pseudo Random Number Generator. An + algorithm used to produce random-looking numbers which are + resistant to prediction. + +* MT: + + Mersenne Twister. An extensively studied PRNG which is currently + used by the ``random`` module as the default. + + +Rationale +========= + +This proposal is motivated by concerns that Python's standard library +makes it too easy for developers to inadvertently make serious security +errors. Theo de Raadt, the founder of OpenBSD, contacted Guido van Rossum +and expressed some concern [#]_ about the use of MT for generating sensitive +information such as passwords, secure tokens, session keys and similar. + +Although the documentation for the ``random`` module explicitly states that +the default is not suitable for security purposes [#]_, it is strongly +believed that this warning may be missed, ignored or misunderstood by +many Python developers. In particular: + +* developers may not have read the documentation and consequently + not seen the warning; + +* they may not realise that their specific use of the module has security + implications; or + +* not realising that there could be a problem, they have copied code + (or learned techniques) from websites which don't offer best + practises. + +The first [#]_ hit when searching for "python how to generate passwords" on +Google is a tutorial that uses the default functions from the ``random`` +module [#]_. Although it is not intended for use in web applications, it is +likely that similar techniques find themselves used in that situation. +The second hit is to a StackOverflow question about generating +passwords [#]_. Most of the answers given, including the accepted one, use +the default functions. When one user warned that the default could be +easily compromised, they were told "I think you worry too much." [#]_ + +This strongly suggests that the existing ``random`` module is an attractive +nuisance when it comes to generating (for example) passwords or secure +tokens. + +Additional motivation (of a more philosophical bent) can be found in the +post which first proposed this idea [#]_. + + +Proposal +======== + +Alternative proposals have focused on the default PRNG in the ``random`` +module, with the aim of providing "secure by default" cryptographically +strong primitives that developers can build upon without thinking about +security. (See Alternatives below.) This proposes a different approach: + +* The standard library already provides cryptographically strong + primitives, but many users don't know they exist or when to use them. + +* Instead of requiring crypto-naive users to write secure code, the + standard library should include a set of ready-to-use "batteries" for + the most common needs, such as generating secure tokens. This code + will both directly satisfy a need ("How do I generate a password reset + token?"), and act as an example of acceptable practises which + developers can learn from [#]_. + +To do this, this PEP proposes that we add a new module to the standard +library, with the suggested name ``secrets``. This module will contain a +set of ready-to-use functions for common activities with security +implications, together with some lower-level primitives. + +The suggestion is that ``secrets`` becomes the go-to module for dealing +with anything which should remain secret (passwords, tokens, etc.) +while the ``random`` module remains backward-compatible. + + +API and Implementation +====================== + +This PEP proposes the following functions for the ``secrets`` module: + +* Functions for generating tokens suitable for use in (e.g.) password + recovery, as session keys, etc., in the following formats: + + - as bytes, ``secrets.token_bytes``; + - as text, using hexadecimal digits, ``secrets.token_hex``; + - as text, using URL-safe base-64 encoding, ``secrets.token_urlsafe``. + +* A limited interface to the system CSPRNG, using either ``os.urandom`` + directly or ``random.SystemRandom``. Unlike the ``random`` module, this + does not need to provide methods for seeding, getting or setting the + state, or any non-uniform distributions. It should provide the + following: + + - A function for choosing items from a sequence, ``secrets.choice``. + - A function for generating a given number of random bits and/or bytes + as an integer, ``secrets.randbits``. + - A function for returning a random integer in the half-open range + 0 to the given upper limit, ``secrets.randbelow`` [#]_. + +* A function for comparing text or bytes digests for equality while being + resistent to timing attacks, ``secrets.compare_digest``. + +The consensus appears to be that there is no need to add a new CSPRNG to +the ``random`` module to support these uses, ``SystemRandom`` will be +sufficient. + +Some illustrative implementations have been given by Nick Coghlan [#]_ +and a minimalist API by Tim Peters [#]_. This idea has also been discussed +on the issue tracker for the "cryptography" module [#]_. The following +pseudo-code should be taken as the starting point for the real +implementation:: + + from random import SystemRandom + from hmac import compare_digest + + _sysrand = SystemRandom() + + randbits = _sysrand.getrandbits + choice = _sysrand.choice + + def randbelow(exclusive_upper_bound): + return _sysrand._randbelow(exclusive_upper_bound) + + DEFAULT_ENTROPY = 32 # bytes + + def token_bytes(nbytes=None): + if nbytes is None: + nbytes = DEFAULT_ENTROPY + return os.urandom(nbytes) + + def token_hex(nbytes=None): + return binascii.hexlify(token_bytes(nbytes)).decode('ascii') + + def token_urlsafe(nbytes=None): + tok = token_bytes(nbytes) + return base64.urlsafe_b64encode(tok).rstrip(b'=').decode('ascii') + + +The ``secrets`` module itself will be pure Python, and other Python +implementations can easily make use of it unchanged, or adapt it as +necessary. An implementation can be found on BitBucket [#]_. + +Default arguments +~~~~~~~~~~~~~~~~~ + +One difficult question is "How many bytes should my token be?". We can +help with this question by providing a default amount of entropy for the +"token_*" functions. If the ``nbytes`` argument is None or not given, the +default entropy will be used. This default value should be large enough +to be expected to be secure for medium-security uses, but is expected to +change in the future, possibly even in a maintenance release [#]_. + +Naming conventions +~~~~~~~~~~~~~~~~~~ + +One question is the naming conventions used in the module [#]_, whether to +use C-like naming conventions such as "randrange" or more Pythonic names +such as "random_range". + +Functions which are simply bound methods of the private ``SystemRandom`` +instance (e.g. ``randrange``), or a thin wrapper around such, should keep +the familiar names. Those which are something new (such as the various +``token_*`` functions) will use more Pythonic names. + +Alternatives +============ + +One alternative is to change the default PRNG provided by the ``random`` +module [#]_. This received considerable scepticism and outright opposition: + +* There is fear that a CSPRNG may be slower than the current PRNG (which + in the case of MT is already quite slow). + +* Some applications (such as scientific simulations, and replaying + gameplay) require the ability to seed the PRNG into a known state, + which a CSPRNG lacks by design. + +* Another major use of the ``random`` module is for simple "guess a number" + games written by beginners, and many people are loath to make any + change to the ``random`` module which may make that harder. + +* Although there is no proposal to remove MT from the ``random`` module, + there was considerable hostility to the idea of having to opt-in to + a non-CSPRNG or any backwards-incompatible changes. + +* Demonstrated attacks against MT are typically against PHP applications. + It is believed that PHP's version of MT is a significantly softer target + than Python's version, due to a poor seeding technique [#]_. Consequently, + without a proven attack against Python applications, many people object + to a backwards-incompatible change. + +Nick Coghlan made an earlier suggestion for a globally configurable PRNG +which uses the system CSPRNG by default [#]_, but has since withdrawn it +in favour of this proposal. + + +Comparison To Other Languages +============================= + +* PHP + + PHP includes a function ``uniqid`` [#]_ which by default returns a + thirteen character string based on the current time in microseconds. + Translated into Python syntax, it has the following signature:: + + def uniqid(prefix='', more_entropy=False)->str + + The PHP documentation warns that this function is not suitable for + security purposes. Nevertheless, various mature, well-known PHP + applications use it for that purpose (citation needed). + + PHP 5.3 and better also includes a function ``openssl_random_pseudo_bytes`` + [#]_. Translated into Python syntax, it has roughly the following + signature:: + + def openssl_random_pseudo_bytes(length:int)->Tuple[str, bool] + + This function returns a pseudo-random string of bytes of the given + length, and an boolean flag giving whether the string is considered + cryptographically strong. The PHP manual suggests that returning + anything but True should be rare except for old or broken platforms. + +* JavaScript + + Based on a rather cursory search [#]_, there do not appear to be any + well-known standard functions for producing strong random values in + JavaScript. ``Math.random`` is often used, despite serious weaknesses + making it unsuitable for cryptographic purposes [#]_. In recent years + the majority of browsers have gained support for ``window.crypto.getRandomValues`` [#]_. + + Node.js offers a rich cryptographic module, ``crypto`` [#]_, most of + which is beyond the scope of this PEP. It does include a single function + for generating random bytes, ``crypto.randomBytes``. + +* Ruby + + The Ruby standard library includes a module ``SecureRandom`` [#]_ + which includes the following methods: + + * base64 - returns a Base64 encoded random string. + + * hex - returns a random hexadecimal string. + + * random_bytes - returns a random byte string. + + * random_number - depending on the argument, returns either a random + integer in the range(0, n), or a random float between 0.0 and 1.0. + + * urlsafe_base64 - returns a random URL-safe Base64 encoded string. + + * uuid - return a version 4 random Universally Unique IDentifier. + + +What Should Be The Name Of The Module? +====================================== + +There was a proposal to add a "random.safe" submodule, quoting the Zen +of Python "Namespaces are one honking great idea" koan. However, the +author of the Zen, Tim Peters, has come out against this idea [#]_, and +recommends a top-level module. + +In discussion on the python-ideas mailing list so far, the name "secrets" +has received some approval, and no strong opposition. + +There is already an existing third-party module with the same name [#]_, +but it appears to be unused and abandoned. + + +Frequently Asked Questions +========================== + +* Q: Is this a real problem? Surely MT is random enough that nobody can + predict its output. + + A: The consensus among security professionals is that MT is not safe + in security contexts. It is not difficult to reconstruct the internal + state of MT [#]_ [#]_ and so predict all past and future values. There + are a number of known, practical attacks on systems using MT for + randomness [#]_. + + While there are currently no known direct attacks on applications + written in Python due to the use of MT, there is widespread agreement + that such usage is unsafe. + +* Q: Is this an alternative to specialise cryptographic software such as SSL? + + A: No. This is a "batteries included" solution, not a full-featured + "nuclear reactor". It is intended to mitigate against some basic + security errors, not be a solution to all security-related issues. To + quote Nick Coghlan referring to his earlier proposal [#]_:: + + "...folks really are better off learning to use things like + cryptography.io for security sensitive software, so this change + is just about harm mitigation given that it's inevitable that a + non-trivial proportion of the millions of current and future + Python developers won't do that." + +* Q: What about a password generator? + + A: The consensus is that the requirements for password generators are too + variable for it to be a good match for the standard library [#]_. No + password generator will be included in the initial release of the + module, instead it will be given in the documentation as a recipe (? la + the recipes in the ``itertools`` module) [#]_. + +* Q: Will ``secrets`` use /dev/random (which blocks) or /dev/urandom (which + doesn't block) on Linux? What about other platforms? + + A: ``secrets`` will be based on ``os.urandom`` and ``random.SystemRandom``, + which are interfaces to your operating system's best source of + cryptographic randomness. On Linux, that may be ``/dev/urandom`` [#]_, + on Windows it may be ``CryptGenRandom()``, but see the documentation + and/or source code for the detailed implementation details. + + +References +========== + +.. [#] https://mail.python.org/pipermail/python-ideas/2015-September/035820.html + +.. [#] https://docs.python.org/3/library/random.html + +.. [#] As of the date of writing. Also, as Google search terms may be + automatically customised for the user without their knowledge, some + readers may see different results. + +.. [#] http://interactivepython.org/runestone/static/everyday/2013/01/3_password.html + +.. [#] http://stackoverflow.com/questions/3854692/generate-password-in-python + +.. [#] http://stackoverflow.com/questions/3854692/generate-password-in-python/3854766#3854766 + +.. [#] https://mail.python.org/pipermail/python-ideas/2015-September/036238.html + +.. [#] At least those who are motivated to read the source code and documentation. + +.. [#] After considerable discussion, Guido ruled that the module need only + provide ``randbelow``, and not similar functions ``randrange`` or + ``randint``. http://code.activestate.com/lists/python-dev/138375/ + +.. [#] https://mail.python.org/pipermail/python-ideas/2015-September/036271.html + +.. [#] https://mail.python.org/pipermail/python-ideas/2015-September/036350.html + +.. [#] https://github.com/pyca/cryptography/issues/2347 + +.. [#] https://bitbucket.org/sdaprano/secrets + +.. [#] https://mail.python.org/pipermail/python-ideas/2015-September/036517.html + https://mail.python.org/pipermail/python-ideas/2015-September/036515.html + +.. [#] https://mail.python.org/pipermail/python-ideas/2015-September/036474.html + +.. [#] Link needed. + +.. [#] By default PHP seeds the MT PRNG with the time (citation needed), + which is exploitable by attackers, while Python seeds the PRNG with + output from the system CSPRNG, which is believed to be much harder to + exploit. + +.. [#] http://legacy.python.org/dev/peps/pep-0504/ + +.. [#] http://php.net/manual/en/function.uniqid.php + +.. [#] http://php.net/manual/en/function.openssl-random-pseudo-bytes.php + +.. [#] Volunteers and patches are welcome. + +.. [#] http://ifsec.blogspot.fr/2012/05/cross-domain-mathrandom-prediction.html + +.. [#] https://developer.mozilla.org/en-US/docs/Web/API/RandomSource/getRandomValues + +.. [#] https://nodejs.org/api/crypto.html + +.. [#] http://ruby-doc.org/stdlib-2.1.2/libdoc/securerandom/rdoc/SecureRandom.html + +.. [#] https://mail.python.org/pipermail/python-ideas/2015-September/036254.html + +.. [#] https://pypi.python.org/pypi/secrets + +.. [#] https://jazzy.id.au/2010/09/22/cracking_random_number_generators_part_3.html + +.. [#] https://mail.python.org/pipermail/python-ideas/2015-September/036077.html + +.. [#] https://media.blackhat.com/bh-us-12/Briefings/Argyros/BH_US_12_Argyros_PRNG_WP.pdf + +.. [#] https://mail.python.org/pipermail/python-ideas/2015-September/036157.html + +.. [#] https://mail.python.org/pipermail/python-ideas/2015-September/036476.html + https://mail.python.org/pipermail/python-ideas/2015-September/036478.html + +.. [#] https://mail.python.org/pipermail/python-ideas/2015-September/036488.html + +.. [#] http://sockpuppet.org/blog/2014/02/25/safely-generate-random-numbers/ + http://www.2uo.de/myths-about-urandom/ + + +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: diff --git a/pep-0514.txt b/pep-0514.txt --- a/pep-0514.txt +++ b/pep-0514.txt @@ -1,253 +1,253 @@ -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, 01-Mar-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. - -When tools are selecting a single installed environment from all registered -environments, the intent is that user preferences from ``HKEY_CURRENT_USER`` -will override matching Company-Tag pairs in ``HKEY_LOCAL_MACHINE``. - -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. Tools consuming these registrations are -not required to disambiguate tags other than by preferring the user's setting. - -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. Alternatively, the interpreter may be -modified to not use any registry keys for determining search paths. Making such -changes is a decision for the third party; this PEP makes no recommendation -either way. - -Copyright -========= - +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, 01-Mar-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. + +When tools are selecting a single installed environment from all registered +environments, the intent is that user preferences from ``HKEY_CURRENT_USER`` +will override matching Company-Tag pairs in ``HKEY_LOCAL_MACHINE``. + +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. Tools consuming these registrations are +not required to disambiguate tags other than by preferring the user's setting. + +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. Alternatively, the interpreter may be +modified to not use any registry keys for determining search paths. Making such +changes is a decision for the third party; this PEP makes no recommendation +either way. + +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 Tue May 3 06:52:34 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 03 May 2016 10:52:34 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Issue_=2326921=3A_Fixed_a/an_?= =?utf-8?q?articles=2E?= Message-ID: <20160503105234.12899.64768.E57359E7@psf.io> https://hg.python.org/peps/rev/d617c7ba4e14 changeset: 6306:d617c7ba4e14 user: Serhiy Storchaka date: Tue May 03 13:52:22 2016 +0300 summary: Issue #26921: Fixed a/an articles. files: pep-0203.txt | 2 +- pep-0207.txt | 2 +- pep-0227.txt | 2 +- pep-0228.txt | 2 +- pep-0234.txt | 2 +- pep-0275.txt | 2 +- pep-0289.txt | 2 +- pep-0319.txt | 2 +- pep-0330.txt | 6 +++--- pep-0369.txt | 2 +- pep-0370.txt | 2 +- pep-0371.txt | 2 +- pep-0372.txt | 4 ++-- pep-0376.txt | 2 +- pep-0382.txt | 2 +- pep-0393.txt | 2 +- pep-0400.txt | 2 +- pep-0410.txt | 4 ++-- pep-0418.txt | 4 ++-- pep-0433.txt | 4 ++-- pep-0434.txt | 4 ++-- pep-0447.txt | 2 +- pep-0454.txt | 2 +- pep-0455.txt | 2 +- pep-0474.txt | 2 +- pep-0485.txt | 4 ++-- pep-0501.txt | 2 +- pep-0506.txt | 2 +- pep-0509.txt | 4 ++-- pep-0510.txt | 2 +- pep-0516.txt | 2 +- pep-0754.txt | 2 +- pep-3131.txt | 2 +- pep-3133.txt | 2 +- pep-3136.txt | 2 +- pep-3146.txt | 2 +- pep-3153.txt | 2 +- pep-3154.txt | 4 ++-- 38 files changed, 48 insertions(+), 48 deletions(-) diff --git a/pep-0203.txt b/pep-0203.txt --- a/pep-0203.txt +++ b/pep-0203.txt @@ -146,7 +146,7 @@ Adding augmented assignment will make Python's syntax more complex. Instead of a single assignment operation, there are now twelve - assignment operations, eleven of which also perform an binary + assignment operations, eleven of which also perform a binary operation. However, these eleven new forms of assignment are easy to understand as the coupling between assignment and the binary operation, and they require no large conceptual leap to diff --git a/pep-0207.txt b/pep-0207.txt --- a/pep-0207.txt +++ b/pep-0207.txt @@ -242,7 +242,7 @@ argument to the comparison function is less than the right one, +1 indicating the contrapositive, and 0 indicating that the two objects are equal. While this mechanism allows the establishment - of a order relationship (e.g. for use by the sort() method of list + of an order relationship (e.g. for use by the sort() method of list objects), it has proven to be limited in the context of Numeric Python (NumPy). diff --git a/pep-0227.txt b/pep-0227.txt --- a/pep-0227.txt +++ b/pep-0227.txt @@ -12,7 +12,7 @@ Abstract This PEP describes the addition of statically nested scoping - (lexical scoping) for Python 2.2, and as an source level option + (lexical scoping) for Python 2.2, and as a source level option for python 2.1. In addition, Python 2.1 will issue warnings about constructs whose meaning may change when this feature is enabled. diff --git a/pep-0228.txt b/pep-0228.txt --- a/pep-0228.txt +++ b/pep-0228.txt @@ -35,7 +35,7 @@ the fact that integer division returns the floor of the division. This makes it hard to program correctly, requiring casts to float() in various parts through the code. Python's numerical - model stems from C, while an model that might be easier to work with + model stems from C, while a model that might be easier to work with can be based on the mathematical understanding of numbers. diff --git a/pep-0234.txt b/pep-0234.txt --- a/pep-0234.txt +++ b/pep-0234.txt @@ -377,7 +377,7 @@ - Using the same name for two different operations (getting an iterator from an object and making an iterator for a function - with an sentinel value) is somewhat ugly. I haven't seen a + with a sentinel value) is somewhat ugly. I haven't seen a better name for the second operation though, and since they both return an iterator, it's easy to remember. diff --git a/pep-0275.txt b/pep-0275.txt --- a/pep-0275.txt +++ b/pep-0275.txt @@ -68,7 +68,7 @@ 1. Adding an optimization to the Python compiler and VM which detects the above if-elif-else construct and - generates special opcodes for it which use an read-only + generates special opcodes for it which use a read-only dictionary for storing jump offsets. 2. Adding new syntax to Python which mimics the C style diff --git a/pep-0289.txt b/pep-0289.txt --- a/pep-0289.txt +++ b/pep-0289.txt @@ -66,7 +66,7 @@ dotproduct = sum(x*y for x,y in itertools.izip(x_vector, y_vector)) Having a syntax similar to list comprehensions also makes it easy to -convert existing code into an generator expression when scaling up +convert existing code into a generator expression when scaling up application. Early timings showed that generators had a significant performance diff --git a/pep-0319.txt b/pep-0319.txt --- a/pep-0319.txt +++ b/pep-0319.txt @@ -349,7 +349,7 @@ unlocked during a synchronized block. During an unqualified synchronized block (the use of the - `synchronize' keyword without an target argument) a lock could be + `synchronize' keyword without a target argument) a lock could be created and associated with the synchronized code block object. Any threads that are to execute the block must first acquire the code block lock. diff --git a/pep-0330.txt b/pep-0330.txt --- a/pep-0330.txt +++ b/pep-0330.txt @@ -123,10 +123,10 @@ boundaries and must fall on an instruction, never between an instruction and its operands. - 2. The operand of a LOAD_* instruction must be an valid index into + 2. The operand of a LOAD_* instruction must be a valid index into its corresponding data structure. - 3. The operand of a STORE_* instruction must be an valid index + 3. The operand of a STORE_* instruction must be a valid index into its corresponding data structure. @@ -149,7 +149,7 @@ Implementation - This PEP is the working document for an Python bytecode + This PEP is the working document for a Python bytecode verification implementation written in Python. This implementation is not used implicitly by the PVM before executing any bytecode, but is to be used explicitly by users concerned diff --git a/pep-0369.txt b/pep-0369.txt --- a/pep-0369.txt +++ b/pep-0369.txt @@ -166,7 +166,7 @@ ``PyObject* PyImport_NotifyLoadedByModule(PyObject *module)`` Notify the post import system that a module was requested. Returns the a borrowed reference to the same module object or NULL if an error has - occured. The function calls only the hooks for the module itself an not + occured. The function calls only the hooks for the module itself and not its parents. The function must be called with the import lock acquired. ``PyObject* PyImport_NotifyLoadedByName(const char *name)`` diff --git a/pep-0370.txt b/pep-0370.txt --- a/pep-0370.txt +++ b/pep-0370.txt @@ -174,7 +174,7 @@ ``distutils.sysconfig`` will get methods to access the private variables of site. (not yet implemented) -The Windows updater needs to be updated, too. It should create an menu +The Windows updater needs to be updated, too. It should create a menu item which opens the user site directory in a new explorer windows. diff --git a/pep-0371.txt b/pep-0371.txt --- a/pep-0371.txt +++ b/pep-0371.txt @@ -149,7 +149,7 @@ picking the best run of that 100 iterations via the timeit module. First, to identify the overhead of the spawning of the workers, we - execute an function which is simply a pass statement (empty): + execute a function which is simply a pass statement (empty): cmd: python run_benchmarks.py empty_func.py Importing empty_func diff --git a/pep-0372.txt b/pep-0372.txt --- a/pep-0372.txt +++ b/pep-0372.txt @@ -176,7 +176,7 @@ the order of key insertion. The only sequence-like addition is support for ``reversed``. - An further advantage of not allowing indexing is that it leaves open + A further advantage of not allowing indexing is that it leaves open the possibility of a fast C implementation using linked lists. Does OrderedDict support alternate sort orders such as alphabetical? @@ -235,7 +235,7 @@ insensitive comparison is used. This allows ordered dictionaries to be substituted anywhere regular dictionaries are used. -How __repr__ format will maintain order during an repr/eval round-trip? +How __repr__ format will maintain order during a repr/eval round-trip? OrderedDict([('a', 1), ('b', 2)]) diff --git a/pep-0376.txt b/pep-0376.txt --- a/pep-0376.txt +++ b/pep-0376.txt @@ -269,7 +269,7 @@ --------- The `install` command has a new option called `installer`. This option -is the name of the tool used to invoke the installation. It's an normalized +is the name of the tool used to invoke the installation. It's a normalized lower-case string matching `[a-z0-9_\-\.]`. $ python setup.py install --installer=pkg-system diff --git a/pep-0382.txt b/pep-0382.txt --- a/pep-0382.txt +++ b/pep-0382.txt @@ -144,7 +144,7 @@ finder.find_package_portion(fullname) This method will be called in the same manner as find_module, and it -must return an string to be added to the package's ``__path__``. +must return a string to be added to the package's ``__path__``. If the finder doesn't find a portion of the package, it shall return ``None``. Raising ``AttributeError`` from above call will be treated as non-conformance with this PEP, and the exception will be ignored. diff --git a/pep-0393.txt b/pep-0393.txt --- a/pep-0393.txt +++ b/pep-0393.txt @@ -160,7 +160,7 @@ Both parameters must denote the eventual size/range of the strings. In particular, codecs using this API must compute both the number of -characters and the maximum character in advance. An string is +characters and the maximum character in advance. A string is allocated according to the specified size and character range and is null-terminated; the actual characters in it may be uninitialized. diff --git a/pep-0400.txt b/pep-0400.txt --- a/pep-0400.txt +++ b/pep-0400.txt @@ -90,7 +90,7 @@ (e.g. UTF-16). * Each codec has to reimplement its own StreamReader and StreamWriter class, even if it's trivial (just call the encoder/decoder). -* codecs.open(filename, "r") creates a io.TextIOWrapper object. +* codecs.open(filename, "r") creates an io.TextIOWrapper object. * No codec implements an optimized method in StreamReader or StreamWriter based on the specificities of the codec. diff --git a/pep-0410.txt b/pep-0410.txt --- a/pep-0410.txt +++ b/pep-0410.txt @@ -391,7 +391,7 @@ Add a string argument to specify the return type ------------------------------------------------ -Add an string argument to function returning timestamps, example: +Add a string argument to function returning timestamps, example: time.time(format="datetime"). A string is more extensible than a type: it is possible to request a format that has no type, like a tuple of integers. @@ -477,7 +477,7 @@ Because we only need one new type (Decimal), a simple boolean flag can be added. Example: time.time(decimal=True) or time.time(hires=True). -Such flag would require to do an hidden import which is considered as a bad +Such flag would require to do a hidden import which is considered as a bad practice. The boolean argument API was rejected because it is not "pythonic". Changing diff --git a/pep-0418.txt b/pep-0418.txt --- a/pep-0418.txt +++ b/pep-0418.txt @@ -709,7 +709,7 @@ List of hardware clocks ----------------------- -* HPET: An High Precision Event Timer (HPET) chip consists of a 64-bit +* HPET: A High Precision Event Timer (HPET) chip consists of a 64-bit up-counter (main counter) counting at least at 10 MHz and a set of up to 256 comparators (at least 3). Each HPET can have up to 32 timers. HPET can cause around 3 seconds of drift per day. @@ -1502,7 +1502,7 @@ Footnotes ========= -.. [#pseudo] "_time" is an hypothetical module only used for the example. +.. [#pseudo] "_time" is a hypothetical module only used for the example. The time module is implemented in C and so there is no need for such a module. diff --git a/pep-0433.txt b/pep-0433.txt --- a/pep-0433.txt +++ b/pep-0433.txt @@ -41,7 +41,7 @@ ``subprocess.Popen`` is created with ``close_fds=False`` for example). Windows does not have "close-on-exec" flag but an inheritance flag which is just the opposite value. For example, setting close-on-exec flag -means clearing the ``HANDLE_FLAG_INHERIT`` flag of an handle. +means clearing the ``HANDLE_FLAG_INHERIT`` flag of a handle. Status in Python 3.3 @@ -263,7 +263,7 @@ the most convervative option. This option does not solve issues listed in the `Rationale`_ -section, it only provides an helper to fix them. All functions creating +section, it only provides a helper to fix them. All functions creating file descriptors have to be modified to set *cloexec=True* in each module used by an application to fix all these issues. diff --git a/pep-0434.txt b/pep-0434.txt --- a/pep-0434.txt +++ b/pep-0434.txt @@ -65,10 +65,10 @@ allowing more liberal backporting than for other stdlib modules. Python does have many advanced features yet Python is well known for -being a easy computer language for beginners [3]_. A major Python +being an easy computer language for beginners [3]_. A major Python philosophy is "batteries included" which is best demonstrated in Python's standard library with many modules that are not typically -included with other programming languages [4]_. IDLE is a important +included with other programming languages [4]_. IDLE is an important "battery" in the Python toolbox because it allows a beginner to get started quickly without downloading and configuring a third party IDE. IDLE represents a commitment by the Python community to encouage the diff --git a/pep-0447.txt b/pep-0447.txt --- a/pep-0447.txt +++ b/pep-0447.txt @@ -388,7 +388,7 @@ The pybench output below compares an implementation of this PEP with the regular source tree, both based on changeset a5681f50bae2, run on an idle -machine an Core i7 processor running Centos 6.4. +machine and Core i7 processor running Centos 6.4. Even though the machine was idle there were clear differences between runs, I've seen difference in "minimum time" vary from -0.1% to +1.5%, with similar diff --git a/pep-0454.txt b/pep-0454.txt --- a/pep-0454.txt +++ b/pep-0454.txt @@ -77,7 +77,7 @@ implemented in the PySizer project in 2005. PySizer was implemented differently: the traceback was stored in frame objects and some Python types were linked the trace with the name of object type. PySizer patch -on CPython adds a overhead on performances and memory footprint, even if +on CPython adds an overhead on performances and memory footprint, even if the PySizer was not used. tracemalloc attachs a traceback to the underlying layer, to memory blocks, and has no overhead when the module is not tracing memory allocations. diff --git a/pep-0455.txt b/pep-0455.txt --- a/pep-0455.txt +++ b/pep-0455.txt @@ -25,7 +25,7 @@ See the rationale at https://mail.python.org/pipermail/python-dev/2015-May/140003.html -and for a earlier partial review, see +and for an earlier partial review, see https://mail.python.org/pipermail/python-dev/2013-October/129937.html . Rationale diff --git a/pep-0474.txt b/pep-0474.txt --- a/pep-0474.txt +++ b/pep-0474.txt @@ -240,7 +240,7 @@ directly integrate the two by offering online merges. This creates the opportunity to blend the low barrier to entry benefits of the GitHub/BitBucket pull request model with the mentoring and task hand-off benefits of Gerrit -in defining a online code merging model for Kallithea in collaboration with +in defining an online code merging model for Kallithea in collaboration with the upstream Kallithea developers. diff --git a/pep-0485.txt b/pep-0485.txt --- a/pep-0485.txt +++ b/pep-0485.txt @@ -27,7 +27,7 @@ their being unable to exactly represent some values, and for errors to accumulate with repeated computation. As a result, it is common advice to only use an equality comparison in very specific situations. -Often a inequality comparison fits the bill, but there are times +Often an inequality comparison fits the bill, but there are times (often in testing) where the programmer wants to determine whether a computed value is "close" to an expected value, without requiring them to be exactly equal. This is common enough, particularly in testing, @@ -88,7 +88,7 @@ which assures that the two values are the same within about 9 decimal digits. ``rel_tol`` must be greater than 0.0 -``abs_tol``: is an minimum absolute tolerance level -- useful for +``abs_tol``: is a minimum absolute tolerance level -- useful for comparisons near zero. Modulo error checking, etc, the function will return the result of:: diff --git a/pep-0501.txt b/pep-0501.txt --- a/pep-0501.txt +++ b/pep-0501.txt @@ -201,7 +201,7 @@ field values and format specifiers include variable substitution expressions. The raw template is just the interpolation template as a string. By default, -it is used to provide an human readable representation for the interpolation +it is used to provide a human readable representation for the interpolation template. The parsed template consists of a tuple of 2-tuples, with each 2-tuple diff --git a/pep-0506.txt b/pep-0506.txt --- a/pep-0506.txt +++ b/pep-0506.txt @@ -253,7 +253,7 @@ def openssl_random_pseudo_bytes(length:int)->Tuple[str, bool] This function returns a pseudo-random string of bytes of the given - length, and an boolean flag giving whether the string is considered + length, and a boolean flag giving whether the string is considered cryptographically strong. The PHP manual suggests that returning anything but True should be rare except for old or broken platforms. diff --git a/pep-0509.txt b/pep-0509.txt --- a/pep-0509.txt +++ b/pep-0509.txt @@ -65,7 +65,7 @@ ============= Pseudo-code of a fast guard to check if a dictionary entry was modified -(created, updated or deleted) using an hypothetical +(created, updated or deleted) using a hypothetical ``dict_get_version(dict)`` function:: UNSET = object() @@ -227,7 +227,7 @@ The version increase must be atomic. In CPython, the Global Interpreter Lock (GIL) already protects ``dict`` methods to make changes atomic. -Example using an hypothetical ``dict_get_version(dict)`` function:: +Example using a hypothetical ``dict_get_version(dict)`` function:: >>> d = {} >>> dict_get_version(d) diff --git a/pep-0510.txt b/pep-0510.txt --- a/pep-0510.txt +++ b/pep-0510.txt @@ -114,7 +114,7 @@ Hypothetical myoptimizer module ------------------------------- -Examples in this PEP uses an hypothetical ``myoptimizer`` module which +Examples in this PEP uses a hypothetical ``myoptimizer`` module which provides the following functions and types: * ``specialize(func, code, guards)``: add the specialized code `code` diff --git a/pep-0516.txt b/pep-0516.txt --- a/pep-0516.txt +++ b/pep-0516.txt @@ -357,7 +357,7 @@ ========= 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 +Subsequent to that an 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 diff --git a/pep-0754.txt b/pep-0754.txt --- a/pep-0754.txt +++ b/pep-0754.txt @@ -146,7 +146,7 @@ Determine if the argument is a IEEE 754 negative infinity value. isFinite(value) - Determine if the argument is an finite IEEE 754 value (i.e., is + Determine if the argument is a finite IEEE 754 value (i.e., is not NaN, positive, or negative infinity). isInf(value) diff --git a/pep-3131.txt b/pep-3131.txt --- a/pep-3131.txt +++ b/pep-3131.txt @@ -208,7 +208,7 @@ subtly/unknowingly wrong; rarely wrong is worse than obviously wrong. 2. Better to raise a warning than to fail silently when encountering - an probably unexpected situation. + a probably unexpected situation. 3. All of current usage is ASCII-only; the vast majority of future usage will be ASCII-only. diff --git a/pep-3133.txt b/pep-3133.txt --- a/pep-3133.txt +++ b/pep-3133.txt @@ -306,7 +306,7 @@ discussion and deliberation, a compromise and a delegation of responsibilities and use-cases has been worked out as follows: -* Roles provide a way of indicating a object's semantics and abstract +* Roles provide a way of indicating an object's semantics and abstract capabilities. A role may define abstract methods, but only as a way of delineating an interface through which a particular set of semantics are accessed. An ``Ordering`` role might require that diff --git a/pep-3136.txt b/pep-3136.txt --- a/pep-3136.txt +++ b/pep-3136.txt @@ -359,7 +359,7 @@ Rather than embellishing for and while loop syntax with labels, the programmer wishing to use labeled breaks would be required to create -the iterator explicitly and assign it to a identifier if he or she +the iterator explicitly and assign it to an identifier if he or she wanted to ``break`` out of or ``continue`` that loop from within a deeper loop. diff --git a/pep-3146.txt b/pep-3146.txt --- a/pep-3146.txt +++ b/pep-3146.txt @@ -1032,7 +1032,7 @@ There is a chance that we will not be able to reduce memory usage or startup time to a level satisfactory to the CPython community. Our primary contingency -plan for this situation is to shift from a online just-in-time compilation +plan for this situation is to shift from an online just-in-time compilation strategy to an offline ahead-of-time strategy using an instrumented CPython interpreter loop to obtain feedback. This is the same model used by gcc's feedback-directed optimizations (`-fprofile-generate`) [#gcc-fdo]_ and diff --git a/pep-3153.txt b/pep-3153.txt --- a/pep-3153.txt +++ b/pep-3153.txt @@ -16,7 +16,7 @@ This PEP describes an abstraction of asynchronous IO for the Python standard library. -The goal is to reach a abstraction that can be implemented by many +The goal is to reach an abstraction that can be implemented by many different asynchronous IO backends and provides a target for library developers to write code portable between those different backends. diff --git a/pep-3154.txt b/pep-3154.txt --- a/pep-3154.txt +++ b/pep-3154.txt @@ -172,11 +172,11 @@ * ``SHORT_BINUNICODE``: push a utf8-encoded str object with a one-byte size prefix (therefore less than 256 bytes long). -* ``BINUNICODE8``: push a utf8-encoded str object with a eight-byte +* ``BINUNICODE8``: push a utf8-encoded str object with an eight-byte size prefix (for strings longer than 2**32 bytes, which therefore cannot be serialized using ``BINUNICODE``). -* ``BINBYTES8``: push a bytes object with a eight-byte size prefix +* ``BINBYTES8``: push a bytes object with an eight-byte size prefix (for bytes objects longer than 2**32 bytes, which therefore cannot be serialized using ``BINBYTES``). -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Tue May 3 07:11:05 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 03 May 2016 11:11:05 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Backed_out_changeset=3A_c4aef?= =?utf-8?q?26d128b?= Message-ID: <20160503111100.12168.50282.CEADA460@psf.io> https://hg.python.org/peps/rev/4e2a90d0a496 changeset: 6307:4e2a90d0a496 user: Serhiy Storchaka date: Tue May 03 14:10:04 2016 +0300 summary: Backed out changeset: c4aef26d128b Unknown interpreted text role "kbd". files: pep-0008.txt | 2 +- pep-0352.txt | 2 +- pep-0475.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pep-0008.txt b/pep-0008.txt --- a/pep-0008.txt +++ b/pep-0008.txt @@ -1111,7 +1111,7 @@ A bare ``except:`` clause will catch SystemExit and KeyboardInterrupt exceptions, making it harder to interrupt a - program with :kbd:`Control-C`, and can disguise other problems. If you + program with Control-C, and can disguise other problems. If you want to catch all exceptions that signal program errors, use ``except Exception:`` (bare except is equivalent to ``except BaseException:``). diff --git a/pep-0352.txt b/pep-0352.txt --- a/pep-0352.txt +++ b/pep-0352.txt @@ -134,7 +134,7 @@ propagate up and allow the interpreter to terminate. KeyboardInterrupt has been moved since users typically expect an -application to exit when they press the interrupt key (usually :kbd:`Ctrl-C`). +application to exit when they press the interrupt key (usually Ctrl-C). If people have overly broad ``except`` clauses the expected behaviour does not occur. diff --git a/pep-0475.txt b/pep-0475.txt --- a/pep-0475.txt +++ b/pep-0475.txt @@ -353,7 +353,7 @@ interrupted. ``PyOS_StdioReadline()`` also used ``sigint_event`` when ``fgets()`` -failed to check if :kbd:`Ctrl-C` or :kbd:`Ctrl-Z` was pressed. +failed to check if Ctrl-C or Ctrl-Z was pressed. Links -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Tue May 3 13:07:12 2016 From: python-checkins at python.org (kushal.das) Date: Tue, 03 May 2016 17:07:12 +0000 Subject: [Python-checkins] =?utf-8?q?devguide=3A_motivations=3A_Adding_mys?= =?utf-8?q?elf?= Message-ID: <20160503170702.21831.73559.19AB3B4F@psf.io> https://hg.python.org/devguide/rev/1e58a0e723f0 changeset: 802:1e58a0e723f0 user: Kushal Das date: Tue May 03 22:33:02 2016 +0530 summary: motivations: Adding myself files: motivations.rst | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/motivations.rst b/motivations.rst --- a/motivations.rst +++ b/motivations.rst @@ -233,3 +233,8 @@ Victor is hacking the development version of CPython to make Python better than ever. +.. topic:: Kushal Das (India) + + * `Personal website `_ + * Red Hat (Fedora Cloud Engineer) + * Python Software Foundation (Fellow) -- Repository URL: https://hg.python.org/devguide From python-checkins at python.org Tue May 3 14:19:06 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 03 May 2016 18:19:06 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2324950=3A_Fixed_expanduser_tests_when_the_users_?= =?utf-8?q?home_directory_in_pwd_is?= Message-ID: <20160503181901.84506.37845.29CE992E@psf.io> https://hg.python.org/cpython/rev/b9b99cb85a5f changeset: 101218:b9b99cb85a5f parent: 101216:63f4fd1ec636 parent: 101217:194b356c84f5 user: Serhiy Storchaka date: Tue May 03 21:17:52 2016 +0300 summary: Issue #24950: Fixed expanduser tests when the users home directory in pwd is "/". Based on patch by SilentGhost. files: Lib/test/test_pathlib.py | 2 +- Lib/test/test_posixpath.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py --- a/Lib/test/test_pathlib.py +++ b/Lib/test/test_pathlib.py @@ -2062,7 +2062,7 @@ import pwd pwdent = pwd.getpwuid(os.getuid()) username = pwdent.pw_name - userhome = pwdent.pw_dir.rstrip('/') + userhome = pwdent.pw_dir.rstrip('/') or '/' # find arbitrary different user (if exists) for pwdent in pwd.getpwall(): othername = pwdent.pw_name diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py --- a/Lib/test/test_posixpath.py +++ b/Lib/test/test_posixpath.py @@ -214,6 +214,13 @@ def test_expanduser(self): self.assertEqual(posixpath.expanduser("foo"), "foo") self.assertEqual(posixpath.expanduser(b"foo"), b"foo") + with support.EnvironmentVarGuard() as env: + for home in '/', '', '//', '///': + with self.subTest(home=home): + env['HOME'] = home + self.assertEqual(posixpath.expanduser("~"), "/") + self.assertEqual(posixpath.expanduser("~/"), "/") + self.assertEqual(posixpath.expanduser("~/foo"), "/foo") try: import pwd except ImportError: @@ -237,14 +244,12 @@ self.assertIsInstance(posixpath.expanduser(b"~foo/"), bytes) with support.EnvironmentVarGuard() as env: - env['HOME'] = '/' - self.assertEqual(posixpath.expanduser("~"), "/") - self.assertEqual(posixpath.expanduser("~/foo"), "/foo") # expanduser should fall back to using the password database del env['HOME'] home = pwd.getpwuid(os.getuid()).pw_dir # $HOME can end with a trailing /, so strip it (see #17809) - self.assertEqual(posixpath.expanduser("~"), home.rstrip("/")) + home = home.rstrip("/") or '/' + self.assertEqual(posixpath.expanduser("~"), home) def test_normpath(self): self.assertEqual(posixpath.normpath(""), ".") -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue May 3 14:19:51 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 03 May 2016 18:19:51 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI0OTUw?= =?utf-8?q?=3A_Fixed_expanduser_tests_when_the_users_home_directory_in_pwd?= =?utf-8?q?_is?= Message-ID: <20160503181900.3400.75066.A236C26C@psf.io> https://hg.python.org/cpython/rev/194b356c84f5 changeset: 101217:194b356c84f5 branch: 3.5 parent: 101215:5ef3eda91051 user: Serhiy Storchaka date: Tue May 03 21:17:03 2016 +0300 summary: Issue #24950: Fixed expanduser tests when the users home directory in pwd is "/". Based on patch by SilentGhost. files: Lib/test/test_pathlib.py | 2 +- Lib/test/test_posixpath.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py --- a/Lib/test/test_pathlib.py +++ b/Lib/test/test_pathlib.py @@ -2062,7 +2062,7 @@ import pwd pwdent = pwd.getpwuid(os.getuid()) username = pwdent.pw_name - userhome = pwdent.pw_dir.rstrip('/') + userhome = pwdent.pw_dir.rstrip('/') or '/' # find arbitrary different user (if exists) for pwdent in pwd.getpwall(): othername = pwdent.pw_name diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py --- a/Lib/test/test_posixpath.py +++ b/Lib/test/test_posixpath.py @@ -216,6 +216,13 @@ def test_expanduser(self): self.assertEqual(posixpath.expanduser("foo"), "foo") self.assertEqual(posixpath.expanduser(b"foo"), b"foo") + with support.EnvironmentVarGuard() as env: + for home in '/', '', '//', '///': + with self.subTest(home=home): + env['HOME'] = home + self.assertEqual(posixpath.expanduser("~"), "/") + self.assertEqual(posixpath.expanduser("~/"), "/") + self.assertEqual(posixpath.expanduser("~/foo"), "/foo") try: import pwd except ImportError: @@ -239,14 +246,12 @@ self.assertIsInstance(posixpath.expanduser(b"~foo/"), bytes) with support.EnvironmentVarGuard() as env: - env['HOME'] = '/' - self.assertEqual(posixpath.expanduser("~"), "/") - self.assertEqual(posixpath.expanduser("~/foo"), "/foo") # expanduser should fall back to using the password database del env['HOME'] home = pwd.getpwuid(os.getuid()).pw_dir # $HOME can end with a trailing /, so strip it (see #17809) - self.assertEqual(posixpath.expanduser("~"), home.rstrip("/")) + home = home.rstrip("/") or '/' + self.assertEqual(posixpath.expanduser("~"), home) def test_normpath(self): self.assertEqual(posixpath.normpath(""), ".") -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue May 3 15:15:57 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 03 May 2016 19:15:57 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Backported_tes?= =?utf-8?q?t_for_posixpath=2Eexpanduser=28=29=2E?= Message-ID: <20160503191553.100784.65428.4D21D41A@psf.io> https://hg.python.org/cpython/rev/e07e2b8c9429 changeset: 101219:e07e2b8c9429 branch: 2.7 parent: 101214:21d18f09822b user: Serhiy Storchaka date: Tue May 03 22:15:29 2016 +0300 summary: Backported test for posixpath.expanduser(). files: Lib/test/test_posixpath.py | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py --- a/Lib/test/test_posixpath.py +++ b/Lib/test/test_posixpath.py @@ -198,6 +198,12 @@ def test_expanduser(self): self.assertEqual(posixpath.expanduser("foo"), "foo") + with test_support.EnvironmentVarGuard() as env: + for home in '/', '', '//', '///': + env['HOME'] = home + self.assertEqual(posixpath.expanduser("~"), "/") + self.assertEqual(posixpath.expanduser("~/"), "/") + self.assertEqual(posixpath.expanduser("~/foo"), "/foo") try: import pwd except ImportError: @@ -214,9 +220,12 @@ self.assertIsInstance(posixpath.expanduser("~foo/"), basestring) with test_support.EnvironmentVarGuard() as env: - env['HOME'] = '/' - self.assertEqual(posixpath.expanduser("~"), "/") - self.assertEqual(posixpath.expanduser("~/foo"), "/foo") + # expanduser should fall back to using the password database + del env['HOME'] + home = pwd.getpwuid(os.getuid()).pw_dir + # $HOME can end with a trailing /, so strip it (see #17809) + home = home.rstrip("/") or '/' + self.assertEqual(posixpath.expanduser("~"), home) def test_normpath(self): self.assertEqual(posixpath.normpath(""), ".") -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed May 4 02:45:18 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 04 May 2016 06:45:18 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2326932=3A_Fixed_su?= =?utf-8?q?pport_of_RTLD=5F*_constants_defined_as_enum_values=2C?= Message-ID: <20160504064518.13894.44787.CF8D0C53@psf.io> https://hg.python.org/cpython/rev/811ccdee6f87 changeset: 101220:811ccdee6f87 parent: 101218:b9b99cb85a5f user: Serhiy Storchaka date: Wed May 04 09:44:44 2016 +0300 summary: Issue #26932: Fixed support of RTLD_* constants defined as enum values, not via macros (in particular on Android). Patch by Chi Hsuan Yen. files: Misc/NEWS | 3 + Modules/_ctypes/_ctypes.c | 4 +- Modules/_ctypes/callproc.c | 2 +- Modules/posixmodule.c | 14 ++-- Python/pystate.c | 4 +- configure | 79 ++++++++++++++++++++++++++ configure.ac | 2 + pyconfig.h.in | 28 +++++++++ 8 files changed, 124 insertions(+), 12 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -1045,6 +1045,9 @@ Build ----- +- Issue #26932: Fixed support of RTLD_* constants defined as enum values, + not via macros (in particular on Android). Patch by Chi Hsuan Yen. + - Issue #22359: Disable the rules for running _freeze_importlib and pgen when cross-compiling. The output of these programs is normally saved with the source code anyway, and is still regenerated when doing a native build. diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -5480,14 +5480,14 @@ #endif /* If RTLD_LOCAL is not defined (Windows!), set it to zero. */ -#ifndef RTLD_LOCAL +#if !HAVE_DECL_RTLD_LOCAL #define RTLD_LOCAL 0 #endif /* If RTLD_GLOBAL is not defined (cygwin), set it to the same value as RTLD_LOCAL. */ -#ifndef RTLD_GLOBAL +#if !HAVE_DECL_RTLD_GLOBAL #define RTLD_GLOBAL RTLD_LOCAL #endif diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -1307,7 +1307,7 @@ PyObject *name, *name2; char *name_str; void * handle; -#ifdef RTLD_LOCAL +#if HAVE_DECL_RTLD_LOCAL int mode = RTLD_NOW | RTLD_LOCAL; #else /* cygwin doesn't define RTLD_LOCAL */ diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -12895,25 +12895,25 @@ if (PyModule_AddIntMacro(m, XATTR_SIZE_MAX)) return -1; #endif -#ifdef RTLD_LAZY +#if HAVE_DECL_RTLD_LAZY if (PyModule_AddIntMacro(m, RTLD_LAZY)) return -1; #endif -#ifdef RTLD_NOW +#if HAVE_DECL_RTLD_NOW if (PyModule_AddIntMacro(m, RTLD_NOW)) return -1; #endif -#ifdef RTLD_GLOBAL +#if HAVE_DECL_RTLD_GLOBAL if (PyModule_AddIntMacro(m, RTLD_GLOBAL)) return -1; #endif -#ifdef RTLD_LOCAL +#if HAVE_DECL_RTLD_LOCAL if (PyModule_AddIntMacro(m, RTLD_LOCAL)) return -1; #endif -#ifdef RTLD_NODELETE +#if HAVE_DECL_RTLD_NODELETE if (PyModule_AddIntMacro(m, RTLD_NODELETE)) return -1; #endif -#ifdef RTLD_NOLOAD +#if HAVE_DECL_RTLD_NOLOAD if (PyModule_AddIntMacro(m, RTLD_NOLOAD)) return -1; #endif -#ifdef RTLD_DEEPBIND +#if HAVE_DECL_RTLD_DEEPBIND if (PyModule_AddIntMacro(m, RTLD_DEEPBIND)) return -1; #endif diff --git a/Python/pystate.c b/Python/pystate.c --- a/Python/pystate.c +++ b/Python/pystate.c @@ -25,7 +25,7 @@ #ifdef HAVE_DLFCN_H #include #endif -#ifndef RTLD_LAZY +#if !HAVE_DECL_RTLD_LAZY #define RTLD_LAZY 1 #endif #endif @@ -91,7 +91,7 @@ interp->fscodec_initialized = 0; interp->importlib = NULL; #ifdef HAVE_DLOPEN -#ifdef RTLD_NOW +#if HAVE_DECL_RTLD_NOW interp->dlopenflags = RTLD_NOW; #else interp->dlopenflags = RTLD_LAZY; diff --git a/configure b/configure --- a/configure +++ b/configure @@ -14255,6 +14255,85 @@ fi +ac_fn_c_check_decl "$LINENO" "RTLD_LAZY" "ac_cv_have_decl_RTLD_LAZY" "#include +" +if test "x$ac_cv_have_decl_RTLD_LAZY" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_RTLD_LAZY $ac_have_decl +_ACEOF +ac_fn_c_check_decl "$LINENO" "RTLD_NOW" "ac_cv_have_decl_RTLD_NOW" "#include +" +if test "x$ac_cv_have_decl_RTLD_NOW" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_RTLD_NOW $ac_have_decl +_ACEOF +ac_fn_c_check_decl "$LINENO" "RTLD_GLOBAL" "ac_cv_have_decl_RTLD_GLOBAL" "#include +" +if test "x$ac_cv_have_decl_RTLD_GLOBAL" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_RTLD_GLOBAL $ac_have_decl +_ACEOF +ac_fn_c_check_decl "$LINENO" "RTLD_LOCAL" "ac_cv_have_decl_RTLD_LOCAL" "#include +" +if test "x$ac_cv_have_decl_RTLD_LOCAL" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_RTLD_LOCAL $ac_have_decl +_ACEOF +ac_fn_c_check_decl "$LINENO" "RTLD_NODELETE" "ac_cv_have_decl_RTLD_NODELETE" "#include +" +if test "x$ac_cv_have_decl_RTLD_NODELETE" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_RTLD_NODELETE $ac_have_decl +_ACEOF +ac_fn_c_check_decl "$LINENO" "RTLD_NOLOAD" "ac_cv_have_decl_RTLD_NOLOAD" "#include +" +if test "x$ac_cv_have_decl_RTLD_NOLOAD" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_RTLD_NOLOAD $ac_have_decl +_ACEOF +ac_fn_c_check_decl "$LINENO" "RTLD_DEEPBIND" "ac_cv_have_decl_RTLD_DEEPBIND" "#include +" +if test "x$ac_cv_have_decl_RTLD_DEEPBIND" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_RTLD_DEEPBIND $ac_have_decl +_ACEOF + + # determine what size digit to use for Python's longs { $as_echo "$as_me:${as_lineno-$LINENO}: checking digit size for Python's longs" >&5 $as_echo_n "checking digit size for Python's longs... " >&6; } diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -4342,6 +4342,8 @@ [define to 1 if your sem_getvalue is broken.]) fi +AC_CHECK_DECLS([RTLD_LAZY, RTLD_NOW, RTLD_GLOBAL, RTLD_LOCAL, RTLD_NODELETE, RTLD_NOLOAD, RTLD_DEEPBIND], [], [], [[#include ]]) + # determine what size digit to use for Python's longs AC_MSG_CHECKING([digit size for Python's longs]) AC_ARG_ENABLE(big-digits, diff --git a/pyconfig.h.in b/pyconfig.h.in --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -167,6 +167,34 @@ */ #undef HAVE_DECL_ISNAN +/* Define to 1 if you have the declaration of `RTLD_DEEPBIND', and to 0 if you + don't. */ +#undef HAVE_DECL_RTLD_DEEPBIND + +/* Define to 1 if you have the declaration of `RTLD_GLOBAL', and to 0 if you + don't. */ +#undef HAVE_DECL_RTLD_GLOBAL + +/* Define to 1 if you have the declaration of `RTLD_LAZY', and to 0 if you + don't. */ +#undef HAVE_DECL_RTLD_LAZY + +/* Define to 1 if you have the declaration of `RTLD_LOCAL', and to 0 if you + don't. */ +#undef HAVE_DECL_RTLD_LOCAL + +/* Define to 1 if you have the declaration of `RTLD_NODELETE', and to 0 if you + don't. */ +#undef HAVE_DECL_RTLD_NODELETE + +/* Define to 1 if you have the declaration of `RTLD_NOLOAD', and to 0 if you + don't. */ +#undef HAVE_DECL_RTLD_NOLOAD + +/* Define to 1 if you have the declaration of `RTLD_NOW', and to 0 if you + don't. */ +#undef HAVE_DECL_RTLD_NOW + /* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. */ #undef HAVE_DECL_TZNAME -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed May 4 04:28:35 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 04 May 2016 08:28:35 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2ODcz?= =?utf-8?q?=3A_xmlrpc_now_raises_ResponseError_on_unsupported_type_tags?= Message-ID: <20160504082834.1512.70370.66DC8428@psf.io> https://hg.python.org/cpython/rev/0d015f6aba8b changeset: 101221:0d015f6aba8b branch: 3.5 parent: 101217:194b356c84f5 user: Serhiy Storchaka date: Wed May 04 11:26:42 2016 +0300 summary: Issue #26873: xmlrpc now raises ResponseError on unsupported type tags instead of silently return incorrect result. files: Lib/test/test_xmlrpc.py | 14 ++++++++++++++ Lib/xmlrpc/client.py | 3 +++ Misc/NEWS | 3 +++ 3 files changed, 20 insertions(+), 0 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 @@ -224,6 +224,20 @@ self.assertIs(type(newvalue), xmlrpclib.Binary) self.assertIsNone(m) + def test_loads_unsupported(self): + ResponseError = xmlrpclib.ResponseError + data = '' + self.assertRaises(ResponseError, xmlrpclib.loads, data) + data = ('' + '' + '') + self.assertRaises(ResponseError, xmlrpclib.loads, data) + data = ('' + 'a' + 'b' + '') + self.assertRaises(ResponseError, xmlrpclib.loads, data) + def test_get_host_info(self): # see bug #3613, this raised a TypeError transp = xmlrpc.client.Transport() diff --git a/Lib/xmlrpc/client.py b/Lib/xmlrpc/client.py --- a/Lib/xmlrpc/client.py +++ b/Lib/xmlrpc/client.py @@ -640,6 +640,7 @@ self._stack = [] self._marks = [] self._data = [] + self._value = False self._methodname = None self._encoding = "utf-8" self.append = self._stack.append @@ -669,6 +670,8 @@ if tag == "array" or tag == "struct": self._marks.append(len(self._stack)) self._data = [] + if self._value and tag not in self.dispatch: + raise ResponseError("unknown tag %r" % tag) self._value = (tag == "value") def data(self, text): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -107,6 +107,9 @@ Library ------- +- Issue #26873: xmlrpc now raises ResponseError on unsupported type tags + instead of silently return incorrect result. + - Issue #26711: Fixed the comparison of plistlib.Data with other types. - Issue #24114: Fix an uninitialized variable in `ctypes.util`. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed May 4 04:28:35 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 04 May 2016 08:28:35 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326873=3A_xmlrpc_now_raises_ResponseError_on_uns?= =?utf-8?q?upported_type_tags?= Message-ID: <20160504082834.7003.38303.984DE04B@psf.io> https://hg.python.org/cpython/rev/8f7cb3b171f3 changeset: 101222:8f7cb3b171f3 parent: 101220:811ccdee6f87 parent: 101221:0d015f6aba8b user: Serhiy Storchaka date: Wed May 04 11:27:17 2016 +0300 summary: Issue #26873: xmlrpc now raises ResponseError on unsupported type tags instead of silently return incorrect result. files: Lib/test/test_xmlrpc.py | 14 ++++++++++++++ Lib/xmlrpc/client.py | 3 +++ Misc/NEWS | 3 +++ 3 files changed, 20 insertions(+), 0 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 @@ -223,6 +223,20 @@ self.assertIs(type(newvalue), xmlrpclib.Binary) self.assertIsNone(m) + def test_loads_unsupported(self): + ResponseError = xmlrpclib.ResponseError + data = '' + self.assertRaises(ResponseError, xmlrpclib.loads, data) + data = ('' + '' + '') + self.assertRaises(ResponseError, xmlrpclib.loads, data) + data = ('' + 'a' + 'b' + '') + self.assertRaises(ResponseError, xmlrpclib.loads, data) + def test_get_host_info(self): # see bug #3613, this raised a TypeError transp = xmlrpc.client.Transport() diff --git a/Lib/xmlrpc/client.py b/Lib/xmlrpc/client.py --- a/Lib/xmlrpc/client.py +++ b/Lib/xmlrpc/client.py @@ -640,6 +640,7 @@ self._stack = [] self._marks = [] self._data = [] + self._value = False self._methodname = None self._encoding = "utf-8" self.append = self._stack.append @@ -669,6 +670,8 @@ if tag == "array" or tag == "struct": self._marks.append(len(self._stack)) self._data = [] + if self._value and tag not in self.dispatch: + raise ResponseError("unknown tag %r" % tag) self._value = (tag == "value") def data(self, text): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -256,6 +256,9 @@ Library ------- +- Issue #26873: xmlrpc now raises ResponseError on unsupported type tags + instead of silently return incorrect result. + - Issue #26711: Fixed the comparison of plistlib.Data with other types. - Issue #24114: Fix an uninitialized variable in `ctypes.util`. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed May 4 04:28:45 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 04 May 2016 08:28:45 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI2ODcz?= =?utf-8?q?=3A_xmlrpclib_now_raises_ResponseError_on_unsupported_type_tags?= Message-ID: <20160504082835.49941.14093.D9AD7F7C@psf.io> https://hg.python.org/cpython/rev/7050c9fc1f72 changeset: 101223:7050c9fc1f72 branch: 2.7 parent: 101219:e07e2b8c9429 user: Serhiy Storchaka date: Wed May 04 11:28:09 2016 +0300 summary: Issue #26873: xmlrpclib now raises ResponseError on unsupported type tags instead of silently return incorrect result. files: Lib/test/test_xmlrpc.py | 14 ++++++++++++++ Lib/xmlrpclib.py | 3 +++ Misc/NEWS | 3 +++ 3 files changed, 20 insertions(+), 0 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 @@ -208,6 +208,20 @@ self.assertEqual(s, "abc \xc2\x95") self.assertEqual(items, [("def \xc2\x96", "ghi \xc2\x97")]) + def test_loads_unsupported(self): + ResponseError = xmlrpclib.ResponseError + data = '' + self.assertRaises(ResponseError, xmlrpclib.loads, data) + data = ('' + '' + '') + self.assertRaises(ResponseError, xmlrpclib.loads, data) + data = ('' + 'a' + 'b' + '') + self.assertRaises(ResponseError, xmlrpclib.loads, data) + class HelperTestCase(unittest.TestCase): def test_escape(self): diff --git a/Lib/xmlrpclib.py b/Lib/xmlrpclib.py --- a/Lib/xmlrpclib.py +++ b/Lib/xmlrpclib.py @@ -784,6 +784,7 @@ self._stack = [] self._marks = [] self._data = [] + self._value = False self._methodname = None self._encoding = "utf-8" self.append = self._stack.append @@ -814,6 +815,8 @@ if tag == "array" or tag == "struct": self._marks.append(len(self._stack)) self._data = [] + if self._value and tag not in self.dispatch: + raise ResponseError("unknown tag %r" % tag) self._value = (tag == "value") def data(self, text): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -77,6 +77,9 @@ Library ------- +- Issue #26873: xmlrpclib now raises ResponseError on unsupported type tags + instead of silently return incorrect result. + - Issue #24114: Fix an uninitialized variable in `ctypes.util`. The bug only occurs on SunOS when the ctypes implementation searches -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Wed May 4 04:52:41 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Wed, 04 May 2016 08:52:41 +0000 Subject: [Python-checkins] Daily reference leaks (b9b99cb85a5f): sum=8 Message-ID: <20160504085240.28489.93789.3612814D@psf.io> results for b9b99cb85a5f on branch "default" -------------------------------------------- test_collections leaked [0, 4, 0] memory blocks, sum=4 test_functools leaked [0, 3, 1] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogBPf4o2', '--timeout', '7200'] From python-checkins at python.org Wed May 4 07:13:50 2016 From: python-checkins at python.org (donald.stufft) Date: Wed, 04 May 2016 11:13:50 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Withdraw_PEP_481_in_favor_of_?= =?utf-8?q?PEP_512?= Message-ID: <20160504111226.71101.95321.B8E9AC66@psf.io> https://hg.python.org/peps/rev/83296b026727 changeset: 6308:83296b026727 user: Donald Stufft date: Wed May 04 07:12:23 2016 -0400 summary: Withdraw PEP 481 in favor of PEP 512 files: pep-0481.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/pep-0481.txt b/pep-0481.txt --- a/pep-0481.txt +++ b/pep-0481.txt @@ -3,7 +3,7 @@ Version: $Revision$ Last-Modified: $Date$ Author: Donald Stufft -Status: Draft +Status: Withdrawn Type: Process Content-Type: text/x-rst Created: 29-Nov-2014 -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Wed May 4 07:17:32 2016 From: python-checkins at python.org (donald.stufft) Date: Wed, 04 May 2016 11:17:32 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Direct_people_from_PEP_481_to?= =?utf-8?q?_PEP_512?= Message-ID: <20160504111556.46286.88977.70AC78EF@psf.io> https://hg.python.org/peps/rev/3d16df35d679 changeset: 6309:3d16df35d679 user: Donald Stufft date: Wed May 04 07:15:53 2016 -0400 summary: Direct people from PEP 481 to PEP 512 files: pep-0481.txt | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/pep-0481.txt b/pep-0481.txt --- a/pep-0481.txt +++ b/pep-0481.txt @@ -13,6 +13,9 @@ Abstract ======== +.. note:: This PEP has been withdrawn, if you're looking for the PEP + documenting the move to Github, please refer to PEP 512. + This PEP proposes migrating the repository hosting of CPython and the supporting repositories to Git and Github. It also proposes adding Phabricator as an alternative to Github Pull Requests to handle reviewing changes. This -- Repository URL: https://hg.python.org/peps From lp_benchmark_robot at intel.com Wed May 4 10:51:17 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Wed, 4 May 2016 15:51:17 +0100 Subject: [Python-checkins] UGLY Benchmark Results for Python Default 2016-05-04 Message-ID: <3af27d45-a9bc-4af2-8901-d379ae594959@irsmsx102.ger.corp.intel.com> Results for project Python default, build date 2016-05-04 13:48:53 +0000 commit: 8f7cb3b171f3 previous commit: aaf2ad84ae1c revision date: 2016-05-04 08:27:17 +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% 1.13% 10.82% 15.96% :-| pybench 0.26% 0.15% 1.02% 5.52% :-( regex_v8 3.15% -7.52% -11.05% 9.20% :-| nbody 0.12% 0.19% -2.00% 12.26% :-| json_dump_v2 0.30% 0.12% 0.09% 12.79% :-| normal_startup 0.94% 0.30% 0.87% 5.53% ---------------------------------------------------------------------------------- * 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-05-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 Wed May 4 10:51:55 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Wed, 4 May 2016 15:51:55 +0100 Subject: [Python-checkins] NEUTRAL Benchmark Results for Python 2.7 2016-05-04 Message-ID: <7996e57e-f03f-4f12-961f-7b2b3c7208e6@irsmsx102.ger.corp.intel.com> Results for project Python 2.7, build date 2016-05-04 07:36:47 +0000 commit: e07e2b8c9429 previous commit: 5a578ec4b3b3 revision date: 2016-05-03 19:15: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.17% -0.93% 5.59% 5.94% :-) pybench 0.11% 0.00% 5.90% 4.57% :-( regex_v8 0.75% -0.27% -2.28% 10.41% :-) nbody 0.14% -0.19% 6.86% 4.47% :-) json_dump_v2 0.54% -0.03% 2.20% 8.89% :-( normal_startup 1.66% -0.02% -5.42% 2.48% :-) ssbench 0.18% -0.04% 2.57% 0.67% ---------------------------------------------------------------------------------- * 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-05-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 Wed May 4 11:24:32 2016 From: python-checkins at python.org (guido.van.rossum) Date: Wed, 04 May 2016 15:24:32 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Update_status_of_PEP_438?= Message-ID: <20160504152427.14769.49762.096B838E@psf.io> https://hg.python.org/peps/rev/ef15e4336ba8 changeset: 6310:ef15e4336ba8 user: Guido van Rossum date: Wed May 04 08:22:20 2016 -0700 summary: Update status of PEP 438 files: pep-0438.txt | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/pep-0438.txt b/pep-0438.txt --- a/pep-0438.txt +++ b/pep-0438.txt @@ -5,12 +5,13 @@ Author: Holger Krekel , Carl Meyer BDFL-Delegate: Richard Jones Discussions-To: distutils-sig at python.org -Status: Accepted +Status: Superseded Type: Process Content-Type: text/x-rst Created: 15-Mar-2013 Post-History: 19-May-2013 Resolution: http://mail.python.org/pipermail/distutils-sig/2013-May/020773.html +Superseded-by: 470 Abstract -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Wed May 4 12:01:06 2016 From: python-checkins at python.org (jason.coombs) Date: Wed, 04 May 2016 16:01:06 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2320120=3A_Merge_with_3=2E5?= Message-ID: <20160504160100.5473.54538.FE0CC64F@psf.io> https://hg.python.org/cpython/rev/89116bd505cb changeset: 101225:89116bd505cb parent: 101222:8f7cb3b171f3 parent: 101224:eae59b6bf133 user: Jason R. Coombs date: Wed May 04 12:00:32 2016 -0400 summary: Issue #20120: Merge with 3.5 files: Lib/distutils/config.py | 4 ++-- Misc/NEWS | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Lib/distutils/config.py b/Lib/distutils/config.py --- a/Lib/distutils/config.py +++ b/Lib/distutils/config.py @@ -4,7 +4,7 @@ that uses .pypirc in the distutils.command package. """ import os -from configparser import ConfigParser +from configparser import RawConfigParser from distutils.cmd import Command @@ -53,7 +53,7 @@ repository = self.repository or self.DEFAULT_REPOSITORY realm = self.realm or self.DEFAULT_REALM - config = ConfigParser() + config = RawConfigParser() config.read(rc) sections = config.sections() if 'distutils' in sections: diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,12 @@ Core and Builtins ----------------- +- Issue #20120: Use RawConfigParser for .pypirc parsing, + removing support for interpolation unintentionally added + with move to Python 3. Behavior no longer does any + interpolation in .pypirc files, matching behavior in Python + 2.7 and Setuptools 19.0. + - Issue #26249: Memory functions of the :c:func:`PyMem_Malloc` domain (:c:data:`PYMEM_DOMAIN_MEM`) now use the :ref:`pymalloc allocator ` rather than system :c:func:`malloc`. Applications calling -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed May 4 12:01:54 2016 From: python-checkins at python.org (jason.coombs) Date: Wed, 04 May 2016 16:01:54 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzIwMTIw?= =?utf-8?q?=3A_Use_RawConfigParser_for_=2Epypirc_parsing=2C_removing_suppo?= =?utf-8?q?rt_for?= Message-ID: <20160504160100.53099.42782.53DBC6E4@psf.io> https://hg.python.org/cpython/rev/eae59b6bf133 changeset: 101224:eae59b6bf133 branch: 3.5 parent: 101221:0d015f6aba8b user: Jason R. Coombs date: Wed May 04 11:57:32 2016 -0400 summary: Issue #20120: Use RawConfigParser for .pypirc parsing, removing support for interpolation unintentionally added with move to Python 3. Behavior no longer does any interpolation in .pypirc files, matching behavior in Python 2.7 and Setuptools 19.0. files: Lib/distutils/config.py | 4 ++-- Misc/NEWS | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Lib/distutils/config.py b/Lib/distutils/config.py --- a/Lib/distutils/config.py +++ b/Lib/distutils/config.py @@ -4,7 +4,7 @@ that uses .pypirc in the distutils.command package. """ import os -from configparser import ConfigParser +from configparser import RawConfigParser from distutils.cmd import Command @@ -53,7 +53,7 @@ repository = self.repository or self.DEFAULT_REPOSITORY realm = self.realm or self.DEFAULT_REALM - config = ConfigParser() + config = RawConfigParser() config.read(rc) sections = config.sections() if 'distutils' in sections: diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,12 @@ Core and Builtins ----------------- +- Issue #20120: Use RawConfigParser for .pypirc parsing, + removing support for interpolation unintentionally added + with move to Python 3. Behavior no longer does any + interpolation in .pypirc files, matching behavior in Python + 2.7 and Setuptools 19.0. + - Issue #26659: Make the builtin slice type support cycle collection. - Issue #26718: super.__init__ no longer leaks memory if called multiple times. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed May 4 14:43:39 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 04 May 2016 18:43:39 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2ODEx?= =?utf-8?q?=3A_gc=2Eget=5Fobjects=28=29_no_longer_contains_a_broken_tuple_?= =?utf-8?q?with_NULL?= Message-ID: <20160504184335.15831.71673.9E8C98BA@psf.io> https://hg.python.org/cpython/rev/a98ef122d73d changeset: 101226:a98ef122d73d branch: 3.5 parent: 101224:eae59b6bf133 user: Serhiy Storchaka date: Wed May 04 21:42:05 2016 +0300 summary: Issue #26811: gc.get_objects() no longer contains a broken tuple with NULL pointer. files: Misc/NEWS | 3 +++ Objects/descrobject.c | 30 +++++++++++++++--------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #26811: gc.get_objects() no longer contains a broken tuple with NULL + pointer. + - Issue #20120: Use RawConfigParser for .pypirc parsing, removing support for interpolation unintentionally added with move to Python 3. Behavior no longer does any diff --git a/Objects/descrobject.c b/Objects/descrobject.c --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1386,27 +1386,27 @@ return NULL; } args = cached_args; - if (!args || Py_REFCNT(args) != 1) { - Py_CLEAR(cached_args); - if (!(cached_args = args = PyTuple_New(1))) + cached_args = NULL; + if (!args) { + args = PyTuple_New(1); + if (!args) return NULL; + _PyObject_GC_UNTRACK(args); } - Py_INCREF(args); - assert (Py_REFCNT(args) == 2); Py_INCREF(obj); PyTuple_SET_ITEM(args, 0, obj); ret = PyObject_Call(gs->prop_get, args, NULL); - if (args == cached_args) { - if (Py_REFCNT(args) == 2) { - obj = PyTuple_GET_ITEM(args, 0); - PyTuple_SET_ITEM(args, 0, NULL); - Py_XDECREF(obj); - } - else { - Py_CLEAR(cached_args); - } + if (cached_args == NULL && Py_REFCNT(args) == 1) { + assert(Py_SIZE(args) == 1); + assert(PyTuple_GET_ITEM(args, 0) == obj); + cached_args = args; + Py_DECREF(obj); } - Py_DECREF(args); + else { + assert(Py_REFCNT(args) >= 1); + _PyObject_GC_TRACK(args); + Py_DECREF(args); + } return ret; } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed May 4 14:43:39 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 04 May 2016 18:43:39 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326811=3A_gc=2Eget=5Fobjects=28=29_no_longer_con?= =?utf-8?q?tains_a_broken_tuple_with_NULL?= Message-ID: <20160504184335.15805.26102.B09F785E@psf.io> https://hg.python.org/cpython/rev/3fe1c7ad3b58 changeset: 101227:3fe1c7ad3b58 parent: 101225:89116bd505cb parent: 101226:a98ef122d73d user: Serhiy Storchaka date: Wed May 04 21:42:52 2016 +0300 summary: Issue #26811: gc.get_objects() no longer contains a broken tuple with NULL pointer. files: Misc/NEWS | 3 +++ Objects/descrobject.c | 30 +++++++++++++++--------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #26811: gc.get_objects() no longer contains a broken tuple with NULL + pointer. + - Issue #20120: Use RawConfigParser for .pypirc parsing, removing support for interpolation unintentionally added with move to Python 3. Behavior no longer does any diff --git a/Objects/descrobject.c b/Objects/descrobject.c --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1386,27 +1386,27 @@ return NULL; } args = cached_args; - if (!args || Py_REFCNT(args) != 1) { - Py_CLEAR(cached_args); - if (!(cached_args = args = PyTuple_New(1))) + cached_args = NULL; + if (!args) { + args = PyTuple_New(1); + if (!args) return NULL; + _PyObject_GC_UNTRACK(args); } - Py_INCREF(args); - assert (Py_REFCNT(args) == 2); Py_INCREF(obj); PyTuple_SET_ITEM(args, 0, obj); ret = PyObject_Call(gs->prop_get, args, NULL); - if (args == cached_args) { - if (Py_REFCNT(args) == 2) { - obj = PyTuple_GET_ITEM(args, 0); - PyTuple_SET_ITEM(args, 0, NULL); - Py_XDECREF(obj); - } - else { - Py_CLEAR(cached_args); - } + if (cached_args == NULL && Py_REFCNT(args) == 1) { + assert(Py_SIZE(args) == 1); + assert(PyTuple_GET_ITEM(args, 0) == obj); + cached_args = args; + Py_DECREF(obj); } - Py_DECREF(args); + else { + assert(Py_REFCNT(args) >= 1); + _PyObject_GC_TRACK(args); + Py_DECREF(args); + } return ret; } -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed May 4 15:15:18 2016 From: python-checkins at python.org (steven.daprano) Date: Wed, 04 May 2016 19:15:18 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_26002_and_25974?= Message-ID: <20160504184721.49925.27404.DB41F432@psf.io> https://hg.python.org/cpython/rev/7b2fafd78c1d changeset: 101228:7b2fafd78c1d parent: 101225:89116bd505cb user: Steven D'Aprano date: Thu May 05 03:54:29 2016 +1000 summary: Issue 26002 and 25974 patches by Upendra Kumar and Stefan Krah speed up median by using bisect, and general speedup for Decimals using as_integer_ratio files: Lib/statistics.py | 68 +++++++++++------------- Lib/test/test_statistics.py | 31 +++++------ 2 files changed, 44 insertions(+), 55 deletions(-) diff --git a/Lib/statistics.py b/Lib/statistics.py --- a/Lib/statistics.py +++ b/Lib/statistics.py @@ -105,6 +105,7 @@ from fractions import Fraction from decimal import Decimal from itertools import groupby +from bisect import bisect_left, bisect_right @@ -223,56 +224,26 @@ # Optimise the common case of floats. We expect that the most often # used numeric type will be builtin floats, so try to make this as # fast as possible. - if type(x) is float: + if type(x) is float or type(x) is Decimal: return x.as_integer_ratio() try: # x may be an int, Fraction, or Integral ABC. return (x.numerator, x.denominator) except AttributeError: try: - # x may be a float subclass. + # x may be a float or Decimal subclass. return x.as_integer_ratio() except AttributeError: - try: - # x may be a Decimal. - return _decimal_to_ratio(x) - except AttributeError: - # Just give up? - pass + # Just give up? + pass except (OverflowError, ValueError): # float NAN or INF. - assert not math.isfinite(x) + assert not _isfinite(x) return (x, None) msg = "can't convert type '{}' to numerator/denominator" raise TypeError(msg.format(type(x).__name__)) -# FIXME This is faster than Fraction.from_decimal, but still too slow. -def _decimal_to_ratio(d): - """Convert Decimal d to exact integer ratio (numerator, denominator). - - >>> from decimal import Decimal - >>> _decimal_to_ratio(Decimal("2.6")) - (26, 10) - - """ - sign, digits, exp = d.as_tuple() - if exp in ('F', 'n', 'N'): # INF, NAN, sNAN - assert not d.is_finite() - return (d, None) - num = 0 - for digit in digits: - num = num*10 + digit - if exp < 0: - den = 10**-exp - else: - num *= 10**exp - den = 1 - if sign: - num = -num - return (num, den) - - def _convert(value, T): """Convert value to given numeric type T.""" if type(value) is T: @@ -305,6 +276,21 @@ return table +def _find_lteq(a, x): + 'Locate the leftmost value exactly equal to x' + i = bisect_left(a, x) + if i != len(a) and a[i] == x: + return i + raise ValueError + + +def _find_rteq(a, l, x): + 'Locate the rightmost value exactly equal to x' + i = bisect_right(a, x, lo=l) + if i != (len(a)+1) and a[i-1] == x: + return i-1 + raise ValueError + # === Measures of central tendency (averages) === def mean(data): @@ -442,9 +428,15 @@ except TypeError: # Mixed type. For now we just coerce to float. L = float(x) - float(interval)/2 - cf = data.index(x) # Number of values below the median interval. - # FIXME The following line could be more efficient for big lists. - f = data.count(x) # Number of data points in the median interval. + + # Uses bisection search to search for x in data with log(n) time complexity + # Find the position of leftmost occurence of x in data + l1 = _find_lteq(data, x) + # Find the position of rightmost occurence of x in data[l1...len(data)] + # Assuming always l1 <= l2 + l2 = _find_rteq(data, l1, x) + cf = l1 + f = l2 - l1 + 1 return L + interval*(n/2 - cf)/f diff --git a/Lib/test/test_statistics.py b/Lib/test/test_statistics.py --- a/Lib/test/test_statistics.py +++ b/Lib/test/test_statistics.py @@ -699,13 +699,12 @@ num, den = statistics._exact_ratio(x) self.assertEqual(x, num/den) - @unittest.skipIf(True, "temporarily disabled: see #25928") def test_decimal(self): D = Decimal _exact_ratio = statistics._exact_ratio - self.assertEqual(_exact_ratio(D("0.125")), (125, 1000)) - self.assertEqual(_exact_ratio(D("12.345")), (12345, 1000)) - self.assertEqual(_exact_ratio(D("-1.98")), (-198, 100)) + self.assertEqual(_exact_ratio(D("0.125")), (1, 8)) + self.assertEqual(_exact_ratio(D("12.345")), (2469, 200)) + self.assertEqual(_exact_ratio(D("-1.98")), (-99, 50)) def test_inf(self): INF = float("INF") @@ -731,7 +730,6 @@ self.assertIs(ratio[1], None) self.assertEqual(type(ratio[0]), type(nan)) - @unittest.skipIf(True, "temporarily disabled: see #25928") def test_decimal_nan(self): NAN = Decimal("NAN") sNAN = Decimal("sNAN") @@ -745,18 +743,18 @@ class DecimalToRatioTest(unittest.TestCase): - # Test _decimal_to_ratio private function. + # Test _exact_ratio private function. def test_infinity(self): # Test that INFs are handled correctly. inf = Decimal('INF') - self.assertEqual(statistics._decimal_to_ratio(inf), (inf, None)) - self.assertEqual(statistics._decimal_to_ratio(-inf), (-inf, None)) + self.assertEqual(statistics._exact_ratio(inf), (inf, None)) + self.assertEqual(statistics._exact_ratio(-inf), (-inf, None)) def test_nan(self): # Test that NANs are handled correctly. for nan in (Decimal('NAN'), Decimal('sNAN')): - num, den = statistics._decimal_to_ratio(nan) + num, den = statistics._exact_ratio(nan) # Because NANs always compare non-equal, we cannot use assertEqual. # Nor can we use an identity test, as we don't guarantee anything # about the object identity. @@ -769,30 +767,30 @@ for d in numbers: # First test positive decimals. assert d > 0 - num, den = statistics._decimal_to_ratio(d) + num, den = statistics._exact_ratio(d) self.assertGreaterEqual(num, 0) self.assertGreater(den, 0) # Then test negative decimals. - num, den = statistics._decimal_to_ratio(-d) + num, den = statistics._exact_ratio(-d) self.assertLessEqual(num, 0) self.assertGreater(den, 0) def test_negative_exponent(self): # Test result when the exponent is negative. - t = statistics._decimal_to_ratio(Decimal("0.1234")) - self.assertEqual(t, (1234, 10000)) + t = statistics._exact_ratio(Decimal("0.1234")) + self.assertEqual(t, (617, 5000)) def test_positive_exponent(self): # Test results when the exponent is positive. - t = statistics._decimal_to_ratio(Decimal("1.234e7")) + t = statistics._exact_ratio(Decimal("1.234e7")) self.assertEqual(t, (12340000, 1)) def test_regression_20536(self): # Regression test for issue 20536. # See http://bugs.python.org/issue20536 - t = statistics._decimal_to_ratio(Decimal("1e2")) + t = statistics._exact_ratio(Decimal("1e2")) self.assertEqual(t, (100, 1)) - t = statistics._decimal_to_ratio(Decimal("1.47e5")) + t = statistics._exact_ratio(Decimal("1.47e5")) self.assertEqual(t, (147000, 1)) @@ -1260,7 +1258,6 @@ with decimal.localcontext(decimal.BasicContext): self.assertRaises(decimal.InvalidOperation, statistics._sum, data) - @unittest.skipIf(True, "temporarily disabled: see #25928") def test_decimal_snan_raises(self): # Adding sNAN should raise InvalidOperation. sNAN = Decimal('sNAN') -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed May 4 15:15:28 2016 From: python-checkins at python.org (steven.daprano) Date: Wed, 04 May 2016 19:15:28 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_default_-=3E_default?= =?utf-8?q?=29=3A_Automated_merge_with_ssh=3A//hg=2Epython=2Eorg/cpython?= Message-ID: <20160504184722.49919.57967.F9672739@psf.io> https://hg.python.org/cpython/rev/f7d34f271104 changeset: 101229:f7d34f271104 parent: 101227:3fe1c7ad3b58 parent: 101228:7b2fafd78c1d user: Steven D'Aprano date: Thu May 05 04:47:10 2016 +1000 summary: Automated merge with ssh://hg.python.org/cpython files: Lib/statistics.py | 68 +++++++++++------------- Lib/test/test_statistics.py | 31 +++++------ 2 files changed, 44 insertions(+), 55 deletions(-) diff --git a/Lib/statistics.py b/Lib/statistics.py --- a/Lib/statistics.py +++ b/Lib/statistics.py @@ -105,6 +105,7 @@ from fractions import Fraction from decimal import Decimal from itertools import groupby +from bisect import bisect_left, bisect_right @@ -223,56 +224,26 @@ # Optimise the common case of floats. We expect that the most often # used numeric type will be builtin floats, so try to make this as # fast as possible. - if type(x) is float: + if type(x) is float or type(x) is Decimal: return x.as_integer_ratio() try: # x may be an int, Fraction, or Integral ABC. return (x.numerator, x.denominator) except AttributeError: try: - # x may be a float subclass. + # x may be a float or Decimal subclass. return x.as_integer_ratio() except AttributeError: - try: - # x may be a Decimal. - return _decimal_to_ratio(x) - except AttributeError: - # Just give up? - pass + # Just give up? + pass except (OverflowError, ValueError): # float NAN or INF. - assert not math.isfinite(x) + assert not _isfinite(x) return (x, None) msg = "can't convert type '{}' to numerator/denominator" raise TypeError(msg.format(type(x).__name__)) -# FIXME This is faster than Fraction.from_decimal, but still too slow. -def _decimal_to_ratio(d): - """Convert Decimal d to exact integer ratio (numerator, denominator). - - >>> from decimal import Decimal - >>> _decimal_to_ratio(Decimal("2.6")) - (26, 10) - - """ - sign, digits, exp = d.as_tuple() - if exp in ('F', 'n', 'N'): # INF, NAN, sNAN - assert not d.is_finite() - return (d, None) - num = 0 - for digit in digits: - num = num*10 + digit - if exp < 0: - den = 10**-exp - else: - num *= 10**exp - den = 1 - if sign: - num = -num - return (num, den) - - def _convert(value, T): """Convert value to given numeric type T.""" if type(value) is T: @@ -305,6 +276,21 @@ return table +def _find_lteq(a, x): + 'Locate the leftmost value exactly equal to x' + i = bisect_left(a, x) + if i != len(a) and a[i] == x: + return i + raise ValueError + + +def _find_rteq(a, l, x): + 'Locate the rightmost value exactly equal to x' + i = bisect_right(a, x, lo=l) + if i != (len(a)+1) and a[i-1] == x: + return i-1 + raise ValueError + # === Measures of central tendency (averages) === def mean(data): @@ -442,9 +428,15 @@ except TypeError: # Mixed type. For now we just coerce to float. L = float(x) - float(interval)/2 - cf = data.index(x) # Number of values below the median interval. - # FIXME The following line could be more efficient for big lists. - f = data.count(x) # Number of data points in the median interval. + + # Uses bisection search to search for x in data with log(n) time complexity + # Find the position of leftmost occurence of x in data + l1 = _find_lteq(data, x) + # Find the position of rightmost occurence of x in data[l1...len(data)] + # Assuming always l1 <= l2 + l2 = _find_rteq(data, l1, x) + cf = l1 + f = l2 - l1 + 1 return L + interval*(n/2 - cf)/f diff --git a/Lib/test/test_statistics.py b/Lib/test/test_statistics.py --- a/Lib/test/test_statistics.py +++ b/Lib/test/test_statistics.py @@ -699,13 +699,12 @@ num, den = statistics._exact_ratio(x) self.assertEqual(x, num/den) - @unittest.skipIf(True, "temporarily disabled: see #25928") def test_decimal(self): D = Decimal _exact_ratio = statistics._exact_ratio - self.assertEqual(_exact_ratio(D("0.125")), (125, 1000)) - self.assertEqual(_exact_ratio(D("12.345")), (12345, 1000)) - self.assertEqual(_exact_ratio(D("-1.98")), (-198, 100)) + self.assertEqual(_exact_ratio(D("0.125")), (1, 8)) + self.assertEqual(_exact_ratio(D("12.345")), (2469, 200)) + self.assertEqual(_exact_ratio(D("-1.98")), (-99, 50)) def test_inf(self): INF = float("INF") @@ -731,7 +730,6 @@ self.assertIs(ratio[1], None) self.assertEqual(type(ratio[0]), type(nan)) - @unittest.skipIf(True, "temporarily disabled: see #25928") def test_decimal_nan(self): NAN = Decimal("NAN") sNAN = Decimal("sNAN") @@ -745,18 +743,18 @@ class DecimalToRatioTest(unittest.TestCase): - # Test _decimal_to_ratio private function. + # Test _exact_ratio private function. def test_infinity(self): # Test that INFs are handled correctly. inf = Decimal('INF') - self.assertEqual(statistics._decimal_to_ratio(inf), (inf, None)) - self.assertEqual(statistics._decimal_to_ratio(-inf), (-inf, None)) + self.assertEqual(statistics._exact_ratio(inf), (inf, None)) + self.assertEqual(statistics._exact_ratio(-inf), (-inf, None)) def test_nan(self): # Test that NANs are handled correctly. for nan in (Decimal('NAN'), Decimal('sNAN')): - num, den = statistics._decimal_to_ratio(nan) + num, den = statistics._exact_ratio(nan) # Because NANs always compare non-equal, we cannot use assertEqual. # Nor can we use an identity test, as we don't guarantee anything # about the object identity. @@ -769,30 +767,30 @@ for d in numbers: # First test positive decimals. assert d > 0 - num, den = statistics._decimal_to_ratio(d) + num, den = statistics._exact_ratio(d) self.assertGreaterEqual(num, 0) self.assertGreater(den, 0) # Then test negative decimals. - num, den = statistics._decimal_to_ratio(-d) + num, den = statistics._exact_ratio(-d) self.assertLessEqual(num, 0) self.assertGreater(den, 0) def test_negative_exponent(self): # Test result when the exponent is negative. - t = statistics._decimal_to_ratio(Decimal("0.1234")) - self.assertEqual(t, (1234, 10000)) + t = statistics._exact_ratio(Decimal("0.1234")) + self.assertEqual(t, (617, 5000)) def test_positive_exponent(self): # Test results when the exponent is positive. - t = statistics._decimal_to_ratio(Decimal("1.234e7")) + t = statistics._exact_ratio(Decimal("1.234e7")) self.assertEqual(t, (12340000, 1)) def test_regression_20536(self): # Regression test for issue 20536. # See http://bugs.python.org/issue20536 - t = statistics._decimal_to_ratio(Decimal("1e2")) + t = statistics._exact_ratio(Decimal("1e2")) self.assertEqual(t, (100, 1)) - t = statistics._decimal_to_ratio(Decimal("1.47e5")) + t = statistics._exact_ratio(Decimal("1.47e5")) self.assertEqual(t, (147000, 1)) @@ -1260,7 +1258,6 @@ with decimal.localcontext(decimal.BasicContext): self.assertRaises(decimal.InvalidOperation, statistics._sum, data) - @unittest.skipIf(True, "temporarily disabled: see #25928") def test_decimal_snan_raises(self): # Adding sNAN should raise InvalidOperation. sNAN = Decimal('sNAN') -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed May 4 15:24:08 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Wed, 04 May 2016 19:24:08 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2326765=3A_Moved_co?= =?utf-8?q?mmon_code_and_docstrings_for_bytes_and_bytearray_methods?= Message-ID: <20160504192353.49917.35973.29766397@psf.io> https://hg.python.org/cpython/rev/41969033eb9d changeset: 101230:41969033eb9d user: Serhiy Storchaka date: Wed May 04 22:23:26 2016 +0300 summary: Issue #26765: Moved common code and docstrings for bytes and bytearray methods to bytes_methods.c. files: Include/bytes_methods.h | 21 + Objects/bytearrayobject.c | 352 +-------------- Objects/bytes_methods.c | 424 +++++++++++++++++++ Objects/bytesobject.c | 362 +--------------- Objects/stringlib/find.h | 73 --- Objects/stringlib/transmogrify.h | 30 - Objects/unicodeobject.c | 34 +- 7 files changed, 519 insertions(+), 777 deletions(-) diff --git a/Include/bytes_methods.h b/Include/bytes_methods.h --- a/Include/bytes_methods.h +++ b/Include/bytes_methods.h @@ -21,6 +21,15 @@ extern void _Py_bytes_capitalize(char *result, const char *s, Py_ssize_t len); extern void _Py_bytes_swapcase(char *result, const char *s, Py_ssize_t len); +extern PyObject *_Py_bytes_find(const char *str, Py_ssize_t len, PyObject *args); +extern PyObject *_Py_bytes_index(const char *str, Py_ssize_t len, PyObject *args); +extern PyObject *_Py_bytes_rfind(const char *str, Py_ssize_t len, PyObject *args); +extern PyObject *_Py_bytes_rindex(const char *str, Py_ssize_t len, PyObject *args); +extern PyObject *_Py_bytes_count(const char *str, Py_ssize_t len, PyObject *args); +extern int _Py_bytes_contains(const char *str, Py_ssize_t len, PyObject *arg); +extern PyObject *_Py_bytes_startswith(const char *str, Py_ssize_t len, PyObject *args); +extern PyObject *_Py_bytes_endswith(const char *str, Py_ssize_t len, PyObject *args); + /* The maketrans() static method. */ extern PyObject* _Py_bytes_maketrans(Py_buffer *frm, Py_buffer *to); @@ -37,7 +46,19 @@ extern const char _Py_title__doc__[]; extern const char _Py_capitalize__doc__[]; extern const char _Py_swapcase__doc__[]; +extern const char _Py_count__doc__[]; +extern const char _Py_find__doc__[]; +extern const char _Py_index__doc__[]; +extern const char _Py_rfind__doc__[]; +extern const char _Py_rindex__doc__[]; +extern const char _Py_startswith__doc__[]; +extern const char _Py_endswith__doc__[]; extern const char _Py_maketrans__doc__[]; +extern const char _Py_expandtabs__doc__[]; +extern const char _Py_ljust__doc__[]; +extern const char _Py_rjust__doc__[]; +extern const char _Py_center__doc__[]; +extern const char _Py_zfill__doc__[]; /* this is needed because some docs are shared from the .o, not static */ #define PyDoc_STRVAR_shared(name,str) const char name[] = PyDoc_STR(str) diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -1097,147 +1097,16 @@ #include "stringlib/transmogrify.h" -/* The following Py_LOCAL_INLINE and Py_LOCAL functions -were copied from the old char* style string object. */ - -/* helper macro to fixup start/end slice values */ -#define ADJUST_INDICES(start, end, len) \ - if (end > len) \ - end = len; \ - else if (end < 0) { \ - end += len; \ - if (end < 0) \ - end = 0; \ - } \ - if (start < 0) { \ - start += len; \ - if (start < 0) \ - start = 0; \ - } - -Py_LOCAL_INLINE(Py_ssize_t) -bytearray_find_internal(PyByteArrayObject *self, PyObject *args, int dir) -{ - PyObject *subobj; - char byte; - Py_buffer subbuf; - const char *sub; - Py_ssize_t len, sub_len; - Py_ssize_t start=0, end=PY_SSIZE_T_MAX; - Py_ssize_t res; - - if (!stringlib_parse_args_finds_byte("find/rfind/index/rindex", - args, &subobj, &byte, &start, &end)) - return -2; - - if (subobj) { - if (PyObject_GetBuffer(subobj, &subbuf, PyBUF_SIMPLE) != 0) - return -2; - - sub = subbuf.buf; - sub_len = subbuf.len; - } - else { - sub = &byte; - sub_len = 1; - } - len = PyByteArray_GET_SIZE(self); - - ADJUST_INDICES(start, end, len); - if (end - start < sub_len) - res = -1; - else if (sub_len == 1) { - if (dir > 0) - res = stringlib_find_char( - PyByteArray_AS_STRING(self) + start, end - start, - *sub); - else - res = stringlib_rfind_char( - PyByteArray_AS_STRING(self) + start, end - start, - *sub); - if (res >= 0) - res += start; - } - else { - if (dir > 0) - res = stringlib_find_slice( - PyByteArray_AS_STRING(self), len, - sub, sub_len, start, end); - else - res = stringlib_rfind_slice( - PyByteArray_AS_STRING(self), len, - sub, sub_len, start, end); - } - - if (subobj) - PyBuffer_Release(&subbuf); - - return res; -} - -PyDoc_STRVAR(find__doc__, -"B.find(sub[, start[, end]]) -> int\n\ -\n\ -Return the lowest index in B where subsection sub is found,\n\ -such that sub is contained within B[start,end]. Optional\n\ -arguments start and end are interpreted as in slice notation.\n\ -\n\ -Return -1 on failure."); - static PyObject * bytearray_find(PyByteArrayObject *self, PyObject *args) { - Py_ssize_t result = bytearray_find_internal(self, args, +1); - if (result == -2) - return NULL; - return PyLong_FromSsize_t(result); + return _Py_bytes_find(PyByteArray_AS_STRING(self), PyByteArray_GET_SIZE(self), args); } -PyDoc_STRVAR(count__doc__, -"B.count(sub[, start[, end]]) -> int\n\ -\n\ -Return the number of non-overlapping occurrences of subsection sub in\n\ -bytes B[start:end]. Optional arguments start and end are interpreted\n\ -as in slice notation."); - static PyObject * bytearray_count(PyByteArrayObject *self, PyObject *args) { - PyObject *sub_obj; - const char *str = PyByteArray_AS_STRING(self), *sub; - Py_ssize_t sub_len; - char byte; - Py_ssize_t start = 0, end = PY_SSIZE_T_MAX; - - Py_buffer vsub; - PyObject *count_obj; - - if (!stringlib_parse_args_finds_byte("count", args, &sub_obj, &byte, - &start, &end)) - return NULL; - - if (sub_obj) { - if (PyObject_GetBuffer(sub_obj, &vsub, PyBUF_SIMPLE) != 0) - return NULL; - - sub = vsub.buf; - sub_len = vsub.len; - } - else { - sub = &byte; - sub_len = 1; - } - - ADJUST_INDICES(start, end, PyByteArray_GET_SIZE(self)); - - count_obj = PyLong_FromSsize_t( - stringlib_count(str + start, end - start, sub, sub_len, PY_SSIZE_T_MAX) - ); - - if (sub_obj) - PyBuffer_Release(&vsub); - - return count_obj; + return _Py_bytes_count(PyByteArray_AS_STRING(self), PyByteArray_GET_SIZE(self), args); } /*[clinic input] @@ -1269,216 +1138,40 @@ PyByteArray_GET_SIZE(self)); } -PyDoc_STRVAR(index__doc__, -"B.index(sub[, start[, end]]) -> int\n\ -\n\ -Like B.find() but raise ValueError when the subsection is not found."); - static PyObject * bytearray_index(PyByteArrayObject *self, PyObject *args) { - Py_ssize_t result = bytearray_find_internal(self, args, +1); - if (result == -2) - return NULL; - if (result == -1) { - PyErr_SetString(PyExc_ValueError, - "subsection not found"); - return NULL; - } - return PyLong_FromSsize_t(result); + return _Py_bytes_index(PyByteArray_AS_STRING(self), PyByteArray_GET_SIZE(self), args); } - -PyDoc_STRVAR(rfind__doc__, -"B.rfind(sub[, start[, end]]) -> int\n\ -\n\ -Return the highest index in B where subsection sub is found,\n\ -such that sub is contained within B[start,end]. Optional\n\ -arguments start and end are interpreted as in slice notation.\n\ -\n\ -Return -1 on failure."); - static PyObject * bytearray_rfind(PyByteArrayObject *self, PyObject *args) { - Py_ssize_t result = bytearray_find_internal(self, args, -1); - if (result == -2) - return NULL; - return PyLong_FromSsize_t(result); + return _Py_bytes_rfind(PyByteArray_AS_STRING(self), PyByteArray_GET_SIZE(self), args); } - -PyDoc_STRVAR(rindex__doc__, -"B.rindex(sub[, start[, end]]) -> int\n\ -\n\ -Like B.rfind() but raise ValueError when the subsection is not found."); - static PyObject * bytearray_rindex(PyByteArrayObject *self, PyObject *args) { - Py_ssize_t result = bytearray_find_internal(self, args, -1); - if (result == -2) - return NULL; - if (result == -1) { - PyErr_SetString(PyExc_ValueError, - "subsection not found"); - return NULL; - } - return PyLong_FromSsize_t(result); + return _Py_bytes_rindex(PyByteArray_AS_STRING(self), PyByteArray_GET_SIZE(self), args); } - static int bytearray_contains(PyObject *self, PyObject *arg) { - Py_ssize_t ival = PyNumber_AsSsize_t(arg, PyExc_ValueError); - if (ival == -1 && PyErr_Occurred()) { - Py_buffer varg; - Py_ssize_t pos; - PyErr_Clear(); - if (PyObject_GetBuffer(arg, &varg, PyBUF_SIMPLE) != 0) - return -1; - pos = stringlib_find(PyByteArray_AS_STRING(self), Py_SIZE(self), - varg.buf, varg.len, 0); - PyBuffer_Release(&varg); - return pos >= 0; - } - if (ival < 0 || ival >= 256) { - PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)"); - return -1; - } - - return memchr(PyByteArray_AS_STRING(self), (int) ival, Py_SIZE(self)) != NULL; + return _Py_bytes_contains(PyByteArray_AS_STRING(self), PyByteArray_GET_SIZE(self), arg); } - -/* Matches the end (direction >= 0) or start (direction < 0) of self - * against substr, using the start and end arguments. Returns - * -1 on error, 0 if not found and 1 if found. - */ -Py_LOCAL(int) -_bytearray_tailmatch(PyByteArrayObject *self, PyObject *substr, Py_ssize_t start, - Py_ssize_t end, int direction) -{ - Py_ssize_t len = PyByteArray_GET_SIZE(self); - const char* str; - Py_buffer vsubstr; - int rv = 0; - - str = PyByteArray_AS_STRING(self); - - if (PyObject_GetBuffer(substr, &vsubstr, PyBUF_SIMPLE) != 0) - return -1; - - ADJUST_INDICES(start, end, len); - - if (direction < 0) { - /* startswith */ - if (start+vsubstr.len > len) { - goto done; - } - } else { - /* endswith */ - if (end-start < vsubstr.len || start > len) { - goto done; - } - - if (end-vsubstr.len > start) - start = end - vsubstr.len; - } - if (end-start >= vsubstr.len) - rv = ! memcmp(str+start, vsubstr.buf, vsubstr.len); - -done: - PyBuffer_Release(&vsubstr); - return rv; -} - - -PyDoc_STRVAR(startswith__doc__, -"B.startswith(prefix[, start[, end]]) -> bool\n\ -\n\ -Return True if B starts with the specified prefix, False otherwise.\n\ -With optional start, test B beginning at that position.\n\ -With optional end, stop comparing B at that position.\n\ -prefix can also be a tuple of bytes to try."); - static PyObject * bytearray_startswith(PyByteArrayObject *self, PyObject *args) { - Py_ssize_t start = 0; - Py_ssize_t end = PY_SSIZE_T_MAX; - PyObject *subobj; - int result; - - if (!stringlib_parse_args_finds("startswith", args, &subobj, &start, &end)) - return NULL; - if (PyTuple_Check(subobj)) { - Py_ssize_t i; - for (i = 0; i < PyTuple_GET_SIZE(subobj); i++) { - result = _bytearray_tailmatch(self, - PyTuple_GET_ITEM(subobj, i), - start, end, -1); - if (result == -1) - return NULL; - else if (result) { - Py_RETURN_TRUE; - } - } - Py_RETURN_FALSE; - } - result = _bytearray_tailmatch(self, subobj, start, end, -1); - if (result == -1) { - if (PyErr_ExceptionMatches(PyExc_TypeError)) - PyErr_Format(PyExc_TypeError, "startswith first arg must be bytes " - "or a tuple of bytes, not %s", Py_TYPE(subobj)->tp_name); - return NULL; - } - else - return PyBool_FromLong(result); + return _Py_bytes_startswith(PyByteArray_AS_STRING(self), PyByteArray_GET_SIZE(self), args); } -PyDoc_STRVAR(endswith__doc__, -"B.endswith(suffix[, start[, end]]) -> bool\n\ -\n\ -Return True if B ends with the specified suffix, False otherwise.\n\ -With optional start, test B beginning at that position.\n\ -With optional end, stop comparing B at that position.\n\ -suffix can also be a tuple of bytes to try."); - static PyObject * bytearray_endswith(PyByteArrayObject *self, PyObject *args) { - Py_ssize_t start = 0; - Py_ssize_t end = PY_SSIZE_T_MAX; - PyObject *subobj; - int result; - - if (!stringlib_parse_args_finds("endswith", args, &subobj, &start, &end)) - return NULL; - if (PyTuple_Check(subobj)) { - Py_ssize_t i; - for (i = 0; i < PyTuple_GET_SIZE(subobj); i++) { - result = _bytearray_tailmatch(self, - PyTuple_GET_ITEM(subobj, i), - start, end, +1); - if (result == -1) - return NULL; - else if (result) { - Py_RETURN_TRUE; - } - } - Py_RETURN_FALSE; - } - result = _bytearray_tailmatch(self, subobj, start, end, +1); - if (result == -1) { - if (PyErr_ExceptionMatches(PyExc_TypeError)) - PyErr_Format(PyExc_TypeError, "endswith first arg must be bytes or " - "a tuple of bytes, not %s", Py_TYPE(subobj)->tp_name); - return NULL; - } - else - return PyBool_FromLong(result); + return _Py_bytes_endswith(PyByteArray_AS_STRING(self), PyByteArray_GET_SIZE(self), args); } @@ -1544,7 +1237,7 @@ result = PyByteArray_FromStringAndSize((char *)NULL, inlen); if (result == NULL) goto done; - output_start = output = PyByteArray_AsString(result); + output_start = output = PyByteArray_AS_STRING(result); input = PyByteArray_AS_STRING(input_obj); if (vdel.len == 0 && table_chars != NULL) { @@ -2919,19 +2612,22 @@ BYTEARRAY_APPEND_METHODDEF {"capitalize", (PyCFunction)stringlib_capitalize, METH_NOARGS, _Py_capitalize__doc__}, - {"center", (PyCFunction)stringlib_center, METH_VARARGS, center__doc__}, + {"center", (PyCFunction)stringlib_center, METH_VARARGS, _Py_center__doc__}, BYTEARRAY_CLEAR_METHODDEF BYTEARRAY_COPY_METHODDEF - {"count", (PyCFunction)bytearray_count, METH_VARARGS, count__doc__}, + {"count", (PyCFunction)bytearray_count, METH_VARARGS, + _Py_count__doc__}, BYTEARRAY_DECODE_METHODDEF - {"endswith", (PyCFunction)bytearray_endswith, METH_VARARGS, endswith__doc__}, + {"endswith", (PyCFunction)bytearray_endswith, METH_VARARGS, + _Py_endswith__doc__}, {"expandtabs", (PyCFunction)stringlib_expandtabs, METH_VARARGS | METH_KEYWORDS, - expandtabs__doc__}, + _Py_expandtabs__doc__}, BYTEARRAY_EXTEND_METHODDEF - {"find", (PyCFunction)bytearray_find, METH_VARARGS, find__doc__}, + {"find", (PyCFunction)bytearray_find, METH_VARARGS, + _Py_find__doc__}, BYTEARRAY_FROMHEX_METHODDEF {"hex", (PyCFunction)bytearray_hex, METH_NOARGS, hex__doc__}, - {"index", (PyCFunction)bytearray_index, METH_VARARGS, index__doc__}, + {"index", (PyCFunction)bytearray_index, METH_VARARGS, _Py_index__doc__}, BYTEARRAY_INSERT_METHODDEF {"isalnum", (PyCFunction)stringlib_isalnum, METH_NOARGS, _Py_isalnum__doc__}, @@ -2948,7 +2644,7 @@ {"isupper", (PyCFunction)stringlib_isupper, METH_NOARGS, _Py_isupper__doc__}, BYTEARRAY_JOIN_METHODDEF - {"ljust", (PyCFunction)stringlib_ljust, METH_VARARGS, ljust__doc__}, + {"ljust", (PyCFunction)stringlib_ljust, METH_VARARGS, _Py_ljust__doc__}, {"lower", (PyCFunction)stringlib_lower, METH_NOARGS, _Py_lower__doc__}, BYTEARRAY_LSTRIP_METHODDEF BYTEARRAY_MAKETRANS_METHODDEF @@ -2957,23 +2653,23 @@ BYTEARRAY_REMOVE_METHODDEF BYTEARRAY_REPLACE_METHODDEF BYTEARRAY_REVERSE_METHODDEF - {"rfind", (PyCFunction)bytearray_rfind, METH_VARARGS, rfind__doc__}, - {"rindex", (PyCFunction)bytearray_rindex, METH_VARARGS, rindex__doc__}, - {"rjust", (PyCFunction)stringlib_rjust, METH_VARARGS, rjust__doc__}, + {"rfind", (PyCFunction)bytearray_rfind, METH_VARARGS, _Py_rfind__doc__}, + {"rindex", (PyCFunction)bytearray_rindex, METH_VARARGS, _Py_rindex__doc__}, + {"rjust", (PyCFunction)stringlib_rjust, METH_VARARGS, _Py_rjust__doc__}, BYTEARRAY_RPARTITION_METHODDEF BYTEARRAY_RSPLIT_METHODDEF BYTEARRAY_RSTRIP_METHODDEF BYTEARRAY_SPLIT_METHODDEF BYTEARRAY_SPLITLINES_METHODDEF {"startswith", (PyCFunction)bytearray_startswith, METH_VARARGS , - startswith__doc__}, + _Py_startswith__doc__}, BYTEARRAY_STRIP_METHODDEF {"swapcase", (PyCFunction)stringlib_swapcase, METH_NOARGS, _Py_swapcase__doc__}, {"title", (PyCFunction)stringlib_title, METH_NOARGS, _Py_title__doc__}, BYTEARRAY_TRANSLATE_METHODDEF {"upper", (PyCFunction)stringlib_upper, METH_NOARGS, _Py_upper__doc__}, - {"zfill", (PyCFunction)stringlib_zfill, METH_VARARGS, zfill__doc__}, + {"zfill", (PyCFunction)stringlib_zfill, METH_VARARGS, _Py_zfill__doc__}, {NULL} }; diff --git a/Objects/bytes_methods.c b/Objects/bytes_methods.c --- a/Objects/bytes_methods.c +++ b/Objects/bytes_methods.c @@ -387,3 +387,427 @@ return res; } + +#define FASTSEARCH fastsearch +#define STRINGLIB(F) stringlib_##F +#define STRINGLIB_CHAR char +#define STRINGLIB_SIZEOF_CHAR 1 + +#include "stringlib/fastsearch.h" +#include "stringlib/count.h" +#include "stringlib/find.h" + +/* +Wraps stringlib_parse_args_finds() and additionally checks whether the +first argument is an integer in range(0, 256). + +If this is the case, writes the integer value to the byte parameter +and sets subobj to NULL. Otherwise, sets the first argument to subobj +and doesn't touch byte. The other parameters are similar to those of +stringlib_parse_args_finds(). +*/ + +Py_LOCAL_INLINE(int) +parse_args_finds_byte(const char *function_name, PyObject *args, + PyObject **subobj, char *byte, + Py_ssize_t *start, Py_ssize_t *end) +{ + PyObject *tmp_subobj; + Py_ssize_t ival; + PyObject *err; + + if(!stringlib_parse_args_finds(function_name, args, &tmp_subobj, + start, end)) + return 0; + + if (!PyNumber_Check(tmp_subobj)) { + *subobj = tmp_subobj; + return 1; + } + + ival = PyNumber_AsSsize_t(tmp_subobj, PyExc_OverflowError); + if (ival == -1) { + err = PyErr_Occurred(); + if (err && !PyErr_GivenExceptionMatches(err, PyExc_OverflowError)) { + PyErr_Clear(); + *subobj = tmp_subobj; + return 1; + } + } + + if (ival < 0 || ival > 255) { + PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)"); + return 0; + } + + *subobj = NULL; + *byte = (char)ival; + return 1; +} + +/* helper macro to fixup start/end slice values */ +#define ADJUST_INDICES(start, end, len) \ + if (end > len) \ + end = len; \ + else if (end < 0) { \ + end += len; \ + if (end < 0) \ + end = 0; \ + } \ + if (start < 0) { \ + start += len; \ + if (start < 0) \ + start = 0; \ + } + +Py_LOCAL_INLINE(Py_ssize_t) +find_internal(const char *str, Py_ssize_t len, + const char *function_name, PyObject *args, int dir) +{ + PyObject *subobj; + char byte; + Py_buffer subbuf; + const char *sub; + Py_ssize_t sub_len; + Py_ssize_t start = 0, end = PY_SSIZE_T_MAX; + Py_ssize_t res; + + if (!parse_args_finds_byte(function_name, args, + &subobj, &byte, &start, &end)) + return -2; + + if (subobj) { + if (PyObject_GetBuffer(subobj, &subbuf, PyBUF_SIMPLE) != 0) + return -2; + + sub = subbuf.buf; + sub_len = subbuf.len; + } + else { + sub = &byte; + sub_len = 1; + } + + ADJUST_INDICES(start, end, len); + if (end - start < sub_len) + res = -1; + else if (sub_len == 1) { + if (dir > 0) + res = stringlib_find_char( + str + start, end - start, + *sub); + else + res = stringlib_rfind_char( + str + start, end - start, + *sub); + if (res >= 0) + res += start; + } + else { + if (dir > 0) + res = stringlib_find_slice( + str, len, + sub, sub_len, start, end); + else + res = stringlib_rfind_slice( + str, len, + sub, sub_len, start, end); + } + + if (subobj) + PyBuffer_Release(&subbuf); + + return res; +} + +PyDoc_STRVAR_shared(_Py_find__doc__, +"B.find(sub[, start[, end]]) -> int\n\ +\n\ +Return the lowest index in B where subsection sub is found,\n\ +such that sub is contained within B[start,end]. Optional\n\ +arguments start and end are interpreted as in slice notation.\n\ +\n\ +Return -1 on failure."); + +PyObject * +_Py_bytes_find(const char *str, Py_ssize_t len, PyObject *args) +{ + Py_ssize_t result = find_internal(str, len, "find", args, +1); + if (result == -2) + return NULL; + return PyLong_FromSsize_t(result); +} + +PyDoc_STRVAR_shared(_Py_index__doc__, +"B.index(sub[, start[, end]]) -> int\n\ +\n\ +Like B.find() but raise ValueError when the subsection is not found."); + +PyObject * +_Py_bytes_index(const char *str, Py_ssize_t len, PyObject *args) +{ + Py_ssize_t result = find_internal(str, len, "index", args, +1); + if (result == -2) + return NULL; + if (result == -1) { + PyErr_SetString(PyExc_ValueError, + "subsection not found"); + return NULL; + } + return PyLong_FromSsize_t(result); +} + +PyDoc_STRVAR_shared(_Py_rfind__doc__, +"B.rfind(sub[, start[, end]]) -> int\n\ +\n\ +Return the highest index in B where subsection sub is found,\n\ +such that sub is contained within B[start,end]. Optional\n\ +arguments start and end are interpreted as in slice notation.\n\ +\n\ +Return -1 on failure."); + +PyObject * +_Py_bytes_rfind(const char *str, Py_ssize_t len, PyObject *args) +{ + Py_ssize_t result = find_internal(str, len, "rfind", args, -1); + if (result == -2) + return NULL; + return PyLong_FromSsize_t(result); +} + +PyDoc_STRVAR_shared(_Py_rindex__doc__, +"B.rindex(sub[, start[, end]]) -> int\n\ +\n\ +Like B.rfind() but raise ValueError when the subsection is not found."); + +PyObject * +_Py_bytes_rindex(const char *str, Py_ssize_t len, PyObject *args) +{ + Py_ssize_t result = find_internal(str, len, "rindex", args, -1); + if (result == -2) + return NULL; + if (result == -1) { + PyErr_SetString(PyExc_ValueError, + "subsection not found"); + return NULL; + } + return PyLong_FromSsize_t(result); +} + +PyDoc_STRVAR_shared(_Py_count__doc__, +"B.count(sub[, start[, end]]) -> int\n\ +\n\ +Return the number of non-overlapping occurrences of subsection sub in\n\ +bytes B[start:end]. Optional arguments start and end are interpreted\n\ +as in slice notation."); + +PyObject * +_Py_bytes_count(const char *str, Py_ssize_t len, PyObject *args) +{ + PyObject *sub_obj; + const char *sub; + Py_ssize_t sub_len; + char byte; + Py_ssize_t start = 0, end = PY_SSIZE_T_MAX; + + Py_buffer vsub; + PyObject *count_obj; + + if (!parse_args_finds_byte("count", args, + &sub_obj, &byte, &start, &end)) + return NULL; + + if (sub_obj) { + if (PyObject_GetBuffer(sub_obj, &vsub, PyBUF_SIMPLE) != 0) + return NULL; + + sub = vsub.buf; + sub_len = vsub.len; + } + else { + sub = &byte; + sub_len = 1; + } + + ADJUST_INDICES(start, end, len); + + count_obj = PyLong_FromSsize_t( + stringlib_count(str + start, end - start, sub, sub_len, PY_SSIZE_T_MAX) + ); + + if (sub_obj) + PyBuffer_Release(&vsub); + + return count_obj; +} + +int +_Py_bytes_contains(const char *str, Py_ssize_t len, PyObject *arg) +{ + Py_ssize_t ival = PyNumber_AsSsize_t(arg, PyExc_ValueError); + if (ival == -1 && PyErr_Occurred()) { + Py_buffer varg; + Py_ssize_t pos; + PyErr_Clear(); + if (PyObject_GetBuffer(arg, &varg, PyBUF_SIMPLE) != 0) + return -1; + pos = stringlib_find(str, len, + varg.buf, varg.len, 0); + PyBuffer_Release(&varg); + return pos >= 0; + } + if (ival < 0 || ival >= 256) { + PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)"); + return -1; + } + + return memchr(str, (int) ival, len) != NULL; +} + + +/* Matches the end (direction >= 0) or start (direction < 0) of the buffer + * against substr, using the start and end arguments. Returns + * -1 on error, 0 if not found and 1 if found. + */ +Py_LOCAL(int) +tailmatch(const char *str, Py_ssize_t len, PyObject *substr, + Py_ssize_t start, Py_ssize_t end, int direction) +{ + Py_buffer sub_view = {NULL, NULL}; + const char *sub; + Py_ssize_t slen; + + if (PyBytes_Check(substr)) { + sub = PyBytes_AS_STRING(substr); + slen = PyBytes_GET_SIZE(substr); + } + else { + if (PyObject_GetBuffer(substr, &sub_view, PyBUF_SIMPLE) != 0) + return -1; + sub = sub_view.buf; + slen = sub_view.len; + } + + ADJUST_INDICES(start, end, len); + + if (direction < 0) { + /* startswith */ + if (start + slen > len) + goto notfound; + } else { + /* endswith */ + if (end - start < slen || start > len) + goto notfound; + + if (end - slen > start) + start = end - slen; + } + if (end - start < slen) + goto notfound; + if (memcmp(str + start, sub, slen) != 0) + goto notfound; + + PyBuffer_Release(&sub_view); + return 1; + +notfound: + PyBuffer_Release(&sub_view); + return 0; +} + +Py_LOCAL(PyObject *) +_Py_bytes_tailmatch(const char *str, Py_ssize_t len, + const char *function_name, PyObject *args, + int direction) +{ + Py_ssize_t start = 0; + Py_ssize_t end = PY_SSIZE_T_MAX; + PyObject *subobj; + int result; + + if (!stringlib_parse_args_finds(function_name, args, &subobj, &start, &end)) + return NULL; + if (PyTuple_Check(subobj)) { + Py_ssize_t i; + for (i = 0; i < PyTuple_GET_SIZE(subobj); i++) { + result = tailmatch(str, len, PyTuple_GET_ITEM(subobj, i), + start, end, direction); + if (result == -1) + return NULL; + else if (result) { + Py_RETURN_TRUE; + } + } + Py_RETURN_FALSE; + } + result = tailmatch(str, len, subobj, start, end, direction); + if (result == -1) { + if (PyErr_ExceptionMatches(PyExc_TypeError)) + PyErr_Format(PyExc_TypeError, + "%s first arg must be bytes or a tuple of bytes, " + "not %s", + function_name, Py_TYPE(subobj)->tp_name); + return NULL; + } + else + return PyBool_FromLong(result); +} + +PyDoc_STRVAR_shared(_Py_startswith__doc__, +"B.startswith(prefix[, start[, end]]) -> bool\n\ +\n\ +Return True if B starts with the specified prefix, False otherwise.\n\ +With optional start, test B beginning at that position.\n\ +With optional end, stop comparing B at that position.\n\ +prefix can also be a tuple of bytes to try."); + +PyObject * +_Py_bytes_startswith(const char *str, Py_ssize_t len, PyObject *args) +{ + return _Py_bytes_tailmatch(str, len, "startswith", args, -1); +} + +PyDoc_STRVAR_shared(_Py_endswith__doc__, +"B.endswith(suffix[, start[, end]]) -> bool\n\ +\n\ +Return True if B ends with the specified suffix, False otherwise.\n\ +With optional start, test B beginning at that position.\n\ +With optional end, stop comparing B at that position.\n\ +suffix can also be a tuple of bytes to try."); + +PyObject * +_Py_bytes_endswith(const char *str, Py_ssize_t len, PyObject *args) +{ + return _Py_bytes_tailmatch(str, len, "endswith", args, +1); +} + +PyDoc_STRVAR_shared(_Py_expandtabs__doc__, +"B.expandtabs(tabsize=8) -> copy of B\n\ +\n\ +Return a copy of B where all tab characters are expanded using spaces.\n\ +If tabsize is not given, a tab size of 8 characters is assumed."); + +PyDoc_STRVAR_shared(_Py_ljust__doc__, +"B.ljust(width[, fillchar]) -> copy of B\n" +"\n" +"Return B left justified in a string of length width. Padding is\n" +"done using the specified fill character (default is a space)."); + +PyDoc_STRVAR_shared(_Py_rjust__doc__, +"B.rjust(width[, fillchar]) -> copy of B\n" +"\n" +"Return B right justified in a string of length width. Padding is\n" +"done using the specified fill character (default is a space)"); + +PyDoc_STRVAR_shared(_Py_center__doc__, +"B.center(width[, fillchar]) -> copy of B\n" +"\n" +"Return B centered in a string of length width. Padding is\n" +"done using the specified fill character (default is a space)."); + +PyDoc_STRVAR_shared(_Py_zfill__doc__, +"B.zfill(width) -> copy of B\n" +"\n" +"Pad a numeric string B with zeros on the left, to fill a field\n" +"of the specified width. B is never truncated."); + diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -486,11 +486,11 @@ static int byte_converter(PyObject *arg, char *p) { - if (PyBytes_Check(arg) && PyBytes_Size(arg) == 1) { + if (PyBytes_Check(arg) && PyBytes_GET_SIZE(arg) == 1) { *p = PyBytes_AS_STRING(arg)[0]; return 1; } - else if (PyByteArray_Check(arg) && PyByteArray_Size(arg) == 1) { + else if (PyByteArray_Check(arg) && PyByteArray_GET_SIZE(arg) == 1) { *p = PyByteArray_AS_STRING(arg)[0]; return 1; } @@ -1488,24 +1488,7 @@ static int bytes_contains(PyObject *self, PyObject *arg) { - Py_ssize_t ival = PyNumber_AsSsize_t(arg, PyExc_ValueError); - if (ival == -1 && PyErr_Occurred()) { - Py_buffer varg; - Py_ssize_t pos; - PyErr_Clear(); - if (PyObject_GetBuffer(arg, &varg, PyBUF_SIMPLE) != 0) - return -1; - pos = stringlib_find(PyBytes_AS_STRING(self), Py_SIZE(self), - varg.buf, varg.len, 0); - PyBuffer_Release(&varg); - return pos >= 0; - } - if (ival < 0 || ival >= 256) { - PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)"); - return -1; - } - - return memchr(PyBytes_AS_STRING(self), (int) ival, Py_SIZE(self)) != NULL; + return _Py_bytes_contains(PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self), arg); } static PyObject * @@ -1890,157 +1873,30 @@ return bytes_join((PyBytesObject*)sep, x); } -/* helper macro to fixup start/end slice values */ -#define ADJUST_INDICES(start, end, len) \ - if (end > len) \ - end = len; \ - else if (end < 0) { \ - end += len; \ - if (end < 0) \ - end = 0; \ - } \ - if (start < 0) { \ - start += len; \ - if (start < 0) \ - start = 0; \ - } - -Py_LOCAL_INLINE(Py_ssize_t) -bytes_find_internal(PyBytesObject *self, PyObject *args, int dir) -{ - PyObject *subobj; - char byte; - Py_buffer subbuf; - const char *sub; - Py_ssize_t len, sub_len; - Py_ssize_t start=0, end=PY_SSIZE_T_MAX; - Py_ssize_t res; - - if (!stringlib_parse_args_finds_byte("find/rfind/index/rindex", - args, &subobj, &byte, &start, &end)) - return -2; - - if (subobj) { - if (PyObject_GetBuffer(subobj, &subbuf, PyBUF_SIMPLE) != 0) - return -2; - - sub = subbuf.buf; - sub_len = subbuf.len; - } - else { - sub = &byte; - sub_len = 1; - } - len = PyBytes_GET_SIZE(self); - - ADJUST_INDICES(start, end, len); - if (end - start < sub_len) - res = -1; - else if (sub_len == 1) { - if (dir > 0) - res = stringlib_find_char( - PyBytes_AS_STRING(self) + start, end - start, - *sub); - else - res = stringlib_rfind_char( - PyBytes_AS_STRING(self) + start, end - start, - *sub); - if (res >= 0) - res += start; - } - else { - if (dir > 0) - res = stringlib_find_slice( - PyBytes_AS_STRING(self), len, - sub, sub_len, start, end); - else - res = stringlib_rfind_slice( - PyBytes_AS_STRING(self), len, - sub, sub_len, start, end); - } - - if (subobj) - PyBuffer_Release(&subbuf); - - return res; -} - - -PyDoc_STRVAR(find__doc__, -"B.find(sub[, start[, end]]) -> int\n\ -\n\ -Return the lowest index in B where substring sub is found,\n\ -such that sub is contained within B[start:end]. Optional\n\ -arguments start and end are interpreted as in slice notation.\n\ -\n\ -Return -1 on failure."); - static PyObject * bytes_find(PyBytesObject *self, PyObject *args) { - Py_ssize_t result = bytes_find_internal(self, args, +1); - if (result == -2) - return NULL; - return PyLong_FromSsize_t(result); + return _Py_bytes_find(PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self), args); } - -PyDoc_STRVAR(index__doc__, -"B.index(sub[, start[, end]]) -> int\n\ -\n\ -Like B.find() but raise ValueError when the substring is not found."); - static PyObject * bytes_index(PyBytesObject *self, PyObject *args) { - Py_ssize_t result = bytes_find_internal(self, args, +1); - if (result == -2) - return NULL; - if (result == -1) { - PyErr_SetString(PyExc_ValueError, - "substring not found"); - return NULL; - } - return PyLong_FromSsize_t(result); + return _Py_bytes_index(PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self), args); } -PyDoc_STRVAR(rfind__doc__, -"B.rfind(sub[, start[, end]]) -> int\n\ -\n\ -Return the highest index in B where substring sub is found,\n\ -such that sub is contained within B[start:end]. Optional\n\ -arguments start and end are interpreted as in slice notation.\n\ -\n\ -Return -1 on failure."); - static PyObject * bytes_rfind(PyBytesObject *self, PyObject *args) { - Py_ssize_t result = bytes_find_internal(self, args, -1); - if (result == -2) - return NULL; - return PyLong_FromSsize_t(result); + return _Py_bytes_rfind(PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self), args); } -PyDoc_STRVAR(rindex__doc__, -"B.rindex(sub[, start[, end]]) -> int\n\ -\n\ -Like B.rfind() but raise ValueError when the substring is not found."); - static PyObject * bytes_rindex(PyBytesObject *self, PyObject *args) { - Py_ssize_t result = bytes_find_internal(self, args, -1); - if (result == -2) - return NULL; - if (result == -1) { - PyErr_SetString(PyExc_ValueError, - "substring not found"); - return NULL; - } - return PyLong_FromSsize_t(result); + return _Py_bytes_rindex(PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self), args); } @@ -2179,51 +2035,10 @@ } -PyDoc_STRVAR(count__doc__, -"B.count(sub[, start[, end]]) -> int\n\ -\n\ -Return the number of non-overlapping occurrences of substring sub in\n\ -string B[start:end]. Optional arguments start and end are interpreted\n\ -as in slice notation."); - static PyObject * bytes_count(PyBytesObject *self, PyObject *args) { - PyObject *sub_obj; - const char *str = PyBytes_AS_STRING(self), *sub; - Py_ssize_t sub_len; - char byte; - Py_ssize_t start = 0, end = PY_SSIZE_T_MAX; - - Py_buffer vsub; - PyObject *count_obj; - - if (!stringlib_parse_args_finds_byte("count", args, &sub_obj, &byte, - &start, &end)) - return NULL; - - if (sub_obj) { - if (PyObject_GetBuffer(sub_obj, &vsub, PyBUF_SIMPLE) != 0) - return NULL; - - sub = vsub.buf; - sub_len = vsub.len; - } - else { - sub = &byte; - sub_len = 1; - } - - ADJUST_INDICES(start, end, PyBytes_GET_SIZE(self)); - - count_obj = PyLong_FromSsize_t( - stringlib_count(str + start, end - start, sub, sub_len, PY_SSIZE_T_MAX) - ); - - if (sub_obj) - PyBuffer_Release(&vsub); - - return count_obj; + return _Py_bytes_count(PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self), args); } @@ -2307,7 +2122,7 @@ PyBuffer_Release(&table_view); return NULL; } - output_start = output = PyBytes_AsString(result); + output_start = output = PyBytes_AS_STRING(result); input = PyBytes_AS_STRING(input_obj); if (dellen == 0 && table_chars != NULL) { @@ -2914,145 +2729,17 @@ /** End DALKE **/ -/* Matches the end (direction >= 0) or start (direction < 0) of self - * against substr, using the start and end arguments. Returns - * -1 on error, 0 if not found and 1 if found. - */ -Py_LOCAL(int) -_bytes_tailmatch(PyBytesObject *self, PyObject *substr, Py_ssize_t start, - Py_ssize_t end, int direction) -{ - Py_ssize_t len = PyBytes_GET_SIZE(self); - Py_ssize_t slen; - Py_buffer sub_view = {NULL, NULL}; - const char* sub; - const char* str; - - if (PyBytes_Check(substr)) { - sub = PyBytes_AS_STRING(substr); - slen = PyBytes_GET_SIZE(substr); - } - else { - if (PyObject_GetBuffer(substr, &sub_view, PyBUF_SIMPLE) != 0) - return -1; - sub = sub_view.buf; - slen = sub_view.len; - } - str = PyBytes_AS_STRING(self); - - ADJUST_INDICES(start, end, len); - - if (direction < 0) { - /* startswith */ - if (start+slen > len) - goto notfound; - } else { - /* endswith */ - if (end-start < slen || start > len) - goto notfound; - - if (end-slen > start) - start = end - slen; - } - if (end-start < slen) - goto notfound; - if (memcmp(str+start, sub, slen) != 0) - goto notfound; - - PyBuffer_Release(&sub_view); - return 1; - -notfound: - PyBuffer_Release(&sub_view); - return 0; -} - - -PyDoc_STRVAR(startswith__doc__, -"B.startswith(prefix[, start[, end]]) -> bool\n\ -\n\ -Return True if B starts with the specified prefix, False otherwise.\n\ -With optional start, test B beginning at that position.\n\ -With optional end, stop comparing B at that position.\n\ -prefix can also be a tuple of bytes to try."); static PyObject * bytes_startswith(PyBytesObject *self, PyObject *args) { - Py_ssize_t start = 0; - Py_ssize_t end = PY_SSIZE_T_MAX; - PyObject *subobj; - int result; - - if (!stringlib_parse_args_finds("startswith", args, &subobj, &start, &end)) - return NULL; - if (PyTuple_Check(subobj)) { - Py_ssize_t i; - for (i = 0; i < PyTuple_GET_SIZE(subobj); i++) { - result = _bytes_tailmatch(self, - PyTuple_GET_ITEM(subobj, i), - start, end, -1); - if (result == -1) - return NULL; - else if (result) { - Py_RETURN_TRUE; - } - } - Py_RETURN_FALSE; - } - result = _bytes_tailmatch(self, subobj, start, end, -1); - if (result == -1) { - if (PyErr_ExceptionMatches(PyExc_TypeError)) - PyErr_Format(PyExc_TypeError, "startswith first arg must be bytes " - "or a tuple of bytes, not %s", Py_TYPE(subobj)->tp_name); - return NULL; - } - else - return PyBool_FromLong(result); + return _Py_bytes_startswith(PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self), args); } - -PyDoc_STRVAR(endswith__doc__, -"B.endswith(suffix[, start[, end]]) -> bool\n\ -\n\ -Return True if B ends with the specified suffix, False otherwise.\n\ -With optional start, test B beginning at that position.\n\ -With optional end, stop comparing B at that position.\n\ -suffix can also be a tuple of bytes to try."); - static PyObject * bytes_endswith(PyBytesObject *self, PyObject *args) { - Py_ssize_t start = 0; - Py_ssize_t end = PY_SSIZE_T_MAX; - PyObject *subobj; - int result; - - if (!stringlib_parse_args_finds("endswith", args, &subobj, &start, &end)) - return NULL; - if (PyTuple_Check(subobj)) { - Py_ssize_t i; - for (i = 0; i < PyTuple_GET_SIZE(subobj); i++) { - result = _bytes_tailmatch(self, - PyTuple_GET_ITEM(subobj, i), - start, end, +1); - if (result == -1) - return NULL; - else if (result) { - Py_RETURN_TRUE; - } - } - Py_RETURN_FALSE; - } - result = _bytes_tailmatch(self, subobj, start, end, +1); - if (result == -1) { - if (PyErr_ExceptionMatches(PyExc_TypeError)) - PyErr_Format(PyExc_TypeError, "endswith first arg must be bytes or " - "a tuple of bytes, not %s", Py_TYPE(subobj)->tp_name); - return NULL; - } - else - return PyBool_FromLong(result); + return _Py_bytes_endswith(PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self), args); } @@ -3224,17 +2911,20 @@ {"__getnewargs__", (PyCFunction)bytes_getnewargs, METH_NOARGS}, {"capitalize", (PyCFunction)stringlib_capitalize, METH_NOARGS, _Py_capitalize__doc__}, - {"center", (PyCFunction)stringlib_center, METH_VARARGS, center__doc__}, - {"count", (PyCFunction)bytes_count, METH_VARARGS, count__doc__}, + {"center", (PyCFunction)stringlib_center, METH_VARARGS, + _Py_center__doc__}, + {"count", (PyCFunction)bytes_count, METH_VARARGS, + _Py_count__doc__}, BYTES_DECODE_METHODDEF {"endswith", (PyCFunction)bytes_endswith, METH_VARARGS, - endswith__doc__}, + _Py_endswith__doc__}, {"expandtabs", (PyCFunction)stringlib_expandtabs, METH_VARARGS | METH_KEYWORDS, - expandtabs__doc__}, - {"find", (PyCFunction)bytes_find, METH_VARARGS, find__doc__}, + _Py_expandtabs__doc__}, + {"find", (PyCFunction)bytes_find, METH_VARARGS, + _Py_find__doc__}, BYTES_FROMHEX_METHODDEF {"hex", (PyCFunction)bytes_hex, METH_NOARGS, hex__doc__}, - {"index", (PyCFunction)bytes_index, METH_VARARGS, index__doc__}, + {"index", (PyCFunction)bytes_index, METH_VARARGS, _Py_index__doc__}, {"isalnum", (PyCFunction)stringlib_isalnum, METH_NOARGS, _Py_isalnum__doc__}, {"isalpha", (PyCFunction)stringlib_isalpha, METH_NOARGS, @@ -3250,29 +2940,29 @@ {"isupper", (PyCFunction)stringlib_isupper, METH_NOARGS, _Py_isupper__doc__}, BYTES_JOIN_METHODDEF - {"ljust", (PyCFunction)stringlib_ljust, METH_VARARGS, ljust__doc__}, + {"ljust", (PyCFunction)stringlib_ljust, METH_VARARGS, _Py_ljust__doc__}, {"lower", (PyCFunction)stringlib_lower, METH_NOARGS, _Py_lower__doc__}, BYTES_LSTRIP_METHODDEF BYTES_MAKETRANS_METHODDEF BYTES_PARTITION_METHODDEF BYTES_REPLACE_METHODDEF - {"rfind", (PyCFunction)bytes_rfind, METH_VARARGS, rfind__doc__}, - {"rindex", (PyCFunction)bytes_rindex, METH_VARARGS, rindex__doc__}, - {"rjust", (PyCFunction)stringlib_rjust, METH_VARARGS, rjust__doc__}, + {"rfind", (PyCFunction)bytes_rfind, METH_VARARGS, _Py_rfind__doc__}, + {"rindex", (PyCFunction)bytes_rindex, METH_VARARGS, _Py_rindex__doc__}, + {"rjust", (PyCFunction)stringlib_rjust, METH_VARARGS, _Py_rjust__doc__}, BYTES_RPARTITION_METHODDEF BYTES_RSPLIT_METHODDEF BYTES_RSTRIP_METHODDEF BYTES_SPLIT_METHODDEF BYTES_SPLITLINES_METHODDEF {"startswith", (PyCFunction)bytes_startswith, METH_VARARGS, - startswith__doc__}, + _Py_startswith__doc__}, BYTES_STRIP_METHODDEF {"swapcase", (PyCFunction)stringlib_swapcase, METH_NOARGS, _Py_swapcase__doc__}, {"title", (PyCFunction)stringlib_title, METH_NOARGS, _Py_title__doc__}, BYTES_TRANSLATE_METHODDEF {"upper", (PyCFunction)stringlib_upper, METH_NOARGS, _Py_upper__doc__}, - {"zfill", (PyCFunction)stringlib_zfill, METH_VARARGS, zfill__doc__}, + {"zfill", (PyCFunction)stringlib_zfill, METH_VARARGS, _Py_zfill__doc__}, {NULL, NULL} /* sentinel */ }; diff --git a/Objects/stringlib/find.h b/Objects/stringlib/find.h --- a/Objects/stringlib/find.h +++ b/Objects/stringlib/find.h @@ -117,76 +117,3 @@ } #undef FORMAT_BUFFER_SIZE - -#if STRINGLIB_IS_UNICODE - -/* -Wraps stringlib_parse_args_finds() and additionally ensures that the -first argument is a unicode object. -*/ - -Py_LOCAL_INLINE(int) -STRINGLIB(parse_args_finds_unicode)(const char * function_name, PyObject *args, - PyObject **substring, - Py_ssize_t *start, Py_ssize_t *end) -{ - if(STRINGLIB(parse_args_finds)(function_name, args, substring, - start, end)) { - if (ensure_unicode(*substring) < 0) - return 0; - return 1; - } - return 0; -} - -#else /* !STRINGLIB_IS_UNICODE */ - -/* -Wraps stringlib_parse_args_finds() and additionally checks whether the -first argument is an integer in range(0, 256). - -If this is the case, writes the integer value to the byte parameter -and sets subobj to NULL. Otherwise, sets the first argument to subobj -and doesn't touch byte. The other parameters are similar to those of -stringlib_parse_args_finds(). -*/ - -Py_LOCAL_INLINE(int) -STRINGLIB(parse_args_finds_byte)(const char *function_name, PyObject *args, - PyObject **subobj, char *byte, - Py_ssize_t *start, Py_ssize_t *end) -{ - PyObject *tmp_subobj; - Py_ssize_t ival; - PyObject *err; - - if(!STRINGLIB(parse_args_finds)(function_name, args, &tmp_subobj, - start, end)) - return 0; - - if (!PyNumber_Check(tmp_subobj)) { - *subobj = tmp_subobj; - return 1; - } - - ival = PyNumber_AsSsize_t(tmp_subobj, PyExc_OverflowError); - if (ival == -1) { - err = PyErr_Occurred(); - if (err && !PyErr_GivenExceptionMatches(err, PyExc_OverflowError)) { - PyErr_Clear(); - *subobj = tmp_subobj; - return 1; - } - } - - if (ival < 0 || ival > 255) { - PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)"); - return 0; - } - - *subobj = NULL; - *byte = (char)ival; - return 1; -} - -#endif /* STRINGLIB_IS_UNICODE */ diff --git a/Objects/stringlib/transmogrify.h b/Objects/stringlib/transmogrify.h --- a/Objects/stringlib/transmogrify.h +++ b/Objects/stringlib/transmogrify.h @@ -4,12 +4,6 @@ /* the more complicated methods. parts of these should be pulled out into the shared code in bytes_methods.c to cut down on duplicate code bloat. */ -PyDoc_STRVAR(expandtabs__doc__, -"B.expandtabs(tabsize=8) -> copy of B\n\ -\n\ -Return a copy of B where all tab characters are expanded using spaces.\n\ -If tabsize is not given, a tab size of 8 characters is assumed."); - static PyObject* stringlib_expandtabs(PyObject *self, PyObject *args, PyObject *kwds) { @@ -120,12 +114,6 @@ return u; } -PyDoc_STRVAR(ljust__doc__, -"B.ljust(width[, fillchar]) -> copy of B\n" -"\n" -"Return B left justified in a string of length width. Padding is\n" -"done using the specified fill character (default is a space)."); - static PyObject * stringlib_ljust(PyObject *self, PyObject *args) { @@ -150,12 +138,6 @@ } -PyDoc_STRVAR(rjust__doc__, -"B.rjust(width[, fillchar]) -> copy of B\n" -"\n" -"Return B right justified in a string of length width. Padding is\n" -"done using the specified fill character (default is a space)"); - static PyObject * stringlib_rjust(PyObject *self, PyObject *args) { @@ -180,12 +162,6 @@ } -PyDoc_STRVAR(center__doc__, -"B.center(width[, fillchar]) -> copy of B\n" -"\n" -"Return B centered in a string of length width. Padding is\n" -"done using the specified fill character (default is a space)."); - static PyObject * stringlib_center(PyObject *self, PyObject *args) { @@ -213,12 +189,6 @@ return pad(self, left, marg - left, fillchar); } -PyDoc_STRVAR(zfill__doc__, -"B.zfill(width) -> copy of B\n" -"\n" -"Pad a numeric string B with zeros on the left, to fill a field\n" -"of the specified width. B is never truncated."); - static PyObject * stringlib_zfill(PyObject *self, PyObject *args) { diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -11244,6 +11244,25 @@ Py_XDECREF(right); } +/* +Wraps stringlib_parse_args_finds() and additionally ensures that the +first argument is a unicode object. +*/ + +Py_LOCAL_INLINE(int) +parse_args_finds_unicode(const char * function_name, PyObject *args, + PyObject **substring, + Py_ssize_t *start, Py_ssize_t *end) +{ + if(stringlib_parse_args_finds(function_name, args, substring, + start, end)) { + if (ensure_unicode(*substring) < 0) + return 0; + return 1; + } + return 0; +} + PyDoc_STRVAR(count__doc__, "S.count(sub[, start[, end]]) -> int\n\ \n\ @@ -11262,8 +11281,7 @@ void *buf1, *buf2; Py_ssize_t len1, len2, iresult; - if (!stringlib_parse_args_finds_unicode("count", args, &substring, - &start, &end)) + if (!parse_args_finds_unicode("count", args, &substring, &start, &end)) return NULL; kind1 = PyUnicode_KIND(self); @@ -11445,8 +11463,7 @@ Py_ssize_t end = 0; Py_ssize_t result; - if (!stringlib_parse_args_finds_unicode("find", args, &substring, - &start, &end)) + if (!parse_args_finds_unicode("find", args, &substring, &start, &end)) return NULL; if (PyUnicode_READY(self) == -1) @@ -11525,8 +11542,7 @@ Py_ssize_t start = 0; Py_ssize_t end = 0; - if (!stringlib_parse_args_finds_unicode("index", args, &substring, - &start, &end)) + if (!parse_args_finds_unicode("index", args, &substring, &start, &end)) return NULL; if (PyUnicode_READY(self) == -1) @@ -12555,8 +12571,7 @@ Py_ssize_t end = 0; Py_ssize_t result; - if (!stringlib_parse_args_finds_unicode("rfind", args, &substring, - &start, &end)) + if (!parse_args_finds_unicode("rfind", args, &substring, &start, &end)) return NULL; if (PyUnicode_READY(self) == -1) @@ -12584,8 +12599,7 @@ Py_ssize_t end = 0; Py_ssize_t result; - if (!stringlib_parse_args_finds_unicode("rindex", args, &substring, - &start, &end)) + if (!parse_args_finds_unicode("rindex", args, &substring, &start, &end)) return NULL; if (PyUnicode_READY(self) == -1) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed May 4 16:25:52 2016 From: python-checkins at python.org (berker.peksag) Date: Wed, 04 May 2016 20:25:52 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2OTU3?= =?utf-8?q?=3A_Remove_duplicate_=27the=27_from_datetime_documentation?= Message-ID: <20160504202549.29225.67777.077343D9@psf.io> https://hg.python.org/cpython/rev/580ddeccd689 changeset: 101231:580ddeccd689 branch: 3.5 parent: 101226:a98ef122d73d user: Berker Peksag date: Wed May 04 23:25:44 2016 +0300 summary: Issue #26957: Remove duplicate 'the' from datetime documentation Patch by Alex Chan. files: Doc/library/datetime.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -1869,7 +1869,7 @@ +-----------+--------------------------------+------------------------+-------+ | ``%z`` | UTC offset in the form +HHMM | (empty), +0000, -0400, | \(6) | | | or -HHMM (empty string if the | +1030 | | -| | the object is naive). | | | +| | object is naive). | | | +-----------+--------------------------------+------------------------+-------+ | ``%Z`` | Time zone name (empty string | (empty), UTC, EST, CST | | | | if the object is naive). | | | -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Wed May 4 16:26:03 2016 From: python-checkins at python.org (berker.peksag) Date: Wed, 04 May 2016 20:26:03 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326957=3A_Remove_duplicate_=27the=27_from_dateti?= =?utf-8?q?me_documentation?= Message-ID: <20160504202550.70745.44274.EF9FF6E3@psf.io> https://hg.python.org/cpython/rev/3a069e5593ef changeset: 101232:3a069e5593ef parent: 101230:41969033eb9d parent: 101231:580ddeccd689 user: Berker Peksag date: Wed May 04 23:26:04 2016 +0300 summary: Issue #26957: Remove duplicate 'the' from datetime documentation Patch by Alex Chan. files: Doc/library/datetime.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -1941,7 +1941,7 @@ +-----------+--------------------------------+------------------------+-------+ | ``%z`` | UTC offset in the form +HHMM | (empty), +0000, -0400, | \(6) | | | or -HHMM (empty string if the | +1030 | | -| | the object is naive). | | | +| | object is naive). | | | +-----------+--------------------------------+------------------------+-------+ | ``%Z`` | Time zone name (empty string | (empty), UTC, EST, CST | | | | if the object is naive). | | | -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu May 5 02:26:29 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 05 May 2016 06:26:29 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2326765=3A_Moved_co?= =?utf-8?q?mmon_code_for_the_replace=28=29_method_of_bytes_and_bytearray?= Message-ID: <20160505062627.22563.67001.911C7F57@psf.io> https://hg.python.org/cpython/rev/f4406d746d27 changeset: 101233:f4406d746d27 user: Serhiy Storchaka date: Thu May 05 09:26:07 2016 +0300 summary: Issue #26765: Moved common code for the replace() method of bytes and bytearray to a template file. files: Objects/bytearrayobject.c | 503 +---------------- Objects/bytesobject.c | 508 +---------------- Objects/stringlib/transmogrify.h | 578 +++++++++++++++++- 3 files changed, 527 insertions(+), 1062 deletions(-) diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -1307,503 +1307,6 @@ } -/* find and count characters and substrings */ - -#define findchar(target, target_len, c) \ - ((char *)memchr((const void *)(target), c, target_len)) - - -/* Bytes ops must return a string, create a copy */ -Py_LOCAL(PyByteArrayObject *) -return_self(PyByteArrayObject *self) -{ - /* always return a new bytearray */ - return (PyByteArrayObject *)PyByteArray_FromStringAndSize( - PyByteArray_AS_STRING(self), - PyByteArray_GET_SIZE(self)); -} - -Py_LOCAL_INLINE(Py_ssize_t) -countchar(const char *target, Py_ssize_t target_len, char c, Py_ssize_t maxcount) -{ - Py_ssize_t count=0; - const char *start=target; - const char *end=target+target_len; - - while ( (start=findchar(start, end-start, c)) != NULL ) { - count++; - if (count >= maxcount) - break; - start += 1; - } - return count; -} - - -/* Algorithms for different cases of string replacement */ - -/* len(self)>=1, from="", len(to)>=1, maxcount>=1 */ -Py_LOCAL(PyByteArrayObject *) -replace_interleave(PyByteArrayObject *self, - const char *to_s, Py_ssize_t to_len, - Py_ssize_t maxcount) -{ - char *self_s, *result_s; - Py_ssize_t self_len, result_len; - Py_ssize_t count, i; - PyByteArrayObject *result; - - self_len = PyByteArray_GET_SIZE(self); - - /* 1 at the end plus 1 after every character; - count = min(maxcount, self_len + 1) */ - if (maxcount <= self_len) - count = maxcount; - else - /* Can't overflow: self_len + 1 <= maxcount <= PY_SSIZE_T_MAX. */ - count = self_len + 1; - - /* Check for overflow */ - /* result_len = count * to_len + self_len; */ - assert(count > 0); - if (to_len > (PY_SSIZE_T_MAX - self_len) / count) { - PyErr_SetString(PyExc_OverflowError, - "replace string is too long"); - return NULL; - } - result_len = count * to_len + self_len; - - if (! (result = (PyByteArrayObject *) - PyByteArray_FromStringAndSize(NULL, result_len)) ) - return NULL; - - self_s = PyByteArray_AS_STRING(self); - result_s = PyByteArray_AS_STRING(result); - - if (to_len > 1) { - /* Lay the first one down (guaranteed this will occur) */ - Py_MEMCPY(result_s, to_s, to_len); - result_s += to_len; - count -= 1; - - for (i = 0; i < count; i++) { - *result_s++ = *self_s++; - Py_MEMCPY(result_s, to_s, to_len); - result_s += to_len; - } - } - else { - result_s[0] = to_s[0]; - result_s += to_len; - count -= 1; - for (i = 0; i < count; i++) { - *result_s++ = *self_s++; - result_s[0] = to_s[0]; - result_s += to_len; - } - } - - /* Copy the rest of the original string */ - Py_MEMCPY(result_s, self_s, self_len-i); - - return result; -} - -/* Special case for deleting a single character */ -/* len(self)>=1, len(from)==1, to="", maxcount>=1 */ -Py_LOCAL(PyByteArrayObject *) -replace_delete_single_character(PyByteArrayObject *self, - char from_c, Py_ssize_t maxcount) -{ - char *self_s, *result_s; - char *start, *next, *end; - Py_ssize_t self_len, result_len; - Py_ssize_t count; - PyByteArrayObject *result; - - self_len = PyByteArray_GET_SIZE(self); - self_s = PyByteArray_AS_STRING(self); - - count = countchar(self_s, self_len, from_c, maxcount); - if (count == 0) { - return return_self(self); - } - - result_len = self_len - count; /* from_len == 1 */ - assert(result_len>=0); - - if ( (result = (PyByteArrayObject *) - PyByteArray_FromStringAndSize(NULL, result_len)) == NULL) - return NULL; - result_s = PyByteArray_AS_STRING(result); - - start = self_s; - end = self_s + self_len; - while (count-- > 0) { - next = findchar(start, end-start, from_c); - if (next == NULL) - break; - Py_MEMCPY(result_s, start, next-start); - result_s += (next-start); - start = next+1; - } - Py_MEMCPY(result_s, start, end-start); - - return result; -} - -/* len(self)>=1, len(from)>=2, to="", maxcount>=1 */ - -Py_LOCAL(PyByteArrayObject *) -replace_delete_substring(PyByteArrayObject *self, - const char *from_s, Py_ssize_t from_len, - Py_ssize_t maxcount) -{ - char *self_s, *result_s; - char *start, *next, *end; - Py_ssize_t self_len, result_len; - Py_ssize_t count, offset; - PyByteArrayObject *result; - - self_len = PyByteArray_GET_SIZE(self); - self_s = PyByteArray_AS_STRING(self); - - count = stringlib_count(self_s, self_len, - from_s, from_len, - maxcount); - - if (count == 0) { - /* no matches */ - return return_self(self); - } - - result_len = self_len - (count * from_len); - assert (result_len>=0); - - if ( (result = (PyByteArrayObject *) - PyByteArray_FromStringAndSize(NULL, result_len)) == NULL ) - return NULL; - - result_s = PyByteArray_AS_STRING(result); - - start = self_s; - end = self_s + self_len; - while (count-- > 0) { - offset = stringlib_find(start, end-start, - from_s, from_len, - 0); - if (offset == -1) - break; - next = start + offset; - - Py_MEMCPY(result_s, start, next-start); - - result_s += (next-start); - start = next+from_len; - } - Py_MEMCPY(result_s, start, end-start); - return result; -} - -/* len(self)>=1, len(from)==len(to)==1, maxcount>=1 */ -Py_LOCAL(PyByteArrayObject *) -replace_single_character_in_place(PyByteArrayObject *self, - char from_c, char to_c, - Py_ssize_t maxcount) -{ - char *self_s, *result_s, *start, *end, *next; - Py_ssize_t self_len; - PyByteArrayObject *result; - - /* The result string will be the same size */ - self_s = PyByteArray_AS_STRING(self); - self_len = PyByteArray_GET_SIZE(self); - - next = findchar(self_s, self_len, from_c); - - if (next == NULL) { - /* No matches; return the original bytes */ - return return_self(self); - } - - /* Need to make a new bytes */ - result = (PyByteArrayObject *) PyByteArray_FromStringAndSize(NULL, self_len); - if (result == NULL) - return NULL; - result_s = PyByteArray_AS_STRING(result); - Py_MEMCPY(result_s, self_s, self_len); - - /* change everything in-place, starting with this one */ - start = result_s + (next-self_s); - *start = to_c; - start++; - end = result_s + self_len; - - while (--maxcount > 0) { - next = findchar(start, end-start, from_c); - if (next == NULL) - break; - *next = to_c; - start = next+1; - } - - return result; -} - -/* len(self)>=1, len(from)==len(to)>=2, maxcount>=1 */ -Py_LOCAL(PyByteArrayObject *) -replace_substring_in_place(PyByteArrayObject *self, - const char *from_s, Py_ssize_t from_len, - const char *to_s, Py_ssize_t to_len, - Py_ssize_t maxcount) -{ - char *result_s, *start, *end; - char *self_s; - Py_ssize_t self_len, offset; - PyByteArrayObject *result; - - /* The result bytes will be the same size */ - - self_s = PyByteArray_AS_STRING(self); - self_len = PyByteArray_GET_SIZE(self); - - offset = stringlib_find(self_s, self_len, - from_s, from_len, - 0); - if (offset == -1) { - /* No matches; return the original bytes */ - return return_self(self); - } - - /* Need to make a new bytes */ - result = (PyByteArrayObject *) PyByteArray_FromStringAndSize(NULL, self_len); - if (result == NULL) - return NULL; - result_s = PyByteArray_AS_STRING(result); - Py_MEMCPY(result_s, self_s, self_len); - - /* change everything in-place, starting with this one */ - start = result_s + offset; - Py_MEMCPY(start, to_s, from_len); - start += from_len; - end = result_s + self_len; - - while ( --maxcount > 0) { - offset = stringlib_find(start, end-start, - from_s, from_len, - 0); - if (offset==-1) - break; - Py_MEMCPY(start+offset, to_s, from_len); - start += offset+from_len; - } - - return result; -} - -/* len(self)>=1, len(from)==1, len(to)>=2, maxcount>=1 */ -Py_LOCAL(PyByteArrayObject *) -replace_single_character(PyByteArrayObject *self, - char from_c, - const char *to_s, Py_ssize_t to_len, - Py_ssize_t maxcount) -{ - char *self_s, *result_s; - char *start, *next, *end; - Py_ssize_t self_len, result_len; - Py_ssize_t count; - PyByteArrayObject *result; - - self_s = PyByteArray_AS_STRING(self); - self_len = PyByteArray_GET_SIZE(self); - - count = countchar(self_s, self_len, from_c, maxcount); - if (count == 0) { - /* no matches, return unchanged */ - return return_self(self); - } - - /* use the difference between current and new, hence the "-1" */ - /* result_len = self_len + count * (to_len-1) */ - assert(count > 0); - if (to_len - 1 > (PY_SSIZE_T_MAX - self_len) / count) { - PyErr_SetString(PyExc_OverflowError, "replace bytes is too long"); - return NULL; - } - result_len = self_len + count * (to_len - 1); - - if ( (result = (PyByteArrayObject *) - PyByteArray_FromStringAndSize(NULL, result_len)) == NULL) - return NULL; - result_s = PyByteArray_AS_STRING(result); - - start = self_s; - end = self_s + self_len; - while (count-- > 0) { - next = findchar(start, end-start, from_c); - if (next == NULL) - break; - - if (next == start) { - /* replace with the 'to' */ - Py_MEMCPY(result_s, to_s, to_len); - result_s += to_len; - start += 1; - } else { - /* copy the unchanged old then the 'to' */ - Py_MEMCPY(result_s, start, next-start); - result_s += (next-start); - Py_MEMCPY(result_s, to_s, to_len); - result_s += to_len; - start = next+1; - } - } - /* Copy the remainder of the remaining bytes */ - Py_MEMCPY(result_s, start, end-start); - - return result; -} - -/* len(self)>=1, len(from)>=2, len(to)>=2, maxcount>=1 */ -Py_LOCAL(PyByteArrayObject *) -replace_substring(PyByteArrayObject *self, - const char *from_s, Py_ssize_t from_len, - const char *to_s, Py_ssize_t to_len, - Py_ssize_t maxcount) -{ - char *self_s, *result_s; - char *start, *next, *end; - Py_ssize_t self_len, result_len; - Py_ssize_t count, offset; - PyByteArrayObject *result; - - self_s = PyByteArray_AS_STRING(self); - self_len = PyByteArray_GET_SIZE(self); - - count = stringlib_count(self_s, self_len, - from_s, from_len, - maxcount); - - if (count == 0) { - /* no matches, return unchanged */ - return return_self(self); - } - - /* Check for overflow */ - /* result_len = self_len + count * (to_len-from_len) */ - assert(count > 0); - if (to_len - from_len > (PY_SSIZE_T_MAX - self_len) / count) { - PyErr_SetString(PyExc_OverflowError, "replace bytes is too long"); - return NULL; - } - result_len = self_len + count * (to_len - from_len); - - if ( (result = (PyByteArrayObject *) - PyByteArray_FromStringAndSize(NULL, result_len)) == NULL) - return NULL; - result_s = PyByteArray_AS_STRING(result); - - start = self_s; - end = self_s + self_len; - while (count-- > 0) { - offset = stringlib_find(start, end-start, - from_s, from_len, - 0); - if (offset == -1) - break; - next = start+offset; - if (next == start) { - /* replace with the 'to' */ - Py_MEMCPY(result_s, to_s, to_len); - result_s += to_len; - start += from_len; - } else { - /* copy the unchanged old then the 'to' */ - Py_MEMCPY(result_s, start, next-start); - result_s += (next-start); - Py_MEMCPY(result_s, to_s, to_len); - result_s += to_len; - start = next+from_len; - } - } - /* Copy the remainder of the remaining bytes */ - Py_MEMCPY(result_s, start, end-start); - - return result; -} - - -Py_LOCAL(PyByteArrayObject *) -replace(PyByteArrayObject *self, - const char *from_s, Py_ssize_t from_len, - const char *to_s, Py_ssize_t to_len, - Py_ssize_t maxcount) -{ - if (maxcount < 0) { - maxcount = PY_SSIZE_T_MAX; - } else if (maxcount == 0 || PyByteArray_GET_SIZE(self) == 0) { - /* nothing to do; return the original bytes */ - return return_self(self); - } - - if (maxcount == 0 || - (from_len == 0 && to_len == 0)) { - /* nothing to do; return the original bytes */ - return return_self(self); - } - - /* Handle zero-length special cases */ - - if (from_len == 0) { - /* insert the 'to' bytes everywhere. */ - /* >>> "Python".replace("", ".") */ - /* '.P.y.t.h.o.n.' */ - return replace_interleave(self, to_s, to_len, maxcount); - } - - /* Except for "".replace("", "A") == "A" there is no way beyond this */ - /* point for an empty self bytes to generate a non-empty bytes */ - /* Special case so the remaining code always gets a non-empty bytes */ - if (PyByteArray_GET_SIZE(self) == 0) { - return return_self(self); - } - - if (to_len == 0) { - /* delete all occurrences of 'from' bytes */ - if (from_len == 1) { - return replace_delete_single_character( - self, from_s[0], maxcount); - } else { - return replace_delete_substring(self, from_s, from_len, maxcount); - } - } - - /* Handle special case where both bytes have the same length */ - - if (from_len == to_len) { - if (from_len == 1) { - return replace_single_character_in_place( - self, - from_s[0], - to_s[0], - maxcount); - } else { - return replace_substring_in_place( - self, from_s, from_len, to_s, to_len, maxcount); - } - } - - /* Otherwise use the more generic algorithms */ - if (from_len == 1) { - return replace_single_character(self, from_s[0], - to_s, to_len, maxcount); - } else { - /* len('from')>=2, len('to')>=1 */ - return replace_substring(self, from_s, from_len, to_s, to_len, maxcount); - } -} - - /*[clinic input] bytearray.replace @@ -1825,9 +1328,9 @@ Py_buffer *new, Py_ssize_t count) /*[clinic end generated code: output=d39884c4dc59412a input=aa379d988637c7fb]*/ { - return (PyObject *)replace((PyByteArrayObject *) self, - old->buf, old->len, - new->buf, new->len, count); + return stringlib_replace((PyObject *)self, + (const char *)old->buf, old->len, + (const char *)new->buf, new->len, count); } /*[clinic input] diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -2198,508 +2198,6 @@ return _Py_bytes_maketrans(frm, to); } -/* find and count characters and substrings */ - -#define findchar(target, target_len, c) \ - ((char *)memchr((const void *)(target), c, target_len)) - -/* String ops must return a string. */ -/* If the object is subclass of string, create a copy */ -Py_LOCAL(PyBytesObject *) -return_self(PyBytesObject *self) -{ - if (PyBytes_CheckExact(self)) { - Py_INCREF(self); - return self; - } - return (PyBytesObject *)PyBytes_FromStringAndSize( - PyBytes_AS_STRING(self), - PyBytes_GET_SIZE(self)); -} - -Py_LOCAL_INLINE(Py_ssize_t) -countchar(const char *target, Py_ssize_t target_len, char c, Py_ssize_t maxcount) -{ - Py_ssize_t count=0; - const char *start=target; - const char *end=target+target_len; - - while ( (start=findchar(start, end-start, c)) != NULL ) { - count++; - if (count >= maxcount) - break; - start += 1; - } - return count; -} - - -/* Algorithms for different cases of string replacement */ - -/* len(self)>=1, from="", len(to)>=1, maxcount>=1 */ -Py_LOCAL(PyBytesObject *) -replace_interleave(PyBytesObject *self, - const char *to_s, Py_ssize_t to_len, - Py_ssize_t maxcount) -{ - char *self_s, *result_s; - Py_ssize_t self_len, result_len; - Py_ssize_t count, i; - PyBytesObject *result; - - self_len = PyBytes_GET_SIZE(self); - - /* 1 at the end plus 1 after every character; - count = min(maxcount, self_len + 1) */ - if (maxcount <= self_len) - count = maxcount; - else - /* Can't overflow: self_len + 1 <= maxcount <= PY_SSIZE_T_MAX. */ - count = self_len + 1; - - /* Check for overflow */ - /* result_len = count * to_len + self_len; */ - assert(count > 0); - if (to_len > (PY_SSIZE_T_MAX - self_len) / count) { - PyErr_SetString(PyExc_OverflowError, - "replacement bytes are too long"); - return NULL; - } - result_len = count * to_len + self_len; - - if (! (result = (PyBytesObject *) - PyBytes_FromStringAndSize(NULL, result_len)) ) - return NULL; - - self_s = PyBytes_AS_STRING(self); - result_s = PyBytes_AS_STRING(result); - - if (to_len > 1) { - /* Lay the first one down (guaranteed this will occur) */ - Py_MEMCPY(result_s, to_s, to_len); - result_s += to_len; - count -= 1; - - for (i = 0; i < count; i++) { - *result_s++ = *self_s++; - Py_MEMCPY(result_s, to_s, to_len); - result_s += to_len; - } - } - else { - result_s[0] = to_s[0]; - result_s += to_len; - count -= 1; - for (i = 0; i < count; i++) { - *result_s++ = *self_s++; - result_s[0] = to_s[0]; - result_s += to_len; - } - } - - /* Copy the rest of the original string */ - Py_MEMCPY(result_s, self_s, self_len-i); - - return result; -} - -/* Special case for deleting a single character */ -/* len(self)>=1, len(from)==1, to="", maxcount>=1 */ -Py_LOCAL(PyBytesObject *) -replace_delete_single_character(PyBytesObject *self, - char from_c, Py_ssize_t maxcount) -{ - char *self_s, *result_s; - char *start, *next, *end; - Py_ssize_t self_len, result_len; - Py_ssize_t count; - PyBytesObject *result; - - self_len = PyBytes_GET_SIZE(self); - self_s = PyBytes_AS_STRING(self); - - count = countchar(self_s, self_len, from_c, maxcount); - if (count == 0) { - return return_self(self); - } - - result_len = self_len - count; /* from_len == 1 */ - assert(result_len>=0); - - if ( (result = (PyBytesObject *) - PyBytes_FromStringAndSize(NULL, result_len)) == NULL) - return NULL; - result_s = PyBytes_AS_STRING(result); - - start = self_s; - end = self_s + self_len; - while (count-- > 0) { - next = findchar(start, end-start, from_c); - if (next == NULL) - break; - Py_MEMCPY(result_s, start, next-start); - result_s += (next-start); - start = next+1; - } - Py_MEMCPY(result_s, start, end-start); - - return result; -} - -/* len(self)>=1, len(from)>=2, to="", maxcount>=1 */ - -Py_LOCAL(PyBytesObject *) -replace_delete_substring(PyBytesObject *self, - const char *from_s, Py_ssize_t from_len, - Py_ssize_t maxcount) { - char *self_s, *result_s; - char *start, *next, *end; - Py_ssize_t self_len, result_len; - Py_ssize_t count, offset; - PyBytesObject *result; - - self_len = PyBytes_GET_SIZE(self); - self_s = PyBytes_AS_STRING(self); - - count = stringlib_count(self_s, self_len, - from_s, from_len, - maxcount); - - if (count == 0) { - /* no matches */ - return return_self(self); - } - - result_len = self_len - (count * from_len); - assert (result_len>=0); - - if ( (result = (PyBytesObject *) - PyBytes_FromStringAndSize(NULL, result_len)) == NULL ) - return NULL; - - result_s = PyBytes_AS_STRING(result); - - start = self_s; - end = self_s + self_len; - while (count-- > 0) { - offset = stringlib_find(start, end-start, - from_s, from_len, - 0); - if (offset == -1) - break; - next = start + offset; - - Py_MEMCPY(result_s, start, next-start); - - result_s += (next-start); - start = next+from_len; - } - Py_MEMCPY(result_s, start, end-start); - return result; -} - -/* len(self)>=1, len(from)==len(to)==1, maxcount>=1 */ -Py_LOCAL(PyBytesObject *) -replace_single_character_in_place(PyBytesObject *self, - char from_c, char to_c, - Py_ssize_t maxcount) -{ - char *self_s, *result_s, *start, *end, *next; - Py_ssize_t self_len; - PyBytesObject *result; - - /* The result string will be the same size */ - self_s = PyBytes_AS_STRING(self); - self_len = PyBytes_GET_SIZE(self); - - next = findchar(self_s, self_len, from_c); - - if (next == NULL) { - /* No matches; return the original string */ - return return_self(self); - } - - /* Need to make a new string */ - result = (PyBytesObject *) PyBytes_FromStringAndSize(NULL, self_len); - if (result == NULL) - return NULL; - result_s = PyBytes_AS_STRING(result); - Py_MEMCPY(result_s, self_s, self_len); - - /* change everything in-place, starting with this one */ - start = result_s + (next-self_s); - *start = to_c; - start++; - end = result_s + self_len; - - while (--maxcount > 0) { - next = findchar(start, end-start, from_c); - if (next == NULL) - break; - *next = to_c; - start = next+1; - } - - return result; -} - -/* len(self)>=1, len(from)==len(to)>=2, maxcount>=1 */ -Py_LOCAL(PyBytesObject *) -replace_substring_in_place(PyBytesObject *self, - const char *from_s, Py_ssize_t from_len, - const char *to_s, Py_ssize_t to_len, - Py_ssize_t maxcount) -{ - char *result_s, *start, *end; - char *self_s; - Py_ssize_t self_len, offset; - PyBytesObject *result; - - /* The result string will be the same size */ - - self_s = PyBytes_AS_STRING(self); - self_len = PyBytes_GET_SIZE(self); - - offset = stringlib_find(self_s, self_len, - from_s, from_len, - 0); - if (offset == -1) { - /* No matches; return the original string */ - return return_self(self); - } - - /* Need to make a new string */ - result = (PyBytesObject *) PyBytes_FromStringAndSize(NULL, self_len); - if (result == NULL) - return NULL; - result_s = PyBytes_AS_STRING(result); - Py_MEMCPY(result_s, self_s, self_len); - - /* change everything in-place, starting with this one */ - start = result_s + offset; - Py_MEMCPY(start, to_s, from_len); - start += from_len; - end = result_s + self_len; - - while ( --maxcount > 0) { - offset = stringlib_find(start, end-start, - from_s, from_len, - 0); - if (offset==-1) - break; - Py_MEMCPY(start+offset, to_s, from_len); - start += offset+from_len; - } - - return result; -} - -/* len(self)>=1, len(from)==1, len(to)>=2, maxcount>=1 */ -Py_LOCAL(PyBytesObject *) -replace_single_character(PyBytesObject *self, - char from_c, - const char *to_s, Py_ssize_t to_len, - Py_ssize_t maxcount) -{ - char *self_s, *result_s; - char *start, *next, *end; - Py_ssize_t self_len, result_len; - Py_ssize_t count; - PyBytesObject *result; - - self_s = PyBytes_AS_STRING(self); - self_len = PyBytes_GET_SIZE(self); - - count = countchar(self_s, self_len, from_c, maxcount); - if (count == 0) { - /* no matches, return unchanged */ - return return_self(self); - } - - /* use the difference between current and new, hence the "-1" */ - /* result_len = self_len + count * (to_len-1) */ - assert(count > 0); - if (to_len - 1 > (PY_SSIZE_T_MAX - self_len) / count) { - PyErr_SetString(PyExc_OverflowError, - "replacement bytes are too long"); - return NULL; - } - result_len = self_len + count * (to_len - 1); - - if ( (result = (PyBytesObject *) - PyBytes_FromStringAndSize(NULL, result_len)) == NULL) - return NULL; - result_s = PyBytes_AS_STRING(result); - - start = self_s; - end = self_s + self_len; - while (count-- > 0) { - next = findchar(start, end-start, from_c); - if (next == NULL) - break; - - if (next == start) { - /* replace with the 'to' */ - Py_MEMCPY(result_s, to_s, to_len); - result_s += to_len; - start += 1; - } else { - /* copy the unchanged old then the 'to' */ - Py_MEMCPY(result_s, start, next-start); - result_s += (next-start); - Py_MEMCPY(result_s, to_s, to_len); - result_s += to_len; - start = next+1; - } - } - /* Copy the remainder of the remaining string */ - Py_MEMCPY(result_s, start, end-start); - - return result; -} - -/* len(self)>=1, len(from)>=2, len(to)>=2, maxcount>=1 */ -Py_LOCAL(PyBytesObject *) -replace_substring(PyBytesObject *self, - const char *from_s, Py_ssize_t from_len, - const char *to_s, Py_ssize_t to_len, - Py_ssize_t maxcount) { - char *self_s, *result_s; - char *start, *next, *end; - Py_ssize_t self_len, result_len; - Py_ssize_t count, offset; - PyBytesObject *result; - - self_s = PyBytes_AS_STRING(self); - self_len = PyBytes_GET_SIZE(self); - - count = stringlib_count(self_s, self_len, - from_s, from_len, - maxcount); - - if (count == 0) { - /* no matches, return unchanged */ - return return_self(self); - } - - /* Check for overflow */ - /* result_len = self_len + count * (to_len-from_len) */ - assert(count > 0); - if (to_len - from_len > (PY_SSIZE_T_MAX - self_len) / count) { - PyErr_SetString(PyExc_OverflowError, - "replacement bytes are too long"); - return NULL; - } - result_len = self_len + count * (to_len-from_len); - - if ( (result = (PyBytesObject *) - PyBytes_FromStringAndSize(NULL, result_len)) == NULL) - return NULL; - result_s = PyBytes_AS_STRING(result); - - start = self_s; - end = self_s + self_len; - while (count-- > 0) { - offset = stringlib_find(start, end-start, - from_s, from_len, - 0); - if (offset == -1) - break; - next = start+offset; - if (next == start) { - /* replace with the 'to' */ - Py_MEMCPY(result_s, to_s, to_len); - result_s += to_len; - start += from_len; - } else { - /* copy the unchanged old then the 'to' */ - Py_MEMCPY(result_s, start, next-start); - result_s += (next-start); - Py_MEMCPY(result_s, to_s, to_len); - result_s += to_len; - start = next+from_len; - } - } - /* Copy the remainder of the remaining string */ - Py_MEMCPY(result_s, start, end-start); - - return result; -} - - -Py_LOCAL(PyBytesObject *) -replace(PyBytesObject *self, - const char *from_s, Py_ssize_t from_len, - const char *to_s, Py_ssize_t to_len, - Py_ssize_t maxcount) -{ - if (maxcount < 0) { - maxcount = PY_SSIZE_T_MAX; - } else if (maxcount == 0 || PyBytes_GET_SIZE(self) == 0) { - /* nothing to do; return the original string */ - return return_self(self); - } - - if (maxcount == 0 || - (from_len == 0 && to_len == 0)) { - /* nothing to do; return the original string */ - return return_self(self); - } - - /* Handle zero-length special cases */ - - if (from_len == 0) { - /* insert the 'to' string everywhere. */ - /* >>> "Python".replace("", ".") */ - /* '.P.y.t.h.o.n.' */ - return replace_interleave(self, to_s, to_len, maxcount); - } - - /* Except for "".replace("", "A") == "A" there is no way beyond this */ - /* point for an empty self string to generate a non-empty string */ - /* Special case so the remaining code always gets a non-empty string */ - if (PyBytes_GET_SIZE(self) == 0) { - return return_self(self); - } - - if (to_len == 0) { - /* delete all occurrences of 'from' string */ - if (from_len == 1) { - return replace_delete_single_character( - self, from_s[0], maxcount); - } else { - return replace_delete_substring(self, from_s, - from_len, maxcount); - } - } - - /* Handle special case where both strings have the same length */ - - if (from_len == to_len) { - if (from_len == 1) { - return replace_single_character_in_place( - self, - from_s[0], - to_s[0], - maxcount); - } else { - return replace_substring_in_place( - self, from_s, from_len, to_s, to_len, - maxcount); - } - } - - /* Otherwise use the more generic algorithms */ - if (from_len == 1) { - return replace_single_character(self, from_s[0], - to_s, to_len, maxcount); - } else { - /* len('from')>=2, len('to')>=1 */ - return replace_substring(self, from_s, from_len, to_s, to_len, - maxcount); - } -} - /*[clinic input] bytes.replace @@ -2722,9 +2220,9 @@ Py_ssize_t count) /*[clinic end generated code: output=994fa588b6b9c104 input=b2fbbf0bf04de8e5]*/ { - return (PyObject *)replace((PyBytesObject *) self, - (const char *)old->buf, old->len, - (const char *)new->buf, new->len, count); + return stringlib_replace((PyObject *)self, + (const char *)old->buf, old->len, + (const char *)new->buf, new->len, count); } /** End DALKE **/ diff --git a/Objects/stringlib/transmogrify.h b/Objects/stringlib/transmogrify.h --- a/Objects/stringlib/transmogrify.h +++ b/Objects/stringlib/transmogrify.h @@ -4,6 +4,18 @@ /* the more complicated methods. parts of these should be pulled out into the shared code in bytes_methods.c to cut down on duplicate code bloat. */ +Py_LOCAL_INLINE(PyObject *) +return_self(PyObject *self) +{ +#if !STRINGLIB_MUTABLE + if (STRINGLIB_CHECK_EXACT(self)) { + Py_INCREF(self); + return self; + } +#endif + return STRINGLIB_NEW(STRINGLIB_STR(self), STRINGLIB_LEN(self)); +} + static PyObject* stringlib_expandtabs(PyObject *self, PyObject *args, PyObject *kwds) { @@ -87,28 +99,20 @@ if (right < 0) right = 0; - if (left == 0 && right == 0 && STRINGLIB_CHECK_EXACT(self)) { -#if STRINGLIB_MUTABLE - /* We're defined as returning a copy; If the object is mutable - * that means we must make an identical copy. */ - return STRINGLIB_NEW(STRINGLIB_STR(self), STRINGLIB_LEN(self)); -#else - Py_INCREF(self); - return (PyObject *)self; -#endif /* STRINGLIB_MUTABLE */ + if (left == 0 && right == 0) { + return return_self(self); } - u = STRINGLIB_NEW(NULL, - left + STRINGLIB_LEN(self) + right); + u = STRINGLIB_NEW(NULL, left + STRINGLIB_LEN(self) + right); if (u) { if (left) memset(STRINGLIB_STR(u), fill, left); Py_MEMCPY(STRINGLIB_STR(u) + left, - STRINGLIB_STR(self), - STRINGLIB_LEN(self)); + STRINGLIB_STR(self), + STRINGLIB_LEN(self)); if (right) memset(STRINGLIB_STR(u) + left + STRINGLIB_LEN(self), - fill, right); + fill, right); } return u; @@ -123,15 +127,8 @@ if (!PyArg_ParseTuple(args, "n|c:ljust", &width, &fillchar)) return NULL; - if (STRINGLIB_LEN(self) >= width && STRINGLIB_CHECK_EXACT(self)) { -#if STRINGLIB_MUTABLE - /* We're defined as returning a copy; If the object is mutable - * that means we must make an identical copy. */ - return STRINGLIB_NEW(STRINGLIB_STR(self), STRINGLIB_LEN(self)); -#else - Py_INCREF(self); - return (PyObject*) self; -#endif + if (STRINGLIB_LEN(self) >= width) { + return return_self(self); } return pad(self, 0, width - STRINGLIB_LEN(self), fillchar); @@ -147,15 +144,8 @@ if (!PyArg_ParseTuple(args, "n|c:rjust", &width, &fillchar)) return NULL; - if (STRINGLIB_LEN(self) >= width && STRINGLIB_CHECK_EXACT(self)) { -#if STRINGLIB_MUTABLE - /* We're defined as returning a copy; If the object is mutable - * that means we must make an identical copy. */ - return STRINGLIB_NEW(STRINGLIB_STR(self), STRINGLIB_LEN(self)); -#else - Py_INCREF(self); - return (PyObject*) self; -#endif + if (STRINGLIB_LEN(self) >= width) { + return return_self(self); } return pad(self, width - STRINGLIB_LEN(self), 0, fillchar); @@ -172,15 +162,8 @@ if (!PyArg_ParseTuple(args, "n|c:center", &width, &fillchar)) return NULL; - if (STRINGLIB_LEN(self) >= width && STRINGLIB_CHECK_EXACT(self)) { -#if STRINGLIB_MUTABLE - /* We're defined as returning a copy; If the object is mutable - * that means we must make an identical copy. */ - return STRINGLIB_NEW(STRINGLIB_STR(self), STRINGLIB_LEN(self)); -#else - Py_INCREF(self); - return (PyObject*) self; -#endif + if (STRINGLIB_LEN(self) >= width) { + return return_self(self); } marg = width - STRINGLIB_LEN(self); @@ -201,21 +184,7 @@ return NULL; if (STRINGLIB_LEN(self) >= width) { - if (STRINGLIB_CHECK_EXACT(self)) { -#if STRINGLIB_MUTABLE - /* We're defined as returning a copy; If the object is mutable - * that means we must make an identical copy. */ - return STRINGLIB_NEW(STRINGLIB_STR(self), STRINGLIB_LEN(self)); -#else - Py_INCREF(self); - return (PyObject*) self; -#endif - } - else - return STRINGLIB_NEW( - STRINGLIB_STR(self), - STRINGLIB_LEN(self) - ); + return return_self(self); } fill = width - STRINGLIB_LEN(self); @@ -232,5 +201,500 @@ p[fill] = '0'; } - return (PyObject*) s; + return s; } + + +/* find and count characters and substrings */ + +#define findchar(target, target_len, c) \ + ((char *)memchr((const void *)(target), c, target_len)) + + +Py_LOCAL_INLINE(Py_ssize_t) +countchar(const char *target, Py_ssize_t target_len, char c, + Py_ssize_t maxcount) +{ + Py_ssize_t count = 0; + const char *start = target; + const char *end = target + target_len; + + while ((start = findchar(start, end - start, c)) != NULL) { + count++; + if (count >= maxcount) + break; + start += 1; + } + return count; +} + + +/* Algorithms for different cases of string replacement */ + +/* len(self)>=1, from="", len(to)>=1, maxcount>=1 */ +Py_LOCAL(PyObject *) +stringlib_replace_interleave(PyObject *self, + const char *to_s, Py_ssize_t to_len, + Py_ssize_t maxcount) +{ + const char *self_s; + char *result_s; + Py_ssize_t self_len, result_len; + Py_ssize_t count, i; + PyObject *result; + + self_len = STRINGLIB_LEN(self); + + /* 1 at the end plus 1 after every character; + count = min(maxcount, self_len + 1) */ + if (maxcount <= self_len) { + count = maxcount; + } + else { + /* Can't overflow: self_len + 1 <= maxcount <= PY_SSIZE_T_MAX. */ + count = self_len + 1; + } + + /* Check for overflow */ + /* result_len = count * to_len + self_len; */ + assert(count > 0); + if (to_len > (PY_SSIZE_T_MAX - self_len) / count) { + PyErr_SetString(PyExc_OverflowError, + "replace bytes are too long"); + return NULL; + } + result_len = count * to_len + self_len; + result = STRINGLIB_NEW(NULL, result_len); + if (result == NULL) { + return NULL; + } + + self_s = STRINGLIB_STR(self); + result_s = STRINGLIB_STR(result); + + if (to_len > 1) { + /* Lay the first one down (guaranteed this will occur) */ + Py_MEMCPY(result_s, to_s, to_len); + result_s += to_len; + count -= 1; + + for (i = 0; i < count; i++) { + *result_s++ = *self_s++; + Py_MEMCPY(result_s, to_s, to_len); + result_s += to_len; + } + } + else { + result_s[0] = to_s[0]; + result_s += to_len; + count -= 1; + for (i = 0; i < count; i++) { + *result_s++ = *self_s++; + result_s[0] = to_s[0]; + result_s += to_len; + } + } + + /* Copy the rest of the original string */ + Py_MEMCPY(result_s, self_s, self_len - i); + + return result; +} + +/* Special case for deleting a single character */ +/* len(self)>=1, len(from)==1, to="", maxcount>=1 */ +Py_LOCAL(PyObject *) +stringlib_replace_delete_single_character(PyObject *self, + char from_c, Py_ssize_t maxcount) +{ + const char *self_s, *start, *next, *end; + char *result_s; + Py_ssize_t self_len, result_len; + Py_ssize_t count; + PyObject *result; + + self_len = STRINGLIB_LEN(self); + self_s = STRINGLIB_STR(self); + + count = countchar(self_s, self_len, from_c, maxcount); + if (count == 0) { + return return_self(self); + } + + result_len = self_len - count; /* from_len == 1 */ + assert(result_len>=0); + + result = STRINGLIB_NEW(NULL, result_len); + if (result == NULL) { + return NULL; + } + result_s = STRINGLIB_STR(result); + + start = self_s; + end = self_s + self_len; + while (count-- > 0) { + next = findchar(start, end - start, from_c); + if (next == NULL) + break; + Py_MEMCPY(result_s, start, next - start); + result_s += (next - start); + start = next + 1; + } + Py_MEMCPY(result_s, start, end - start); + + return result; +} + +/* len(self)>=1, len(from)>=2, to="", maxcount>=1 */ + +Py_LOCAL(PyObject *) +stringlib_replace_delete_substring(PyObject *self, + const char *from_s, Py_ssize_t from_len, + Py_ssize_t maxcount) +{ + const char *self_s, *start, *next, *end; + char *result_s; + Py_ssize_t self_len, result_len; + Py_ssize_t count, offset; + PyObject *result; + + self_len = STRINGLIB_LEN(self); + self_s = STRINGLIB_STR(self); + + count = stringlib_count(self_s, self_len, + from_s, from_len, + maxcount); + + if (count == 0) { + /* no matches */ + return return_self(self); + } + + result_len = self_len - (count * from_len); + assert (result_len>=0); + + result = STRINGLIB_NEW(NULL, result_len); + if (result == NULL) { + return NULL; + } + result_s = STRINGLIB_STR(result); + + start = self_s; + end = self_s + self_len; + while (count-- > 0) { + offset = stringlib_find(start, end - start, + from_s, from_len, + 0); + if (offset == -1) + break; + next = start + offset; + + Py_MEMCPY(result_s, start, next - start); + + result_s += (next - start); + start = next + from_len; + } + Py_MEMCPY(result_s, start, end - start); + return result; +} + +/* len(self)>=1, len(from)==len(to)==1, maxcount>=1 */ +Py_LOCAL(PyObject *) +stringlib_replace_single_character_in_place(PyObject *self, + char from_c, char to_c, + Py_ssize_t maxcount) +{ + const char *self_s, *end; + char *result_s, *start, *next; + Py_ssize_t self_len; + PyObject *result; + + /* The result string will be the same size */ + self_s = STRINGLIB_STR(self); + self_len = STRINGLIB_LEN(self); + + next = findchar(self_s, self_len, from_c); + + if (next == NULL) { + /* No matches; return the original bytes */ + return return_self(self); + } + + /* Need to make a new bytes */ + result = STRINGLIB_NEW(NULL, self_len); + if (result == NULL) { + return NULL; + } + result_s = STRINGLIB_STR(result); + Py_MEMCPY(result_s, self_s, self_len); + + /* change everything in-place, starting with this one */ + start = result_s + (next - self_s); + *start = to_c; + start++; + end = result_s + self_len; + + while (--maxcount > 0) { + next = findchar(start, end - start, from_c); + if (next == NULL) + break; + *next = to_c; + start = next + 1; + } + + return result; +} + +/* len(self)>=1, len(from)==len(to)>=2, maxcount>=1 */ +Py_LOCAL(PyObject *) +stringlib_replace_substring_in_place(PyObject *self, + const char *from_s, Py_ssize_t from_len, + const char *to_s, Py_ssize_t to_len, + Py_ssize_t maxcount) +{ + const char *self_s, *end; + char *result_s, *start; + Py_ssize_t self_len, offset; + PyObject *result; + + /* The result bytes will be the same size */ + + self_s = STRINGLIB_STR(self); + self_len = STRINGLIB_LEN(self); + + offset = stringlib_find(self_s, self_len, + from_s, from_len, + 0); + if (offset == -1) { + /* No matches; return the original bytes */ + return return_self(self); + } + + /* Need to make a new bytes */ + result = STRINGLIB_NEW(NULL, self_len); + if (result == NULL) { + return NULL; + } + result_s = STRINGLIB_STR(result); + Py_MEMCPY(result_s, self_s, self_len); + + /* change everything in-place, starting with this one */ + start = result_s + offset; + Py_MEMCPY(start, to_s, from_len); + start += from_len; + end = result_s + self_len; + + while ( --maxcount > 0) { + offset = stringlib_find(start, end - start, + from_s, from_len, + 0); + if (offset == -1) + break; + Py_MEMCPY(start + offset, to_s, from_len); + start += offset + from_len; + } + + return result; +} + +/* len(self)>=1, len(from)==1, len(to)>=2, maxcount>=1 */ +Py_LOCAL(PyObject *) +stringlib_replace_single_character(PyObject *self, + char from_c, + const char *to_s, Py_ssize_t to_len, + Py_ssize_t maxcount) +{ + const char *self_s, *start, *next, *end; + char *result_s; + Py_ssize_t self_len, result_len; + Py_ssize_t count; + PyObject *result; + + self_s = STRINGLIB_STR(self); + self_len = STRINGLIB_LEN(self); + + count = countchar(self_s, self_len, from_c, maxcount); + if (count == 0) { + /* no matches, return unchanged */ + return return_self(self); + } + + /* use the difference between current and new, hence the "-1" */ + /* result_len = self_len + count * (to_len-1) */ + assert(count > 0); + if (to_len - 1 > (PY_SSIZE_T_MAX - self_len) / count) { + PyErr_SetString(PyExc_OverflowError, "replace bytes is too long"); + return NULL; + } + result_len = self_len + count * (to_len - 1); + + result = STRINGLIB_NEW(NULL, result_len); + if (result == NULL) { + return NULL; + } + result_s = STRINGLIB_STR(result); + + start = self_s; + end = self_s + self_len; + while (count-- > 0) { + next = findchar(start, end - start, from_c); + if (next == NULL) + break; + + if (next == start) { + /* replace with the 'to' */ + Py_MEMCPY(result_s, to_s, to_len); + result_s += to_len; + start += 1; + } else { + /* copy the unchanged old then the 'to' */ + Py_MEMCPY(result_s, start, next - start); + result_s += (next - start); + Py_MEMCPY(result_s, to_s, to_len); + result_s += to_len; + start = next + 1; + } + } + /* Copy the remainder of the remaining bytes */ + Py_MEMCPY(result_s, start, end - start); + + return result; +} + +/* len(self)>=1, len(from)>=2, len(to)>=2, maxcount>=1 */ +Py_LOCAL(PyObject *) +stringlib_replace_substring(PyObject *self, + const char *from_s, Py_ssize_t from_len, + const char *to_s, Py_ssize_t to_len, + Py_ssize_t maxcount) +{ + const char *self_s, *start, *next, *end; + char *result_s; + Py_ssize_t self_len, result_len; + Py_ssize_t count, offset; + PyObject *result; + + self_s = STRINGLIB_STR(self); + self_len = STRINGLIB_LEN(self); + + count = stringlib_count(self_s, self_len, + from_s, from_len, + maxcount); + + if (count == 0) { + /* no matches, return unchanged */ + return return_self(self); + } + + /* Check for overflow */ + /* result_len = self_len + count * (to_len-from_len) */ + assert(count > 0); + if (to_len - from_len > (PY_SSIZE_T_MAX - self_len) / count) { + PyErr_SetString(PyExc_OverflowError, "replace bytes is too long"); + return NULL; + } + result_len = self_len + count * (to_len - from_len); + + result = STRINGLIB_NEW(NULL, result_len); + if (result == NULL) { + return NULL; + } + result_s = STRINGLIB_STR(result); + + start = self_s; + end = self_s + self_len; + while (count-- > 0) { + offset = stringlib_find(start, end - start, + from_s, from_len, + 0); + if (offset == -1) + break; + next = start + offset; + if (next == start) { + /* replace with the 'to' */ + Py_MEMCPY(result_s, to_s, to_len); + result_s += to_len; + start += from_len; + } else { + /* copy the unchanged old then the 'to' */ + Py_MEMCPY(result_s, start, next - start); + result_s += (next - start); + Py_MEMCPY(result_s, to_s, to_len); + result_s += to_len; + start = next + from_len; + } + } + /* Copy the remainder of the remaining bytes */ + Py_MEMCPY(result_s, start, end - start); + + return result; +} + + +Py_LOCAL(PyObject *) +stringlib_replace(PyObject *self, + const char *from_s, Py_ssize_t from_len, + const char *to_s, Py_ssize_t to_len, + Py_ssize_t maxcount) +{ + if (maxcount < 0) { + maxcount = PY_SSIZE_T_MAX; + } else if (maxcount == 0 || STRINGLIB_LEN(self) == 0) { + /* nothing to do; return the original bytes */ + return return_self(self); + } + + /* Handle zero-length special cases */ + if (from_len == 0) { + if (to_len == 0) { + /* nothing to do; return the original bytes */ + return return_self(self); + } + /* insert the 'to' bytes everywhere. */ + /* >>> b"Python".replace(b"", b".") */ + /* b'.P.y.t.h.o.n.' */ + return stringlib_replace_interleave(self, to_s, to_len, maxcount); + } + + /* Except for b"".replace(b"", b"A") == b"A" there is no way beyond this */ + /* point for an empty self bytes to generate a non-empty bytes */ + /* Special case so the remaining code always gets a non-empty bytes */ + if (STRINGLIB_LEN(self) == 0) { + return return_self(self); + } + + if (to_len == 0) { + /* delete all occurrences of 'from' bytes */ + if (from_len == 1) { + return stringlib_replace_delete_single_character( + self, from_s[0], maxcount); + } else { + return stringlib_replace_delete_substring( + self, from_s, from_len, maxcount); + } + } + + /* Handle special case where both bytes have the same length */ + + if (from_len == to_len) { + if (from_len == 1) { + return stringlib_replace_single_character_in_place( + self, from_s[0], to_s[0], maxcount); + } else { + return stringlib_replace_substring_in_place( + self, from_s, from_len, to_s, to_len, maxcount); + } + } + + /* Otherwise use the more generic algorithms */ + if (from_len == 1) { + return stringlib_replace_single_character( + self, from_s[0], to_s, to_len, maxcount); + } else { + /* len('from')>=2, len('to')>=1 */ + return stringlib_replace_substring( + self, from_s, from_len, to_s, to_len, maxcount); + } +} + +#undef findchar -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu May 5 03:56:25 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 05 May 2016 07:56:25 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2326918=3A_Skipped_?= =?utf-8?q?some_tests_in_test=5Fpipes_on_Android=2E?= Message-ID: <20160505075624.89095.30277.34E6E5B6@psf.io> https://hg.python.org/cpython/rev/3bad4b0f7612 changeset: 101234:3bad4b0f7612 user: Serhiy Storchaka date: Thu May 05 10:55:45 2016 +0300 summary: Issue #26918: Skipped some tests in test_pipes on Android. Patch by Xavier de Gaye. files: Lib/test/test_pipes.py | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_pipes.py b/Lib/test/test_pipes.py --- a/Lib/test/test_pipes.py +++ b/Lib/test/test_pipes.py @@ -2,6 +2,7 @@ import os import string import unittest +import shutil from test.support import TESTFN, run_unittest, unlink, reap_children if os.name != 'posix': @@ -18,6 +19,8 @@ unlink(f) def testSimplePipe1(self): + if shutil.which('tr') is None: + self.skipTest('tr is not available') t = pipes.Template() t.append(s_command, pipes.STDIN_STDOUT) f = t.open(TESTFN, 'w') @@ -27,6 +30,8 @@ self.assertEqual(f.read(), 'HELLO WORLD #1') def testSimplePipe2(self): + if shutil.which('tr') is None: + self.skipTest('tr is not available') with open(TESTFN, 'w') as f: f.write('hello world #2') t = pipes.Template() @@ -36,6 +41,8 @@ self.assertEqual(f.read(), 'HELLO WORLD #2') def testSimplePipe3(self): + if shutil.which('tr') is None: + self.skipTest('tr is not available') with open(TESTFN, 'w') as f: f.write('hello world #2') t = pipes.Template() -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu May 5 04:05:34 2016 From: python-checkins at python.org (berker.peksag) Date: Thu, 05 May 2016 08:05:34 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI2OTYy?= =?utf-8?q?=3A_Backport_23d986228c6b_to_2=2E7?= Message-ID: <20160505080532.31189.69932.39C1CBC9@psf.io> https://hg.python.org/cpython/rev/4462e193f089 changeset: 101235:4462e193f089 branch: 2.7 parent: 101223:7050c9fc1f72 user: Berker Peksag date: Thu May 05 11:05:49 2016 +0300 summary: Issue #26962: Backport 23d986228c6b to 2.7 files: Doc/library/curses.rst | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/curses.rst b/Doc/library/curses.rst --- a/Doc/library/curses.rst +++ b/Doc/library/curses.rst @@ -1474,9 +1474,9 @@ +------------------+-----------+ | :kbd:`End` | KEY_END | +------------------+-----------+ -| :kbd:`Page Up` | KEY_NPAGE | +| :kbd:`Page Up` | KEY_PPAGE | +------------------+-----------+ -| :kbd:`Page Down` | KEY_PPAGE | +| :kbd:`Page Down` | KEY_NPAGE | +------------------+-----------+ The following table lists characters from the alternate character set. These are -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Thu May 5 04:14:16 2016 From: python-checkins at python.org (raymond.hettinger) Date: Thu, 05 May 2016 08:14:16 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_26915=3A__Add_identi?= =?utf-8?q?ty_checks_to_the_collections_ABC_=5F=5Fcontains=5F=5F_methods?= =?utf-8?q?=2E?= Message-ID: <20160505081412.130779.35800.834666F8@psf.io> https://hg.python.org/cpython/rev/1c6cf4010df3 changeset: 101236:1c6cf4010df3 parent: 101234:3bad4b0f7612 user: Raymond Hettinger date: Thu May 05 11:14:06 2016 +0300 summary: Issue 26915: Add identity checks to the collections ABC __contains__ methods. files: Lib/_collections_abc.py | 7 ++++--- Lib/test/test_collections.py | 22 +++++++++++++++++++++- Misc/NEWS | 5 +++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Lib/_collections_abc.py b/Lib/_collections_abc.py --- a/Lib/_collections_abc.py +++ b/Lib/_collections_abc.py @@ -689,7 +689,7 @@ except KeyError: return False else: - return v == value + return v is value or v == value def __iter__(self): for key in self._mapping: @@ -704,7 +704,8 @@ def __contains__(self, value): for key in self._mapping: - if value == self._mapping[key]: + v = self._mapping[key] + if v is value or v == value: return True return False @@ -839,7 +840,7 @@ def __contains__(self, value): for v in self: - if v == value: + if v is value or v == value: return True return False diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py --- a/Lib/test/test_collections.py +++ b/Lib/test/test_collections.py @@ -23,7 +23,7 @@ from collections.abc import Hashable, Iterable, Iterator, Generator, Reversible from collections.abc import Sized, Container, Callable from collections.abc import Set, MutableSet -from collections.abc import Mapping, MutableMapping, KeysView, ItemsView +from collections.abc import Mapping, MutableMapping, KeysView, ItemsView, ValuesView from collections.abc import Sequence, MutableSequence from collections.abc import ByteString @@ -1074,6 +1074,26 @@ self.assertFalse(ncs > cs) self.assertTrue(ncs >= cs) + def test_issue26915(self): + # Container membership test should check identity first + class CustomEqualObject: + def __eq__(self, other): + return False + class CustomSequence(list): + def __contains__(self, value): + return Sequence.__contains__(self, value) + + nan = float('nan') + obj = CustomEqualObject() + containers = [ + CustomSequence([nan, obj]), + ItemsView({1: nan, 2: obj}), + ValuesView({1: nan, 2: obj}) + ] + for container in containers: + for elem in container: + self.assertIn(elem, container) + def assertSameSet(self, s1, s2): # coerce both to a real set then check equality self.assertSetEqual(set(s1), set(s2)) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -268,6 +268,11 @@ - Issue #26873: xmlrpc now raises ResponseError on unsupported type tags instead of silently return incorrect result. +- Issue #26915: The __contains__ methods in the collections ABCs now check + for identity before checking equality. This better matches the behavior + of the concrete classes, allows sensible handling of NaNs, and makes it + easier to reason about container invariants. + - Issue #26711: Fixed the comparison of plistlib.Data with other types. - Issue #24114: Fix an uninitialized variable in `ctypes.util`. -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Thu May 5 04:48:29 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Thu, 05 May 2016 08:48:29 +0000 Subject: [Python-checkins] Daily reference leaks (3a069e5593ef): sum=4 Message-ID: <20160505084829.22567.87180.AB9ACCC2@psf.io> results for 3a069e5593ef on branch "default" -------------------------------------------- test_collections leaked [4, -4, 0] memory blocks, sum=0 test_functools leaked [0, 3, 1] memory blocks, sum=4 test_multiprocessing_forkserver leaked [0, -2, 2] memory blocks, sum=0 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogR1_n8S', '--timeout', '7200'] From lp_benchmark_robot at intel.com Thu May 5 08:12:23 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Thu, 5 May 2016 13:12:23 +0100 Subject: [Python-checkins] UGLY Benchmark Results for Python Default 2016-05-05 Message-ID: Results for project Python default, build date 2016-05-05 02:02:03 +0000 commit: 3a069e5593ef previous commit: 8f7cb3b171f3 revision date: 2016-05-04 20:26: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 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% -2.72% 8.40% 17.04% :-| pybench 0.11% -0.34% 0.69% 5.23% :-( regex_v8 3.07% 0.49% -10.51% 8.76% :-| nbody 0.15% 0.94% -1.03% 10.91% :-| json_dump_v2 0.38% 1.29% 1.38% 10.77% :-| normal_startup 0.83% -0.18% 1.09% 4.76% ---------------------------------------------------------------------------------- * 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-05-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 Thu May 5 08:12:59 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Thu, 5 May 2016 13:12:59 +0100 Subject: [Python-checkins] GOOD Benchmark Results for Python 2.7 2016-05-05 Message-ID: <509c1fc5-2557-4e55-b8f8-0d14e8861f6b@irsmsx102.ger.corp.intel.com> Results for project Python 2.7, build date 2016-05-05 02:46:06 +0000 commit: 7050c9fc1f72 previous commit: e07e2b8c9429 revision date: 2016-05-04 08:28:09 +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.58% 1.39% 6.90% 3.07% :-) pybench 0.15% 0.06% 5.96% 4.32% :-| regex_v8 0.74% 0.32% -1.96% 10.39% :-) nbody 0.50% -0.39% 6.50% 4.70% :-) json_dump_v2 0.53% 0.19% 2.39% 9.74% :-( normal_startup 1.82% 0.10% -5.32% 2.19% :-) ssbench 0.15% -0.14% 2.43% 1.57% ---------------------------------------------------------------------------------- * 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-05-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 Thu May 5 09:22:09 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Thu, 05 May 2016 13:22:09 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Restored_parameter_name_?= =?utf-8?q?=22self=22_since_gdb_needs_exact_specific_parameter_names=2E?= Message-ID: <20160505132205.67123.59920.A68C0CE5@psf.io> https://hg.python.org/cpython/rev/66a1fbdbe4bb changeset: 101237:66a1fbdbe4bb user: Serhiy Storchaka date: Thu May 05 16:21:35 2016 +0300 summary: Restored parameter name "self" since gdb needs exact specific parameter names. files: Python/bltinmodule.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -1078,6 +1078,7 @@ /*[clinic input] id as builtin_id + self: self(type="PyModuleDef *") obj as v: object / @@ -1088,8 +1089,8 @@ [clinic start generated code]*/ static PyObject * -builtin_id(PyModuleDef *module, PyObject *v) -/*[clinic end generated code: output=63635e497e09c2f7 input=57fb4a9aaff96384]*/ +builtin_id(PyModuleDef *self, PyObject *v) +/*[clinic end generated code: output=0aa640785f697f65 input=5a534136419631f4]*/ { return PyLong_FromVoidPtr(v); } -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Fri May 6 04:51:15 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Fri, 06 May 2016 08:51:15 +0000 Subject: [Python-checkins] Daily reference leaks (66a1fbdbe4bb): sum=2 Message-ID: <20160506085111.67141.87003.D17AE2DD@psf.io> results for 66a1fbdbe4bb on branch "default" -------------------------------------------- test_functools leaked [0, 3, 1] memory blocks, sum=4 test_multiprocessing_forkserver leaked [0, 0, -2] memory blocks, sum=-2 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogjIJNps', '--timeout', '7200'] From lp_benchmark_robot at intel.com Fri May 6 08:56:17 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Fri, 6 May 2016 13:56:17 +0100 Subject: [Python-checkins] UGLY Benchmark Results for Python Default 2016-05-06 Message-ID: Results for project Python default, build date 2016-05-06 02:02:48 +0000 commit: 66a1fbdbe4bb previous commit: 3a069e5593ef revision date: 2016-05-05 13:21: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.21% 1.11% 9.42% 14.62% :-| pybench 0.19% -0.09% 0.60% 6.16% :-) regex_v8 2.84% 7.86% -1.83% 4.71% :-( nbody 0.11% -1.39% -2.44% 10.19% :-( json_dump_v2 0.34% -2.78% -1.37% 12.26% :-| normal_startup 0.71% -0.12% 0.27% 5.48% ---------------------------------------------------------------------------------- * 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-05-06/ 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 May 6 08:57:07 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Fri, 6 May 2016 13:57:07 +0100 Subject: [Python-checkins] NEUTRAL Benchmark Results for Python 2.7 2016-05-06 Message-ID: <3e30ae3f-c1a0-4b86-adfb-122d335694c8@irsmsx103.ger.corp.intel.com> Results for project Python 2.7, build date 2016-05-06 02:47:19 +0000 commit: 4462e193f089 previous commit: 7050c9fc1f72 revision date: 2016-05-05 08:05:49 +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.37% 6.56% 8.35% :-) pybench 0.16% -0.30% 5.68% 4.97% :-( regex_v8 0.72% -0.22% -2.18% 10.95% :-) nbody 0.14% 0.38% 6.85% 6.26% :-) json_dump_v2 0.56% 0.07% 2.46% 9.18% :-( normal_startup 1.92% -0.32% -5.66% 3.05% :-) ssbench 0.12% -0.23% 2.20% 1.93% ---------------------------------------------------------------------------------- * 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-05-06/ 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 May 6 11:42:07 2016 From: python-checkins at python.org (larry.hastings) Date: Fri, 06 May 2016 15:42:07 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Add_release_schedule_for_3=2E?= =?utf-8?q?4=2E5=2E?= Message-ID: <20160506154200.88886.2706.41EBBE80@psf.io> https://hg.python.org/peps/rev/afd473e4a99d changeset: 6311:afd473e4a99d user: Larry Hastings date: Fri May 06 08:41:31 2016 -0700 summary: Add release schedule for 3.4.5. files: pep-0429.txt | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/pep-0429.txt b/pep-0429.txt --- a/pep-0429.txt +++ b/pep-0429.txt @@ -76,7 +76,8 @@ Planned future releases: -- tba +- 3.4.5 candidate 1: June 12, 2015 +- 3.4.5 final: June 26, 2015 Features for 3.4 -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Fri May 6 15:58:28 2016 From: python-checkins at python.org (terry.reedy) Date: Fri, 06 May 2016 19:58:28 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgMjY5MTE6?= =?utf-8?q?_fix_import_=28other_problems_remain=29=2E?= Message-ID: <20160506195827.88900.98442.925CD6D6@psf.io> https://hg.python.org/cpython/rev/3279c910d0e0 changeset: 101238:3279c910d0e0 branch: 3.5 parent: 101231:580ddeccd689 user: Terry Jan Reedy date: Fri May 06 15:57:57 2016 -0400 summary: Issue 26911: fix import (other problems remain). files: Lib/lib2to3/tests/pytree_idempotency.py | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/lib2to3/tests/pytree_idempotency.py b/Lib/lib2to3/tests/pytree_idempotency.py --- a/Lib/lib2to3/tests/pytree_idempotency.py +++ b/Lib/lib2to3/tests/pytree_idempotency.py @@ -18,8 +18,8 @@ # Local imports from .. import pytree -import pgen2 -from pgen2 import driver +from .. import pgen2 +from ..pgen2 import driver logging.basicConfig() -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri May 6 15:58:28 2016 From: python-checkins at python.org (terry.reedy) Date: Fri, 06 May 2016 19:58:28 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Merge_with_3=2E5?= Message-ID: <20160506195827.17976.91315.C56DFC5C@psf.io> https://hg.python.org/cpython/rev/697dfcadfc99 changeset: 101239:697dfcadfc99 parent: 101237:66a1fbdbe4bb parent: 101238:3279c910d0e0 user: Terry Jan Reedy date: Fri May 06 15:58:13 2016 -0400 summary: Merge with 3.5 files: Lib/lib2to3/tests/pytree_idempotency.py | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/lib2to3/tests/pytree_idempotency.py b/Lib/lib2to3/tests/pytree_idempotency.py --- a/Lib/lib2to3/tests/pytree_idempotency.py +++ b/Lib/lib2to3/tests/pytree_idempotency.py @@ -18,8 +18,8 @@ # Local imports from .. import pytree -import pgen2 -from pgen2 import driver +from .. import pgen2 +from ..pgen2 import driver logging.basicConfig() -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri May 6 17:35:36 2016 From: python-checkins at python.org (terry.reedy) Date: Fri, 06 May 2016 21:35: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: <20160506213535.31177.25192.675EC3E0@psf.io> https://hg.python.org/cpython/rev/786de3f37ca7 changeset: 101241:786de3f37ca7 parent: 101239:697dfcadfc99 parent: 101240:e7da216ba17c user: Terry Jan Reedy date: Fri May 06 17:35:21 2016 -0400 summary: Merge with 3.5 files: Lib/test/test_email/test_asian_codecs.py | 6 ++-- Lib/test/test_email/torture_test.py | 15 ++++------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Lib/test/test_email/test_asian_codecs.py b/Lib/test/test_email/test_asian_codecs.py --- a/Lib/test/test_email/test_asian_codecs.py +++ b/Lib/test/test_email/test_asian_codecs.py @@ -4,7 +4,7 @@ import unittest -from test.test_email.test_email import TestEmailBase +from test.test_email import TestEmailBase from email.charset import Charset from email.header import Header, decode_header from email.message import Message @@ -17,7 +17,7 @@ raise unittest.SkipTest - + class TestEmailAsianCodecs(TestEmailBase): def test_japanese_codecs(self): eq = self.ndiffAssertEqual @@ -76,6 +76,6 @@ self.assertEqual(jhello, ustr) - + if __name__ == '__main__': unittest.main() diff --git a/Lib/test/test_email/torture_test.py b/Lib/test/test_email/torture_test.py --- a/Lib/test/test_email/torture_test.py +++ b/Lib/test/test_email/torture_test.py @@ -10,10 +10,9 @@ import os import unittest from io import StringIO -from types import ListType -from email.test.test_email import TestEmailBase -from test.support import TestSkipped, run_unittest +from test.test_email import TestEmailBase +from test.support import run_unittest import email from email import __file__ as testfile @@ -28,10 +27,10 @@ try: openfile('crispin-torture.txt') except OSError: - raise TestSkipped + raise unittest.SkipTest - + class TortureBase(TestEmailBase): def _msgobj(self, filename): fp = openfile(filename) @@ -42,7 +41,7 @@ return msg - + class TestCrispinTorture(TortureBase): # Mark Crispin's torture test from the SquirrelMail project def test_mondo_message(self): @@ -50,7 +49,7 @@ neq = self.ndiffAssertEqual msg = self._msgobj('crispin-torture.txt') payload = msg.get_payload() - eq(type(payload), ListType) + eq(type(payload), list) eq(len(payload), 12) eq(msg.preamble, None) eq(msg.epilogue, '\n') @@ -113,7 +112,6 @@ audio/x-sun """) - def _testclasses(): mod = sys.modules[__name__] return [getattr(mod, name) for name in dir(mod) if name.startswith('Test')] @@ -131,6 +129,5 @@ run_unittest(testclass) - if __name__ == '__main__': unittest.main(defaultTest='suite') -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri May 6 17:35:36 2016 From: python-checkins at python.org (terry.reedy) Date: Fri, 06 May 2016 21:35:36 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgMjY5MTI6?= =?utf-8?q?_fix_broken_imports_in_test=5Femail_package=2E?= Message-ID: <20160506213535.42349.62670.CBD0777E@psf.io> https://hg.python.org/cpython/rev/e7da216ba17c changeset: 101240:e7da216ba17c branch: 3.5 parent: 101238:3279c910d0e0 user: Terry Jan Reedy date: Fri May 06 17:35:05 2016 -0400 summary: Issue 26912: fix broken imports in test_email package. files: Lib/test/test_email/test_asian_codecs.py | 6 ++-- Lib/test/test_email/torture_test.py | 15 ++++------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Lib/test/test_email/test_asian_codecs.py b/Lib/test/test_email/test_asian_codecs.py --- a/Lib/test/test_email/test_asian_codecs.py +++ b/Lib/test/test_email/test_asian_codecs.py @@ -5,7 +5,7 @@ import unittest from test.support import run_unittest -from test.test_email.test_email import TestEmailBase +from test.test_email import TestEmailBase from email.charset import Charset from email.header import Header, decode_header from email.message import Message @@ -18,7 +18,7 @@ raise unittest.SkipTest - + class TestEmailAsianCodecs(TestEmailBase): def test_japanese_codecs(self): eq = self.ndiffAssertEqual @@ -77,6 +77,6 @@ self.assertEqual(jhello, ustr) - + if __name__ == '__main__': unittest.main() diff --git a/Lib/test/test_email/torture_test.py b/Lib/test/test_email/torture_test.py --- a/Lib/test/test_email/torture_test.py +++ b/Lib/test/test_email/torture_test.py @@ -10,10 +10,9 @@ import os import unittest from io import StringIO -from types import ListType -from email.test.test_email import TestEmailBase -from test.support import TestSkipped, run_unittest +from test.test_email import TestEmailBase +from test.support import run_unittest import email from email import __file__ as testfile @@ -28,10 +27,10 @@ try: openfile('crispin-torture.txt') except OSError: - raise TestSkipped + raise unittest.SkipTest - + class TortureBase(TestEmailBase): def _msgobj(self, filename): fp = openfile(filename) @@ -42,7 +41,7 @@ return msg - + class TestCrispinTorture(TortureBase): # Mark Crispin's torture test from the SquirrelMail project def test_mondo_message(self): @@ -50,7 +49,7 @@ neq = self.ndiffAssertEqual msg = self._msgobj('crispin-torture.txt') payload = msg.get_payload() - eq(type(payload), ListType) + eq(type(payload), list) eq(len(payload), 12) eq(msg.preamble, None) eq(msg.epilogue, '\n') @@ -113,7 +112,6 @@ audio/x-sun """) - def _testclasses(): mod = sys.modules[__name__] return [getattr(mod, name) for name in dir(mod) if name.startswith('Test')] @@ -131,6 +129,5 @@ run_unittest(testclass) - if __name__ == '__main__': unittest.main(defaultTest='suite') -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Fri May 6 19:07:26 2016 From: python-checkins at python.org (guido.van.rossum) Date: Fri, 06 May 2016 23:07:26 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Edits_by_Ivan_Levkivskyi_to_b?= =?utf-8?q?e_more_precise_about_types_vs=2E_classes=2E?= Message-ID: <20160506230724.42375.96741.9145CE86@psf.io> https://hg.python.org/peps/rev/6836e79adbc3 changeset: 6312:6836e79adbc3 user: Guido van Rossum date: Fri May 06 16:06:56 2016 -0700 summary: Edits by Ivan Levkivskyi to be more precise about types vs. classes. From https://github.com/python/typing/pull/214. files: pep-0484.txt | 17 ++++++++++++----- 1 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pep-0484.txt b/pep-0484.txt --- a/pep-0484.txt +++ b/pep-0484.txt @@ -587,7 +587,7 @@ A type variable may specify an upper bound using ``bound=``. This means that an actual type substituted (explicitly or implictly) -for the type variable must be a subclass of the boundary type. A +for the type variable must be a subtype of the boundary type. A common example is the definition of a Comparable type that works well enough to catch the most common errors:: @@ -618,7 +618,7 @@ An upper bound cannot be combined with type constraints (as in used ``AnyStr``, see the example earlier); type constraints cause the inferred type to be _exactly_ one of the constraint types, while an -upper bound just requires that the actual type is a subclass of the +upper bound just requires that the actual type is a subtype of the boundary type. @@ -819,9 +819,10 @@ e = [e] ... -A type factored by ``Union[T1, T2, ...]`` responds ``True`` to -``issubclass`` checks for ``T1`` and any of its subtypes, ``T2`` and -any of its subtypes, and so on. +A type factored by ``Union[T1, T2, ...]`` is a supertype +of all types ``T1``, ``T2``, etc., so that a value that +is a member of one of these types is acceptable for an argument +annotated by ``Union[T1, T2, ...]``. One common case of union types are *optional* types. By default, ``None`` is an invalid value for any type, unless a default value of @@ -1294,6 +1295,12 @@ collection ABCs (e.g. ``Sequence``), and a small collection of convenience definitions. +Note that special type constructs, such as ``Any``, ``Union``, +and type variables defined using ``TypeVar`` are only supported +in the type annotation context, and ``Generic`` may only be used +as a base class. All of these will raise ``TypeError`` if appear +in ``isinstance`` or ``issubclass``. + Fundamental building blocks: * Any, used as ``def get(key: str) -> Any: ...`` -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Fri May 6 21:03:57 2016 From: python-checkins at python.org (brett.cannon) Date: Sat, 07 May 2016 01:03:57 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Update_status?= Message-ID: <20160507010356.130972.2842.6D7CCFBD@psf.io> https://hg.python.org/peps/rev/7ee0d785a550 changeset: 6313:7ee0d785a550 user: Brett Cannon date: Fri May 06 18:03:51 2016 -0700 summary: Update status files: pep-0512.txt | 15 ++++++--------- 1 files changed, 6 insertions(+), 9 deletions(-) diff --git a/pep-0512.txt b/pep-0512.txt --- a/pep-0512.txt +++ b/pep-0512.txt @@ -137,14 +137,14 @@ benchmarks repository does not; therefore, it will be named "python-benchmarks". -Create a 'python-dev' team -'''''''''''''''''''''''''' -To manage permissions, a 'python-dev' team will be created as part of +Create a 'Python core' team +''''''''''''''''''''''''''' +To manage permissions, a 'Python core' team will be created as part of the python organization [#github-python-org]_. Any repository that is -moved will have the 'python-dev' team added to it with write +moved will have the 'Python core' team added to it with write permissions [#github-org-perms]_. Anyone who previously had rights to manage SSH keys on hg.python.org will become a team maintainer for the -'python-dev' team. +'Python core' team. Define commands to move a Mercurial repository to Git ''''''''''''''''''''''''''''''''''''''''''''''''''''' @@ -531,10 +531,6 @@ Requirements for migrating the devinabox [#devinabox-repo]_ and benchmarks [#benchmarks-repo]_ repositories: -* Not started - - - `Create a 'python-dev' team`_ - * In progress - `Define commands to move a Mercurial repository to Git`_: @@ -546,6 +542,7 @@ (Maciej Szulik and Ezio Melotti) - `A bot to enforce CLA signing`_: https://github.com/python/the-knights-who-say-ni (Brett Cannon) + - `Create a 'Python core' team`_ Repositories whose build steps need updating: -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Sat May 7 01:45:33 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 07 May 2016 05:45:33 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2ODg5?= =?utf-8?q?=3A_Tweaked_xmlrpc=2Eclient_documentation=2E?= Message-ID: <20160507054533.22583.3375.EBDC8E3C@psf.io> https://hg.python.org/cpython/rev/04250fc723e6 changeset: 101242:04250fc723e6 branch: 3.5 parent: 101240:e7da216ba17c user: Serhiy Storchaka date: Sat May 07 08:44:15 2016 +0300 summary: Issue #26889: Tweaked xmlrpc.client documentation. files: Doc/library/xmlrpc.client.rst | 191 +++++++++++---------- 1 files changed, 102 insertions(+), 89 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 @@ -14,7 +14,7 @@ -------------- -XML-RPC is a Remote Procedure Call method that uses XML passed via HTTP as a +XML-RPC is a Remote Procedure Call method that uses XML passed via HTTP(S) as a transport. With it, a client can call methods with parameters on a remote server (the server is named by a URI) and get back structured data. This module supports writing XML-RPC client code; it handles all the details of translating @@ -30,7 +30,7 @@ .. versionchanged:: 3.5 For https URIs, :mod:`xmlrpc.client` now performs all the necessary - certificate and hostname checks by default + certificate and hostname checks by default. .. class:: ServerProxy(uri, transport=None, encoding=None, verbose=False, \ allow_none=False, use_datetime=False, \ @@ -46,15 +46,19 @@ :class:`SafeTransport` instance for https: URLs and an internal HTTP :class:`Transport` instance otherwise. The optional third argument is an encoding, by default UTF-8. The optional fourth argument is a debugging flag. + + The following parameters govern the use of the returned proxy instance. If *allow_none* is true, the Python constant ``None`` will be translated into XML; the default behaviour is for ``None`` to raise a :exc:`TypeError`. This is a commonly-used extension to the XML-RPC specification, but isn't supported by - all clients and servers; see http://ontosys.com/xml-rpc/extensions.php for a - description. The *use_builtin_types* flag can be used to cause date/time values + all clients and servers; see `http://ontosys.com/xml-rpc/extensions.php + ` + for a description. + The *use_builtin_types* flag can be used to cause date/time values to be presented as :class:`datetime.datetime` objects and binary data to be presented as :class:`bytes` objects; this flag is false by default. - :class:`datetime.datetime` and :class:`bytes` objects may be passed to calls. - + :class:`datetime.datetime`, :class:`bytes` and :class:`bytearray` objects + may be passed to calls. The obsolete *use_datetime* flag is similar to *use_builtin_types* but it applies only to date/time values. @@ -73,42 +77,43 @@ methods it supports (service discovery) and fetch other server-associated metadata. - :class:`ServerProxy` instance methods take Python basic types and objects as - arguments and return Python basic types and classes. Types that are conformable - (e.g. that can be marshalled through XML), include the following (and except - where noted, they are unmarshalled as the same Python type): + Types that are conformable (e.g. that can be marshalled through XML), + include the following (and except where noted, they are unmarshalled + as the same Python type): .. tabularcolumns:: |l|L| - +---------------------------------+---------------------------------------------+ - | Name | Meaning | - +=================================+=============================================+ - | :const:`boolean` | The :const:`True` and :const:`False` | - | | constants | - +---------------------------------+---------------------------------------------+ - | :const:`integers` | Pass in directly | - +---------------------------------+---------------------------------------------+ - | :const:`floating-point numbers` | Pass in directly | - +---------------------------------+---------------------------------------------+ - | :const:`strings` | Pass in directly | - +---------------------------------+---------------------------------------------+ - | :const:`arrays` | Any Python sequence type containing | - | | conformable elements. Arrays are returned | - | | as lists | - +---------------------------------+---------------------------------------------+ - | :const:`structures` | A Python dictionary. Keys must be strings, | - | | values may be any conformable type. Objects | - | | of user-defined classes can be passed in; | - | | only their *__dict__* attribute is | - | | transmitted. | - +---------------------------------+---------------------------------------------+ - | :const:`dates` | In seconds since the epoch. Pass in an | - | | instance of the :class:`DateTime` class or | - | | a :class:`datetime.datetime` instance. | - +---------------------------------+---------------------------------------------+ - | :const:`binary data` | Pass in an instance of the :class:`Binary` | - | | wrapper class or a :class:`bytes` instance. | - +---------------------------------+---------------------------------------------+ + +----------------------+-------------------------------------------------------+ + | XML-RPC type | Python type | + +======================+=======================================================+ + | ``boolean`` | :class:`bool` | + +----------------------+-------------------------------------------------------+ + | ``int`` or ``i4`` | :class:`int` in range from -2147483648 to 2147483647. | + +----------------------+-------------------------------------------------------+ + | ``double`` | :class:`float` | + +----------------------+-------------------------------------------------------+ + | ``string`` | :class:`str` | + +----------------------+-------------------------------------------------------+ + | ``array`` | :class:`list` or :class:`tuple` containing | + | | conformable elements. Arrays are returned as | + | | :class:`list`\ s. | + +----------------------+-------------------------------------------------------+ + | ``struct`` | :class:`dict`. Keys must be strings, values may be | + | | any conformable type. Objects of user-defined | + | | classes can be passed in; only their :attr:`__dict__` | + | | attribute is transmitted. | + +----------------------+-------------------------------------------------------+ + | ``dateTime.iso8601`` | :class:`DateTime` or :class:`datetime.datetime`. | + | | Returned type depends on values of | + | | *use_builtin_types* and *use_datetime* flags. | + +----------------------+-------------------------------------------------------+ + | ``base64`` | :class:`Binary`, :class:`bytes` or | + | | :class:`bytearray`. Returned type depends on the | + | | value of the *use_builtin_types* flag. | + +----------------------+-------------------------------------------------------+ + | ``nil`` | The ``None`` constant. Passing is allowed only if | + | | *allow_none* is true. | + +----------------------+-------------------------------------------------------+ This is the full set of data types supported by XML-RPC. Method calls may also raise a special :exc:`Fault` instance, used to signal XML-RPC server errors, or @@ -123,8 +128,8 @@ the control characters with ASCII values between 0 and 31 (except, of course, tab, newline and carriage return); failing to do this will result in an XML-RPC request that isn't well-formed XML. If you have to pass arbitrary bytes - via XML-RPC, use the :class:`bytes` class or the class:`Binary` wrapper class - described below. + via XML-RPC, use :class:`bytes` or :class:`bytearray` classes or the + :class:`Binary` wrapper class described below. :class:`Server` is retained as an alias for :class:`ServerProxy` for backwards compatibility. New code should use :class:`ServerProxy`. @@ -164,7 +169,7 @@ :class:`Fault` or :class:`ProtocolError` object indicating an error. Servers that support the XML introspection API support some common methods -grouped under the reserved :attr:`system` attribute: +grouped under the reserved :attr:`~ServerProxy.system` attribute: .. method:: ServerProxy.system.listMethods() @@ -231,24 +236,26 @@ DateTime Objects ---------------- -This class may be initialized with seconds since the epoch, a time -tuple, an ISO 8601 time/date string, or a :class:`datetime.datetime` -instance. It has the following methods, supported mainly for internal -use by the marshalling/unmarshalling code: +.. class:: DateTime + This class may be initialized with seconds since the epoch, a time + tuple, an ISO 8601 time/date string, or a :class:`datetime.datetime` + instance. It has the following methods, supported mainly for internal + use by the marshalling/unmarshalling code: -.. method:: DateTime.decode(string) - Accept a string as the instance's new time value. + .. method:: decode(string) + Accept a string as the instance's new time value. -.. method:: DateTime.encode(out) - Write the XML-RPC encoding of this :class:`DateTime` item to the *out* stream - object. + .. method:: encode(out) -It also supports certain of Python's built-in operators through rich comparison -and :meth:`__repr__` methods. + Write the XML-RPC encoding of this :class:`DateTime` item to the *out* stream + object. + + It also supports certain of Python's built-in operators through rich comparison + and :meth:`__repr__` methods. A working example follows. The server code:: @@ -282,36 +289,38 @@ Binary Objects -------------- -This class may be initialized from bytes data (which may include NULs). The -primary access to the content of a :class:`Binary` object is provided by an -attribute: +.. class:: Binary + This class may be initialized from bytes data (which may include NULs). The + primary access to the content of a :class:`Binary` object is provided by an + attribute: -.. attribute:: Binary.data - The binary data encapsulated by the :class:`Binary` instance. The data is - provided as a :class:`bytes` object. + .. attribute:: data -:class:`Binary` objects have the following methods, supported mainly for -internal use by the marshalling/unmarshalling code: + The binary data encapsulated by the :class:`Binary` instance. The data is + provided as a :class:`bytes` object. + :class:`Binary` objects have the following methods, supported mainly for + internal use by the marshalling/unmarshalling code: -.. method:: Binary.decode(bytes) - Accept a base64 :class:`bytes` object and decode it as the instance's new data. + .. method:: decode(bytes) + Accept a base64 :class:`bytes` object and decode it as the instance's new data. -.. method:: Binary.encode(out) - Write the XML-RPC base 64 encoding of this binary item to the out stream object. + .. method:: encode(out) - The encoded data will have newlines every 76 characters as per - `RFC 2045 section 6.8 `_, - which was the de facto standard base64 specification when the - XML-RPC spec was written. + Write the XML-RPC base 64 encoding of this binary item to the *out* stream object. -It also supports certain of Python's built-in operators through :meth:`__eq__` -and :meth:`__ne__` methods. + The encoded data will have newlines every 76 characters as per + `RFC 2045 section 6.8 `_, + which was the de facto standard base64 specification when the + XML-RPC spec was written. + + It also supports certain of Python's built-in operators through :meth:`__eq__` + and :meth:`__ne__` methods. Example usage of the binary objects. We're going to transfer an image over XMLRPC:: @@ -342,18 +351,20 @@ Fault Objects ------------- -A :class:`Fault` object encapsulates the content of an XML-RPC fault tag. Fault -objects have the following attributes: +.. class:: Fault + A :class:`Fault` object encapsulates the content of an XML-RPC fault tag. Fault + objects have the following attributes: -.. attribute:: Fault.faultCode - A string indicating the fault type. + .. attribute:: faultCode + A string indicating the fault type. -.. attribute:: Fault.faultString - A string containing a diagnostic message associated with the fault. + .. attribute:: faultString + + A string containing a diagnostic message associated with the fault. In the following example we're going to intentionally cause a :exc:`Fault` by returning a complex type object. The server code:: @@ -390,30 +401,32 @@ ProtocolError Objects --------------------- -A :class:`ProtocolError` object describes a protocol error in the underlying -transport layer (such as a 404 'not found' error if the server named by the URI -does not exist). It has the following attributes: +.. class:: ProtocolError + A :class:`ProtocolError` object describes a protocol error in the underlying + transport layer (such as a 404 'not found' error if the server named by the URI + does not exist). It has the following attributes: -.. attribute:: ProtocolError.url - The URI or URL that triggered the error. + .. attribute:: url + The URI or URL that triggered the error. -.. attribute:: ProtocolError.errcode - The error code. + .. attribute:: errcode + The error code. -.. attribute:: ProtocolError.errmsg - The error message or diagnostic string. + .. attribute:: errmsg + The error message or diagnostic string. -.. attribute:: ProtocolError.headers - A dict containing the headers of the HTTP/HTTPS request that triggered the - error. + .. attribute:: headers + + A dict containing the headers of the HTTP/HTTPS request that triggered the + error. In the following example we're going to intentionally cause a :exc:`ProtocolError` by providing an invalid URI:: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat May 7 01:45:33 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 07 May 2016 05:45:33 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI2ODg5?= =?utf-8?q?=3A_Tweaked_xmlrpclib_documentation=2E?= Message-ID: <20160507054533.31187.23060.C9DA53B3@psf.io> https://hg.python.org/cpython/rev/fb5bd513751f changeset: 101244:fb5bd513751f branch: 2.7 parent: 101235:4462e193f089 user: Serhiy Storchaka date: Sat May 07 08:44:58 2016 +0300 summary: Issue #26889: Tweaked xmlrpclib documentation. files: Doc/library/xmlrpclib.rst | 184 +++++++++++++------------ 1 files changed, 99 insertions(+), 85 deletions(-) diff --git a/Doc/library/xmlrpclib.rst b/Doc/library/xmlrpclib.rst --- a/Doc/library/xmlrpclib.rst +++ b/Doc/library/xmlrpclib.rst @@ -21,7 +21,7 @@ -------------- -XML-RPC is a Remote Procedure Call method that uses XML passed via HTTP as a +XML-RPC is a Remote Procedure Call method that uses XML passed via HTTP(S) as a transport. With it, a client can call methods with parameters on a remote server (the server is named by a URI) and get back structured data. This module supports writing XML-RPC client code; it handles all the details of translating @@ -37,7 +37,7 @@ .. versionchanged:: 2.7.9 For https URIs, :mod:`xmlrpclib` now performs all the necessary certificate - and hostname checks by default + and hostname checks by default. .. class:: ServerProxy(uri[, transport[, encoding[, verbose[, allow_none[, use_datetime[, context]]]]]]) @@ -48,11 +48,15 @@ :class:`SafeTransport` instance for https: URLs and an internal HTTP :class:`Transport` instance otherwise. The optional third argument is an encoding, by default UTF-8. The optional fourth argument is a debugging flag. + + The following parameters govern the use of the returned proxy instance. If *allow_none* is true, the Python constant ``None`` will be translated into XML; the default behaviour is for ``None`` to raise a :exc:`TypeError`. This is a commonly-used extension to the XML-RPC specification, but isn't supported by - all clients and servers; see http://ontosys.com/xml-rpc/extensions.php for a - description. The *use_datetime* flag can be used to cause date/time values to + all clients and servers; see `http://ontosys.com/xml-rpc/extensions.php + ` + for a description. + The *use_datetime* flag can be used to cause date/time values to be presented as :class:`datetime.datetime` objects; this is false by default. :class:`datetime.datetime` objects may be passed to calls. @@ -71,40 +75,42 @@ methods it supports (service discovery) and fetch other server-associated metadata. - :class:`ServerProxy` instance methods take Python basic types and objects as - arguments and return Python basic types and classes. Types that are conformable - (e.g. that can be marshalled through XML), include the following (and except - where noted, they are unmarshalled as the same Python type): + Types that are conformable (e.g. that can be marshalled through XML), + include the following (and except where noted, they are unmarshalled + as the same Python type): - +---------------------------------+---------------------------------------------+ - | Name | Meaning | - +=================================+=============================================+ - | :const:`boolean` | The :const:`True` and :const:`False` | - | | constants | - +---------------------------------+---------------------------------------------+ - | :const:`integers` | Pass in directly | - +---------------------------------+---------------------------------------------+ - | :const:`floating-point numbers` | Pass in directly | - +---------------------------------+---------------------------------------------+ - | :const:`strings` | Pass in directly | - +---------------------------------+---------------------------------------------+ - | :const:`arrays` | Any Python sequence type containing | - | | conformable elements. Arrays are returned | - | | as lists | - +---------------------------------+---------------------------------------------+ - | :const:`structures` | A Python dictionary. Keys must be strings, | - | | values may be any conformable type. Objects | - | | of user-defined classes can be passed in; | - | | only their *__dict__* attribute is | - | | transmitted. | - +---------------------------------+---------------------------------------------+ - | :const:`dates` | in seconds since the epoch (pass in an | - | | instance of the :class:`DateTime` class) or | - | | a :class:`datetime.datetime` instance. | - +---------------------------------+---------------------------------------------+ - | :const:`binary data` | pass in an instance of the :class:`Binary` | - | | wrapper class | - +---------------------------------+---------------------------------------------+ + .. tabularcolumns:: |l|L| + + +----------------------+-------------------------------------------------------+ + | XML-RPC type | Python type | + +======================+=======================================================+ + | ``boolean`` | :class:`bool` | + +----------------------+-------------------------------------------------------+ + | ``int`` or ``i4`` | :class:`int` or :class:`long` in range from | + | | -2147483648 to 2147483647. | + +----------------------+-------------------------------------------------------+ + | ``double`` | :class:`float` | + +----------------------+-------------------------------------------------------+ + | ``string`` | :class:`str` or :class:`unicode` | + +----------------------+-------------------------------------------------------+ + | ``array`` | :class:`list` or :class:`tuple` containing | + | | conformable elements. Arrays are returned as | + | | :class:`list`\ s. | + +----------------------+-------------------------------------------------------+ + | ``struct`` | :class:`dict`. Keys must be strings, values may be | + | | any conformable type. Objects of user-defined | + | | classes can be passed in; only their :attr:`__dict__` | + | | attribute is transmitted. | + +----------------------+-------------------------------------------------------+ + | ``dateTime.iso8601`` | :class:`DateTime` or :class:`datetime.datetime`. | + | | Returned type depends on values of the *use_datetime* | + | | flags. | + +----------------------+-------------------------------------------------------+ + | ``base64`` | :class:`Binary` | + +----------------------+-------------------------------------------------------+ + | ``nil`` | The ``None`` constant. Passing is allowed only if | + | | *allow_none* is true. | + +----------------------+-------------------------------------------------------+ This is the full set of data types supported by XML-RPC. Method calls may also raise a special :exc:`Fault` instance, used to signal XML-RPC server errors, or @@ -168,7 +174,7 @@ :class:`Fault` or :class:`ProtocolError` object indicating an error. Servers that support the XML introspection API support some common methods -grouped under the reserved :attr:`system` attribute: +grouped under the reserved :attr:`~ServerProxy.system` attribute: .. method:: ServerProxy.system.listMethods() @@ -249,24 +255,26 @@ DateTime Objects ---------------- -This class may be initialized with seconds since the epoch, a time -tuple, an ISO 8601 time/date string, or a :class:`datetime.datetime` -instance. It has the following methods, supported mainly for internal -use by the marshalling/unmarshalling code: +.. class:: DateTime + This class may be initialized with seconds since the epoch, a time + tuple, an ISO 8601 time/date string, or a :class:`datetime.datetime` + instance. It has the following methods, supported mainly for internal + use by the marshalling/unmarshalling code: -.. method:: DateTime.decode(string) - Accept a string as the instance's new time value. + .. method:: decode(string) + Accept a string as the instance's new time value. -.. method:: DateTime.encode(out) - Write the XML-RPC encoding of this :class:`DateTime` item to the *out* stream - object. + .. method:: encode(out) -It also supports certain of Python's built-in operators through :meth:`__cmp__` -and :meth:`__repr__` methods. + Write the XML-RPC encoding of this :class:`DateTime` item to the *out* stream + object. + + It also supports certain of Python's built-in operators through :meth:`__cmp__` + and :meth:`__repr__` methods. A working example follows. The server code:: @@ -300,36 +308,38 @@ Binary Objects -------------- -This class may be initialized from string data (which may include NULs). The -primary access to the content of a :class:`Binary` object is provided by an -attribute: +.. class:: Binary + This class may be initialized from string data (which may include NULs). The + primary access to the content of a :class:`Binary` object is provided by an + attribute: -.. attribute:: Binary.data - The binary data encapsulated by the :class:`Binary` instance. The data is - provided as an 8-bit string. + .. attribute:: data -:class:`Binary` objects have the following methods, supported mainly for -internal use by the marshalling/unmarshalling code: + The binary data encapsulated by the :class:`Binary` instance. The data is + provided as an 8-bit string. + :class:`Binary` objects have the following methods, supported mainly for + internal use by the marshalling/unmarshalling code: -.. method:: Binary.decode(string) - Accept a base64 string and decode it as the instance's new data. + .. method:: decode(string) + Accept a base64 string and decode it as the instance's new data. -.. method:: Binary.encode(out) - Write the XML-RPC base 64 encoding of this binary item to the out stream object. + .. method:: encode(out) - The encoded data will have newlines every 76 characters as per - `RFC 2045 section 6.8 `_, - which was the de facto standard base64 specification when the - XML-RPC spec was written. + Write the XML-RPC base 64 encoding of this binary item to the *out* stream object. -It also supports certain of Python's built-in operators through a -:meth:`__cmp__` method. + The encoded data will have newlines every 76 characters as per + `RFC 2045 section 6.8 `_, + which was the de facto standard base64 specification when the + XML-RPC spec was written. + + It also supports certain of Python's built-in operators through a + :meth:`__cmp__` method. Example usage of the binary objects. We're going to transfer an image over XMLRPC:: @@ -360,18 +370,20 @@ Fault Objects ------------- -A :class:`Fault` object encapsulates the content of an XML-RPC fault tag. Fault -objects have the following attributes: +.. class:: Fault + A :class:`Fault` object encapsulates the content of an XML-RPC fault tag. Fault + objects have the following attributes: -.. attribute:: Fault.faultCode - A string indicating the fault type. + .. attribute:: faultCode + A string indicating the fault type. -.. attribute:: Fault.faultString - A string containing a diagnostic message associated with the fault. + .. attribute:: faultString + + A string containing a diagnostic message associated with the fault. In the following example we're going to intentionally cause a :exc:`Fault` by returning a complex type object. The server code:: @@ -408,30 +420,32 @@ ProtocolError Objects --------------------- -A :class:`ProtocolError` object describes a protocol error in the underlying -transport layer (such as a 404 'not found' error if the server named by the URI -does not exist). It has the following attributes: +.. class:: ProtocolError + A :class:`ProtocolError` object describes a protocol error in the underlying + transport layer (such as a 404 'not found' error if the server named by the URI + does not exist). It has the following attributes: -.. attribute:: ProtocolError.url - The URI or URL that triggered the error. + .. attribute:: url + The URI or URL that triggered the error. -.. attribute:: ProtocolError.errcode - The error code. + .. attribute:: errcode + The error code. -.. attribute:: ProtocolError.errmsg - The error message or diagnostic string. + .. attribute:: errmsg + The error message or diagnostic string. -.. attribute:: ProtocolError.headers - A string containing the headers of the HTTP/HTTPS request that triggered the - error. + .. attribute:: headers + + A string containing the headers of the HTTP/HTTPS request that triggered the + error. In the following example we're going to intentionally cause a :exc:`ProtocolError` by providing a URI that doesn't point to an XMLRPC server:: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat May 7 01:45:33 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 07 May 2016 05:45:33 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326889=3A_Tweaked_xmlrpc=2Eclient_documentation?= =?utf-8?q?=2E?= Message-ID: <20160507054533.89109.15663.A5F36EC4@psf.io> https://hg.python.org/cpython/rev/9bdec549bad3 changeset: 101243:9bdec549bad3 parent: 101241:786de3f37ca7 parent: 101242:04250fc723e6 user: Serhiy Storchaka date: Sat May 07 08:44:36 2016 +0300 summary: Issue #26889: Tweaked xmlrpc.client documentation. files: Doc/library/xmlrpc.client.rst | 191 +++++++++++---------- 1 files changed, 102 insertions(+), 89 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 @@ -14,7 +14,7 @@ -------------- -XML-RPC is a Remote Procedure Call method that uses XML passed via HTTP as a +XML-RPC is a Remote Procedure Call method that uses XML passed via HTTP(S) as a transport. With it, a client can call methods with parameters on a remote server (the server is named by a URI) and get back structured data. This module supports writing XML-RPC client code; it handles all the details of translating @@ -30,7 +30,7 @@ .. versionchanged:: 3.5 For https URIs, :mod:`xmlrpc.client` now performs all the necessary - certificate and hostname checks by default + certificate and hostname checks by default. .. class:: ServerProxy(uri, transport=None, encoding=None, verbose=False, \ allow_none=False, use_datetime=False, \ @@ -46,15 +46,19 @@ :class:`SafeTransport` instance for https: URLs and an internal HTTP :class:`Transport` instance otherwise. The optional third argument is an encoding, by default UTF-8. The optional fourth argument is a debugging flag. + + The following parameters govern the use of the returned proxy instance. If *allow_none* is true, the Python constant ``None`` will be translated into XML; the default behaviour is for ``None`` to raise a :exc:`TypeError`. This is a commonly-used extension to the XML-RPC specification, but isn't supported by - all clients and servers; see http://ontosys.com/xml-rpc/extensions.php for a - description. The *use_builtin_types* flag can be used to cause date/time values + all clients and servers; see `http://ontosys.com/xml-rpc/extensions.php + ` + for a description. + The *use_builtin_types* flag can be used to cause date/time values to be presented as :class:`datetime.datetime` objects and binary data to be presented as :class:`bytes` objects; this flag is false by default. - :class:`datetime.datetime` and :class:`bytes` objects may be passed to calls. - + :class:`datetime.datetime`, :class:`bytes` and :class:`bytearray` objects + may be passed to calls. The obsolete *use_datetime* flag is similar to *use_builtin_types* but it applies only to date/time values. @@ -73,42 +77,43 @@ methods it supports (service discovery) and fetch other server-associated metadata. - :class:`ServerProxy` instance methods take Python basic types and objects as - arguments and return Python basic types and classes. Types that are conformable - (e.g. that can be marshalled through XML), include the following (and except - where noted, they are unmarshalled as the same Python type): + Types that are conformable (e.g. that can be marshalled through XML), + include the following (and except where noted, they are unmarshalled + as the same Python type): .. tabularcolumns:: |l|L| - +---------------------------------+---------------------------------------------+ - | Name | Meaning | - +=================================+=============================================+ - | :const:`boolean` | The :const:`True` and :const:`False` | - | | constants | - +---------------------------------+---------------------------------------------+ - | :const:`integers` | Pass in directly | - +---------------------------------+---------------------------------------------+ - | :const:`floating-point numbers` | Pass in directly | - +---------------------------------+---------------------------------------------+ - | :const:`strings` | Pass in directly | - +---------------------------------+---------------------------------------------+ - | :const:`arrays` | Any Python sequence type containing | - | | conformable elements. Arrays are returned | - | | as lists | - +---------------------------------+---------------------------------------------+ - | :const:`structures` | A Python dictionary. Keys must be strings, | - | | values may be any conformable type. Objects | - | | of user-defined classes can be passed in; | - | | only their *__dict__* attribute is | - | | transmitted. | - +---------------------------------+---------------------------------------------+ - | :const:`dates` | In seconds since the epoch. Pass in an | - | | instance of the :class:`DateTime` class or | - | | a :class:`datetime.datetime` instance. | - +---------------------------------+---------------------------------------------+ - | :const:`binary data` | Pass in an instance of the :class:`Binary` | - | | wrapper class or a :class:`bytes` instance. | - +---------------------------------+---------------------------------------------+ + +----------------------+-------------------------------------------------------+ + | XML-RPC type | Python type | + +======================+=======================================================+ + | ``boolean`` | :class:`bool` | + +----------------------+-------------------------------------------------------+ + | ``int`` or ``i4`` | :class:`int` in range from -2147483648 to 2147483647. | + +----------------------+-------------------------------------------------------+ + | ``double`` | :class:`float` | + +----------------------+-------------------------------------------------------+ + | ``string`` | :class:`str` | + +----------------------+-------------------------------------------------------+ + | ``array`` | :class:`list` or :class:`tuple` containing | + | | conformable elements. Arrays are returned as | + | | :class:`list`\ s. | + +----------------------+-------------------------------------------------------+ + | ``struct`` | :class:`dict`. Keys must be strings, values may be | + | | any conformable type. Objects of user-defined | + | | classes can be passed in; only their :attr:`__dict__` | + | | attribute is transmitted. | + +----------------------+-------------------------------------------------------+ + | ``dateTime.iso8601`` | :class:`DateTime` or :class:`datetime.datetime`. | + | | Returned type depends on values of | + | | *use_builtin_types* and *use_datetime* flags. | + +----------------------+-------------------------------------------------------+ + | ``base64`` | :class:`Binary`, :class:`bytes` or | + | | :class:`bytearray`. Returned type depends on the | + | | value of the *use_builtin_types* flag. | + +----------------------+-------------------------------------------------------+ + | ``nil`` | The ``None`` constant. Passing is allowed only if | + | | *allow_none* is true. | + +----------------------+-------------------------------------------------------+ This is the full set of data types supported by XML-RPC. Method calls may also raise a special :exc:`Fault` instance, used to signal XML-RPC server errors, or @@ -123,8 +128,8 @@ the control characters with ASCII values between 0 and 31 (except, of course, tab, newline and carriage return); failing to do this will result in an XML-RPC request that isn't well-formed XML. If you have to pass arbitrary bytes - via XML-RPC, use the :class:`bytes` class or the class:`Binary` wrapper class - described below. + via XML-RPC, use :class:`bytes` or :class:`bytearray` classes or the + :class:`Binary` wrapper class described below. :class:`Server` is retained as an alias for :class:`ServerProxy` for backwards compatibility. New code should use :class:`ServerProxy`. @@ -164,7 +169,7 @@ :class:`Fault` or :class:`ProtocolError` object indicating an error. Servers that support the XML introspection API support some common methods -grouped under the reserved :attr:`system` attribute: +grouped under the reserved :attr:`~ServerProxy.system` attribute: .. method:: ServerProxy.system.listMethods() @@ -231,24 +236,26 @@ DateTime Objects ---------------- -This class may be initialized with seconds since the epoch, a time -tuple, an ISO 8601 time/date string, or a :class:`datetime.datetime` -instance. It has the following methods, supported mainly for internal -use by the marshalling/unmarshalling code: +.. class:: DateTime + This class may be initialized with seconds since the epoch, a time + tuple, an ISO 8601 time/date string, or a :class:`datetime.datetime` + instance. It has the following methods, supported mainly for internal + use by the marshalling/unmarshalling code: -.. method:: DateTime.decode(string) - Accept a string as the instance's new time value. + .. method:: decode(string) + Accept a string as the instance's new time value. -.. method:: DateTime.encode(out) - Write the XML-RPC encoding of this :class:`DateTime` item to the *out* stream - object. + .. method:: encode(out) -It also supports certain of Python's built-in operators through rich comparison -and :meth:`__repr__` methods. + Write the XML-RPC encoding of this :class:`DateTime` item to the *out* stream + object. + + It also supports certain of Python's built-in operators through rich comparison + and :meth:`__repr__` methods. A working example follows. The server code:: @@ -282,36 +289,38 @@ Binary Objects -------------- -This class may be initialized from bytes data (which may include NULs). The -primary access to the content of a :class:`Binary` object is provided by an -attribute: +.. class:: Binary + This class may be initialized from bytes data (which may include NULs). The + primary access to the content of a :class:`Binary` object is provided by an + attribute: -.. attribute:: Binary.data - The binary data encapsulated by the :class:`Binary` instance. The data is - provided as a :class:`bytes` object. + .. attribute:: data -:class:`Binary` objects have the following methods, supported mainly for -internal use by the marshalling/unmarshalling code: + The binary data encapsulated by the :class:`Binary` instance. The data is + provided as a :class:`bytes` object. + :class:`Binary` objects have the following methods, supported mainly for + internal use by the marshalling/unmarshalling code: -.. method:: Binary.decode(bytes) - Accept a base64 :class:`bytes` object and decode it as the instance's new data. + .. method:: decode(bytes) + Accept a base64 :class:`bytes` object and decode it as the instance's new data. -.. method:: Binary.encode(out) - Write the XML-RPC base 64 encoding of this binary item to the out stream object. + .. method:: encode(out) - The encoded data will have newlines every 76 characters as per - `RFC 2045 section 6.8 `_, - which was the de facto standard base64 specification when the - XML-RPC spec was written. + Write the XML-RPC base 64 encoding of this binary item to the *out* stream object. -It also supports certain of Python's built-in operators through :meth:`__eq__` -and :meth:`__ne__` methods. + The encoded data will have newlines every 76 characters as per + `RFC 2045 section 6.8 `_, + which was the de facto standard base64 specification when the + XML-RPC spec was written. + + It also supports certain of Python's built-in operators through :meth:`__eq__` + and :meth:`__ne__` methods. Example usage of the binary objects. We're going to transfer an image over XMLRPC:: @@ -342,18 +351,20 @@ Fault Objects ------------- -A :class:`Fault` object encapsulates the content of an XML-RPC fault tag. Fault -objects have the following attributes: +.. class:: Fault + A :class:`Fault` object encapsulates the content of an XML-RPC fault tag. Fault + objects have the following attributes: -.. attribute:: Fault.faultCode - A string indicating the fault type. + .. attribute:: faultCode + A string indicating the fault type. -.. attribute:: Fault.faultString - A string containing a diagnostic message associated with the fault. + .. attribute:: faultString + + A string containing a diagnostic message associated with the fault. In the following example we're going to intentionally cause a :exc:`Fault` by returning a complex type object. The server code:: @@ -390,30 +401,32 @@ ProtocolError Objects --------------------- -A :class:`ProtocolError` object describes a protocol error in the underlying -transport layer (such as a 404 'not found' error if the server named by the URI -does not exist). It has the following attributes: +.. class:: ProtocolError + A :class:`ProtocolError` object describes a protocol error in the underlying + transport layer (such as a 404 'not found' error if the server named by the URI + does not exist). It has the following attributes: -.. attribute:: ProtocolError.url - The URI or URL that triggered the error. + .. attribute:: url + The URI or URL that triggered the error. -.. attribute:: ProtocolError.errcode - The error code. + .. attribute:: errcode + The error code. -.. attribute:: ProtocolError.errmsg - The error message or diagnostic string. + .. attribute:: errmsg + The error message or diagnostic string. -.. attribute:: ProtocolError.headers - A dict containing the headers of the HTTP/HTTPS request that triggered the - error. + .. attribute:: headers + + A dict containing the headers of the HTTP/HTTPS request that triggered the + error. In the following example we're going to intentionally cause a :exc:`ProtocolError` by providing an invalid URI:: -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat May 7 03:07:25 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 07 May 2016 07:07:25 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2ODg5?= =?utf-8?q?=3A_Fixed_hyperlinks_formatting=2E?= Message-ID: <20160507070724.67131.48870.D2510F69@psf.io> https://hg.python.org/cpython/rev/52924d962027 changeset: 101245:52924d962027 branch: 3.5 parent: 101242:04250fc723e6 user: Serhiy Storchaka date: Sat May 07 10:05:02 2016 +0300 summary: Issue #26889: Fixed hyperlinks formatting. 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 @@ -52,7 +52,7 @@ XML; the default behaviour is for ``None`` to raise a :exc:`TypeError`. This is a commonly-used extension to the XML-RPC specification, but isn't supported by all clients and servers; see `http://ontosys.com/xml-rpc/extensions.php - ` + `_ for a description. The *use_builtin_types* flag can be used to cause date/time values to be presented as :class:`datetime.datetime` objects and binary data to be @@ -96,12 +96,12 @@ +----------------------+-------------------------------------------------------+ | ``array`` | :class:`list` or :class:`tuple` containing | | | conformable elements. Arrays are returned as | - | | :class:`list`\ s. | + | | :class:`lists `. | +----------------------+-------------------------------------------------------+ | ``struct`` | :class:`dict`. Keys must be strings, values may be | | | any conformable type. Objects of user-defined | - | | classes can be passed in; only their :attr:`__dict__` | - | | attribute is transmitted. | + | | classes can be passed in; only their | + | | :attr:`~object.__dict__` attribute is transmitted. | +----------------------+-------------------------------------------------------+ | ``dateTime.iso8601`` | :class:`DateTime` or :class:`datetime.datetime`. | | | Returned type depends on values of | -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat May 7 03:07:25 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 07 May 2016 07:07:25 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI2ODg5?= =?utf-8?q?=3A_Fixed_hyperlinks_formatting=2E?= Message-ID: <20160507070724.21003.47636.2F8EB7E8@psf.io> https://hg.python.org/cpython/rev/29a927c524cb changeset: 101247:29a927c524cb branch: 2.7 parent: 101244:fb5bd513751f user: Serhiy Storchaka date: Sat May 07 10:06:53 2016 +0300 summary: Issue #26889: Fixed hyperlinks formatting. files: Doc/library/xmlrpclib.rst | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/library/xmlrpclib.rst b/Doc/library/xmlrpclib.rst --- a/Doc/library/xmlrpclib.rst +++ b/Doc/library/xmlrpclib.rst @@ -54,7 +54,7 @@ XML; the default behaviour is for ``None`` to raise a :exc:`TypeError`. This is a commonly-used extension to the XML-RPC specification, but isn't supported by all clients and servers; see `http://ontosys.com/xml-rpc/extensions.php - ` + `_ for a description. The *use_datetime* flag can be used to cause date/time values to be presented as :class:`datetime.datetime` objects; this is false by default. @@ -95,12 +95,12 @@ +----------------------+-------------------------------------------------------+ | ``array`` | :class:`list` or :class:`tuple` containing | | | conformable elements. Arrays are returned as | - | | :class:`list`\ s. | + | | :class:`lists `. | +----------------------+-------------------------------------------------------+ | ``struct`` | :class:`dict`. Keys must be strings, values may be | | | any conformable type. Objects of user-defined | - | | classes can be passed in; only their :attr:`__dict__` | - | | attribute is transmitted. | + | | classes can be passed in; only their | + | | :attr:`~object.__dict__` attribute is transmitted. | +----------------------+-------------------------------------------------------+ | ``dateTime.iso8601`` | :class:`DateTime` or :class:`datetime.datetime`. | | | Returned type depends on values of the *use_datetime* | -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat May 7 03:07:25 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 07 May 2016 07:07:25 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326889=3A_Fixed_hyperlinks_formatting=2E?= Message-ID: <20160507070724.89093.75303.C6C325C1@psf.io> https://hg.python.org/cpython/rev/ea9d69a4d0fe changeset: 101246:ea9d69a4d0fe parent: 101243:9bdec549bad3 parent: 101245:52924d962027 user: Serhiy Storchaka date: Sat May 07 10:06:39 2016 +0300 summary: Issue #26889: Fixed hyperlinks formatting. 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 @@ -52,7 +52,7 @@ XML; the default behaviour is for ``None`` to raise a :exc:`TypeError`. This is a commonly-used extension to the XML-RPC specification, but isn't supported by all clients and servers; see `http://ontosys.com/xml-rpc/extensions.php - ` + `_ for a description. The *use_builtin_types* flag can be used to cause date/time values to be presented as :class:`datetime.datetime` objects and binary data to be @@ -96,12 +96,12 @@ +----------------------+-------------------------------------------------------+ | ``array`` | :class:`list` or :class:`tuple` containing | | | conformable elements. Arrays are returned as | - | | :class:`list`\ s. | + | | :class:`lists `. | +----------------------+-------------------------------------------------------+ | ``struct`` | :class:`dict`. Keys must be strings, values may be | | | any conformable type. Objects of user-defined | - | | classes can be passed in; only their :attr:`__dict__` | - | | attribute is transmitted. | + | | classes can be passed in; only their | + | | :attr:`~object.__dict__` attribute is transmitted. | +----------------------+-------------------------------------------------------+ | ``dateTime.iso8601`` | :class:`DateTime` or :class:`datetime.datetime`. | | | Returned type depends on values of | -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat May 7 03:50:41 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 07 May 2016 07:50:41 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI2NzM2?= =?utf-8?q?=3A_Used_HTTPS_for_external_links_in_the_documentation_if_possi?= =?utf-8?q?ble=2E?= Message-ID: <20160507075041.9140.36579.5462809C@psf.io> https://hg.python.org/cpython/rev/e3af25d70976 changeset: 101250:e3af25d70976 branch: 2.7 parent: 101247:29a927c524cb user: Serhiy Storchaka date: Sat May 07 10:50:12 2016 +0300 summary: Issue #26736: Used HTTPS for external links in the documentation if possible. files: Doc/c-api/init.rst | 2 +- Doc/faq/design.rst | 4 +- Doc/faq/extending.rst | 2 +- Doc/faq/general.rst | 2 +- Doc/faq/gui.rst | 4 +- Doc/faq/programming.rst | 16 +++++++------- Doc/faq/windows.rst | 2 +- Doc/howto/functional.rst | 6 ++-- Doc/howto/logging-cookbook.rst | 4 +- Doc/howto/pyporting.rst | 4 +- Doc/howto/unicode.rst | 2 +- Doc/howto/urllib2.rst | 6 ++-- Doc/install/index.rst | 6 ++-- Doc/library/array.rst | 2 +- Doc/library/bisect.rst | 2 +- Doc/library/codecs.rst | 2 +- Doc/library/collections.rst | 10 ++++---- Doc/library/colorsys.rst | 2 +- Doc/library/cookielib.rst | 2 +- Doc/library/datetime.rst | 4 +- Doc/library/difflib.rst | 2 +- Doc/library/htmllib.rst | 2 +- Doc/library/htmlparser.rst | 4 +- Doc/library/imaplib.rst | 2 +- Doc/library/json.rst | 2 +- Doc/library/mailbox.rst | 6 ++-- Doc/library/mimetypes.rst | 2 +- Doc/library/othergui.rst | 4 +- Doc/library/pyexpat.rst | 4 +- Doc/library/select.rst | 2 +- Doc/library/sqlite3.rst | 4 +- Doc/library/ssl.rst | 14 ++++++------ Doc/library/tarfile.rst | 2 +- Doc/library/tkinter.rst | 4 +- Doc/library/ttk.rst | 2 +- Doc/library/urllib2.rst | 2 +- Doc/library/urlparse.rst | 2 +- Doc/library/xml.dom.minidom.rst | 6 ++-- Doc/library/xml.dom.rst | 12 +++++----- Doc/library/xml.etree.elementtree.rst | 8 +++--- Doc/library/xmlrpclib.rst | 4 +- Doc/license.rst | 6 ++-- Doc/tutorial/interactive.rst | 2 +- Doc/tutorial/whatnow.rst | 2 +- Doc/using/mac.rst | 6 ++-- Doc/using/unix.rst | 8 +++--- Doc/using/windows.rst | 4 +- Doc/whatsnew/2.0.rst | 2 +- Doc/whatsnew/2.2.rst | 4 +- Doc/whatsnew/2.3.rst | 4 +- Doc/whatsnew/2.5.rst | 6 ++-- Doc/whatsnew/2.6.rst | 8 +++--- Doc/whatsnew/2.7.rst | 10 ++++---- Misc/NEWS | 2 + 54 files changed, 120 insertions(+), 118 deletions(-) diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -297,7 +297,7 @@ It is recommended that applications embedding the Python interpreter for purposes other than executing a single script pass 0 as *updatepath*, and update :data:`sys.path` themselves if desired. - See `CVE-2008-5983 `_. + See `CVE-2008-5983 `_. On versions before 2.6.6, you can achieve the same effect by manually popping the first :data:`sys.path` element after having called diff --git a/Doc/faq/design.rst b/Doc/faq/design.rst --- a/Doc/faq/design.rst +++ b/Doc/faq/design.rst @@ -431,10 +431,10 @@ There are also several programs which make it easier to intermingle Python and C code in various ways to increase performance. See, for example, `Cython `_ , `Psyco `_, `Pyrex -`_, `PyInline +`_, `PyInline `_, `Py2Cmod `_, and -`Weave `_. +`Weave `_. How does Python manage memory? diff --git a/Doc/faq/extending.rst b/Doc/faq/extending.rst --- a/Doc/faq/extending.rst +++ b/Doc/faq/extending.rst @@ -45,7 +45,7 @@ x86-compatible processor. `Cython `_ and its relative `Pyrex -`_ are compilers +`_ are compilers that accept a slightly modified form of Python and generate the corresponding C code. Pyrex makes it possible to write an extension without having to learn Python's C API. diff --git a/Doc/faq/general.rst b/Doc/faq/general.rst --- a/Doc/faq/general.rst +++ b/Doc/faq/general.rst @@ -271,7 +271,7 @@ The Python project's infrastructure is located all over the world. `www.python.org `_ is graciously hosted by `Rackspace -`_, with CDN caching provided by `Fastly +`_, with CDN caching provided by `Fastly `_. `Upfront Systems `_ hosts `bugs.python.org `_. Many other Python services like `the Wiki diff --git a/Doc/faq/gui.rst b/Doc/faq/gui.rst --- a/Doc/faq/gui.rst +++ b/Doc/faq/gui.rst @@ -21,13 +21,13 @@ Standard builds of Python include an object-oriented interface to the Tcl/Tk widget set, called Tkinter. This is probably the easiest to install and use. For more info about Tk, including pointers to the source, see the Tcl/Tk home -page at http://www.tcl.tk. Tcl/Tk is fully portable to the Mac OS X, Windows, +page at https://www.tcl.tk. Tcl/Tk is fully portable to the Mac OS X, Windows, and Unix platforms. wxWidgets --------- -wxWidgets (http://www.wxwidgets.org) is a free, portable GUI class +wxWidgets (https://www.wxwidgets.org) is a free, portable GUI class library written in C++ that provides a native look and feel on a number of platforms, with Windows, Mac OS X, GTK, X11, all listed as current stable targets. Language bindings are available for a number diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -28,9 +28,9 @@ PythonWin is a Python IDE that includes a GUI debugger based on pdb. The Pythonwin debugger colors breakpoints and has quite a few cool features such as debugging non-Pythonwin programs. Pythonwin is available as part of the `Python -for Windows Extensions `__ project and +for Windows Extensions `__ project and as a part of the ActivePython distribution (see -http://www.activestate.com/activepython\ ). +https://www.activestate.com/activepython\ ). `Boa Constructor `_ is an IDE and GUI builder that uses wxWidgets. It offers visual frame creation and manipulation, @@ -44,13 +44,13 @@ Pydb is a version of the standard Python debugger pdb, modified for use with DDD (Data Display Debugger), a popular graphical debugger front end. Pydb can be found at http://bashdb.sourceforge.net/pydb/ and DDD can be found at -http://www.gnu.org/software/ddd. +https://www.gnu.org/software/ddd. There are a number of commercial Python IDEs that include graphical debuggers. They include: -* Wing IDE (http://wingware.com/) -* Komodo IDE (http://komodoide.com/) +* Wing IDE (https://wingware.com/) +* Komodo IDE (https://komodoide.com/) * PyCharm (https://www.jetbrains.com/pycharm/) @@ -63,13 +63,13 @@ 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 length, whether variable names are well-formed according to your coding standard, whether declared interfaces are fully implemented, and more. -http://docs.pylint.org/ provides a full list of Pylint's features. +https://docs.pylint.org/ provides a full list of Pylint's features. How can I create a stand-alone binary from a Python script? @@ -1225,7 +1225,7 @@ See the Python Cookbook for a long discussion of many ways to do this: - http://code.activestate.com/recipes/52560/ + https://code.activestate.com/recipes/52560/ If you don't mind reordering the list, sort it and then scan from the end of the list, deleting duplicates as you go:: diff --git a/Doc/faq/windows.rst b/Doc/faq/windows.rst --- a/Doc/faq/windows.rst +++ b/Doc/faq/windows.rst @@ -334,5 +334,5 @@ Simply rename the downloaded file to have the .TGZ extension, and WinZip will be able to handle it. (If your copy of WinZip doesn't, get a newer one from -http://www.winzip.com.) +https://www.winzip.com.) diff --git a/Doc/howto/functional.rst b/Doc/howto/functional.rst --- a/Doc/howto/functional.rst +++ b/Doc/howto/functional.rst @@ -1171,9 +1171,9 @@ Mertz also wrote a 3-part series of articles on functional programming for IBM's DeveloperWorks site; see -`part 1 `__, -`part 2 `__, and -`part 3 `__, +`part 1 `__, +`part 2 `__, and +`part 3 `__, Python documentation 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 @@ -767,11 +767,11 @@ Inserting a BOM into messages sent to a SysLogHandler ----------------------------------------------------- -`RFC 5424 `_ requires that a +`RFC 5424 `_ requires that a Unicode message be sent to a syslog daemon as a set of bytes which have the following structure: an optional pure-ASCII component, followed by a UTF-8 Byte Order Mark (BOM), followed by Unicode encoded using UTF-8. (See the `relevant -section of the specification `_.) +section of the specification `_.) In Python 2.6 and 2.7, code was added to :class:`~logging.handlers.SysLogHandler` to insert a BOM into the message, but diff --git a/Doc/howto/pyporting.rst b/Doc/howto/pyporting.rst --- a/Doc/howto/pyporting.rst +++ b/Doc/howto/pyporting.rst @@ -379,10 +379,10 @@ .. _cheat sheet: http://python-future.org/compatible_idioms.html .. _coverage.py: https://pypi.python.org/pypi/coverage .. _Futurize: http://python-future.org/automatic_conversion.html -.. _Modernize: http://python-modernize.readthedocs.org/en/latest/ +.. _Modernize: https://python-modernize.readthedocs.org/en/latest/ .. _Porting to Python 3: http://python3porting.com/ .. _Pylint: https://pypi.python.org/pypi/pylint -.. _Python 3 Q & A: http://ncoghlan-devs-python-notes.readthedocs.org/en/latest/python3/questions_and_answers.html +.. _Python 3 Q & A: https://ncoghlan-devs-python-notes.readthedocs.org/en/latest/python3/questions_and_answers.html .. _python-future: http://python-future.org/ .. _python-porting: https://mail.python.org/mailman/listinfo/python-porting diff --git a/Doc/howto/unicode.rst b/Doc/howto/unicode.rst --- a/Doc/howto/unicode.rst +++ b/Doc/howto/unicode.rst @@ -211,7 +211,7 @@ To help understand the standard, Jukka Korpela has written an introductory guide to reading the Unicode character tables, available at -. +. Another good introductory article was written by Joel Spolsky . diff --git a/Doc/howto/urllib2.rst b/Doc/howto/urllib2.rst --- a/Doc/howto/urllib2.rst +++ b/Doc/howto/urllib2.rst @@ -112,7 +112,7 @@ Note that other encodings are sometimes required (e.g. for file upload from HTML forms - see `HTML Specification, Form Submission -`_ for more +`_ for more details). If you do not pass the ``data`` argument, urllib2 uses a **GET** request. One @@ -388,7 +388,7 @@ ``httplib.HTTPMessage`` instance. Typical headers include 'Content-length', 'Content-type', and so on. See the -`Quick Reference to HTTP Headers `_ +`Quick Reference to HTTP Headers `_ for a useful listing of HTTP headers with brief explanations of their meaning and use. @@ -573,5 +573,5 @@ scripts with a localhost server, I have to prevent urllib2 from using the proxy. .. [#] urllib2 opener for SSL proxy (CONNECT method): `ASPN Cookbook Recipe - `_. + `_. diff --git a/Doc/install/index.rst b/Doc/install/index.rst --- a/Doc/install/index.rst +++ b/Doc/install/index.rst @@ -1009,7 +1009,7 @@ .. seealso:: - `C++Builder Compiler `_ + `C++Builder Compiler `_ Information about the free C++ compiler from Borland, including links to the download pages. @@ -1052,7 +1052,7 @@ for Borland's C++, because there is no program to convert the library. First you have to create a list of symbols which the Python DLL exports. (You can find a good program for this task at -http://sourceforge.net/projects/mingw/files/MinGW/Extension/pexports/). +https://sourceforge.net/projects/mingw/files/MinGW/Extension/pexports/). .. I don't understand what the next line means. --amk .. (inclusive the references on data structures.) @@ -1090,7 +1090,7 @@ .. [#] This also means you could replace all existing COFF-libraries with OMF-libraries of the same name. -.. [#] Check http://www.sourceware.org/cygwin/ and http://www.mingw.org/ for more +.. [#] Check https://www.sourceware.org/cygwin/ and http://www.mingw.org/ for more information .. [#] Then you have no POSIX emulation available, but you also don't need diff --git a/Doc/library/array.rst b/Doc/library/array.rst --- a/Doc/library/array.rst +++ b/Doc/library/array.rst @@ -268,7 +268,7 @@ Packing and unpacking of External Data Representation (XDR) data as used in some remote procedure call systems. - `The Numerical Python Documentation `_ + `The Numerical Python Documentation `_ The Numeric Python extension (NumPy) defines another array type; see http://www.numpy.org/ for further information about Numerical Python. diff --git a/Doc/library/bisect.rst b/Doc/library/bisect.rst --- a/Doc/library/bisect.rst +++ b/Doc/library/bisect.rst @@ -62,7 +62,7 @@ .. seealso:: `SortedCollection recipe - `_ that uses + `_ that uses bisect to build a full-featured collection class with straight-forward search methods and support for a key-function. The keys are precomputed to save unnecessary calls to the key function during searches. diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst --- a/Doc/library/codecs.rst +++ b/Doc/library/codecs.rst @@ -1273,7 +1273,7 @@ (:mod:`httplib` then also transparently sends an IDNA hostname in the :mailheader:`Host` field if it sends that field at all). -.. _section 3.1: http://tools.ietf.org/html/rfc3490#section-3.1 +.. _section 3.1: https://tools.ietf.org/html/rfc3490#section-3.1 When receiving host names from the wire (such as in reverse name lookup), no automatic conversion to Unicode is performed: Applications wishing to present diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst --- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -196,9 +196,9 @@ .. seealso:: - * `Counter class `_ + * `Counter class `_ adapted for Python 2.5 and an early `Bag recipe - `_ for Python 2.4. + `_ for Python 2.4. in Smalltalk. @@ -785,7 +785,7 @@ .. seealso:: - `Named tuple recipe `_ + `Named tuple recipe `_ adapted for Python 2.4. @@ -828,7 +828,7 @@ .. seealso:: - `Equivalent OrderedDict recipe `_ + `Equivalent OrderedDict recipe `_ that runs on Python 2.4 or later. :class:`OrderedDict` Examples and Recipes @@ -1040,7 +1040,7 @@ .. seealso:: - * `OrderedSet recipe `_ for an + * `OrderedSet recipe `_ for an example built on :class:`MutableSet`. * For more about ABCs, see the :mod:`abc` module and :pep:`3119`. diff --git a/Doc/library/colorsys.rst b/Doc/library/colorsys.rst --- a/Doc/library/colorsys.rst +++ b/Doc/library/colorsys.rst @@ -21,7 +21,7 @@ More information about color spaces can be found at http://www.poynton.com/ColorFAQ.html and - http://www.cambridgeincolour.com/tutorials/color-spaces.htm. + https://www.cambridgeincolour.com/tutorials/color-spaces.htm. The :mod:`colorsys` module defines the following functions: diff --git a/Doc/library/cookielib.rst b/Doc/library/cookielib.rst --- a/Doc/library/cookielib.rst +++ b/Doc/library/cookielib.rst @@ -122,7 +122,7 @@ HTTP cookie classes, principally useful for server-side code. The :mod:`cookielib` and :mod:`Cookie` modules do not depend on each other. - http://curl.haxx.se/rfc/cookie_spec.html + https://curl.haxx.se/rfc/cookie_spec.html The specification of the original Netscape cookie protocol. Though this is still the dominant protocol, the 'Netscape cookie protocol' implemented by all the major browsers (and :mod:`cookielib`) only bears a passing resemblance to diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -515,7 +515,7 @@ Return a 3-tuple, (ISO year, ISO week number, ISO weekday). The ISO calendar is a widely used variant of the Gregorian calendar. See - http://www.staff.science.uu.nl/~gent0113/calendar/isocalendar.htm for a good + https://www.staff.science.uu.nl/~gent0113/calendar/isocalendar.htm for a good explanation. The ISO year consists of 52 or 53 full weeks, and where a week starts on a @@ -1573,7 +1573,7 @@ *pytz* contains up-to-date information and its usage is recommended. - `IANA timezone database `_ + `IANA timezone database `_ The Time Zone Database (often called tz or zoneinfo) contains code and data that represent the history of local time for many representative locations around the globe. It is updated periodically to reflect changes diff --git a/Doc/library/difflib.rst b/Doc/library/difflib.rst --- a/Doc/library/difflib.rst +++ b/Doc/library/difflib.rst @@ -594,7 +594,7 @@ work. * `Simple version control recipe - `_ for a small application + `_ for a small application built with :class:`SequenceMatcher`. diff --git a/Doc/library/htmllib.rst b/Doc/library/htmllib.rst --- a/Doc/library/htmllib.rst +++ b/Doc/library/htmllib.rst @@ -64,7 +64,7 @@ .. class:: HTMLParser(formatter) This is the basic HTML parser class. It supports all entity names required by - the XHTML 1.0 Recommendation (http://www.w3.org/TR/xhtml1). It also defines + the XHTML 1.0 Recommendation (https://www.w3.org/TR/xhtml1). It also defines handlers for all HTML 2.0 and many HTML 3.0 and 3.2 elements. diff --git a/Doc/library/htmlparser.rst b/Doc/library/htmlparser.rst --- a/Doc/library/htmlparser.rst +++ b/Doc/library/htmlparser.rst @@ -148,8 +148,8 @@ and quotes in the *value* have been removed, and character and entity references have been replaced. - For instance, for the tag ````, this method - would be called as ``handle_starttag('a', [('href', 'http://www.cwi.nl/')])``. + For instance, for the tag ````, this method + would be called as ``handle_starttag('a', [('href', 'https://www.cwi.nl/')])``. .. versionchanged:: 2.6 All entity references from :mod:`htmlentitydefs` are now replaced in the diff --git a/Doc/library/imaplib.rst b/Doc/library/imaplib.rst --- a/Doc/library/imaplib.rst +++ b/Doc/library/imaplib.rst @@ -125,7 +125,7 @@ Documents describing the protocol, and sources and binaries for servers implementing it, can all be found at the University of Washington's *IMAP - Information Center* (http://www.washington.edu/imap/). + Information Center* (https://www.washington.edu/imap/). .. _imap4-objects: diff --git a/Doc/library/json.rst b/Doc/library/json.rst --- a/Doc/library/json.rst +++ b/Doc/library/json.rst @@ -613,7 +613,7 @@ .. rubric:: Footnotes .. [#rfc-errata] As noted in `the errata for RFC 7159 - `_, + `_, JSON permits literal U+2028 (LINE SEPARATOR) and U+2029 (PARAGRAPH SEPARATOR) characters in strings, whereas JavaScript (as of ECMAScript Edition 5.1) does not. diff --git a/Doc/library/mailbox.rst b/Doc/library/mailbox.rst --- a/Doc/library/mailbox.rst +++ b/Doc/library/mailbox.rst @@ -409,7 +409,7 @@ `maildir man page from qmail `_ The original specification of the format. - `Using maildir format `_ + `Using maildir format `_ Notes on Maildir by its inventor. Includes an updated name-creation scheme and details on "info" semantics. @@ -677,10 +677,10 @@ .. seealso:: - `Format of Version 5 Babyl Files `_ + `Format of Version 5 Babyl Files `_ A specification of the Babyl format. - `Reading Mail with Rmail `_ + `Reading Mail with Rmail `_ The Rmail manual, with some information on Babyl semantics. diff --git a/Doc/library/mimetypes.rst b/Doc/library/mimetypes.rst --- a/Doc/library/mimetypes.rst +++ b/Doc/library/mimetypes.rst @@ -44,7 +44,7 @@ The optional *strict* argument is a flag specifying whether the list of known MIME types is limited to only the official types `registered with IANA - `_. + `_. When *strict* is ``True`` (the default), only the IANA types are supported; when *strict* is ``False``, some additional non-standard but commonly used MIME types are also recognized. diff --git a/Doc/library/othergui.rst b/Doc/library/othergui.rst --- a/Doc/library/othergui.rst +++ b/Doc/library/othergui.rst @@ -25,12 +25,12 @@ book, `GUI Programming with Python: QT Edition `_ by Boudewijn Rempt. The *PyQt4* bindings also have a book, `Rapid GUI Programming - with Python and Qt `_, by Mark + with Python and Qt `_, by Mark Summerfield. `wxPython `_ wxPython is a cross-platform GUI toolkit for Python that is built around - the popular `wxWidgets `_ (formerly wxWindows) + the popular `wxWidgets `_ (formerly wxWindows) C++ toolkit. It provides a native look and feel for applications on Windows, Mac OS X, and Unix systems by using each platform's native widgets where ever possible, (GTK+ on Unix-like systems). In addition to diff --git a/Doc/library/pyexpat.rst b/Doc/library/pyexpat.rst --- a/Doc/library/pyexpat.rst +++ b/Doc/library/pyexpat.rst @@ -911,6 +911,6 @@ .. [#] The encoding string included in XML output should conform to the appropriate standards. For example, "UTF-8" is valid, but "UTF8" is - not. See http://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl - and http://www.iana.org/assignments/character-sets/character-sets.xhtml. + not. See https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl + and https://www.iana.org/assignments/character-sets/character-sets.xhtml. diff --git a/Doc/library/select.rst b/Doc/library/select.rst --- a/Doc/library/select.rst +++ b/Doc/library/select.rst @@ -305,7 +305,7 @@ Kevent Objects -------------- -http://www.freebsd.org/cgi/man.cgi?query=kqueue&sektion=2 +https://www.freebsd.org/cgi/man.cgi?query=kqueue&sektion=2 .. attribute:: kevent.ident diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -55,7 +55,7 @@ Usually your SQL operations will need to use values from Python variables. You shouldn't assemble your query using Python's string operations because doing so is insecure; it makes your program vulnerable to an SQL injection attack -(see http://xkcd.com/327/ for humorous example of what can go wrong). +(see https://xkcd.com/327/ for humorous example of what can go wrong). Instead, use the DB-API's parameter substitution. Put ``?`` as a placeholder wherever you want to use a value, and then provide a tuple of values as the @@ -101,7 +101,7 @@ The pysqlite web page -- sqlite3 is developed externally under the name "pysqlite". - http://www.sqlite.org + https://www.sqlite.org The SQLite web page; the documentation describes the syntax and the available data types for the supported SQL dialect. 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 @@ -761,7 +761,7 @@ ALERT_DESCRIPTION_* Alert Descriptions from :rfc:`5246` and others. The `IANA TLS Alert Registry - `_ + `_ contains this list and references to the RFCs where their meaning is defined. Used as the return value of the callback function in @@ -1062,7 +1062,7 @@ The *capath* string, if present, is the path to a directory containing several CA certificates in PEM format, following an `OpenSSL specific layout - `_. + `_. The *cadata* object, if present, is either an ASCII string of one or more PEM-encoded certificates or a bytes-like object of DER-encoded @@ -1091,7 +1091,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. @@ -1230,7 +1230,7 @@ Get statistics about the SSL sessions created or managed by this context. A dictionary is returned which maps the names of each `piece of information - `_ to their + `_ to their numeric values. For example, here is the total number of hits and misses in the session cache since the context was created:: @@ -1722,7 +1722,7 @@ :meth:`SSLContext.set_ciphers` method. Starting from Python 2.7.9, 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. @@ -1764,5 +1764,5 @@ `RFC 6066: Transport Layer Security (TLS) Extensions `_ D. Eastlake - `IANA TLS: Transport Layer Security (TLS) Parameters `_ + `IANA TLS: Transport Layer Security (TLS) Parameters `_ IANA diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst --- a/Doc/library/tarfile.rst +++ b/Doc/library/tarfile.rst @@ -229,7 +229,7 @@ Documentation of the higher-level archiving facilities provided by the standard :mod:`shutil` module. - `GNU tar manual, Basic Tar Format `_ + `GNU tar manual, Basic Tar Format `_ Documentation for tar archive files, including GNU tar extensions. diff --git a/Doc/library/tkinter.rst b/Doc/library/tkinter.rst --- a/Doc/library/tkinter.rst +++ b/Doc/library/tkinter.rst @@ -26,13 +26,13 @@ `TKDocs `_ Extensive tutorial plus friendlier widget pages for some of the widgets. - `Tkinter reference: a GUI for Python `_ + `Tkinter reference: a GUI for Python `_ On-line reference material. `Tkinter docs from effbot `_ Online reference for tkinter supported by effbot.org. - `Tcl/Tk manual `_ + `Tcl/Tk manual `_ Official manual for the latest tcl/tk version. `Programming Python `_ diff --git a/Doc/library/ttk.rst b/Doc/library/ttk.rst --- a/Doc/library/ttk.rst +++ b/Doc/library/ttk.rst @@ -21,7 +21,7 @@ .. seealso:: - `Tk Widget Styling Support `_ + `Tk Widget Styling Support `_ The document which brought up theming support for Tk diff --git a/Doc/library/urllib2.rst b/Doc/library/urllib2.rst --- a/Doc/library/urllib2.rst +++ b/Doc/library/urllib2.rst @@ -64,7 +64,7 @@ * :meth:`info` --- return the meta-information of the page, such as headers, in the form of an :class:`mimetools.Message` instance - (see `Quick Reference to HTTP Headers `_) + (see `Quick Reference to HTTP Headers `_) * :meth:`getcode` --- return the HTTP status code of the response. diff --git a/Doc/library/urlparse.rst b/Doc/library/urlparse.rst --- a/Doc/library/urlparse.rst +++ b/Doc/library/urlparse.rst @@ -258,7 +258,7 @@ .. doctest:: - >>> urljoin('http://www.cwi.nl/%7Eguido/Python.html', + >>> urljoin('https://www.cwi.nl/%7Eguido/Python.html', ... '//www.python.org/%7Eguido') 'http://www.python.org/%7Eguido' diff --git a/Doc/library/xml.dom.minidom.rst b/Doc/library/xml.dom.minidom.rst --- a/Doc/library/xml.dom.minidom.rst +++ b/Doc/library/xml.dom.minidom.rst @@ -107,7 +107,7 @@ .. seealso:: - `Document Object Model (DOM) Level 1 Specification `_ + `Document Object Model (DOM) Level 1 Specification `_ The W3C recommendation for the DOM supported by :mod:`xml.dom.minidom`. @@ -275,5 +275,5 @@ .. [#] The encoding string included in XML output should conform to the appropriate standards. For example, "UTF-8" is valid, but "UTF8" is - not. See http://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl - and http://www.iana.org/assignments/character-sets/character-sets.xhtml. + not. See https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl + and https://www.iana.org/assignments/character-sets/character-sets.xhtml. diff --git a/Doc/library/xml.dom.rst b/Doc/library/xml.dom.rst --- a/Doc/library/xml.dom.rst +++ b/Doc/library/xml.dom.rst @@ -73,10 +73,10 @@ .. seealso:: - `Document Object Model (DOM) Level 2 Specification `_ + `Document Object Model (DOM) Level 2 Specification `_ The W3C recommendation upon which the Python DOM API is based. - `Document Object Model (DOM) Level 1 Specification `_ + `Document Object Model (DOM) Level 1 Specification `_ The W3C recommendation for the DOM supported by :mod:`xml.dom.minidom`. `Python Language Mapping Specification `_ @@ -127,7 +127,7 @@ .. data:: XML_NAMESPACE The namespace URI associated with the reserved prefix ``xml``, as defined by - `Namespaces in XML `_ (section 4). + `Namespaces in XML `_ (section 4). .. versionadded:: 2.2 @@ -136,7 +136,7 @@ The namespace URI for namespace declarations, as defined by `Document Object Model (DOM) Level 2 Core Specification - `_ (section 1.1.8). + `_ (section 1.1.8). .. versionadded:: 2.2 @@ -144,7 +144,7 @@ .. data:: XHTML_NAMESPACE The URI of the XHTML namespace as defined by `XHTML 1.0: The Extensible - HyperText Markup Language `_ (section 3.1.1). + HyperText Markup Language `_ (section 3.1.1). .. versionadded:: 2.2 @@ -895,7 +895,7 @@ .. exception:: NamespaceErr If an attempt is made to change any object in a way that is not permitted with - regard to the `Namespaces in XML `_ + regard to the `Namespaces in XML `_ recommendation, this exception is raised. 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 @@ -274,7 +274,7 @@ with prefixes in the form ``prefix:sometag`` get expanded to ``{uri}sometag`` where the *prefix* is replaced by the full *URI*. Also, if there is a `default namespace -`__, +`__, that full URI gets prepended to all of the non-prefixed tags. Here is an XML example that incorporates two namespaces, one with the @@ -345,7 +345,7 @@ ------------- This module provides limited support for -`XPath expressions `_ for locating elements in a +`XPath expressions `_ for locating elements in a tree. The goal is to support a small subset of the abbreviated syntax; a full XPath engine is outside the scope of the module. @@ -1032,5 +1032,5 @@ .. [#] The encoding string included in XML output should conform to the appropriate standards. For example, "UTF-8" is valid, but "UTF8" is - not. See http://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl - and http://www.iana.org/assignments/character-sets/character-sets.xhtml. + not. See https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl + and https://www.iana.org/assignments/character-sets/character-sets.xhtml. diff --git a/Doc/library/xmlrpclib.rst b/Doc/library/xmlrpclib.rst --- a/Doc/library/xmlrpclib.rst +++ b/Doc/library/xmlrpclib.rst @@ -334,7 +334,7 @@ Write the XML-RPC base 64 encoding of this binary item to the *out* stream object. The encoded data will have newlines every 76 characters as per - `RFC 2045 section 6.8 `_, + `RFC 2045 section 6.8 `_, which was the de facto standard base64 specification when the XML-RPC spec was written. @@ -614,7 +614,7 @@ .. rubric:: Footnotes .. [#] This approach has been first presented in `a discussion on xmlrpc.com - `_. + `_. .. the link now points to webarchive since the one at .. http://www.xmlrpc.com/discuss/msgReader%241208 is broken (and webadmin .. doesn't reply) diff --git a/Doc/license.rst b/Doc/license.rst --- a/Doc/license.rst +++ b/Doc/license.rst @@ -11,12 +11,12 @@ ======================= Python was created in the early 1990s by Guido van Rossum at Stichting -Mathematisch Centrum (CWI, see http://www.cwi.nl/) in the Netherlands as a +Mathematisch Centrum (CWI, see https://www.cwi.nl/) in the Netherlands as a successor of a language called ABC. Guido remains Python's principal author, although it includes many contributions from others. In 1995, Guido continued his work on Python at the Corporation for National -Research Initiatives (CNRI, see http://www.cnri.reston.va.us/) in Reston, +Research Initiatives (CNRI, see https://www.cnri.reston.va.us/) in Reston, Virginia where he released several versions of the software. In May 2000, Guido and the Python core development team moved to BeOpen.com to @@ -27,7 +27,7 @@ specifically to own Python-related Intellectual Property. Zope Corporation is a sponsoring member of the PSF. -All Python releases are Open Source (see http://opensource.org/ for the Open +All Python releases are Open Source (see https://opensource.org/ for the Open Source Definition). Historically, most, but not all, Python releases have also been GPL-compatible; the table below summarizes the various releases. diff --git a/Doc/tutorial/interactive.rst b/Doc/tutorial/interactive.rst --- a/Doc/tutorial/interactive.rst +++ b/Doc/tutorial/interactive.rst @@ -170,6 +170,6 @@ :ref:`tut-customize`. -.. _GNU Readline: http://tiswww.case.edu/php/chet/readline/rltop.html +.. _GNU Readline: https://tiswww.case.edu/php/chet/readline/rltop.html .. _IPython: http://ipython.scipy.org/ .. _bpython: http://www.bpython-interpreter.org/ diff --git a/Doc/tutorial/whatnow.rst b/Doc/tutorial/whatnow.rst --- a/Doc/tutorial/whatnow.rst +++ b/Doc/tutorial/whatnow.rst @@ -43,7 +43,7 @@ for download. Once you begin releasing code, you can register it here so that others can find it. -* http://code.activestate.com/recipes/langs/python/: The Python Cookbook is a +* https://code.activestate.com/recipes/langs/python/: The Python Cookbook is a sizable collection of code examples, larger modules, and useful scripts. Particularly notable contributions are collected in a book also titled Python Cookbook (O'Reilly & Associates, ISBN 0-596-00797-3.) diff --git a/Doc/using/mac.rst b/Doc/using/mac.rst --- a/Doc/using/mac.rst +++ b/Doc/using/mac.rst @@ -72,7 +72,7 @@ :program:`emacs` among them. If you want a more Mac-like editor, :program:`BBEdit` or :program:`TextWrangler` from Bare Bones Software (see http://www.barebones.com/products/bbedit/index.html) are good choices, as is -:program:`TextMate` (see http://macromates.com/). Other editors include +:program:`TextMate` (see https://macromates.com/). Other editors include :program:`Gvim` (http://macvim.org) and :program:`Aquamacs` (http://aquamacs.org/). @@ -151,9 +151,9 @@ available from https://pythonhosted.org/pyobjc/. The standard Python GUI toolkit is :mod:`Tkinter`, based on the cross-platform -Tk toolkit (http://www.tcl.tk). An Aqua-native version of Tk is bundled with OS +Tk toolkit (https://www.tcl.tk). An Aqua-native version of Tk is bundled with OS X by Apple, and the latest version can be downloaded and installed from -http://www.activestate.com; it can also be built from source. +https://www.activestate.com; it can also be built from source. *wxPython* is another popular cross-platform GUI toolkit that runs natively on Mac OS X. Packages and documentation are available from http://www.wxpython.org. diff --git a/Doc/using/unix.rst b/Doc/using/unix.rst --- a/Doc/using/unix.rst +++ b/Doc/using/unix.rst @@ -55,7 +55,7 @@ On OpenSolaris -------------- -You can get Python from `OpenCSW `_. Various versions +You can get Python from `OpenCSW `_. Various versions of Python are available and can be installed with e.g. ``pkgutil -i python27``. @@ -143,10 +143,10 @@ information on how to code in Python in these editors, look at: * http://www.vim.org/scripts/script.php?script_id=790 -* http://sourceforge.net/projects/python-mode +* https://sourceforge.net/projects/python-mode Geany is an excellent IDE with support for a lot of languages. For more -information, read: http://www.geany.org/ +information, read: https://www.geany.org/ Komodo edit is another extremely good IDE. It also has support for a lot of -languages. For more information, read http://komodoide.com/. +languages. For more information, read https://komodoide.com/. diff --git a/Doc/using/windows.rst b/Doc/using/windows.rst --- a/Doc/using/windows.rst +++ b/Doc/using/windows.rst @@ -31,7 +31,7 @@ following releases), this support was dropped and new releases are just expected to work on the Windows NT family. * `Windows CE `_ is still supported. -* The `Cygwin `_ installer offers to install the Python +* The `Cygwin `_ installer offers to install the Python interpreter as well (cf. `Cygwin package source `_, `Maintainer releases @@ -129,7 +129,7 @@ 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 + https://www.chem.gla.ac.uk/~louis/software/faq/q1.html Setting Environment variables, Louis J. Farrugia 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 @@ -61,7 +61,7 @@ made available by SourceForge for storing source code, tracking bug reports, and managing the queue of patch submissions. To report bugs or submit patches for Python 2.0, use the bug tracking and patch manager tools available from -Python's project page, located at http://sourceforge.net/projects/python/. +Python's project page, located at https://sourceforge.net/projects/python/. The most important of the services now hosted at SourceForge is the Python CVS tree, the version-controlled repository containing the source code for Python. diff --git a/Doc/whatsnew/2.2.rst b/Doc/whatsnew/2.2.rst --- a/Doc/whatsnew/2.2.rst +++ b/Doc/whatsnew/2.2.rst @@ -632,10 +632,10 @@ every square of an $NxN$ chessboard without visiting any square twice). The idea of generators comes from other programming languages, especially Icon -(http://www.cs.arizona.edu/icon/), where the idea of generators is central. In +(https://www.cs.arizona.edu/icon/), where the idea of generators is central. In Icon, every expression and function call behaves like a generator. One example from "An Overview of the Icon Programming Language" at -http://www.cs.arizona.edu/icon/docs/ipd266.htm gives an idea of what this looks +https://www.cs.arizona.edu/icon/docs/ipd266.htm gives an idea of what this looks like:: sentence := "Store it in the neighboring harbor" 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 @@ -218,10 +218,10 @@ every square of an $NxN$ chessboard without visiting any square twice). The idea of generators comes from other programming languages, especially Icon -(http://www.cs.arizona.edu/icon/), where the idea of generators is central. In +(https://www.cs.arizona.edu/icon/), where the idea of generators is central. In Icon, every expression and function call behaves like a generator. One example from "An Overview of the Icon Programming Language" at -http://www.cs.arizona.edu/icon/docs/ipd266.htm gives an idea of what this looks +https://www.cs.arizona.edu/icon/docs/ipd266.htm gives an idea of what this looks like:: sentence := "Store it in the neighboring harbor" 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 @@ -1528,7 +1528,7 @@ * The :mod:`socket` module now supports :const:`AF_NETLINK` sockets on Linux, thanks to a patch from Philippe Biondi. Netlink sockets are a Linux-specific mechanism for communications between a user-space process and kernel code; an - introductory article about them is at http://www.linuxjournal.com/article/7356. + introductory article about them is at https://www.linuxjournal.com/article/7356. In Python code, netlink addresses are represented as a tuple of 2 integers, ``(pid, group_mask)``. @@ -2013,7 +2013,7 @@ >>> For more information about the SQL dialect supported by SQLite, see -http://www.sqlite.org. +https://www.sqlite.org. .. seealso:: @@ -2021,7 +2021,7 @@ http://www.pysqlite.org The pysqlite web page. - http://www.sqlite.org + https://www.sqlite.org The SQLite web page; the documentation describes the syntax and the available data types for the supported SQL dialect. 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 @@ -152,9 +152,9 @@ up different products and import some of the bugs and patches from SourceForge. Four different trackers were examined: `Jira `__, -`Launchpad `__, +`Launchpad `__, `Roundup `__, and -`Trac `__. +`Trac `__. The committee eventually settled on Jira and Roundup as the two candidates. Jira is a commercial product that offers no-cost hosted instances to free-software projects; Roundup @@ -1427,7 +1427,7 @@ :pep:`3141` - A Type Hierarchy for Numbers PEP written by Jeffrey Yasskin. - `Scheme's numerical tower `__, from the Guile manual. + `Scheme's numerical tower `__, from the Guile manual. `Scheme's number datatypes `__ from the R5RS Scheme specification. @@ -2885,7 +2885,7 @@ Bill Janssen made extensive improvements to Python 2.6's support for the Secure Sockets Layer by adding a new module, :mod:`ssl`, that's -built atop the `OpenSSL `__ library. +built atop the `OpenSSL `__ library. This new module provides more control over the protocol negotiated, the X.509 certificates used, and has better support for writing SSL servers (as opposed to clients) in Python. The existing SSL support 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 @@ -1157,7 +1157,7 @@ * The :mod:`ctypes` module now always converts ``None`` to a C NULL pointer for arguments declared as pointers. (Changed by Thomas Heller; :issue:`4606`.) The underlying `libffi library - `__ has been updated to version + `__ has been updated to version 3.0.9, containing various fixes for different platforms. (Updated by Matthias Klose; :issue:`8142`.) @@ -1530,7 +1530,7 @@ *ciphers* argument that's a string listing the encryption algorithms to be allowed; the format of the string is described `in the OpenSSL documentation - `__. + `__. (Added by Antoine Pitrou; :issue:`8322`.) Another change makes the extension load all of OpenSSL's ciphers and @@ -1783,7 +1783,7 @@ To learn more, read the :mod:`ttk` module documentation. You may also wish to read the Tcl/Tk manual page describing the Ttk theme engine, available at -http://www.tcl.tk/man/tcl8.5/TkCmd/ttk_intro.htm. Some +https://www.tcl.tk/man/tcl8.5/TkCmd/ttk_intro.htm. Some screenshots of the Python/Ttk code in use are at http://code.google.com/p/python-ttk/wiki/Screenshots. @@ -2079,7 +2079,7 @@ * The latest release of the GNU Debugger, GDB 7, can be `scripted using Python - `__. + `__. When you begin debugging an executable program P, GDB will look for a file named ``P-gdb.py`` and automatically read it. Dave Malcolm contributed a :file:`python-gdb.py` that adds a number of @@ -2149,7 +2149,7 @@ with *updatepath* set to false. Security issue reported as `CVE-2008-5983 - `_; + `_; discussed in :issue:`5753`, and fixed by Antoine Pitrou. * New macros: the Python header files now define the following macros: diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -231,6 +231,8 @@ Documentation ------------- +- Issue #26736: Used HTTPS for external links in the documentation if possible. + - Issue #6953: Rework the Readline module documentation to group related functions together, and add more details such as what underlying Readline functions and variables are accessed. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat May 7 03:50:41 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 07 May 2016 07:50:41 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2NzM2?= =?utf-8?q?=3A_Used_HTTPS_for_external_links_in_the_documentation_if_possi?= =?utf-8?q?ble=2E?= Message-ID: <20160507075040.89249.3943.2C60CF71@psf.io> https://hg.python.org/cpython/rev/211a9f32dfb9 changeset: 101248:211a9f32dfb9 branch: 3.5 parent: 101245:52924d962027 user: Serhiy Storchaka date: Sat May 07 10:49:07 2016 +0300 summary: Issue #26736: Used HTTPS for external links in the documentation if possible. files: Doc/c-api/init.rst | 2 +- Doc/faq/design.rst | 2 +- Doc/faq/extending.rst | 2 +- Doc/faq/general.rst | 2 +- Doc/faq/gui.rst | 6 ++-- Doc/faq/programming.rst | 16 +++++++------- Doc/faq/windows.rst | 2 +- Doc/howto/functional.rst | 6 ++-- Doc/howto/logging-cookbook.rst | 4 +- Doc/howto/pyporting.rst | 4 +- Doc/howto/unicode.rst | 2 +- Doc/howto/urllib2.rst | 6 ++-- Doc/install/index.rst | 6 ++-- Doc/library/array.rst | 2 +- Doc/library/bisect.rst | 2 +- Doc/library/codecs.rst | 2 +- Doc/library/collections.abc.rst | 2 +- Doc/library/collections.rst | 6 ++-- Doc/library/colorsys.rst | 2 +- Doc/library/datetime.rst | 4 +- Doc/library/difflib.rst | 2 +- Doc/library/hashlib.rst | 2 +- Doc/library/html.entities.rst | 2 +- Doc/library/html.parser.rst | 4 +- Doc/library/http.cookiejar.rst | 2 +- Doc/library/http.rst | 2 +- Doc/library/imaplib.rst | 2 +- Doc/library/ipaddress.rst | 4 +- Doc/library/json.rst | 2 +- Doc/library/mailbox.rst | 6 ++-- Doc/library/mimetypes.rst | 2 +- Doc/library/othergui.rst | 4 +- Doc/library/pyexpat.rst | 4 +- Doc/library/select.rst | 2 +- Doc/library/sqlite3.rst | 6 ++-- Doc/library/ssl.rst | 14 ++++++------ Doc/library/statistics.rst | 2 +- Doc/library/sys.rst | 2 +- Doc/library/tarfile.rst | 2 +- Doc/library/tkinter.rst | 6 ++-- Doc/library/tkinter.ttk.rst | 2 +- Doc/library/unittest.mock-examples.rst | 4 +- Doc/library/unittest.rst | 2 +- Doc/library/urllib.request.rst | 4 +- Doc/library/xml.dom.minidom.rst | 6 ++-- Doc/library/xml.dom.rst | 12 +++++----- Doc/library/xml.etree.elementtree.rst | 8 +++--- Doc/library/xmlrpc.client.rst | 4 +- Doc/license.rst | 6 ++-- Doc/reference/lexical_analysis.rst | 2 +- Doc/tutorial/floatingpoint.rst | 2 +- Doc/tutorial/interactive.rst | 2 +- Doc/tutorial/stdlib.rst | 2 +- Doc/tutorial/whatnow.rst | 4 +- Doc/using/mac.rst | 6 ++-- Doc/using/unix.rst | 8 +++--- Doc/using/windows.rst | 4 +- Doc/whatsnew/2.0.rst | 2 +- Doc/whatsnew/2.2.rst | 4 +- Doc/whatsnew/2.3.rst | 4 +- Doc/whatsnew/2.5.rst | 6 ++-- Doc/whatsnew/2.6.rst | 8 +++--- Doc/whatsnew/2.7.rst | 10 ++++---- Doc/whatsnew/3.2.rst | 10 ++++---- Doc/whatsnew/3.4.rst | 2 +- Misc/NEWS | 2 + 66 files changed, 140 insertions(+), 138 deletions(-) diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -357,7 +357,7 @@ It is recommended that applications embedding the Python interpreter for purposes other than executing a single script pass 0 as *updatepath*, and update :data:`sys.path` themselves if desired. - See `CVE-2008-5983 `_. + See `CVE-2008-5983 `_. On versions before 3.1.3, you can achieve the same effect by manually popping the first :data:`sys.path` element after having called diff --git a/Doc/faq/design.rst b/Doc/faq/design.rst --- a/Doc/faq/design.rst +++ b/Doc/faq/design.rst @@ -368,7 +368,7 @@ Practical answer: -`Cython `_ and `Pyrex `_ +`Cython `_ and `Pyrex `_ compile a modified version of Python with optional annotations into C extensions. `Weave `_ makes it easy to intermingle Python and C code in various ways to increase performance. diff --git a/Doc/faq/extending.rst b/Doc/faq/extending.rst --- a/Doc/faq/extending.rst +++ b/Doc/faq/extending.rst @@ -42,7 +42,7 @@ .. XXX make sure these all work `Cython `_ and its relative `Pyrex -`_ are compilers +`_ are compilers that accept a slightly modified form of Python and generate the corresponding C code. Cython and Pyrex make it possible to write an extension without having to learn Python's C API. diff --git a/Doc/faq/general.rst b/Doc/faq/general.rst --- a/Doc/faq/general.rst +++ b/Doc/faq/general.rst @@ -271,7 +271,7 @@ The Python project's infrastructure is located all over the world. `www.python.org `_ is graciously hosted by `Rackspace -`_, with CDN caching provided by `Fastly +`_, with CDN caching provided by `Fastly `_. `Upfront Systems `_ hosts `bugs.python.org `_. Many other Python services like `the Wiki diff --git a/Doc/faq/gui.rst b/Doc/faq/gui.rst --- a/Doc/faq/gui.rst +++ b/Doc/faq/gui.rst @@ -31,13 +31,13 @@ install (since it comes included with most `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 +`Tcl/Tk home page `_. Tcl/Tk is fully portable to the Mac OS X, Windows, and Unix platforms. wxWidgets --------- -wxWidgets (http://www.wxwidgets.org) is a free, portable GUI class +wxWidgets (https://www.wxwidgets.org) is a free, portable GUI class library written in C++ that provides a native look and feel on a number of platforms, with Windows, Mac OS X, GTK, X11, all listed as current stable targets. Language bindings are available for a number @@ -72,7 +72,7 @@ The `GObject introspection bindings `_ for Python allow you to write GTK+ 3 applications. There is also a -`Python GTK+ 3 Tutorial `_. +`Python GTK+ 3 Tutorial `_. The older PyGtk bindings for the `Gtk+ 2 toolkit `_ have been implemented by James Henstridge; see . diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -28,9 +28,9 @@ PythonWin is a Python IDE that includes a GUI debugger based on pdb. The Pythonwin debugger colors breakpoints and has quite a few cool features such as debugging non-Pythonwin programs. Pythonwin is available as part of the `Python -for Windows Extensions `__ project and +for Windows Extensions `__ project and as a part of the ActivePython distribution (see -http://www.activestate.com/activepython\ ). +https://www.activestate.com/activepython\ ). `Boa Constructor `_ is an IDE and GUI builder that uses wxWidgets. It offers visual frame creation and manipulation, @@ -44,13 +44,13 @@ Pydb is a version of the standard Python debugger pdb, modified for use with DDD (Data Display Debugger), a popular graphical debugger front end. Pydb can be found at http://bashdb.sourceforge.net/pydb/ and DDD can be found at -http://www.gnu.org/software/ddd. +https://www.gnu.org/software/ddd. There are a number of commercial Python IDEs that include graphical debuggers. They include: -* Wing IDE (http://wingware.com/) -* Komodo IDE (http://komodoide.com/) +* Wing IDE (https://wingware.com/) +* Komodo IDE (https://komodoide.com/) * PyCharm (https://www.jetbrains.com/pycharm/) @@ -63,13 +63,13 @@ 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 length, whether variable names are well-formed according to your coding standard, whether declared interfaces are fully implemented, and more. -http://docs.pylint.org/ provides a full list of Pylint's features. +https://docs.pylint.org/ provides a full list of Pylint's features. How can I create a stand-alone binary from a Python script? @@ -1115,7 +1115,7 @@ See the Python Cookbook for a long discussion of many ways to do this: - http://code.activestate.com/recipes/52560/ + https://code.activestate.com/recipes/52560/ If you don't mind reordering the list, sort it and then scan from the end of the list, deleting duplicates as you go:: diff --git a/Doc/faq/windows.rst b/Doc/faq/windows.rst --- a/Doc/faq/windows.rst +++ b/Doc/faq/windows.rst @@ -340,5 +340,5 @@ Simply rename the downloaded file to have the .TGZ extension, and WinZip will be able to handle it. (If your copy of WinZip doesn't, get a newer one from -http://www.winzip.com.) +https://www.winzip.com.) diff --git a/Doc/howto/functional.rst b/Doc/howto/functional.rst --- a/Doc/howto/functional.rst +++ b/Doc/howto/functional.rst @@ -1225,9 +1225,9 @@ Mertz also wrote a 3-part series of articles on functional programming for IBM's DeveloperWorks site; see -`part 1 `__, -`part 2 `__, and -`part 3 `__, +`part 1 `__, +`part 2 `__, and +`part 3 `__, Python documentation 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 @@ -1634,11 +1634,11 @@ Inserting a BOM into messages sent to a SysLogHandler ----------------------------------------------------- -`RFC 5424 `_ requires that a +`RFC 5424 `_ requires that a Unicode message be sent to a syslog daemon as a set of bytes which have the following structure: an optional pure-ASCII component, followed by a UTF-8 Byte Order Mark (BOM), followed by Unicode encoded using UTF-8. (See the `relevant -section of the specification `_.) +section of the specification `_.) In Python 3.1, code was added to :class:`~logging.handlers.SysLogHandler` to insert a BOM into the message, but diff --git a/Doc/howto/pyporting.rst b/Doc/howto/pyporting.rst --- a/Doc/howto/pyporting.rst +++ b/Doc/howto/pyporting.rst @@ -427,10 +427,10 @@ .. _Futurize: http://python-future.org/automatic_conversion.html .. _importlib: https://docs.python.org/3/library/importlib.html#module-importlib .. _importlib2: https://pypi.python.org/pypi/importlib2 -.. _Modernize: http://python-modernize.readthedocs.org/en/latest/ +.. _Modernize: https://python-modernize.readthedocs.org/en/latest/ .. _Porting to Python 3: http://python3porting.com/ .. _Pylint: https://pypi.python.org/pypi/pylint -.. _Python 3 Q & A: http://ncoghlan-devs-python-notes.readthedocs.org/en/latest/python3/questions_and_answers.html +.. _Python 3 Q & A: https://ncoghlan-devs-python-notes.readthedocs.org/en/latest/python3/questions_and_answers.html .. _python-future: http://python-future.org/ .. _python-porting: https://mail.python.org/mailman/listinfo/python-porting diff --git a/Doc/howto/unicode.rst b/Doc/howto/unicode.rst --- a/Doc/howto/unicode.rst +++ b/Doc/howto/unicode.rst @@ -214,7 +214,7 @@ origin and development of Unicode is also available on the site. To help understand the standard, Jukka Korpela has written `an introductory -guide `_ to reading the +guide `_ to reading the Unicode character tables. Another `good introductory article `_ diff --git a/Doc/howto/urllib2.rst b/Doc/howto/urllib2.rst --- a/Doc/howto/urllib2.rst +++ b/Doc/howto/urllib2.rst @@ -122,7 +122,7 @@ Note that other encodings are sometimes required (e.g. for file upload from HTML forms - see `HTML Specification, Form Submission -`_ for more +`_ for more details). If you do not pass the ``data`` argument, urllib uses a **GET** request. One @@ -403,7 +403,7 @@ :class:`http.client.HTTPMessage` instance. Typical headers include 'Content-length', 'Content-type', and so on. See the -`Quick Reference to HTTP Headers `_ +`Quick Reference to HTTP Headers `_ for a useful listing of HTTP headers with brief explanations of their meaning and use. @@ -586,5 +586,5 @@ scripts with a localhost server, I have to prevent urllib from using the proxy. .. [#] urllib opener for SSL proxy (CONNECT method): `ASPN Cookbook Recipe - `_. + `_. diff --git a/Doc/install/index.rst b/Doc/install/index.rst --- a/Doc/install/index.rst +++ b/Doc/install/index.rst @@ -1012,7 +1012,7 @@ .. seealso:: - `C++Builder Compiler `_ + `C++Builder Compiler `_ Information about the free C++ compiler from Borland, including links to the download pages. @@ -1055,7 +1055,7 @@ for Borland's C++, because there is no program to convert the library. First you have to create a list of symbols which the Python DLL exports. (You can find a good program for this task at -http://sourceforge.net/projects/mingw/files/MinGW/Extension/pexports/). +https://sourceforge.net/projects/mingw/files/MinGW/Extension/pexports/). .. I don't understand what the next line means. --amk .. (inclusive the references on data structures.) @@ -1093,7 +1093,7 @@ .. [#] This also means you could replace all existing COFF-libraries with OMF-libraries of the same name. -.. [#] Check http://www.sourceware.org/cygwin/ and http://www.mingw.org/ for more +.. [#] Check https://www.sourceware.org/cygwin/ and http://www.mingw.org/ for more information .. [#] Then you have no POSIX emulation available, but you also don't need diff --git a/Doc/library/array.rst b/Doc/library/array.rst --- a/Doc/library/array.rst +++ b/Doc/library/array.rst @@ -271,7 +271,7 @@ Packing and unpacking of External Data Representation (XDR) data as used in some remote procedure call systems. - `The Numerical Python Documentation `_ + `The Numerical Python Documentation `_ The Numeric Python extension (NumPy) defines another array type; see http://www.numpy.org/ for further information about Numerical Python. diff --git a/Doc/library/bisect.rst b/Doc/library/bisect.rst --- a/Doc/library/bisect.rst +++ b/Doc/library/bisect.rst @@ -60,7 +60,7 @@ .. seealso:: `SortedCollection recipe - `_ that uses + `_ that uses bisect to build a full-featured collection class with straight-forward search methods and support for a key-function. The keys are precomputed to save unnecessary calls to the key function during searches. diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst --- a/Doc/library/codecs.rst +++ b/Doc/library/codecs.rst @@ -1414,7 +1414,7 @@ names (:mod:`http.client` then also transparently sends an IDNA hostname in the :mailheader:`Host` field if it sends that field at all). -.. _section 3.1: http://tools.ietf.org/html/rfc3490#section-3.1 +.. _section 3.1: https://tools.ietf.org/html/rfc3490#section-3.1 When receiving host names from the wire (such as in reverse name lookup), no automatic conversion to Unicode is performed: Applications wishing to present diff --git a/Doc/library/collections.abc.rst b/Doc/library/collections.abc.rst --- a/Doc/library/collections.abc.rst +++ b/Doc/library/collections.abc.rst @@ -263,7 +263,7 @@ .. seealso:: - * `OrderedSet recipe `_ for an + * `OrderedSet recipe `_ for an example built on :class:`MutableSet`. * For more about ABCs, see the :mod:`abc` module and :pep:`3119`. diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst --- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -116,12 +116,12 @@ :meth:`~collections.ChainMap.parents` property. * The `Nested Contexts recipe - `_ has options to control + `_ has options to control whether writes and other mutations apply only to the first mapping or to any mapping in the chain. * A `greatly simplified read-only version of Chainmap - `_. + `_. :class:`ChainMap` Examples and Recipes @@ -957,7 +957,7 @@ .. seealso:: * `Recipe for named tuple abstract base class with a metaclass mix-in - `_ + `_ by Jan Kaliszewski. Besides providing an :term:`abstract base class` for named tuples, it also supports an alternate :term:`metaclass`-based constructor that is convenient for use cases where named tuples are being diff --git a/Doc/library/colorsys.rst b/Doc/library/colorsys.rst --- a/Doc/library/colorsys.rst +++ b/Doc/library/colorsys.rst @@ -21,7 +21,7 @@ More information about color spaces can be found at http://www.poynton.com/ColorFAQ.html and - http://www.cambridgeincolour.com/tutorials/color-spaces.htm. + https://www.cambridgeincolour.com/tutorials/color-spaces.htm. The :mod:`colorsys` module defines the following functions: diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -562,7 +562,7 @@ Return a 3-tuple, (ISO year, ISO week number, ISO weekday). The ISO calendar is a widely used variant of the Gregorian calendar. See - http://www.staff.science.uu.nl/~gent0113/calendar/isocalendar.htm for a good + https://www.staff.science.uu.nl/~gent0113/calendar/isocalendar.htm for a good explanation. The ISO year consists of 52 or 53 full weeks, and where a week starts on a @@ -1708,7 +1708,7 @@ *pytz* library brings the *IANA timezone database* (also known as the Olson database) to Python and its usage is recommended. - `IANA timezone database `_ + `IANA timezone database `_ The Time Zone Database (often called tz or zoneinfo) contains code and data that represent the history of local time for many representative locations around the globe. It is updated periodically to reflect changes diff --git a/Doc/library/difflib.rst b/Doc/library/difflib.rst --- a/Doc/library/difflib.rst +++ b/Doc/library/difflib.rst @@ -613,7 +613,7 @@ work. * `Simple version control recipe - `_ for a small application + `_ for a small application built with :class:`SequenceMatcher`. diff --git a/Doc/library/hashlib.rst b/Doc/library/hashlib.rst --- a/Doc/library/hashlib.rst +++ b/Doc/library/hashlib.rst @@ -232,5 +232,5 @@ Wikipedia article with information on which algorithms have known issues and what that means regarding their use. - http://www.ietf.org/rfc/rfc2898.txt + https://www.ietf.org/rfc/rfc2898.txt PKCS #5: Password-Based Cryptography Specification Version 2.0 diff --git a/Doc/library/html.entities.rst b/Doc/library/html.entities.rst --- a/Doc/library/html.entities.rst +++ b/Doc/library/html.entities.rst @@ -43,4 +43,4 @@ .. rubric:: Footnotes -.. [#] See http://www.w3.org/TR/html5/syntax.html#named-character-references +.. [#] See https://www.w3.org/TR/html5/syntax.html#named-character-references diff --git a/Doc/library/html.parser.rst b/Doc/library/html.parser.rst --- a/Doc/library/html.parser.rst +++ b/Doc/library/html.parser.rst @@ -131,8 +131,8 @@ and quotes in the *value* have been removed, and character and entity references have been replaced. - For instance, for the tag ````, this method - would be called as ``handle_starttag('a', [('href', 'http://www.cwi.nl/')])``. + For instance, for the tag ````, this method + would be called as ``handle_starttag('a', [('href', 'https://www.cwi.nl/')])``. All entity references from :mod:`html.entities` are replaced in the attribute values. diff --git a/Doc/library/http.cookiejar.rst b/Doc/library/http.cookiejar.rst --- a/Doc/library/http.cookiejar.rst +++ b/Doc/library/http.cookiejar.rst @@ -115,7 +115,7 @@ :mod:`http.cookiejar` and :mod:`http.cookies` modules do not depend on each other. - http://curl.haxx.se/rfc/cookie_spec.html + https://curl.haxx.se/rfc/cookie_spec.html The specification of the original Netscape cookie protocol. Though this is still the dominant protocol, the 'Netscape cookie protocol' implemented by all the major browsers (and :mod:`http.cookiejar`) only bears a passing resemblance to diff --git a/Doc/library/http.rst b/Doc/library/http.rst --- a/Doc/library/http.rst +++ b/Doc/library/http.rst @@ -51,7 +51,7 @@ ----------------- Supported, -`IANA-registered `_ +`IANA-registered `_ status codes available in :class:`http.HTTPStatus` are: ======= =================================== ================================================================== diff --git a/Doc/library/imaplib.rst b/Doc/library/imaplib.rst --- a/Doc/library/imaplib.rst +++ b/Doc/library/imaplib.rst @@ -157,7 +157,7 @@ Documents describing the protocol, and sources and binaries for servers implementing it, can all be found at the University of Washington's *IMAP - Information Center* (http://www.washington.edu/imap/). + Information Center* (https://www.washington.edu/imap/). .. _imap4-objects: diff --git a/Doc/library/ipaddress.rst b/Doc/library/ipaddress.rst --- a/Doc/library/ipaddress.rst +++ b/Doc/library/ipaddress.rst @@ -198,8 +198,8 @@ ``True`` if the address is reserved for link-local usage. See :RFC:`3927`. -.. _iana-ipv4-special-registry: http://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml -.. _iana-ipv6-special-registry: http://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml +.. _iana-ipv4-special-registry: https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml +.. _iana-ipv6-special-registry: https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml .. class:: IPv6Address(address) diff --git a/Doc/library/json.rst b/Doc/library/json.rst --- a/Doc/library/json.rst +++ b/Doc/library/json.rst @@ -689,7 +689,7 @@ .. rubric:: Footnotes .. [#rfc-errata] As noted in `the errata for RFC 7159 - `_, + `_, JSON permits literal U+2028 (LINE SEPARATOR) and U+2029 (PARAGRAPH SEPARATOR) characters in strings, whereas JavaScript (as of ECMAScript Edition 5.1) does not. diff --git a/Doc/library/mailbox.rst b/Doc/library/mailbox.rst --- a/Doc/library/mailbox.rst +++ b/Doc/library/mailbox.rst @@ -422,7 +422,7 @@ `maildir man page from qmail `_ The original specification of the format. - `Using maildir format `_ + `Using maildir format `_ Notes on Maildir by its inventor. Includes an updated name-creation scheme and details on "info" semantics. @@ -690,10 +690,10 @@ .. seealso:: - `Format of Version 5 Babyl Files `_ + `Format of Version 5 Babyl Files `_ A specification of the Babyl format. - `Reading Mail with Rmail `_ + `Reading Mail with Rmail `_ The Rmail manual, with some information on Babyl semantics. diff --git a/Doc/library/mimetypes.rst b/Doc/library/mimetypes.rst --- a/Doc/library/mimetypes.rst +++ b/Doc/library/mimetypes.rst @@ -44,7 +44,7 @@ The optional *strict* argument is a flag specifying whether the list of known MIME types is limited to only the official types `registered with IANA - `_. + `_. When *strict* is ``True`` (the default), only the IANA types are supported; when *strict* is ``False``, some additional non-standard but commonly used MIME types are also recognized. diff --git a/Doc/library/othergui.rst b/Doc/library/othergui.rst --- a/Doc/library/othergui.rst +++ b/Doc/library/othergui.rst @@ -31,7 +31,7 @@ book, `GUI Programming with Python: QT Edition `_ by Boudewijn Rempt. The *PyQt4* bindings also have a book, `Rapid GUI Programming - with Python and Qt `_, by Mark + with Python and Qt `_, by Mark Summerfield. `PySide `_ @@ -41,7 +41,7 @@ `wxPython `_ wxPython is a cross-platform GUI toolkit for Python that is built around - the popular `wxWidgets `_ (formerly wxWindows) + the popular `wxWidgets `_ (formerly wxWindows) C++ toolkit. It provides a native look and feel for applications on Windows, Mac OS X, and Unix systems by using each platform's native widgets where ever possible, (GTK+ on Unix-like systems). In addition to diff --git a/Doc/library/pyexpat.rst b/Doc/library/pyexpat.rst --- a/Doc/library/pyexpat.rst +++ b/Doc/library/pyexpat.rst @@ -867,6 +867,6 @@ .. [#] The encoding string included in XML output should conform to the appropriate standards. For example, "UTF-8" is valid, but "UTF8" is - not. See http://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl - and http://www.iana.org/assignments/character-sets/character-sets.xhtml. + not. See https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl + and https://www.iana.org/assignments/character-sets/character-sets.xhtml. diff --git a/Doc/library/select.rst b/Doc/library/select.rst --- a/Doc/library/select.rst +++ b/Doc/library/select.rst @@ -472,7 +472,7 @@ Kevent Objects -------------- -http://www.freebsd.org/cgi/man.cgi?query=kqueue&sektion=2 +https://www.freebsd.org/cgi/man.cgi?query=kqueue&sektion=2 .. attribute:: kevent.ident diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -53,7 +53,7 @@ Usually your SQL operations will need to use values from Python variables. You shouldn't assemble your query using Python's string operations because doing so is insecure; it makes your program vulnerable to an SQL injection attack -(see http://xkcd.com/327/ for humorous example of what can go wrong). +(see https://xkcd.com/327/ for humorous example of what can go wrong). Instead, use the DB-API's parameter substitution. Put ``?`` as a placeholder wherever you want to use a value, and then provide a tuple of values as the @@ -99,7 +99,7 @@ The pysqlite web page -- sqlite3 is developed externally under the name "pysqlite". - http://www.sqlite.org + https://www.sqlite.org The SQLite web page; the documentation describes the syntax and the available data types for the supported SQL dialect. @@ -209,7 +209,7 @@ db = sqlite3.connect('file:path/to/database?mode=ro', uri=True) More information about this feature, including a list of recognized options, can - be found in the `SQLite URI documentation `_. + be found in the `SQLite URI documentation `_. .. versionchanged:: 3.4 Added the *uri* parameter. 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 @@ -769,7 +769,7 @@ ALERT_DESCRIPTION_* Alert Descriptions from :rfc:`5246` and others. The `IANA TLS Alert Registry - `_ + `_ contains this list and references to the RFCs where their meaning is defined. Used as the return value of the callback function in @@ -1174,7 +1174,7 @@ The *capath* string, if present, is the path to a directory containing several CA certificates in PEM format, following an `OpenSSL specific layout - `_. + `_. The *cadata* object, if present, is either an ASCII string of one or more PEM-encoded certificates or a :term:`bytes-like object` of DER-encoded @@ -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. @@ -1369,7 +1369,7 @@ Get statistics about the SSL sessions created or managed by this context. A dictionary is returned which maps the names of each `piece of information - `_ to their + `_ to their numeric values. For example, here is the total number of hits and misses in the session cache since the context was created:: @@ -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. @@ -2061,5 +2061,5 @@ `RFC 6066: Transport Layer Security (TLS) Extensions `_ D. Eastlake - `IANA TLS: Transport Layer Security (TLS) Parameters `_ + `IANA TLS: Transport Layer Security (TLS) Parameters `_ IANA diff --git a/Doc/library/statistics.rst b/Doc/library/statistics.rst --- a/Doc/library/statistics.rst +++ b/Doc/library/statistics.rst @@ -223,7 +223,7 @@ * "Statistics for the Behavioral Sciences", Frederick J Gravetter and Larry B Wallnau (8th Edition). - * Calculating the `median `_. + * Calculating the `median `_. * The `SSMEDIAN `_ diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -474,7 +474,7 @@ additional garbage collector overhead if the object is managed by the garbage collector. - See `recursive sizeof recipe `_ + See `recursive sizeof recipe `_ for an example of using :func:`getsizeof` recursively to find the size of containers and all their contents. diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst --- a/Doc/library/tarfile.rst +++ b/Doc/library/tarfile.rst @@ -238,7 +238,7 @@ Documentation of the higher-level archiving facilities provided by the standard :mod:`shutil` module. - `GNU tar manual, Basic Tar Format `_ + `GNU tar manual, Basic Tar Format `_ Documentation for tar archive files, including GNU tar extensions. diff --git a/Doc/library/tkinter.rst b/Doc/library/tkinter.rst --- a/Doc/library/tkinter.rst +++ b/Doc/library/tkinter.rst @@ -22,13 +22,13 @@ `TKDocs `_ Extensive tutorial plus friendlier widget pages for some of the widgets. - `Tkinter reference: a GUI for Python `_ + `Tkinter reference: a GUI for Python `_ On-line reference material. `Tkinter docs from effbot `_ Online reference for tkinter supported by effbot.org. - `Tcl/Tk manual `_ + `Tcl/Tk manual `_ Official manual for the latest tcl/tk version. `Programming Python `_ @@ -173,7 +173,7 @@ .. seealso:: - `Tcl/Tk 8.6 man pages `_ + `Tcl/Tk 8.6 man pages `_ The Tcl/Tk manual on www.tcl.tk. `ActiveState Tcl Home Page `_ 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 @@ -22,7 +22,7 @@ .. seealso:: - `Tk Widget Styling Support `_ + `Tk Widget Styling Support `_ A document introducing theming support for Tk 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 @@ -1010,7 +1010,7 @@ Sometimes this is inconvenient. For example, `one user `_ is subclassing mock to created a `Twisted adaptor -`_. +`_. Having this applied to attributes too actually causes errors. ``Mock`` (in all its flavours) uses a method called ``_get_child_mock`` to create diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst --- a/Doc/library/unittest.rst +++ b/Doc/library/unittest.rst @@ -67,7 +67,7 @@ a GUI tool for test discovery and execution. This is intended largely for ease of use for those new to unit testing. For production environments it is recommended that tests be driven by a continuous integration system such as - `Buildbot `_, `Jenkins `_ + `Buildbot `_, `Jenkins `_ or `Hudson `_. 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 @@ -67,7 +67,7 @@ * :meth:`~urllib.response.addinfourl.info` --- return the meta-information of the page, such as headers, in the form of an :func:`email.message_from_string` instance (see - `Quick Reference to HTTP Headers `_) + `Quick Reference to HTTP Headers `_) * :meth:`~urllib.response.addinfourl.getcode` -- return the HTTP status code of the response. @@ -1130,7 +1130,7 @@ the returned bytes object to string once it determines or guesses the appropriate encoding. -The following W3C document, http://www.w3.org/International/O-charset\ , lists +The following W3C document, https://www.w3.org/International/O-charset\ , lists the various ways in which a (X)HTML or a XML document could have specified its encoding information. diff --git a/Doc/library/xml.dom.minidom.rst b/Doc/library/xml.dom.minidom.rst --- a/Doc/library/xml.dom.minidom.rst +++ b/Doc/library/xml.dom.minidom.rst @@ -100,7 +100,7 @@ .. seealso:: - `Document Object Model (DOM) Level 1 Specification `_ + `Document Object Model (DOM) Level 1 Specification `_ The W3C recommendation for the DOM supported by :mod:`xml.dom.minidom`. @@ -251,5 +251,5 @@ the appropriate standards. For example, "UTF-8" is valid, but "UTF8" is not valid in an XML document's declaration, even though Python accepts it as an encoding name. - See http://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl - and http://www.iana.org/assignments/character-sets/character-sets.xhtml. + See https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl + and https://www.iana.org/assignments/character-sets/character-sets.xhtml. diff --git a/Doc/library/xml.dom.rst b/Doc/library/xml.dom.rst --- a/Doc/library/xml.dom.rst +++ b/Doc/library/xml.dom.rst @@ -63,10 +63,10 @@ .. seealso:: - `Document Object Model (DOM) Level 2 Specification `_ + `Document Object Model (DOM) Level 2 Specification `_ The W3C recommendation upon which the Python DOM API is based. - `Document Object Model (DOM) Level 1 Specification `_ + `Document Object Model (DOM) Level 1 Specification `_ The W3C recommendation for the DOM supported by :mod:`xml.dom.minidom`. `Python Language Mapping Specification `_ @@ -115,20 +115,20 @@ .. data:: XML_NAMESPACE The namespace URI associated with the reserved prefix ``xml``, as defined by - `Namespaces in XML `_ (section 4). + `Namespaces in XML `_ (section 4). .. data:: XMLNS_NAMESPACE The namespace URI for namespace declarations, as defined by `Document Object Model (DOM) Level 2 Core Specification - `_ (section 1.1.8). + `_ (section 1.1.8). .. data:: XHTML_NAMESPACE The URI of the XHTML namespace as defined by `XHTML 1.0: The Extensible - HyperText Markup Language `_ (section 3.1.1). + HyperText Markup Language `_ (section 3.1.1). In addition, :mod:`xml.dom` contains a base :class:`Node` class and the DOM @@ -874,7 +874,7 @@ .. exception:: NamespaceErr If an attempt is made to change any object in a way that is not permitted with - regard to the `Namespaces in XML `_ + regard to the `Namespaces in XML `_ recommendation, this exception is raised. 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 @@ -292,7 +292,7 @@ with prefixes in the form ``prefix:sometag`` get expanded to ``{uri}sometag`` where the *prefix* is replaced by the full *URI*. Also, if there is a `default namespace -`__, +`__, that full URI gets prepended to all of the non-prefixed tags. Here is an XML example that incorporates two namespaces, one with the @@ -363,7 +363,7 @@ ------------- This module provides limited support for -`XPath expressions `_ for locating elements in a +`XPath expressions `_ for locating elements in a tree. The goal is to support a small subset of the abbreviated syntax; a full XPath engine is outside the scope of the module. @@ -1189,5 +1189,5 @@ .. [#] The encoding string included in XML output should conform to the appropriate standards. For example, "UTF-8" is valid, but "UTF8" is - not. See http://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl - and http://www.iana.org/assignments/character-sets/character-sets.xhtml. + not. See https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl + and https://www.iana.org/assignments/character-sets/character-sets.xhtml. 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 @@ -315,7 +315,7 @@ Write the XML-RPC base 64 encoding of this binary item to the *out* stream object. The encoded data will have newlines every 76 characters as per - `RFC 2045 section 6.8 `_, + `RFC 2045 section 6.8 `_, which was the de facto standard base64 specification when the XML-RPC spec was written. @@ -590,7 +590,7 @@ .. rubric:: Footnotes .. [#] This approach has been first presented in `a discussion on xmlrpc.com - `_. + `_. .. the link now points to webarchive since the one at .. http://www.xmlrpc.com/discuss/msgReader%241208 is broken (and webadmin .. doesn't reply) diff --git a/Doc/license.rst b/Doc/license.rst --- a/Doc/license.rst +++ b/Doc/license.rst @@ -11,12 +11,12 @@ ======================= Python was created in the early 1990s by Guido van Rossum at Stichting -Mathematisch Centrum (CWI, see http://www.cwi.nl/) in the Netherlands as a +Mathematisch Centrum (CWI, see https://www.cwi.nl/) in the Netherlands as a successor of a language called ABC. Guido remains Python's principal author, although it includes many contributions from others. In 1995, Guido continued his work on Python at the Corporation for National -Research Initiatives (CNRI, see http://www.cnri.reston.va.us/) in Reston, +Research Initiatives (CNRI, see https://www.cnri.reston.va.us/) in Reston, Virginia where he released several versions of the software. In May 2000, Guido and the Python core development team moved to BeOpen.com to @@ -27,7 +27,7 @@ specifically to own Python-related Intellectual Property. Zope Corporation is a sponsoring member of the PSF. -All Python releases are Open Source (see http://opensource.org/ for the Open +All Python releases are Open Source (see https://opensource.org/ for the Open Source Definition). Historically, most, but not all, Python releases have also been GPL-compatible; the table below summarizes the various releases. 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 @@ -322,7 +322,7 @@ A non-normative HTML file listing all valid identifier characters for Unicode 4.1 can be found at -http://www.dcl.hpi.uni-potsdam.de/home/loewis/table-3131.html. +https://www.dcl.hpi.uni-potsdam.de/home/loewis/table-3131.html. .. _keywords: diff --git a/Doc/tutorial/floatingpoint.rst b/Doc/tutorial/floatingpoint.rst --- a/Doc/tutorial/floatingpoint.rst +++ b/Doc/tutorial/floatingpoint.rst @@ -155,7 +155,7 @@ If you are a heavy user of floating point operations you should take a look at the Numerical Python package and many other packages for mathematical and -statistical operations supplied by the SciPy project. See . +statistical operations supplied by the SciPy project. See . Python provides tools that may help on those rare occasions when you really *do* want to know the exact value of a float. The diff --git a/Doc/tutorial/interactive.rst b/Doc/tutorial/interactive.rst --- a/Doc/tutorial/interactive.rst +++ b/Doc/tutorial/interactive.rst @@ -49,6 +49,6 @@ bpython_. -.. _GNU Readline: http://tiswww.case.edu/php/chet/readline/rltop.html +.. _GNU Readline: https://tiswww.case.edu/php/chet/readline/rltop.html .. _IPython: http://ipython.scipy.org/ .. _bpython: http://www.bpython-interpreter.org/ diff --git a/Doc/tutorial/stdlib.rst b/Doc/tutorial/stdlib.rst --- a/Doc/tutorial/stdlib.rst +++ b/Doc/tutorial/stdlib.rst @@ -152,7 +152,7 @@ >>> statistics.variance(data) 1.3720238095238095 -The SciPy project has many other modules for numerical +The SciPy project has many other modules for numerical computations. .. _tut-internet-access: diff --git a/Doc/tutorial/whatnow.rst b/Doc/tutorial/whatnow.rst --- a/Doc/tutorial/whatnow.rst +++ b/Doc/tutorial/whatnow.rst @@ -43,7 +43,7 @@ for download. Once you begin releasing code, you can register it here so that others can find it. -* http://code.activestate.com/recipes/langs/python/: The Python Cookbook is a +* https://code.activestate.com/recipes/langs/python/: The Python Cookbook is a sizable collection of code examples, larger modules, and useful scripts. Particularly notable contributions are collected in a book also titled Python Cookbook (O'Reilly & Associates, ISBN 0-596-00797-3.) @@ -51,7 +51,7 @@ * http://www.pyvideo.org collects links to Python-related videos from conferences and user-group meetings. -* http://scipy.org: The Scientific Python project includes modules for fast +* https://scipy.org: The Scientific Python project includes modules for fast array computations and manipulations plus a host of packages for such things as linear algebra, Fourier transforms, non-linear solvers, random number distributions, statistical analysis and the like. diff --git a/Doc/using/mac.rst b/Doc/using/mac.rst --- a/Doc/using/mac.rst +++ b/Doc/using/mac.rst @@ -65,7 +65,7 @@ :program:`emacs` among them. If you want a more Mac-like editor, :program:`BBEdit` or :program:`TextWrangler` from Bare Bones Software (see http://www.barebones.com/products/bbedit/index.html) are good choices, as is -:program:`TextMate` (see http://macromates.com/). Other editors include +:program:`TextMate` (see https://macromates.com/). Other editors include :program:`Gvim` (http://macvim.org) and :program:`Aquamacs` (http://aquamacs.org/). @@ -144,9 +144,9 @@ available from https://pythonhosted.org/pyobjc/. The standard Python GUI toolkit is :mod:`tkinter`, based on the cross-platform -Tk toolkit (http://www.tcl.tk). An Aqua-native version of Tk is bundled with OS +Tk toolkit (https://www.tcl.tk). An Aqua-native version of Tk is bundled with OS X by Apple, and the latest version can be downloaded and installed from -http://www.activestate.com; it can also be built from source. +https://www.activestate.com; it can also be built from source. *wxPython* is another popular cross-platform GUI toolkit that runs natively on Mac OS X. Packages and documentation are available from http://www.wxpython.org. diff --git a/Doc/using/unix.rst b/Doc/using/unix.rst --- a/Doc/using/unix.rst +++ b/Doc/using/unix.rst @@ -55,7 +55,7 @@ On OpenSolaris -------------- -You can get Python from `OpenCSW `_. Various versions +You can get Python from `OpenCSW `_. Various versions of Python are available and can be installed with e.g. ``pkgutil -i python27``. @@ -139,10 +139,10 @@ information on how to code in Python in these editors, look at: * http://www.vim.org/scripts/script.php?script_id=790 -* http://sourceforge.net/projects/python-mode +* https://sourceforge.net/projects/python-mode Geany is an excellent IDE with support for a lot of languages. For more -information, read: http://www.geany.org/ +information, read: https://www.geany.org/ Komodo edit is another extremely good IDE. It also has support for a lot of -languages. For more information, read http://komodoide.com/. +languages. For more information, read https://komodoide.com/. diff --git a/Doc/using/windows.rst b/Doc/using/windows.rst --- a/Doc/using/windows.rst +++ b/Doc/using/windows.rst @@ -245,7 +245,7 @@ Check :pep:`11` for details on all unsupported platforms. * `Windows CE `_ is still supported. -* The `Cygwin `_ installer offers to install the Python +* The `Cygwin `_ installer offers to install the Python interpreter as well (cf. `Cygwin package source `_, `Maintainer releases @@ -364,7 +364,7 @@ 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 + https://www.chem.gla.ac.uk/~louis/software/faq/q1.html Setting Environment variables, Louis J. Farrugia .. _windows-path-mod: 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 @@ -61,7 +61,7 @@ made available by SourceForge for storing source code, tracking bug reports, and managing the queue of patch submissions. To report bugs or submit patches for Python 2.0, use the bug tracking and patch manager tools available from -Python's project page, located at http://sourceforge.net/projects/python/. +Python's project page, located at https://sourceforge.net/projects/python/. The most important of the services now hosted at SourceForge is the Python CVS tree, the version-controlled repository containing the source code for Python. diff --git a/Doc/whatsnew/2.2.rst b/Doc/whatsnew/2.2.rst --- a/Doc/whatsnew/2.2.rst +++ b/Doc/whatsnew/2.2.rst @@ -632,10 +632,10 @@ every square of an $NxN$ chessboard without visiting any square twice). The idea of generators comes from other programming languages, especially Icon -(http://www.cs.arizona.edu/icon/), where the idea of generators is central. In +(https://www.cs.arizona.edu/icon/), where the idea of generators is central. In Icon, every expression and function call behaves like a generator. One example from "An Overview of the Icon Programming Language" at -http://www.cs.arizona.edu/icon/docs/ipd266.htm gives an idea of what this looks +https://www.cs.arizona.edu/icon/docs/ipd266.htm gives an idea of what this looks like:: sentence := "Store it in the neighboring harbor" 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 @@ -218,10 +218,10 @@ every square of an $NxN$ chessboard without visiting any square twice). The idea of generators comes from other programming languages, especially Icon -(http://www.cs.arizona.edu/icon/), where the idea of generators is central. In +(https://www.cs.arizona.edu/icon/), where the idea of generators is central. In Icon, every expression and function call behaves like a generator. One example from "An Overview of the Icon Programming Language" at -http://www.cs.arizona.edu/icon/docs/ipd266.htm gives an idea of what this looks +https://www.cs.arizona.edu/icon/docs/ipd266.htm gives an idea of what this looks like:: sentence := "Store it in the neighboring harbor" 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 @@ -1528,7 +1528,7 @@ * The :mod:`socket` module now supports :const:`AF_NETLINK` sockets on Linux, thanks to a patch from Philippe Biondi. Netlink sockets are a Linux-specific mechanism for communications between a user-space process and kernel code; an - introductory article about them is at http://www.linuxjournal.com/article/7356. + introductory article about them is at https://www.linuxjournal.com/article/7356. In Python code, netlink addresses are represented as a tuple of 2 integers, ``(pid, group_mask)``. @@ -2013,7 +2013,7 @@ >>> For more information about the SQL dialect supported by SQLite, see -http://www.sqlite.org. +https://www.sqlite.org. .. seealso:: @@ -2021,7 +2021,7 @@ http://www.pysqlite.org The pysqlite web page. - http://www.sqlite.org + https://www.sqlite.org The SQLite web page; the documentation describes the syntax and the available data types for the supported SQL dialect. 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 @@ -154,9 +154,9 @@ up different products and import some of the bugs and patches from SourceForge. Four different trackers were examined: `Jira `__, -`Launchpad `__, +`Launchpad `__, `Roundup `__, and -`Trac `__. +`Trac `__. The committee eventually settled on Jira and Roundup as the two candidates. Jira is a commercial product that offers no-cost hosted instances to free-software projects; Roundup @@ -1431,7 +1431,7 @@ :pep:`3141` - A Type Hierarchy for Numbers PEP written by Jeffrey Yasskin. - `Scheme's numerical tower `__, from the Guile manual. + `Scheme's numerical tower `__, from the Guile manual. `Scheme's number datatypes `__ from the R5RS Scheme specification. @@ -2889,7 +2889,7 @@ Bill Janssen made extensive improvements to Python 2.6's support for the Secure Sockets Layer by adding a new module, :mod:`ssl`, that's -built atop the `OpenSSL `__ library. +built atop the `OpenSSL `__ library. This new module provides more control over the protocol negotiated, the X.509 certificates used, and has better support for writing SSL servers (as opposed to clients) in Python. The existing SSL support 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 @@ -1157,7 +1157,7 @@ * The :mod:`ctypes` module now always converts ``None`` to a C NULL pointer for arguments declared as pointers. (Changed by Thomas Heller; :issue:`4606`.) The underlying `libffi library - `__ has been updated to version + `__ has been updated to version 3.0.9, containing various fixes for different platforms. (Updated by Matthias Klose; :issue:`8142`.) @@ -1530,7 +1530,7 @@ *ciphers* argument that's a string listing the encryption algorithms to be allowed; the format of the string is described `in the OpenSSL documentation - `__. + `__. (Added by Antoine Pitrou; :issue:`8322`.) Another change makes the extension load all of OpenSSL's ciphers and @@ -1783,7 +1783,7 @@ To learn more, read the :mod:`ttk` module documentation. You may also wish to read the Tcl/Tk manual page describing the Ttk theme engine, available at -http://www.tcl.tk/man/tcl8.5/TkCmd/ttk_intro.htm. Some +https://www.tcl.tk/man/tcl8.5/TkCmd/ttk_intro.htm. Some screenshots of the Python/Ttk code in use are at http://code.google.com/p/python-ttk/wiki/Screenshots. @@ -2079,7 +2079,7 @@ * The latest release of the GNU Debugger, GDB 7, can be `scripted using Python - `__. + `__. When you begin debugging an executable program P, GDB will look for a file named ``P-gdb.py`` and automatically read it. Dave Malcolm contributed a :file:`python-gdb.py` that adds a number of @@ -2149,7 +2149,7 @@ with *updatepath* set to false. Security issue reported as `CVE-2008-5983 - `_; + `_; discussed in :issue:`5753`, and fixed by Antoine Pitrou. * New macros: the Python header files now define the following macros: 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 @@ -769,8 +769,8 @@ (Contributed by Raymond Hettinger and incorporating design ideas from Jim Baker, Miki Tebeka, and Nick Coghlan; see `recipe 498245 - `_\, `recipe 577479 - `_\, :issue:`10586`, and + `_\, `recipe 577479 + `_\, :issue:`10586`, and :issue:`10593`.) * The :func:`functools.wraps` decorator now adds a :attr:`__wrapped__` attribute @@ -955,7 +955,7 @@ sealed and deposited in a queue for later handling. See `Barrier Synchronization Patterns -`_ for +`_ for more examples of how barriers can be used in parallel computing. Also, there is a simple but thorough explanation of barriers in `The Little Book of Semaphores `_, *section 3.6*. @@ -1618,7 +1618,7 @@ * The :func:`ssl.wrap_socket` constructor function now takes a *ciphers* argument. The *ciphers* string lists the allowed encryption algorithms using the format described in the `OpenSSL documentation - `__. + `__. * When linked against recent versions of OpenSSL, the :mod:`ssl` module now supports the Server Name Indication extension to the TLS protocol, allowing @@ -2559,7 +2559,7 @@ :source:`Mac/BuildScript/README.txt` for details. For users running a 32/64-bit build, there is a known problem with the default Tcl/Tk on Mac OS X 10.6. Accordingly, we recommend installing an updated alternative such as -`ActiveState Tcl/Tk 8.5.9 `_\. +`ActiveState Tcl/Tk 8.5.9 `_\. See https://www.python.org/download/mac/tcltk/ for additional details. Porting to Python 3.2 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 @@ -1410,7 +1410,7 @@ A new boolean parameter to the :func:`~sqlite3.connect` function, *uri*, can be used to indicate that the *database* parameter is a ``uri`` (see the `SQLite -URI documentation `_). (Contributed by poq in +URI documentation `_). (Contributed by poq in :issue:`13773`.) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -418,6 +418,8 @@ Documentation ------------- +- Issue #26736: Used HTTPS for external links in the documentation if possible. + - Issue #6953: Rework the Readline module documentation to group related functions together, and add more details such as what underlying Readline functions and variables are accessed. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat May 7 03:50:41 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 07 May 2016 07:50:41 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326736=3A_Used_HTTPS_for_external_links_in_the_d?= =?utf-8?q?ocumentation_if_possible=2E?= Message-ID: <20160507075041.88908.29314.AA469DB3@psf.io> https://hg.python.org/cpython/rev/3ceb54a49387 changeset: 101249:3ceb54a49387 parent: 101246:ea9d69a4d0fe parent: 101248:211a9f32dfb9 user: Serhiy Storchaka date: Sat May 07 10:49:58 2016 +0300 summary: Issue #26736: Used HTTPS for external links in the documentation if possible. files: Doc/c-api/init.rst | 2 +- Doc/faq/design.rst | 2 +- Doc/faq/extending.rst | 2 +- Doc/faq/general.rst | 2 +- Doc/faq/gui.rst | 6 ++-- Doc/faq/programming.rst | 16 +++++++------- Doc/faq/windows.rst | 2 +- Doc/howto/functional.rst | 6 ++-- Doc/howto/logging-cookbook.rst | 4 +- Doc/howto/pyporting.rst | 4 +- Doc/howto/unicode.rst | 2 +- Doc/howto/urllib2.rst | 6 ++-- Doc/install/index.rst | 6 ++-- Doc/library/array.rst | 2 +- Doc/library/bisect.rst | 2 +- Doc/library/codecs.rst | 2 +- Doc/library/collections.abc.rst | 2 +- Doc/library/collections.rst | 6 ++-- Doc/library/colorsys.rst | 2 +- Doc/library/datetime.rst | 4 +- Doc/library/difflib.rst | 2 +- Doc/library/hashlib.rst | 2 +- Doc/library/html.entities.rst | 2 +- Doc/library/html.parser.rst | 4 +- Doc/library/http.cookiejar.rst | 2 +- Doc/library/http.rst | 2 +- Doc/library/imaplib.rst | 2 +- Doc/library/ipaddress.rst | 4 +- Doc/library/json.rst | 2 +- Doc/library/mailbox.rst | 6 ++-- Doc/library/mimetypes.rst | 2 +- Doc/library/othergui.rst | 4 +- Doc/library/pyexpat.rst | 4 +- Doc/library/select.rst | 2 +- Doc/library/sqlite3.rst | 6 ++-- Doc/library/ssl.rst | 14 ++++++------ Doc/library/statistics.rst | 2 +- Doc/library/sys.rst | 2 +- Doc/library/tarfile.rst | 2 +- Doc/library/tkinter.rst | 6 ++-- Doc/library/tkinter.ttk.rst | 2 +- Doc/library/unittest.mock-examples.rst | 4 +- Doc/library/unittest.rst | 2 +- Doc/library/urllib.request.rst | 4 +- Doc/library/xml.dom.minidom.rst | 6 ++-- Doc/library/xml.dom.rst | 12 +++++----- Doc/library/xml.etree.elementtree.rst | 8 +++--- Doc/library/xmlrpc.client.rst | 4 +- Doc/license.rst | 6 ++-- Doc/reference/lexical_analysis.rst | 2 +- Doc/tutorial/floatingpoint.rst | 2 +- Doc/tutorial/interactive.rst | 2 +- Doc/tutorial/stdlib.rst | 2 +- Doc/tutorial/whatnow.rst | 4 +- Doc/using/mac.rst | 6 ++-- Doc/using/unix.rst | 8 +++--- Doc/using/windows.rst | 4 +- Doc/whatsnew/2.0.rst | 2 +- Doc/whatsnew/2.2.rst | 4 +- Doc/whatsnew/2.3.rst | 4 +- Doc/whatsnew/2.5.rst | 6 ++-- Doc/whatsnew/2.6.rst | 8 +++--- Doc/whatsnew/2.7.rst | 10 ++++---- Doc/whatsnew/3.2.rst | 10 ++++---- Doc/whatsnew/3.4.rst | 2 +- Misc/NEWS | 2 + 66 files changed, 140 insertions(+), 138 deletions(-) diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -366,7 +366,7 @@ It is recommended that applications embedding the Python interpreter for purposes other than executing a single script pass 0 as *updatepath*, and update :data:`sys.path` themselves if desired. - See `CVE-2008-5983 `_. + See `CVE-2008-5983 `_. On versions before 3.1.3, you can achieve the same effect by manually popping the first :data:`sys.path` element after having called diff --git a/Doc/faq/design.rst b/Doc/faq/design.rst --- a/Doc/faq/design.rst +++ b/Doc/faq/design.rst @@ -368,7 +368,7 @@ Practical answer: -`Cython `_ and `Pyrex `_ +`Cython `_ and `Pyrex `_ compile a modified version of Python with optional annotations into C extensions. `Weave `_ makes it easy to intermingle Python and C code in various ways to increase performance. diff --git a/Doc/faq/extending.rst b/Doc/faq/extending.rst --- a/Doc/faq/extending.rst +++ b/Doc/faq/extending.rst @@ -42,7 +42,7 @@ .. XXX make sure these all work `Cython `_ and its relative `Pyrex -`_ are compilers +`_ are compilers that accept a slightly modified form of Python and generate the corresponding C code. Cython and Pyrex make it possible to write an extension without having to learn Python's C API. diff --git a/Doc/faq/general.rst b/Doc/faq/general.rst --- a/Doc/faq/general.rst +++ b/Doc/faq/general.rst @@ -271,7 +271,7 @@ The Python project's infrastructure is located all over the world. `www.python.org `_ is graciously hosted by `Rackspace -`_, with CDN caching provided by `Fastly +`_, with CDN caching provided by `Fastly `_. `Upfront Systems `_ hosts `bugs.python.org `_. Many other Python services like `the Wiki diff --git a/Doc/faq/gui.rst b/Doc/faq/gui.rst --- a/Doc/faq/gui.rst +++ b/Doc/faq/gui.rst @@ -31,13 +31,13 @@ install (since it comes included with most `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 +`Tcl/Tk home page `_. Tcl/Tk is fully portable to the Mac OS X, Windows, and Unix platforms. wxWidgets --------- -wxWidgets (http://www.wxwidgets.org) is a free, portable GUI class +wxWidgets (https://www.wxwidgets.org) is a free, portable GUI class library written in C++ that provides a native look and feel on a number of platforms, with Windows, Mac OS X, GTK, X11, all listed as current stable targets. Language bindings are available for a number @@ -72,7 +72,7 @@ The `GObject introspection bindings `_ for Python allow you to write GTK+ 3 applications. There is also a -`Python GTK+ 3 Tutorial `_. +`Python GTK+ 3 Tutorial `_. The older PyGtk bindings for the `Gtk+ 2 toolkit `_ have been implemented by James Henstridge; see . diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -28,9 +28,9 @@ PythonWin is a Python IDE that includes a GUI debugger based on pdb. The Pythonwin debugger colors breakpoints and has quite a few cool features such as debugging non-Pythonwin programs. Pythonwin is available as part of the `Python -for Windows Extensions `__ project and +for Windows Extensions `__ project and as a part of the ActivePython distribution (see -http://www.activestate.com/activepython\ ). +https://www.activestate.com/activepython\ ). `Boa Constructor `_ is an IDE and GUI builder that uses wxWidgets. It offers visual frame creation and manipulation, @@ -44,13 +44,13 @@ Pydb is a version of the standard Python debugger pdb, modified for use with DDD (Data Display Debugger), a popular graphical debugger front end. Pydb can be found at http://bashdb.sourceforge.net/pydb/ and DDD can be found at -http://www.gnu.org/software/ddd. +https://www.gnu.org/software/ddd. There are a number of commercial Python IDEs that include graphical debuggers. They include: -* Wing IDE (http://wingware.com/) -* Komodo IDE (http://komodoide.com/) +* Wing IDE (https://wingware.com/) +* Komodo IDE (https://komodoide.com/) * PyCharm (https://www.jetbrains.com/pycharm/) @@ -63,13 +63,13 @@ 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 length, whether variable names are well-formed according to your coding standard, whether declared interfaces are fully implemented, and more. -http://docs.pylint.org/ provides a full list of Pylint's features. +https://docs.pylint.org/ provides a full list of Pylint's features. How can I create a stand-alone binary from a Python script? @@ -1116,7 +1116,7 @@ See the Python Cookbook for a long discussion of many ways to do this: - http://code.activestate.com/recipes/52560/ + https://code.activestate.com/recipes/52560/ If you don't mind reordering the list, sort it and then scan from the end of the list, deleting duplicates as you go:: diff --git a/Doc/faq/windows.rst b/Doc/faq/windows.rst --- a/Doc/faq/windows.rst +++ b/Doc/faq/windows.rst @@ -340,5 +340,5 @@ Simply rename the downloaded file to have the .TGZ extension, and WinZip will be able to handle it. (If your copy of WinZip doesn't, get a newer one from -http://www.winzip.com.) +https://www.winzip.com.) diff --git a/Doc/howto/functional.rst b/Doc/howto/functional.rst --- a/Doc/howto/functional.rst +++ b/Doc/howto/functional.rst @@ -1225,9 +1225,9 @@ Mertz also wrote a 3-part series of articles on functional programming for IBM's DeveloperWorks site; see -`part 1 `__, -`part 2 `__, and -`part 3 `__, +`part 1 `__, +`part 2 `__, and +`part 3 `__, Python documentation 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 @@ -1634,11 +1634,11 @@ Inserting a BOM into messages sent to a SysLogHandler ----------------------------------------------------- -`RFC 5424 `_ requires that a +`RFC 5424 `_ requires that a Unicode message be sent to a syslog daemon as a set of bytes which have the following structure: an optional pure-ASCII component, followed by a UTF-8 Byte Order Mark (BOM), followed by Unicode encoded using UTF-8. (See the `relevant -section of the specification `_.) +section of the specification `_.) In Python 3.1, code was added to :class:`~logging.handlers.SysLogHandler` to insert a BOM into the message, but diff --git a/Doc/howto/pyporting.rst b/Doc/howto/pyporting.rst --- a/Doc/howto/pyporting.rst +++ b/Doc/howto/pyporting.rst @@ -427,10 +427,10 @@ .. _Futurize: http://python-future.org/automatic_conversion.html .. _importlib: https://docs.python.org/3/library/importlib.html#module-importlib .. _importlib2: https://pypi.python.org/pypi/importlib2 -.. _Modernize: http://python-modernize.readthedocs.org/en/latest/ +.. _Modernize: https://python-modernize.readthedocs.org/en/latest/ .. _Porting to Python 3: http://python3porting.com/ .. _Pylint: https://pypi.python.org/pypi/pylint -.. _Python 3 Q & A: http://ncoghlan-devs-python-notes.readthedocs.org/en/latest/python3/questions_and_answers.html +.. _Python 3 Q & A: https://ncoghlan-devs-python-notes.readthedocs.org/en/latest/python3/questions_and_answers.html .. _python-future: http://python-future.org/ .. _python-porting: https://mail.python.org/mailman/listinfo/python-porting diff --git a/Doc/howto/unicode.rst b/Doc/howto/unicode.rst --- a/Doc/howto/unicode.rst +++ b/Doc/howto/unicode.rst @@ -214,7 +214,7 @@ origin and development of Unicode is also available on the site. To help understand the standard, Jukka Korpela has written `an introductory -guide `_ to reading the +guide `_ to reading the Unicode character tables. Another `good introductory article `_ diff --git a/Doc/howto/urllib2.rst b/Doc/howto/urllib2.rst --- a/Doc/howto/urllib2.rst +++ b/Doc/howto/urllib2.rst @@ -122,7 +122,7 @@ Note that other encodings are sometimes required (e.g. for file upload from HTML forms - see `HTML Specification, Form Submission -`_ for more +`_ for more details). If you do not pass the ``data`` argument, urllib uses a **GET** request. One @@ -403,7 +403,7 @@ :class:`http.client.HTTPMessage` instance. Typical headers include 'Content-length', 'Content-type', and so on. See the -`Quick Reference to HTTP Headers `_ +`Quick Reference to HTTP Headers `_ for a useful listing of HTTP headers with brief explanations of their meaning and use. @@ -586,5 +586,5 @@ scripts with a localhost server, I have to prevent urllib from using the proxy. .. [#] urllib opener for SSL proxy (CONNECT method): `ASPN Cookbook Recipe - `_. + `_. diff --git a/Doc/install/index.rst b/Doc/install/index.rst --- a/Doc/install/index.rst +++ b/Doc/install/index.rst @@ -1012,7 +1012,7 @@ .. seealso:: - `C++Builder Compiler `_ + `C++Builder Compiler `_ Information about the free C++ compiler from Borland, including links to the download pages. @@ -1055,7 +1055,7 @@ for Borland's C++, because there is no program to convert the library. First you have to create a list of symbols which the Python DLL exports. (You can find a good program for this task at -http://sourceforge.net/projects/mingw/files/MinGW/Extension/pexports/). +https://sourceforge.net/projects/mingw/files/MinGW/Extension/pexports/). .. I don't understand what the next line means. --amk .. (inclusive the references on data structures.) @@ -1093,7 +1093,7 @@ .. [#] This also means you could replace all existing COFF-libraries with OMF-libraries of the same name. -.. [#] Check http://www.sourceware.org/cygwin/ and http://www.mingw.org/ for more +.. [#] Check https://www.sourceware.org/cygwin/ and http://www.mingw.org/ for more information .. [#] Then you have no POSIX emulation available, but you also don't need diff --git a/Doc/library/array.rst b/Doc/library/array.rst --- a/Doc/library/array.rst +++ b/Doc/library/array.rst @@ -271,7 +271,7 @@ Packing and unpacking of External Data Representation (XDR) data as used in some remote procedure call systems. - `The Numerical Python Documentation `_ + `The Numerical Python Documentation `_ The Numeric Python extension (NumPy) defines another array type; see http://www.numpy.org/ for further information about Numerical Python. diff --git a/Doc/library/bisect.rst b/Doc/library/bisect.rst --- a/Doc/library/bisect.rst +++ b/Doc/library/bisect.rst @@ -60,7 +60,7 @@ .. seealso:: `SortedCollection recipe - `_ that uses + `_ that uses bisect to build a full-featured collection class with straight-forward search methods and support for a key-function. The keys are precomputed to save unnecessary calls to the key function during searches. diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst --- a/Doc/library/codecs.rst +++ b/Doc/library/codecs.rst @@ -1414,7 +1414,7 @@ names (:mod:`http.client` then also transparently sends an IDNA hostname in the :mailheader:`Host` field if it sends that field at all). -.. _section 3.1: http://tools.ietf.org/html/rfc3490#section-3.1 +.. _section 3.1: https://tools.ietf.org/html/rfc3490#section-3.1 When receiving host names from the wire (such as in reverse name lookup), no automatic conversion to Unicode is performed: Applications wishing to present diff --git a/Doc/library/collections.abc.rst b/Doc/library/collections.abc.rst --- a/Doc/library/collections.abc.rst +++ b/Doc/library/collections.abc.rst @@ -270,7 +270,7 @@ .. seealso:: - * `OrderedSet recipe `_ for an + * `OrderedSet recipe `_ for an example built on :class:`MutableSet`. * For more about ABCs, see the :mod:`abc` module and :pep:`3119`. diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst --- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -116,12 +116,12 @@ :meth:`~collections.ChainMap.parents` property. * The `Nested Contexts recipe - `_ has options to control + `_ has options to control whether writes and other mutations apply only to the first mapping or to any mapping in the chain. * A `greatly simplified read-only version of Chainmap - `_. + `_. :class:`ChainMap` Examples and Recipes @@ -957,7 +957,7 @@ .. seealso:: * `Recipe for named tuple abstract base class with a metaclass mix-in - `_ + `_ by Jan Kaliszewski. Besides providing an :term:`abstract base class` for named tuples, it also supports an alternate :term:`metaclass`-based constructor that is convenient for use cases where named tuples are being diff --git a/Doc/library/colorsys.rst b/Doc/library/colorsys.rst --- a/Doc/library/colorsys.rst +++ b/Doc/library/colorsys.rst @@ -21,7 +21,7 @@ More information about color spaces can be found at http://www.poynton.com/ColorFAQ.html and - http://www.cambridgeincolour.com/tutorials/color-spaces.htm. + https://www.cambridgeincolour.com/tutorials/color-spaces.htm. The :mod:`colorsys` module defines the following functions: diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -562,7 +562,7 @@ Return a 3-tuple, (ISO year, ISO week number, ISO weekday). The ISO calendar is a widely used variant of the Gregorian calendar. See - http://www.staff.science.uu.nl/~gent0113/calendar/isocalendar.htm for a good + https://www.staff.science.uu.nl/~gent0113/calendar/isocalendar.htm for a good explanation. The ISO year consists of 52 or 53 full weeks, and where a week starts on a @@ -1775,7 +1775,7 @@ *pytz* library brings the *IANA timezone database* (also known as the Olson database) to Python and its usage is recommended. - `IANA timezone database `_ + `IANA timezone database `_ The Time Zone Database (often called tz or zoneinfo) contains code and data that represent the history of local time for many representative locations around the globe. It is updated periodically to reflect changes diff --git a/Doc/library/difflib.rst b/Doc/library/difflib.rst --- a/Doc/library/difflib.rst +++ b/Doc/library/difflib.rst @@ -613,7 +613,7 @@ work. * `Simple version control recipe - `_ for a small application + `_ for a small application built with :class:`SequenceMatcher`. diff --git a/Doc/library/hashlib.rst b/Doc/library/hashlib.rst --- a/Doc/library/hashlib.rst +++ b/Doc/library/hashlib.rst @@ -232,5 +232,5 @@ Wikipedia article with information on which algorithms have known issues and what that means regarding their use. - http://www.ietf.org/rfc/rfc2898.txt + https://www.ietf.org/rfc/rfc2898.txt PKCS #5: Password-Based Cryptography Specification Version 2.0 diff --git a/Doc/library/html.entities.rst b/Doc/library/html.entities.rst --- a/Doc/library/html.entities.rst +++ b/Doc/library/html.entities.rst @@ -43,4 +43,4 @@ .. rubric:: Footnotes -.. [#] See http://www.w3.org/TR/html5/syntax.html#named-character-references +.. [#] See https://www.w3.org/TR/html5/syntax.html#named-character-references diff --git a/Doc/library/html.parser.rst b/Doc/library/html.parser.rst --- a/Doc/library/html.parser.rst +++ b/Doc/library/html.parser.rst @@ -131,8 +131,8 @@ and quotes in the *value* have been removed, and character and entity references have been replaced. - For instance, for the tag ````, this method - would be called as ``handle_starttag('a', [('href', 'http://www.cwi.nl/')])``. + For instance, for the tag ````, this method + would be called as ``handle_starttag('a', [('href', 'https://www.cwi.nl/')])``. All entity references from :mod:`html.entities` are replaced in the attribute values. diff --git a/Doc/library/http.cookiejar.rst b/Doc/library/http.cookiejar.rst --- a/Doc/library/http.cookiejar.rst +++ b/Doc/library/http.cookiejar.rst @@ -115,7 +115,7 @@ :mod:`http.cookiejar` and :mod:`http.cookies` modules do not depend on each other. - http://curl.haxx.se/rfc/cookie_spec.html + https://curl.haxx.se/rfc/cookie_spec.html The specification of the original Netscape cookie protocol. Though this is still the dominant protocol, the 'Netscape cookie protocol' implemented by all the major browsers (and :mod:`http.cookiejar`) only bears a passing resemblance to diff --git a/Doc/library/http.rst b/Doc/library/http.rst --- a/Doc/library/http.rst +++ b/Doc/library/http.rst @@ -51,7 +51,7 @@ ----------------- Supported, -`IANA-registered `_ +`IANA-registered `_ status codes available in :class:`http.HTTPStatus` are: ======= =================================== ================================================================== diff --git a/Doc/library/imaplib.rst b/Doc/library/imaplib.rst --- a/Doc/library/imaplib.rst +++ b/Doc/library/imaplib.rst @@ -157,7 +157,7 @@ Documents describing the protocol, and sources and binaries for servers implementing it, can all be found at the University of Washington's *IMAP - Information Center* (http://www.washington.edu/imap/). + Information Center* (https://www.washington.edu/imap/). .. _imap4-objects: diff --git a/Doc/library/ipaddress.rst b/Doc/library/ipaddress.rst --- a/Doc/library/ipaddress.rst +++ b/Doc/library/ipaddress.rst @@ -198,8 +198,8 @@ ``True`` if the address is reserved for link-local usage. See :RFC:`3927`. -.. _iana-ipv4-special-registry: http://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml -.. _iana-ipv6-special-registry: http://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml +.. _iana-ipv4-special-registry: https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml +.. _iana-ipv6-special-registry: https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml .. class:: IPv6Address(address) diff --git a/Doc/library/json.rst b/Doc/library/json.rst --- a/Doc/library/json.rst +++ b/Doc/library/json.rst @@ -689,7 +689,7 @@ .. rubric:: Footnotes .. [#rfc-errata] As noted in `the errata for RFC 7159 - `_, + `_, JSON permits literal U+2028 (LINE SEPARATOR) and U+2029 (PARAGRAPH SEPARATOR) characters in strings, whereas JavaScript (as of ECMAScript Edition 5.1) does not. diff --git a/Doc/library/mailbox.rst b/Doc/library/mailbox.rst --- a/Doc/library/mailbox.rst +++ b/Doc/library/mailbox.rst @@ -422,7 +422,7 @@ `maildir man page from qmail `_ The original specification of the format. - `Using maildir format `_ + `Using maildir format `_ Notes on Maildir by its inventor. Includes an updated name-creation scheme and details on "info" semantics. @@ -690,10 +690,10 @@ .. seealso:: - `Format of Version 5 Babyl Files `_ + `Format of Version 5 Babyl Files `_ A specification of the Babyl format. - `Reading Mail with Rmail `_ + `Reading Mail with Rmail `_ The Rmail manual, with some information on Babyl semantics. diff --git a/Doc/library/mimetypes.rst b/Doc/library/mimetypes.rst --- a/Doc/library/mimetypes.rst +++ b/Doc/library/mimetypes.rst @@ -44,7 +44,7 @@ The optional *strict* argument is a flag specifying whether the list of known MIME types is limited to only the official types `registered with IANA - `_. + `_. When *strict* is ``True`` (the default), only the IANA types are supported; when *strict* is ``False``, some additional non-standard but commonly used MIME types are also recognized. diff --git a/Doc/library/othergui.rst b/Doc/library/othergui.rst --- a/Doc/library/othergui.rst +++ b/Doc/library/othergui.rst @@ -31,7 +31,7 @@ book, `GUI Programming with Python: QT Edition `_ by Boudewijn Rempt. The *PyQt4* bindings also have a book, `Rapid GUI Programming - with Python and Qt `_, by Mark + with Python and Qt `_, by Mark Summerfield. `PySide `_ @@ -41,7 +41,7 @@ `wxPython `_ wxPython is a cross-platform GUI toolkit for Python that is built around - the popular `wxWidgets `_ (formerly wxWindows) + the popular `wxWidgets `_ (formerly wxWindows) C++ toolkit. It provides a native look and feel for applications on Windows, Mac OS X, and Unix systems by using each platform's native widgets where ever possible, (GTK+ on Unix-like systems). In addition to diff --git a/Doc/library/pyexpat.rst b/Doc/library/pyexpat.rst --- a/Doc/library/pyexpat.rst +++ b/Doc/library/pyexpat.rst @@ -867,6 +867,6 @@ .. [#] The encoding string included in XML output should conform to the appropriate standards. For example, "UTF-8" is valid, but "UTF8" is - not. See http://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl - and http://www.iana.org/assignments/character-sets/character-sets.xhtml. + not. See https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl + and https://www.iana.org/assignments/character-sets/character-sets.xhtml. diff --git a/Doc/library/select.rst b/Doc/library/select.rst --- a/Doc/library/select.rst +++ b/Doc/library/select.rst @@ -472,7 +472,7 @@ Kevent Objects -------------- -http://www.freebsd.org/cgi/man.cgi?query=kqueue&sektion=2 +https://www.freebsd.org/cgi/man.cgi?query=kqueue&sektion=2 .. attribute:: kevent.ident diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -53,7 +53,7 @@ Usually your SQL operations will need to use values from Python variables. You shouldn't assemble your query using Python's string operations because doing so is insecure; it makes your program vulnerable to an SQL injection attack -(see http://xkcd.com/327/ for humorous example of what can go wrong). +(see https://xkcd.com/327/ for humorous example of what can go wrong). Instead, use the DB-API's parameter substitution. Put ``?`` as a placeholder wherever you want to use a value, and then provide a tuple of values as the @@ -99,7 +99,7 @@ The pysqlite web page -- sqlite3 is developed externally under the name "pysqlite". - http://www.sqlite.org + https://www.sqlite.org The SQLite web page; the documentation describes the syntax and the available data types for the supported SQL dialect. @@ -209,7 +209,7 @@ db = sqlite3.connect('file:path/to/database?mode=ro', uri=True) More information about this feature, including a list of recognized options, can - be found in the `SQLite URI documentation `_. + be found in the `SQLite URI documentation `_. .. versionchanged:: 3.4 Added the *uri* parameter. 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 @@ -769,7 +769,7 @@ ALERT_DESCRIPTION_* Alert Descriptions from :rfc:`5246` and others. The `IANA TLS Alert Registry - `_ + `_ contains this list and references to the RFCs where their meaning is defined. Used as the return value of the callback function in @@ -1174,7 +1174,7 @@ The *capath* string, if present, is the path to a directory containing several CA certificates in PEM format, following an `OpenSSL specific layout - `_. + `_. The *cadata* object, if present, is either an ASCII string of one or more PEM-encoded certificates or a :term:`bytes-like object` of DER-encoded @@ -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. @@ -1369,7 +1369,7 @@ Get statistics about the SSL sessions created or managed by this context. A dictionary is returned which maps the names of each `piece of information - `_ to their + `_ to their numeric values. For example, here is the total number of hits and misses in the session cache since the context was created:: @@ -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. @@ -2061,5 +2061,5 @@ `RFC 6066: Transport Layer Security (TLS) Extensions `_ D. Eastlake - `IANA TLS: Transport Layer Security (TLS) Parameters `_ + `IANA TLS: Transport Layer Security (TLS) Parameters `_ IANA diff --git a/Doc/library/statistics.rst b/Doc/library/statistics.rst --- a/Doc/library/statistics.rst +++ b/Doc/library/statistics.rst @@ -223,7 +223,7 @@ * "Statistics for the Behavioral Sciences", Frederick J Gravetter and Larry B Wallnau (8th Edition). - * Calculating the `median `_. + * Calculating the `median `_. * The `SSMEDIAN `_ diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -479,7 +479,7 @@ additional garbage collector overhead if the object is managed by the garbage collector. - See `recursive sizeof recipe `_ + See `recursive sizeof recipe `_ for an example of using :func:`getsizeof` recursively to find the size of containers and all their contents. diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst --- a/Doc/library/tarfile.rst +++ b/Doc/library/tarfile.rst @@ -238,7 +238,7 @@ Documentation of the higher-level archiving facilities provided by the standard :mod:`shutil` module. - `GNU tar manual, Basic Tar Format `_ + `GNU tar manual, Basic Tar Format `_ Documentation for tar archive files, including GNU tar extensions. diff --git a/Doc/library/tkinter.rst b/Doc/library/tkinter.rst --- a/Doc/library/tkinter.rst +++ b/Doc/library/tkinter.rst @@ -22,13 +22,13 @@ `TKDocs `_ Extensive tutorial plus friendlier widget pages for some of the widgets. - `Tkinter reference: a GUI for Python `_ + `Tkinter reference: a GUI for Python `_ On-line reference material. `Tkinter docs from effbot `_ Online reference for tkinter supported by effbot.org. - `Tcl/Tk manual `_ + `Tcl/Tk manual `_ Official manual for the latest tcl/tk version. `Programming Python `_ @@ -173,7 +173,7 @@ .. seealso:: - `Tcl/Tk 8.6 man pages `_ + `Tcl/Tk 8.6 man pages `_ The Tcl/Tk manual on www.tcl.tk. `ActiveState Tcl Home Page `_ 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 @@ -22,7 +22,7 @@ .. seealso:: - `Tk Widget Styling Support `_ + `Tk Widget Styling Support `_ A document introducing theming support for Tk 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 @@ -1010,7 +1010,7 @@ Sometimes this is inconvenient. For example, `one user `_ is subclassing mock to created a `Twisted adaptor -`_. +`_. Having this applied to attributes too actually causes errors. ``Mock`` (in all its flavours) uses a method called ``_get_child_mock`` to create diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst --- a/Doc/library/unittest.rst +++ b/Doc/library/unittest.rst @@ -67,7 +67,7 @@ a GUI tool for test discovery and execution. This is intended largely for ease of use for those new to unit testing. For production environments it is recommended that tests be driven by a continuous integration system such as - `Buildbot `_, `Jenkins `_ + `Buildbot `_, `Jenkins `_ or `Hudson `_. 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 @@ -67,7 +67,7 @@ * :meth:`~urllib.response.addinfourl.info` --- return the meta-information of the page, such as headers, in the form of an :func:`email.message_from_string` instance (see - `Quick Reference to HTTP Headers `_) + `Quick Reference to HTTP Headers `_) * :meth:`~urllib.response.addinfourl.getcode` -- return the HTTP status code of the response. @@ -1130,7 +1130,7 @@ the returned bytes object to string once it determines or guesses the appropriate encoding. -The following W3C document, http://www.w3.org/International/O-charset\ , lists +The following W3C document, https://www.w3.org/International/O-charset\ , lists the various ways in which a (X)HTML or a XML document could have specified its encoding information. diff --git a/Doc/library/xml.dom.minidom.rst b/Doc/library/xml.dom.minidom.rst --- a/Doc/library/xml.dom.minidom.rst +++ b/Doc/library/xml.dom.minidom.rst @@ -100,7 +100,7 @@ .. seealso:: - `Document Object Model (DOM) Level 1 Specification `_ + `Document Object Model (DOM) Level 1 Specification `_ The W3C recommendation for the DOM supported by :mod:`xml.dom.minidom`. @@ -251,5 +251,5 @@ the appropriate standards. For example, "UTF-8" is valid, but "UTF8" is not valid in an XML document's declaration, even though Python accepts it as an encoding name. - See http://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl - and http://www.iana.org/assignments/character-sets/character-sets.xhtml. + See https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl + and https://www.iana.org/assignments/character-sets/character-sets.xhtml. diff --git a/Doc/library/xml.dom.rst b/Doc/library/xml.dom.rst --- a/Doc/library/xml.dom.rst +++ b/Doc/library/xml.dom.rst @@ -63,10 +63,10 @@ .. seealso:: - `Document Object Model (DOM) Level 2 Specification `_ + `Document Object Model (DOM) Level 2 Specification `_ The W3C recommendation upon which the Python DOM API is based. - `Document Object Model (DOM) Level 1 Specification `_ + `Document Object Model (DOM) Level 1 Specification `_ The W3C recommendation for the DOM supported by :mod:`xml.dom.minidom`. `Python Language Mapping Specification `_ @@ -115,20 +115,20 @@ .. data:: XML_NAMESPACE The namespace URI associated with the reserved prefix ``xml``, as defined by - `Namespaces in XML `_ (section 4). + `Namespaces in XML `_ (section 4). .. data:: XMLNS_NAMESPACE The namespace URI for namespace declarations, as defined by `Document Object Model (DOM) Level 2 Core Specification - `_ (section 1.1.8). + `_ (section 1.1.8). .. data:: XHTML_NAMESPACE The URI of the XHTML namespace as defined by `XHTML 1.0: The Extensible - HyperText Markup Language `_ (section 3.1.1). + HyperText Markup Language `_ (section 3.1.1). In addition, :mod:`xml.dom` contains a base :class:`Node` class and the DOM @@ -874,7 +874,7 @@ .. exception:: NamespaceErr If an attempt is made to change any object in a way that is not permitted with - regard to the `Namespaces in XML `_ + regard to the `Namespaces in XML `_ recommendation, this exception is raised. 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 @@ -292,7 +292,7 @@ with prefixes in the form ``prefix:sometag`` get expanded to ``{uri}sometag`` where the *prefix* is replaced by the full *URI*. Also, if there is a `default namespace -`__, +`__, that full URI gets prepended to all of the non-prefixed tags. Here is an XML example that incorporates two namespaces, one with the @@ -363,7 +363,7 @@ ------------- This module provides limited support for -`XPath expressions `_ for locating elements in a +`XPath expressions `_ for locating elements in a tree. The goal is to support a small subset of the abbreviated syntax; a full XPath engine is outside the scope of the module. @@ -1189,5 +1189,5 @@ .. [#] The encoding string included in XML output should conform to the appropriate standards. For example, "UTF-8" is valid, but "UTF8" is - not. See http://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl - and http://www.iana.org/assignments/character-sets/character-sets.xhtml. + not. See https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl + and https://www.iana.org/assignments/character-sets/character-sets.xhtml. 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 @@ -315,7 +315,7 @@ Write the XML-RPC base 64 encoding of this binary item to the *out* stream object. The encoded data will have newlines every 76 characters as per - `RFC 2045 section 6.8 `_, + `RFC 2045 section 6.8 `_, which was the de facto standard base64 specification when the XML-RPC spec was written. @@ -590,7 +590,7 @@ .. rubric:: Footnotes .. [#] This approach has been first presented in `a discussion on xmlrpc.com - `_. + `_. .. the link now points to webarchive since the one at .. http://www.xmlrpc.com/discuss/msgReader%241208 is broken (and webadmin .. doesn't reply) diff --git a/Doc/license.rst b/Doc/license.rst --- a/Doc/license.rst +++ b/Doc/license.rst @@ -11,12 +11,12 @@ ======================= Python was created in the early 1990s by Guido van Rossum at Stichting -Mathematisch Centrum (CWI, see http://www.cwi.nl/) in the Netherlands as a +Mathematisch Centrum (CWI, see https://www.cwi.nl/) in the Netherlands as a successor of a language called ABC. Guido remains Python's principal author, although it includes many contributions from others. In 1995, Guido continued his work on Python at the Corporation for National -Research Initiatives (CNRI, see http://www.cnri.reston.va.us/) in Reston, +Research Initiatives (CNRI, see https://www.cnri.reston.va.us/) in Reston, Virginia where he released several versions of the software. In May 2000, Guido and the Python core development team moved to BeOpen.com to @@ -27,7 +27,7 @@ specifically to own Python-related Intellectual Property. Zope Corporation is a sponsoring member of the PSF. -All Python releases are Open Source (see http://opensource.org/ for the Open +All Python releases are Open Source (see https://opensource.org/ for the Open Source Definition). Historically, most, but not all, Python releases have also been GPL-compatible; the table below summarizes the various releases. 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 @@ -322,7 +322,7 @@ A non-normative HTML file listing all valid identifier characters for Unicode 4.1 can be found at -http://www.dcl.hpi.uni-potsdam.de/home/loewis/table-3131.html. +https://www.dcl.hpi.uni-potsdam.de/home/loewis/table-3131.html. .. _keywords: diff --git a/Doc/tutorial/floatingpoint.rst b/Doc/tutorial/floatingpoint.rst --- a/Doc/tutorial/floatingpoint.rst +++ b/Doc/tutorial/floatingpoint.rst @@ -155,7 +155,7 @@ If you are a heavy user of floating point operations you should take a look at the Numerical Python package and many other packages for mathematical and -statistical operations supplied by the SciPy project. See . +statistical operations supplied by the SciPy project. See . Python provides tools that may help on those rare occasions when you really *do* want to know the exact value of a float. The diff --git a/Doc/tutorial/interactive.rst b/Doc/tutorial/interactive.rst --- a/Doc/tutorial/interactive.rst +++ b/Doc/tutorial/interactive.rst @@ -49,6 +49,6 @@ bpython_. -.. _GNU Readline: http://tiswww.case.edu/php/chet/readline/rltop.html +.. _GNU Readline: https://tiswww.case.edu/php/chet/readline/rltop.html .. _IPython: http://ipython.scipy.org/ .. _bpython: http://www.bpython-interpreter.org/ diff --git a/Doc/tutorial/stdlib.rst b/Doc/tutorial/stdlib.rst --- a/Doc/tutorial/stdlib.rst +++ b/Doc/tutorial/stdlib.rst @@ -152,7 +152,7 @@ >>> statistics.variance(data) 1.3720238095238095 -The SciPy project has many other modules for numerical +The SciPy project has many other modules for numerical computations. .. _tut-internet-access: diff --git a/Doc/tutorial/whatnow.rst b/Doc/tutorial/whatnow.rst --- a/Doc/tutorial/whatnow.rst +++ b/Doc/tutorial/whatnow.rst @@ -43,7 +43,7 @@ for download. Once you begin releasing code, you can register it here so that others can find it. -* http://code.activestate.com/recipes/langs/python/: The Python Cookbook is a +* https://code.activestate.com/recipes/langs/python/: The Python Cookbook is a sizable collection of code examples, larger modules, and useful scripts. Particularly notable contributions are collected in a book also titled Python Cookbook (O'Reilly & Associates, ISBN 0-596-00797-3.) @@ -51,7 +51,7 @@ * http://www.pyvideo.org collects links to Python-related videos from conferences and user-group meetings. -* http://scipy.org: The Scientific Python project includes modules for fast +* https://scipy.org: The Scientific Python project includes modules for fast array computations and manipulations plus a host of packages for such things as linear algebra, Fourier transforms, non-linear solvers, random number distributions, statistical analysis and the like. diff --git a/Doc/using/mac.rst b/Doc/using/mac.rst --- a/Doc/using/mac.rst +++ b/Doc/using/mac.rst @@ -65,7 +65,7 @@ :program:`emacs` among them. If you want a more Mac-like editor, :program:`BBEdit` or :program:`TextWrangler` from Bare Bones Software (see http://www.barebones.com/products/bbedit/index.html) are good choices, as is -:program:`TextMate` (see http://macromates.com/). Other editors include +:program:`TextMate` (see https://macromates.com/). Other editors include :program:`Gvim` (http://macvim.org) and :program:`Aquamacs` (http://aquamacs.org/). @@ -144,9 +144,9 @@ available from https://pythonhosted.org/pyobjc/. The standard Python GUI toolkit is :mod:`tkinter`, based on the cross-platform -Tk toolkit (http://www.tcl.tk). An Aqua-native version of Tk is bundled with OS +Tk toolkit (https://www.tcl.tk). An Aqua-native version of Tk is bundled with OS X by Apple, and the latest version can be downloaded and installed from -http://www.activestate.com; it can also be built from source. +https://www.activestate.com; it can also be built from source. *wxPython* is another popular cross-platform GUI toolkit that runs natively on Mac OS X. Packages and documentation are available from http://www.wxpython.org. diff --git a/Doc/using/unix.rst b/Doc/using/unix.rst --- a/Doc/using/unix.rst +++ b/Doc/using/unix.rst @@ -55,7 +55,7 @@ On OpenSolaris -------------- -You can get Python from `OpenCSW `_. Various versions +You can get Python from `OpenCSW `_. Various versions of Python are available and can be installed with e.g. ``pkgutil -i python27``. @@ -139,10 +139,10 @@ information on how to code in Python in these editors, look at: * http://www.vim.org/scripts/script.php?script_id=790 -* http://sourceforge.net/projects/python-mode +* https://sourceforge.net/projects/python-mode Geany is an excellent IDE with support for a lot of languages. For more -information, read: http://www.geany.org/ +information, read: https://www.geany.org/ Komodo edit is another extremely good IDE. It also has support for a lot of -languages. For more information, read http://komodoide.com/. +languages. For more information, read https://komodoide.com/. diff --git a/Doc/using/windows.rst b/Doc/using/windows.rst --- a/Doc/using/windows.rst +++ b/Doc/using/windows.rst @@ -245,7 +245,7 @@ Check :pep:`11` for details on all unsupported platforms. * `Windows CE `_ is still supported. -* The `Cygwin `_ installer offers to install the Python +* The `Cygwin `_ installer offers to install the Python interpreter as well (cf. `Cygwin package source `_, `Maintainer releases @@ -364,7 +364,7 @@ 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 + https://www.chem.gla.ac.uk/~louis/software/faq/q1.html Setting Environment variables, Louis J. Farrugia .. _windows-path-mod: 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 @@ -61,7 +61,7 @@ made available by SourceForge for storing source code, tracking bug reports, and managing the queue of patch submissions. To report bugs or submit patches for Python 2.0, use the bug tracking and patch manager tools available from -Python's project page, located at http://sourceforge.net/projects/python/. +Python's project page, located at https://sourceforge.net/projects/python/. The most important of the services now hosted at SourceForge is the Python CVS tree, the version-controlled repository containing the source code for Python. diff --git a/Doc/whatsnew/2.2.rst b/Doc/whatsnew/2.2.rst --- a/Doc/whatsnew/2.2.rst +++ b/Doc/whatsnew/2.2.rst @@ -632,10 +632,10 @@ every square of an $NxN$ chessboard without visiting any square twice). The idea of generators comes from other programming languages, especially Icon -(http://www.cs.arizona.edu/icon/), where the idea of generators is central. In +(https://www.cs.arizona.edu/icon/), where the idea of generators is central. In Icon, every expression and function call behaves like a generator. One example from "An Overview of the Icon Programming Language" at -http://www.cs.arizona.edu/icon/docs/ipd266.htm gives an idea of what this looks +https://www.cs.arizona.edu/icon/docs/ipd266.htm gives an idea of what this looks like:: sentence := "Store it in the neighboring harbor" 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 @@ -218,10 +218,10 @@ every square of an $NxN$ chessboard without visiting any square twice). The idea of generators comes from other programming languages, especially Icon -(http://www.cs.arizona.edu/icon/), where the idea of generators is central. In +(https://www.cs.arizona.edu/icon/), where the idea of generators is central. In Icon, every expression and function call behaves like a generator. One example from "An Overview of the Icon Programming Language" at -http://www.cs.arizona.edu/icon/docs/ipd266.htm gives an idea of what this looks +https://www.cs.arizona.edu/icon/docs/ipd266.htm gives an idea of what this looks like:: sentence := "Store it in the neighboring harbor" 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 @@ -1528,7 +1528,7 @@ * The :mod:`socket` module now supports :const:`AF_NETLINK` sockets on Linux, thanks to a patch from Philippe Biondi. Netlink sockets are a Linux-specific mechanism for communications between a user-space process and kernel code; an - introductory article about them is at http://www.linuxjournal.com/article/7356. + introductory article about them is at https://www.linuxjournal.com/article/7356. In Python code, netlink addresses are represented as a tuple of 2 integers, ``(pid, group_mask)``. @@ -2013,7 +2013,7 @@ >>> For more information about the SQL dialect supported by SQLite, see -http://www.sqlite.org. +https://www.sqlite.org. .. seealso:: @@ -2021,7 +2021,7 @@ http://www.pysqlite.org The pysqlite web page. - http://www.sqlite.org + https://www.sqlite.org The SQLite web page; the documentation describes the syntax and the available data types for the supported SQL dialect. 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 @@ -154,9 +154,9 @@ up different products and import some of the bugs and patches from SourceForge. Four different trackers were examined: `Jira `__, -`Launchpad `__, +`Launchpad `__, `Roundup `__, and -`Trac `__. +`Trac `__. The committee eventually settled on Jira and Roundup as the two candidates. Jira is a commercial product that offers no-cost hosted instances to free-software projects; Roundup @@ -1431,7 +1431,7 @@ :pep:`3141` - A Type Hierarchy for Numbers PEP written by Jeffrey Yasskin. - `Scheme's numerical tower `__, from the Guile manual. + `Scheme's numerical tower `__, from the Guile manual. `Scheme's number datatypes `__ from the R5RS Scheme specification. @@ -2889,7 +2889,7 @@ Bill Janssen made extensive improvements to Python 2.6's support for the Secure Sockets Layer by adding a new module, :mod:`ssl`, that's -built atop the `OpenSSL `__ library. +built atop the `OpenSSL `__ library. This new module provides more control over the protocol negotiated, the X.509 certificates used, and has better support for writing SSL servers (as opposed to clients) in Python. The existing SSL support 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 @@ -1157,7 +1157,7 @@ * The :mod:`ctypes` module now always converts ``None`` to a C NULL pointer for arguments declared as pointers. (Changed by Thomas Heller; :issue:`4606`.) The underlying `libffi library - `__ has been updated to version + `__ has been updated to version 3.0.9, containing various fixes for different platforms. (Updated by Matthias Klose; :issue:`8142`.) @@ -1530,7 +1530,7 @@ *ciphers* argument that's a string listing the encryption algorithms to be allowed; the format of the string is described `in the OpenSSL documentation - `__. + `__. (Added by Antoine Pitrou; :issue:`8322`.) Another change makes the extension load all of OpenSSL's ciphers and @@ -1783,7 +1783,7 @@ To learn more, read the :mod:`ttk` module documentation. You may also wish to read the Tcl/Tk manual page describing the Ttk theme engine, available at -http://www.tcl.tk/man/tcl8.5/TkCmd/ttk_intro.htm. Some +https://www.tcl.tk/man/tcl8.5/TkCmd/ttk_intro.htm. Some screenshots of the Python/Ttk code in use are at http://code.google.com/p/python-ttk/wiki/Screenshots. @@ -2079,7 +2079,7 @@ * The latest release of the GNU Debugger, GDB 7, can be `scripted using Python - `__. + `__. When you begin debugging an executable program P, GDB will look for a file named ``P-gdb.py`` and automatically read it. Dave Malcolm contributed a :file:`python-gdb.py` that adds a number of @@ -2149,7 +2149,7 @@ with *updatepath* set to false. Security issue reported as `CVE-2008-5983 - `_; + `_; discussed in :issue:`5753`, and fixed by Antoine Pitrou. * New macros: the Python header files now define the following macros: 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 @@ -769,8 +769,8 @@ (Contributed by Raymond Hettinger and incorporating design ideas from Jim Baker, Miki Tebeka, and Nick Coghlan; see `recipe 498245 - `_\, `recipe 577479 - `_\, :issue:`10586`, and + `_\, `recipe 577479 + `_\, :issue:`10586`, and :issue:`10593`.) * The :func:`functools.wraps` decorator now adds a :attr:`__wrapped__` attribute @@ -955,7 +955,7 @@ sealed and deposited in a queue for later handling. See `Barrier Synchronization Patterns -`_ for +`_ for more examples of how barriers can be used in parallel computing. Also, there is a simple but thorough explanation of barriers in `The Little Book of Semaphores `_, *section 3.6*. @@ -1618,7 +1618,7 @@ * The :func:`ssl.wrap_socket` constructor function now takes a *ciphers* argument. The *ciphers* string lists the allowed encryption algorithms using the format described in the `OpenSSL documentation - `__. + `__. * When linked against recent versions of OpenSSL, the :mod:`ssl` module now supports the Server Name Indication extension to the TLS protocol, allowing @@ -2559,7 +2559,7 @@ :source:`Mac/BuildScript/README.txt` for details. For users running a 32/64-bit build, there is a known problem with the default Tcl/Tk on Mac OS X 10.6. Accordingly, we recommend installing an updated alternative such as -`ActiveState Tcl/Tk 8.5.9 `_\. +`ActiveState Tcl/Tk 8.5.9 `_\. See https://www.python.org/download/mac/tcltk/ for additional details. Porting to Python 3.2 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 @@ -1410,7 +1410,7 @@ A new boolean parameter to the :func:`~sqlite3.connect` function, *uri*, can be used to indicate that the *database* parameter is a ``uri`` (see the `SQLite -URI documentation `_). (Contributed by poq in +URI documentation `_). (Contributed by poq in :issue:`13773`.) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -1010,6 +1010,8 @@ Documentation ------------- +- Issue #26736: Used HTTPS for external links in the documentation if possible. + - Issue #6953: Rework the Readline module documentation to group related functions together, and add more details such as what underlying Readline functions and variables are accessed. -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Sat May 7 04:53:11 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Sat, 07 May 2016 08:53:11 +0000 Subject: [Python-checkins] Daily reference leaks (786de3f37ca7): sum=10 Message-ID: <20160507085311.69961.85105.790AA77E@psf.io> results for 786de3f37ca7 on branch "default" -------------------------------------------- test_collections leaked [0, 0, 4] memory blocks, sum=4 test_functools leaked [0, 3, 1] memory blocks, sum=4 test_typing leaked [2, 0, 0] references, sum=2 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogVvuKKj', '--timeout', '7200'] From python-checkins at python.org Sat May 7 08:44:31 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 07 May 2016 12:44:31 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzE3NzY1?= =?utf-8?q?=3A_weakref=2Eref=28=29_no_longer_silently_ignores_keyword_argu?= =?utf-8?q?ments=2E?= Message-ID: <20160507124430.130801.23310.6F485AF6@psf.io> https://hg.python.org/cpython/rev/ee17a83feabc changeset: 101251:ee17a83feabc branch: 3.5 parent: 101248:211a9f32dfb9 user: Serhiy Storchaka date: Sat May 07 15:41:09 2016 +0300 summary: Issue #17765: weakref.ref() no longer silently ignores keyword arguments. Patch by Georg Brandl. files: Lib/test/test_weakref.py | 4 ++++ Misc/NEWS | 3 +++ Objects/weakrefobject.c | 4 +++- 3 files changed, 10 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py --- a/Lib/test/test_weakref.py +++ b/Lib/test/test_weakref.py @@ -133,6 +133,10 @@ ref1 = weakref.ref(c, callback) del c + def test_constructor_kwargs(self): + c = C() + self.assertRaises(TypeError, weakref.ref, c, callback=None) + def test_proxy_ref(self): o = C() o.bar = 1 diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -116,6 +116,9 @@ Library ------- +- Issue #17765: weakref.ref() no longer silently ignores keyword arguments. + Patch by Georg Brandl. + - Issue #26873: xmlrpc now raises ResponseError on unsupported type tags instead of silently return incorrect result. diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c --- a/Objects/weakrefobject.c +++ b/Objects/weakrefobject.c @@ -268,7 +268,6 @@ parse_weakref_init_args(char *funcname, PyObject *args, PyObject *kwargs, PyObject **obp, PyObject **callbackp) { - /* XXX Should check that kwargs == NULL or is empty. */ return PyArg_UnpackTuple(args, funcname, 1, 2, obp, callbackp); } @@ -331,6 +330,9 @@ { PyObject *tmp; + if (!_PyArg_NoKeywords("ref()", kwargs)) + return -1; + if (parse_weakref_init_args("__init__", args, kwargs, &tmp, &tmp)) return 0; else -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat May 7 08:44:38 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 07 May 2016 12:44:38 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzE3NzY1?= =?utf-8?q?=3A_weakref=2Eref=28=29_no_longer_silently_ignores_keyword_argu?= =?utf-8?q?ments=2E?= Message-ID: <20160507124430.22573.16333.67652900@psf.io> https://hg.python.org/cpython/rev/60de9c6188cc changeset: 101252:60de9c6188cc branch: 2.7 parent: 101250:e3af25d70976 user: Serhiy Storchaka date: Sat May 07 15:41:09 2016 +0300 summary: Issue #17765: weakref.ref() no longer silently ignores keyword arguments. Patch by Georg Brandl. files: Lib/test/test_weakref.py | 4 ++++ Misc/NEWS | 3 +++ Objects/weakrefobject.c | 4 +++- 3 files changed, 10 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py --- a/Lib/test/test_weakref.py +++ b/Lib/test/test_weakref.py @@ -116,6 +116,10 @@ ref1 = weakref.ref(c, callback) del c + def test_constructor_kwargs(self): + c = C() + self.assertRaises(TypeError, weakref.ref, c, callback=None) + def test_proxy_ref(self): o = C() o.bar = 1 diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -77,6 +77,9 @@ Library ------- +- Issue #17765: weakref.ref() no longer silently ignores keyword arguments. + Patch by Georg Brandl. + - Issue #26873: xmlrpclib now raises ResponseError on unsupported type tags instead of silently return incorrect result. diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c --- a/Objects/weakrefobject.c +++ b/Objects/weakrefobject.c @@ -271,7 +271,6 @@ parse_weakref_init_args(char *funcname, PyObject *args, PyObject *kwargs, PyObject **obp, PyObject **callbackp) { - /* XXX Should check that kwargs == NULL or is empty. */ return PyArg_UnpackTuple(args, funcname, 1, 2, obp, callbackp); } @@ -334,6 +333,9 @@ { PyObject *tmp; + if (!_PyArg_NoKeywords("ref()", kwargs)) + return -1; + if (parse_weakref_init_args("__init__", args, kwargs, &tmp, &tmp)) return 0; else -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat May 7 08:44:38 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 07 May 2016 12:44:38 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2317765=3A_weakref=2Eref=28=29_no_longer_silently?= =?utf-8?q?_ignores_keyword_arguments=2E?= Message-ID: <20160507124430.21015.45282.E7136FA5@psf.io> https://hg.python.org/cpython/rev/ef55fa8c4b82 changeset: 101253:ef55fa8c4b82 parent: 101249:3ceb54a49387 parent: 101251:ee17a83feabc user: Serhiy Storchaka date: Sat May 07 15:43:59 2016 +0300 summary: Issue #17765: weakref.ref() no longer silently ignores keyword arguments. Patch by Georg Brandl. files: Lib/test/test_weakref.py | 4 ++++ Misc/NEWS | 3 +++ Objects/weakrefobject.c | 4 +++- 3 files changed, 10 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py --- a/Lib/test/test_weakref.py +++ b/Lib/test/test_weakref.py @@ -133,6 +133,10 @@ ref1 = weakref.ref(c, callback) del c + def test_constructor_kwargs(self): + c = C() + self.assertRaises(TypeError, weakref.ref, c, callback=None) + def test_proxy_ref(self): o = C() o.bar = 1 diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -265,6 +265,9 @@ Library ------- +- Issue #17765: weakref.ref() no longer silently ignores keyword arguments. + Patch by Georg Brandl. + - Issue #26873: xmlrpc now raises ResponseError on unsupported type tags instead of silently return incorrect result. diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c --- a/Objects/weakrefobject.c +++ b/Objects/weakrefobject.c @@ -268,7 +268,6 @@ parse_weakref_init_args(const char *funcname, PyObject *args, PyObject *kwargs, PyObject **obp, PyObject **callbackp) { - /* XXX Should check that kwargs == NULL or is empty. */ return PyArg_UnpackTuple(args, funcname, 1, 2, obp, callbackp); } @@ -331,6 +330,9 @@ { PyObject *tmp; + if (!_PyArg_NoKeywords("ref()", kwargs)) + return -1; + if (parse_weakref_init_args("__init__", args, kwargs, &tmp, &tmp)) return 0; else -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat May 7 09:37:10 2016 From: python-checkins at python.org (berker.peksag) Date: Sat, 07 May 2016 13:37:10 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Replace_exampl?= =?utf-8?q?e=2Ecom_with_pythontest=2Enet_in_test=5Furllibnet?= Message-ID: <20160507133710.31189.80782.D5ACD22B@psf.io> https://hg.python.org/cpython/rev/d1a33c93fa1b changeset: 101254:d1a33c93fa1b branch: 3.5 parent: 101251:ee17a83feabc user: Berker Peksag date: Sat May 07 16:37:09 2016 +0300 summary: Replace example.com with pythontest.net in test_urllibnet example.com/404 returns 500 instead of 404 now. files: Lib/test/test_urllibnet.py | 25 +++++++++++++------------ 1 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py --- a/Lib/test/test_urllibnet.py +++ b/Lib/test/test_urllibnet.py @@ -38,12 +38,14 @@ for transparent redirection have been written. setUp is not used for always constructing a connection to - http://www.example.com/ since there a few tests that don't use that address + http://www.pythontest.net/ since there a few tests that don't use that address and making a connection is expensive enough to warrant minimizing unneeded connections. """ + url = 'http://www.pythontest.net/' + @contextlib.contextmanager def urlopen(self, *args, **kwargs): resource = args[0] @@ -56,7 +58,7 @@ def test_basic(self): # Simple test expected to pass. - with self.urlopen("http://www.example.com/") as open_url: + with self.urlopen(self.url) as open_url: for attr in ("read", "readline", "readlines", "fileno", "close", "info", "geturl"): self.assertTrue(hasattr(open_url, attr), "object returned from " @@ -65,7 +67,7 @@ def test_readlines(self): # Test both readline and readlines. - with self.urlopen("http://www.example.com/") as open_url: + with self.urlopen(self.url) as open_url: self.assertIsInstance(open_url.readline(), bytes, "readline did not return a string") self.assertIsInstance(open_url.readlines(), list, @@ -73,7 +75,7 @@ def test_info(self): # Test 'info'. - with self.urlopen("http://www.example.com/") as open_url: + with self.urlopen(self.url) as open_url: info_obj = open_url.info() self.assertIsInstance(info_obj, email.message.Message, "object returned by 'info' is not an " @@ -82,14 +84,13 @@ def test_geturl(self): # Make sure same URL as opened is returned by geturl. - URL = "http://www.example.com/" - with self.urlopen(URL) as open_url: + with self.urlopen(self.url) as open_url: gotten_url = open_url.geturl() - self.assertEqual(gotten_url, URL) + self.assertEqual(gotten_url, self.url) def test_getcode(self): # test getcode() with the fancy opener to get 404 error codes - URL = "http://www.example.com/XXXinvalidXXX" + URL = self.url + "XXXinvalidXXX" with support.transient_internet(URL): with self.assertWarns(DeprecationWarning): open_url = urllib.request.FancyURLopener().open(URL) @@ -153,7 +154,7 @@ def test_basic(self): # Test basic functionality. - with self.urlretrieve("http://www.example.com/") as (file_location, info): + with self.urlretrieve(self.logo) as (file_location, info): self.assertTrue(os.path.exists(file_location), "file location returned by" " urlretrieve is not a valid path") with open(file_location, 'rb') as f: @@ -162,7 +163,7 @@ def test_specified_path(self): # Make sure that specifying the location of the file to write to works. - with self.urlretrieve("http://www.example.com/", + with self.urlretrieve(self.logo, support.TESTFN) as (file_location, info): self.assertEqual(file_location, support.TESTFN) self.assertTrue(os.path.exists(file_location)) @@ -171,11 +172,11 @@ def test_header(self): # Make sure header returned as 2nd value from urlretrieve is good. - with self.urlretrieve("http://www.example.com/") as (file_location, info): + with self.urlretrieve(self.logo) as (file_location, info): self.assertIsInstance(info, email.message.Message, "info is not an instance of email.message.Message") - logo = "http://www.example.com/" + logo = "http://www.pythontest.net/" def test_data_header(self): with self.urlretrieve(self.logo) as (file_location, fileheaders): -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat May 7 09:37:10 2016 From: python-checkins at python.org (berker.peksag) Date: Sat, 07 May 2016 13:37:10 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Replace_example=2Ecom_with_pythontest=2Enet_in_test=5Fur?= =?utf-8?q?llibnet?= Message-ID: <20160507133710.42375.86912.35F8EC39@psf.io> https://hg.python.org/cpython/rev/07b118f9527a changeset: 101255:07b118f9527a parent: 101253:ef55fa8c4b82 parent: 101254:d1a33c93fa1b user: Berker Peksag date: Sat May 07 16:37:35 2016 +0300 summary: Replace example.com with pythontest.net in test_urllibnet example.com/404 returns 500 instead of 404 now. files: Lib/test/test_urllibnet.py | 25 +++++++++++++------------ 1 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py --- a/Lib/test/test_urllibnet.py +++ b/Lib/test/test_urllibnet.py @@ -37,12 +37,14 @@ for transparent redirection have been written. setUp is not used for always constructing a connection to - http://www.example.com/ since there a few tests that don't use that address + http://www.pythontest.net/ since there a few tests that don't use that address and making a connection is expensive enough to warrant minimizing unneeded connections. """ + url = 'http://www.pythontest.net/' + @contextlib.contextmanager def urlopen(self, *args, **kwargs): resource = args[0] @@ -55,7 +57,7 @@ def test_basic(self): # Simple test expected to pass. - with self.urlopen("http://www.example.com/") as open_url: + with self.urlopen(self.url) as open_url: for attr in ("read", "readline", "readlines", "fileno", "close", "info", "geturl"): self.assertTrue(hasattr(open_url, attr), "object returned from " @@ -64,7 +66,7 @@ def test_readlines(self): # Test both readline and readlines. - with self.urlopen("http://www.example.com/") as open_url: + with self.urlopen(self.url) as open_url: self.assertIsInstance(open_url.readline(), bytes, "readline did not return a string") self.assertIsInstance(open_url.readlines(), list, @@ -72,7 +74,7 @@ def test_info(self): # Test 'info'. - with self.urlopen("http://www.example.com/") as open_url: + with self.urlopen(self.url) as open_url: info_obj = open_url.info() self.assertIsInstance(info_obj, email.message.Message, "object returned by 'info' is not an " @@ -81,14 +83,13 @@ def test_geturl(self): # Make sure same URL as opened is returned by geturl. - URL = "http://www.example.com/" - with self.urlopen(URL) as open_url: + with self.urlopen(self.url) as open_url: gotten_url = open_url.geturl() - self.assertEqual(gotten_url, URL) + self.assertEqual(gotten_url, self.url) def test_getcode(self): # test getcode() with the fancy opener to get 404 error codes - URL = "http://www.example.com/XXXinvalidXXX" + URL = self.url + "XXXinvalidXXX" with support.transient_internet(URL): with self.assertWarns(DeprecationWarning): open_url = urllib.request.FancyURLopener().open(URL) @@ -152,7 +153,7 @@ def test_basic(self): # Test basic functionality. - with self.urlretrieve("http://www.example.com/") as (file_location, info): + with self.urlretrieve(self.logo) as (file_location, info): self.assertTrue(os.path.exists(file_location), "file location returned by" " urlretrieve is not a valid path") with open(file_location, 'rb') as f: @@ -161,7 +162,7 @@ def test_specified_path(self): # Make sure that specifying the location of the file to write to works. - with self.urlretrieve("http://www.example.com/", + with self.urlretrieve(self.logo, support.TESTFN) as (file_location, info): self.assertEqual(file_location, support.TESTFN) self.assertTrue(os.path.exists(file_location)) @@ -170,11 +171,11 @@ def test_header(self): # Make sure header returned as 2nd value from urlretrieve is good. - with self.urlretrieve("http://www.example.com/") as (file_location, info): + with self.urlretrieve(self.logo) as (file_location, info): self.assertIsInstance(info, email.message.Message, "info is not an instance of email.message.Message") - logo = "http://www.example.com/" + logo = "http://www.pythontest.net/" def test_data_header(self): with self.urlretrieve(self.logo) as (file_location, fileheaders): -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat May 7 09:41:11 2016 From: python-checkins at python.org (berker.peksag) Date: Sat, 07 May 2016 13:41:11 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Replace_exampl?= =?utf-8?q?e=2Ecom_with_pythontest=2Enet_in_test=5Fgetcode_of_test=5Furlli?= =?utf-8?q?bnet?= Message-ID: <20160507134111.88888.53025.EFCA0215@psf.io> https://hg.python.org/cpython/rev/806dfe65ddcf changeset: 101256:806dfe65ddcf branch: 2.7 parent: 101252:60de9c6188cc user: Berker Peksag date: Sat May 07 16:41:39 2016 +0300 summary: Replace example.com with pythontest.net in test_getcode of test_urllibnet files: Lib/test/test_urllibnet.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py --- a/Lib/test/test_urllibnet.py +++ b/Lib/test/test_urllibnet.py @@ -111,7 +111,7 @@ def test_getcode(self): # test getcode() with the fancy opener to get 404 error codes - URL = "http://www.example.com/XXXinvalidXXX" + URL = "http://www.pythontest.net/XXXinvalidXXX" open_url = urllib.FancyURLopener().open(URL) try: code = open_url.getcode() -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat May 7 09:45:39 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sat, 07 May 2016 13:45:39 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2326708=3A_Use_the_?= =?utf-8?q?=22const=22_qualifier_for_immutable_strings=2E?= Message-ID: <20160507134537.9353.79550.B894F261@psf.io> https://hg.python.org/cpython/rev/7edf74098c76 changeset: 101257:7edf74098c76 parent: 101255:07b118f9527a user: Serhiy Storchaka date: Sat May 07 16:45:18 2016 +0300 summary: Issue #26708: Use the "const" qualifier for immutable strings. This can help to avoid unintentional modification. files: Modules/posixmodule.c | 76 +++++++++++++++--------------- 1 files changed, 39 insertions(+), 37 deletions(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -810,8 +810,8 @@ const char *argument_name; int nullable; int allow_fd; - wchar_t *wide; - char *narrow; + const wchar_t *wide; + const char *narrow; int fd; Py_ssize_t length; PyObject *object; @@ -834,7 +834,7 @@ path_t *path = (path_t *)p; PyObject *bytes; Py_ssize_t length; - char *narrow; + const char *narrow; #define FORMAT_EXCEPTION(exc, fmt) \ PyErr_Format(exc, "%s%s" fmt, \ @@ -862,7 +862,7 @@ if (PyUnicode_Check(o)) { #ifdef MS_WINDOWS - wchar_t *wide; + const wchar_t *wide; wide = PyUnicode_AsUnicodeAndSize(o, &length); if (!wide) { @@ -1164,7 +1164,7 @@ for (e = _wenviron; *e != NULL; e++) { PyObject *k; PyObject *v; - wchar_t *p = wcschr(*e, L'='); + const wchar_t *p = wcschr(*e, L'='); if (p == NULL) continue; k = PyUnicode_FromWideChar(*e, (Py_ssize_t)(p-*e)); @@ -1192,7 +1192,7 @@ for (e = environ; *e != NULL; e++) { PyObject *k; PyObject *v; - char *p = strchr(*e, '='); + const char *p = strchr(*e, '='); if (p == NULL) continue; k = PyBytes_FromStringAndSize(*e, (int)(p-*e)); @@ -3483,7 +3483,7 @@ if (!path->narrow) { WIN32_FIND_DATAW wFileData; - wchar_t *po_wchars; + const wchar_t *po_wchars; if (!path->wide) { /* Default arg: "." */ po_wchars = L"."; @@ -3649,7 +3649,7 @@ else #endif { - char *name; + const char *name; if (path->narrow) { name = path->narrow; /* only return bytes if they specified a bytes object */ @@ -3831,7 +3831,7 @@ wchar_t *target_path; int result_length; PyObject *result; - wchar_t *path_wchar; + const wchar_t *path_wchar; path_wchar = PyUnicode_AsUnicode(path); if (path_wchar == NULL) @@ -3920,7 +3920,8 @@ /*[clinic end generated code: output=79a0ba729f956dbe input=7eacadc40acbda6b]*/ { PyObject *result; - wchar_t *path_wchar, *mountpath=NULL; + const wchar_t *path_wchar; + wchar_t *mountpath=NULL; size_t buflen; BOOL ret; @@ -4118,7 +4119,7 @@ static PyObject * internal_rename(path_t *src, path_t *dst, int src_dir_fd, int dst_dir_fd, int is_replace) { - char *function_name = is_replace ? "replace" : "rename"; + const char *function_name = is_replace ? "replace" : "rename"; int dir_fd_specified; #ifdef MS_WINDOWS @@ -4298,7 +4299,7 @@ /*[clinic end generated code: output=800f775e10b7be55 input=86a58554ba6094af]*/ { long result; - char *bytes = PyBytes_AsString(command); + const char *bytes = PyBytes_AsString(command); Py_BEGIN_ALLOW_THREADS result = system(bytes); Py_END_ALLOW_THREADS @@ -4937,7 +4938,8 @@ Py_ssize_t i, pos, envc; PyObject *keys=NULL, *vals=NULL; PyObject *key, *val, *key2, *val2; - char *p, *k, *v; + char *p; + const char *k, *v; size_t len; i = PyMapping_Size(env); @@ -5052,7 +5054,7 @@ os_execv_impl(PyModuleDef *module, PyObject *path, PyObject *argv) /*[clinic end generated code: output=9221f08143146fff input=96041559925e5229]*/ { - char *path_char; + const char *path_char; char **argvlist; Py_ssize_t argc; @@ -5173,7 +5175,7 @@ os_spawnv_impl(PyModuleDef *module, int mode, PyObject *path, PyObject *argv) /*[clinic end generated code: output=140a7945484c8cc5 input=042c91dfc1e6debc]*/ { - char *path_char; + const char *path_char; char **argvlist; int i; Py_ssize_t argc; @@ -5251,7 +5253,7 @@ PyObject *argv, PyObject *env) /*[clinic end generated code: output=e7f5f0703610531f input=02362fd937963f8f]*/ { - char *path_char; + const char *path_char; char **argvlist; char **envlist; PyObject *res = NULL; @@ -6264,7 +6266,7 @@ posix_initgroups(PyObject *self, PyObject *args) { PyObject *oname; - char *username; + const char *username; int res; #ifdef __APPLE__ int gid; @@ -7138,16 +7140,16 @@ static PyObject * win_readlink(PyObject *self, PyObject *args, PyObject *kwargs) { - wchar_t *path; + const wchar_t *path; DWORD n_bytes_returned; DWORD io_result; PyObject *po, *result; - int dir_fd; + int dir_fd; HANDLE reparse_point_handle; char target_buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; REPARSE_DATA_BUFFER *rdb = (REPARSE_DATA_BUFFER *)target_buffer; - wchar_t *print_name; + const wchar_t *print_name; static char *keywords[] = {"path", "dir_fd", NULL}; @@ -7215,8 +7217,8 @@ #if defined(MS_WINDOWS) /* Grab CreateSymbolicLinkW dynamically from kernel32 */ -static DWORD (CALLBACK *Py_CreateSymbolicLinkW)(LPWSTR, LPWSTR, DWORD) = NULL; -static DWORD (CALLBACK *Py_CreateSymbolicLinkA)(LPSTR, LPSTR, DWORD) = NULL; +static DWORD (CALLBACK *Py_CreateSymbolicLinkW)(LPCWSTR, LPCWSTR, DWORD) = NULL; +static DWORD (CALLBACK *Py_CreateSymbolicLinkA)(LPCSTR, LPCSTR, DWORD) = NULL; static int check_CreateSymbolicLink(void) @@ -7321,7 +7323,7 @@ /* Return True if the path at src relative to dest is a directory */ static int -_check_dirW(WCHAR *src, WCHAR *dest) +_check_dirW(LPCWSTR src, LPCWSTR dest) { WIN32_FILE_ATTRIBUTE_DATA src_info; WCHAR dest_parent[MAX_PATH]; @@ -7340,7 +7342,7 @@ /* Return True if the path at src relative to dest is a directory */ static int -_check_dirA(const char *src, char *dest) +_check_dirA(LPCSTR src, LPCSTR dest) { WIN32_FILE_ATTRIBUTE_DATA src_info; char dest_parent[MAX_PATH]; @@ -9030,7 +9032,7 @@ os_putenv_impl(PyModuleDef *module, PyObject *name, PyObject *value) /*[clinic end generated code: output=a2438cf95e5a0c1c input=ba586581c2e6105f]*/ { - wchar_t *env; + const wchar_t *env; PyObject *unicode = PyUnicode_FromFormat("%U=%U", name, value); if (unicode == NULL) { @@ -9076,8 +9078,8 @@ { PyObject *bytes = NULL; char *env; - char *name_string = PyBytes_AsString(name); - char *value_string = PyBytes_AsString(value); + const char *name_string = PyBytes_AsString(name); + const char *value_string = PyBytes_AsString(value); bytes = PyBytes_FromFormat("%s=%s", name_string, value_string); if (bytes == NULL) { @@ -10469,7 +10471,7 @@ static int setup_confname_table(struct constdef *table, size_t tablesize, - char *tablename, PyObject *module) + const char *tablename, PyObject *module) { PyObject *d = NULL; size_t i; @@ -10596,9 +10598,9 @@ win32_startfile(PyObject *self, PyObject *args) { PyObject *ofilepath; - char *filepath; - char *operation = NULL; - wchar_t *wpath, *woperation; + const char *filepath; + const char *operation = NULL; + const wchar_t *wpath, *woperation; HINSTANCE rc; PyObject *unipath, *uoperation = NULL; @@ -11003,7 +11005,7 @@ name = path->narrow ? path->narrow : "."; for (i = 0; ; i++) { - char *start, *trace, *end; + const char *start, *trace, *end; ssize_t length; static const Py_ssize_t buffer_sizes[] = { 256, XATTR_LIST_MAX, 0 }; Py_ssize_t buffer_size = buffer_sizes[i]; @@ -11482,7 +11484,7 @@ struct _Py_stat_struct st; #ifdef MS_WINDOWS - wchar_t *path; + const wchar_t *path; path = PyUnicode_AsUnicode(self->path); if (!path) @@ -11499,7 +11501,7 @@ } #else /* POSIX */ PyObject *bytes; - char *path; + const char *path; if (!PyUnicode_FSConverter(self->path, &bytes)) return NULL; @@ -11683,7 +11685,7 @@ { #ifdef MS_WINDOWS if (!self->got_file_index) { - wchar_t *path; + const wchar_t *path; struct _Py_stat_struct stat; path = PyUnicode_AsUnicode(self->path); @@ -11777,7 +11779,7 @@ #ifdef MS_WINDOWS static wchar_t * -join_path_filenameW(wchar_t *path_wide, wchar_t* filename) +join_path_filenameW(const wchar_t *path_wide, const wchar_t *filename) { Py_ssize_t path_len; Py_ssize_t size; @@ -12208,7 +12210,7 @@ #ifdef MS_WINDOWS wchar_t *path_strW; #else - char *path; + const char *path; #endif iterator = PyObject_New(ScandirIterator, &ScandirIteratorType); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat May 7 09:58:34 2016 From: python-checkins at python.org (berker.peksag) Date: Sat, 07 May 2016 13:58:34 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogRml4IHNlbGYuZmFp?= =?utf-8?q?l=28=29_call_in_test=5Fdata=5Fheader?= Message-ID: <20160507135834.89111.18945.6D56F141@psf.io> https://hg.python.org/cpython/rev/52a23bdb7177 changeset: 101258:52a23bdb7177 branch: 3.5 parent: 101254:d1a33c93fa1b user: Berker Peksag date: Sat May 07 16:58:41 2016 +0300 summary: Fix self.fail() call in test_data_header files: Lib/test/test_urllibnet.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py --- a/Lib/test/test_urllibnet.py +++ b/Lib/test/test_urllibnet.py @@ -185,7 +185,7 @@ try: time.strptime(datevalue, dateformat) except ValueError: - self.fail('Date value not in %r format', dateformat) + self.fail('Date value not in %r format' % dateformat) def test_reporthook(self): records = [] -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat May 7 09:58:34 2016 From: python-checkins at python.org (berker.peksag) Date: Sat, 07 May 2016 13:58:34 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Fix_self=2Efail=28=29_call_in_test=5Fdata=5Fheader?= Message-ID: <20160507135834.89117.11174.E14A6F81@psf.io> https://hg.python.org/cpython/rev/8d9f6c1f65f9 changeset: 101259:8d9f6c1f65f9 parent: 101257:7edf74098c76 parent: 101258:52a23bdb7177 user: Berker Peksag date: Sat May 07 16:59:01 2016 +0300 summary: Fix self.fail() call in test_data_header files: Lib/test/test_urllibnet.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py --- a/Lib/test/test_urllibnet.py +++ b/Lib/test/test_urllibnet.py @@ -184,7 +184,7 @@ try: time.strptime(datevalue, dateformat) except ValueError: - self.fail('Date value not in %r format', dateformat) + self.fail('Date value not in %r format' % dateformat) def test_reporthook(self): records = [] -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat May 7 13:38:51 2016 From: python-checkins at python.org (berker.peksag) Date: Sat, 07 May 2016 17:38:51 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2326924=3A_Do_not_d?= =?utf-8?q?efine_=5Fmultiprocessing=2Esem=5Funlink_under_Android?= Message-ID: <20160507173851.31189.87074.7267DB8F@psf.io> https://hg.python.org/cpython/rev/1030aa8357a7 changeset: 101260:1030aa8357a7 user: Berker Peksag date: Sat May 07 20:39:20 2016 +0300 summary: Issue #26924: Do not define _multiprocessing.sem_unlink under Android Android declares sem_unlink but doesn't implement it. files: Modules/_multiprocessing/multiprocessing.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Modules/_multiprocessing/multiprocessing.c b/Modules/_multiprocessing/multiprocessing.c --- a/Modules/_multiprocessing/multiprocessing.c +++ b/Modules/_multiprocessing/multiprocessing.c @@ -128,7 +128,7 @@ {"recv", multiprocessing_recv, METH_VARARGS, ""}, {"send", multiprocessing_send, METH_VARARGS, ""}, #endif -#ifndef POSIX_SEMAPHORES_NOT_ENABLED +#if defined(HAVE_SEM_UNLINK) && !defined(POSIX_SEMAPHORES_NOT_ENABLED) && !defined(__ANDROID__) {"sem_unlink", _PyMp_sem_unlink, METH_VARARGS, ""}, #endif {NULL} -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sat May 7 14:13:22 2016 From: python-checkins at python.org (berker.peksag) Date: Sat, 07 May 2016 18:13:22 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2326924=3A_Fix_Wind?= =?utf-8?q?ows_buildbots?= Message-ID: <20160507181322.42367.34039.F466E662@psf.io> https://hg.python.org/cpython/rev/eee959fee5f5 changeset: 101261:eee959fee5f5 user: Berker Peksag date: Sat May 07 21:13:50 2016 +0300 summary: Issue #26924: Fix Windows buildbots sem_unlink is defined as #define SEM_UNLINK(name) 0 under Windows. files: Modules/_multiprocessing/multiprocessing.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Modules/_multiprocessing/multiprocessing.c b/Modules/_multiprocessing/multiprocessing.c --- a/Modules/_multiprocessing/multiprocessing.c +++ b/Modules/_multiprocessing/multiprocessing.c @@ -128,7 +128,7 @@ {"recv", multiprocessing_recv, METH_VARARGS, ""}, {"send", multiprocessing_send, METH_VARARGS, ""}, #endif -#if defined(HAVE_SEM_UNLINK) && !defined(POSIX_SEMAPHORES_NOT_ENABLED) && !defined(__ANDROID__) +#if !defined(POSIX_SEMAPHORES_NOT_ENABLED) && !defined(__ANDROID__) {"sem_unlink", _PyMp_sem_unlink, METH_VARARGS, ""}, #endif {NULL} -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Sun May 8 05:04:22 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Sun, 08 May 2016 09:04:22 +0000 Subject: [Python-checkins] Daily reference leaks (eee959fee5f5): sum=-19 Message-ID: <20160508090422.130972.76983.B7D259D6@psf.io> results for eee959fee5f5 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, 3, 1] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflog60L1bw', '--timeout', '7200'] From python-checkins at python.org Sun May 8 07:59:29 2016 From: python-checkins at python.org (martin.panter) Date: Sun, 08 May 2016 11:59:29 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI2NTEy?= =?utf-8?q?=3A_Clarify_Integral=3B_tidy_up_table_of_rounding_functions?= Message-ID: <20160508115929.88888.36574.939B7230@psf.io> https://hg.python.org/cpython/rev/a69805edfadd changeset: 101264:a69805edfadd branch: 2.7 parent: 101256:806dfe65ddcf user: Martin Panter date: Sun May 08 12:47:37 2016 +0000 summary: Issue #26512: Clarify Integral; tidy up table of rounding functions Based on patch by Julien. files: Doc/library/stdtypes.rst | 29 +++++++++++++++------------ 1 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -393,19 +393,22 @@ All :class:`numbers.Real` types (:class:`int`, :class:`long`, and :class:`float`) also include the following operations: -+--------------------+------------------------------------+--------+ -| Operation | Result | Notes | -+====================+====================================+========+ -| ``math.trunc(x)`` | *x* truncated to Integral | | -+--------------------+------------------------------------+--------+ -| ``round(x[, n])`` | *x* rounded to n digits, | | -| | rounding ties away from zero. If n | | -| | is omitted, it defaults to 0. | | -+--------------------+------------------------------------+--------+ -| ``math.floor(x)`` | the greatest integral float <= *x* | | -+--------------------+------------------------------------+--------+ -| ``math.ceil(x)`` | the least integral float >= *x* | | -+--------------------+------------------------------------+--------+ ++--------------------+---------------------------------------------+ +| Operation | Result | ++====================+=============================================+ +| :func:`math.trunc(\| *x* truncated to :class:`~numbers.Integral` | +| x) ` | | ++--------------------+---------------------------------------------+ +| :func:`round(x[, | *x* rounded to *n* digits, | +| n]) ` | rounding ties away from zero. If *n* | +| | is omitted, it defaults to 0. | ++--------------------+---------------------------------------------+ +| :func:`math.floor(\| the greatest integer as a float <= *x* | +| x) ` | | ++--------------------+---------------------------------------------+ +| :func:`math.ceil(x)| the least integer as a float >= *x* | +| ` | | ++--------------------+---------------------------------------------+ .. XXXJH exceptions: overflow (when? what operations?) zerodivision -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 8 07:59:29 2016 From: python-checkins at python.org (martin.panter) Date: Sun, 08 May 2016 11:59:29 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2NTEy?= =?utf-8?q?=3A_Clarify_Integral=3B_tidy_up_table_of_rounding_functions?= Message-ID: <20160508115928.9353.52667.BC65F148@psf.io> https://hg.python.org/cpython/rev/9e29034a41fa changeset: 101262:9e29034a41fa branch: 3.5 parent: 101258:52a23bdb7177 user: Martin Panter date: Sun May 08 12:22:37 2016 +0000 summary: Issue #26512: Clarify Integral; tidy up table of rounding functions Based on patch by Julien. files: Doc/library/stdtypes.rst | 29 +++++++++++++++------------ Modules/mathmodule.c | 8 +++--- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -361,19 +361,22 @@ All :class:`numbers.Real` types (:class:`int` and :class:`float`) also include the following operations: -+--------------------+------------------------------------+--------+ -| Operation | Result | Notes | -+====================+====================================+========+ -| ``math.trunc(x)`` | *x* truncated to Integral | | -+--------------------+------------------------------------+--------+ -| ``round(x[, n])`` | *x* rounded to n digits, | | -| | rounding half to even. If n is | | -| | omitted, it defaults to 0. | | -+--------------------+------------------------------------+--------+ -| ``math.floor(x)`` | the greatest integral float <= *x* | | -+--------------------+------------------------------------+--------+ -| ``math.ceil(x)`` | the least integral float >= *x* | | -+--------------------+------------------------------------+--------+ ++--------------------+---------------------------------------------+ +| Operation | Result | ++====================+=============================================+ +| :func:`math.trunc(\| *x* truncated to :class:`~numbers.Integral` | +| x) ` | | ++--------------------+---------------------------------------------+ +| :func:`round(x[, | *x* rounded to *n* digits, | +| n]) ` | rounding half to even. If *n* is | +| | omitted, it defaults to 0. | ++--------------------+---------------------------------------------+ +| :func:`math.floor(\| the greatest :class:`~numbers.Integral` | +| x) ` | <= *x* | ++--------------------+---------------------------------------------+ +| :func:`math.ceil(x)| the least :class:`~numbers.Integral` >= *x* | +| ` | | ++--------------------+---------------------------------------------+ For additional numeric operations see the :mod:`math` and :mod:`cmath` modules. diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -957,8 +957,8 @@ } PyDoc_STRVAR(math_ceil_doc, - "ceil(x)\n\nReturn the ceiling of x as an int.\n" - "This is the smallest integral value >= x."); + "ceil(x)\n\nReturn the ceiling of x as an Integral.\n" + "This is the smallest integer >= x."); FUNC2(copysign, copysign, "copysign(x, y)\n\nReturn a float with the magnitude (absolute value) " @@ -997,8 +997,8 @@ } PyDoc_STRVAR(math_floor_doc, - "floor(x)\n\nReturn the floor of x as an int.\n" - "This is the largest integral value <= x."); + "floor(x)\n\nReturn the floor of x as an Integral.\n" + "This is the largest integer <= x."); FUNC1A(gamma, m_tgamma, "gamma(x)\n\nGamma function at x.") -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 8 07:59:29 2016 From: python-checkins at python.org (martin.panter) Date: Sun, 08 May 2016 11:59:29 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326512=3A_Merge_rounding_doc_from_3=2E5?= Message-ID: <20160508115928.15110.89825.C3C23B7B@psf.io> https://hg.python.org/cpython/rev/a8883951b2ff changeset: 101263:a8883951b2ff parent: 101261:eee959fee5f5 parent: 101262:9e29034a41fa user: Martin Panter date: Sun May 08 12:34:58 2016 +0000 summary: Issue #26512: Merge rounding doc from 3.5 files: Doc/library/stdtypes.rst | 29 +++++++++++++++------------ Modules/mathmodule.c | 8 +++--- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -361,19 +361,22 @@ All :class:`numbers.Real` types (:class:`int` and :class:`float`) also include the following operations: -+--------------------+------------------------------------+--------+ -| Operation | Result | Notes | -+====================+====================================+========+ -| ``math.trunc(x)`` | *x* truncated to Integral | | -+--------------------+------------------------------------+--------+ -| ``round(x[, n])`` | *x* rounded to n digits, | | -| | rounding half to even. If n is | | -| | omitted, it defaults to 0. | | -+--------------------+------------------------------------+--------+ -| ``math.floor(x)`` | the greatest integral float <= *x* | | -+--------------------+------------------------------------+--------+ -| ``math.ceil(x)`` | the least integral float >= *x* | | -+--------------------+------------------------------------+--------+ ++--------------------+---------------------------------------------+ +| Operation | Result | ++====================+=============================================+ +| :func:`math.trunc(\| *x* truncated to :class:`~numbers.Integral` | +| x) ` | | ++--------------------+---------------------------------------------+ +| :func:`round(x[, | *x* rounded to *n* digits, | +| n]) ` | rounding half to even. If *n* is | +| | omitted, it defaults to 0. | ++--------------------+---------------------------------------------+ +| :func:`math.floor(\| the greatest :class:`~numbers.Integral` | +| x) ` | <= *x* | ++--------------------+---------------------------------------------+ +| :func:`math.ceil(x)| the least :class:`~numbers.Integral` >= *x* | +| ` | | ++--------------------+---------------------------------------------+ For additional numeric operations see the :mod:`math` and :mod:`cmath` modules. diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -957,8 +957,8 @@ } PyDoc_STRVAR(math_ceil_doc, - "ceil(x)\n\nReturn the ceiling of x as an int.\n" - "This is the smallest integral value >= x."); + "ceil(x)\n\nReturn the ceiling of x as an Integral.\n" + "This is the smallest integer >= x."); FUNC2(copysign, copysign, "copysign(x, y)\n\nReturn a float with the magnitude (absolute value) " @@ -997,8 +997,8 @@ } PyDoc_STRVAR(math_floor_doc, - "floor(x)\n\nReturn the floor of x as an int.\n" - "This is the largest integral value <= x."); + "floor(x)\n\nReturn the floor of x as an Integral.\n" + "This is the largest integer <= x."); FUNC1A(gamma, m_tgamma, "gamma(x)\n\nGamma function at x.") -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 8 08:14:54 2016 From: python-checkins at python.org (steven.daprano) Date: Sun, 08 May 2016 12:14:54 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_26977=2C_remove_unne?= =?utf-8?q?eded_line_in_pvariance_=28duplicate_call_to_=5Fss=29=2E?= Message-ID: <20160508121454.15110.90273.B0D177A2@psf.io> https://hg.python.org/cpython/rev/2bf4a02f3570 changeset: 101265:2bf4a02f3570 parent: 101263:a8883951b2ff user: Steven D'Aprano date: Sun May 08 22:14:38 2016 +1000 summary: Issue 26977, remove unneeded line in pvariance (duplicate call to _ss). files: Lib/statistics.py | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/Lib/statistics.py b/Lib/statistics.py --- a/Lib/statistics.py +++ b/Lib/statistics.py @@ -593,7 +593,6 @@ n = len(data) if n < 1: raise StatisticsError('pvariance requires at least one data point') - ss = _ss(data, mu) T, ss = _ss(data, mu) return _convert(ss/n, T) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 8 09:18:26 2016 From: python-checkins at python.org (martin.panter) Date: Sun, 08 May 2016 13:18:26 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Fix_typos_in_c?= =?utf-8?q?omments=2C_documentation_and_test_method_names?= Message-ID: <20160508131826.31201.19080.AABD15CB@psf.io> https://hg.python.org/cpython/rev/f6e8b2bbad31 changeset: 101268:f6e8b2bbad31 branch: 3.5 parent: 101262:9e29034a41fa user: Martin Panter date: Sun May 08 13:48:10 2016 +0000 summary: Fix typos in comments, documentation and test method names files: Doc/howto/logging-cookbook.rst | 2 +- Doc/reference/simple_stmts.rst | 2 +- Lib/http/cookiejar.py | 2 +- Lib/idlelib/ChangeLog | 2 +- Lib/test/test_descr.py | 2 +- Lib/test/test_module.py | 2 +- Lib/tkinter/__init__.py | 4 ++-- Lib/urllib/robotparser.py | 2 +- Mac/BuildScript/scripts/postflight.patch-profile | 4 ++-- Misc/NEWS | 2 +- 10 files changed, 12 insertions(+), 12 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 @@ -2231,7 +2231,7 @@ The example script has a simple function, ``foo``, which just cycles through all the logging levels, writing to ``sys.stderr`` to say what level it's about -to log at, and then actually logging a message that that level. You can pass a +to log at, and then actually logging a message at that level. You can pass a parameter to ``foo`` which, if true, will log at ERROR and CRITICAL levels - otherwise, it only logs at DEBUG, INFO and WARNING levels. diff --git a/Doc/reference/simple_stmts.rst b/Doc/reference/simple_stmts.rst --- a/Doc/reference/simple_stmts.rst +++ b/Doc/reference/simple_stmts.rst @@ -237,7 +237,7 @@ phase, causing less detailed error messages. Although the definition of assignment implies that overlaps between the -left-hand side and the right-hand side are 'simultanenous' (for example ``a, b = +left-hand side and the right-hand side are 'simultaneous' (for example ``a, b = b, a`` swaps two variables), overlaps *within* the collection of assigned-to variables occur left-to-right, sometimes resulting in confusion. For instance, the following program prints ``[0, 2]``:: diff --git a/Lib/http/cookiejar.py b/Lib/http/cookiejar.py --- a/Lib/http/cookiejar.py +++ b/Lib/http/cookiejar.py @@ -1841,7 +1841,7 @@ class LWPCookieJar(FileCookieJar): """ The LWPCookieJar saves a sequence of "Set-Cookie3" lines. - "Set-Cookie3" is the format used by the libwww-perl libary, not known + "Set-Cookie3" is the format used by the libwww-perl library, not known to be compatible with any browser, but which is easy to read and doesn't lose information about RFC 2965 cookies. diff --git a/Lib/idlelib/ChangeLog b/Lib/idlelib/ChangeLog --- a/Lib/idlelib/ChangeLog +++ b/Lib/idlelib/ChangeLog @@ -1574,7 +1574,7 @@ * Attic/PopupMenu.py: Pass a root to the help window. * SearchBinding.py: - Add parent argument to 'to to line number' dialog box. + Add parent argument to 'go to line number' dialog box. Sat Oct 10 19:15:32 1998 Guido van Rossum diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -3489,7 +3489,7 @@ b.a = a z = deepcopy(a) # This blew up before - def test_unintialized_modules(self): + def test_uninitialized_modules(self): # Testing uninitialized module objects... from types import ModuleType as M m = M.__new__(M) diff --git a/Lib/test/test_module.py b/Lib/test/test_module.py --- a/Lib/test/test_module.py +++ b/Lib/test/test_module.py @@ -30,7 +30,7 @@ pass self.assertEqual(foo.__doc__, ModuleType.__doc__) - def test_unintialized_missing_getattr(self): + def test_uninitialized_missing_getattr(self): # Issue 8297 # test the text in the AttributeError of an uninitialized module foo = ModuleType.__new__(ModuleType) diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -1249,7 +1249,7 @@ nsign, b, f, h, k, s, t, w, x, y, A, E, K, N, W, T, X, Y, D = args # Missing: (a, c, d, m, o, v, B, R) e = Event() - # serial field: valid vor all events + # serial field: valid for all events # number of button: ButtonPress and ButtonRelease events only # height field: Configure, ConfigureRequest, Create, # ResizeRequest, and Expose events only @@ -1261,7 +1261,7 @@ # y field: "valid for events that contain a y field" # keysym as decimal: KeyPress and KeyRelease events only # x_root, y_root fields: ButtonPress, ButtonRelease, KeyPress, - # KeyRelease,and Motion events + # KeyRelease, and Motion events e.serial = getint(nsign) e.num = getint_event(b) try: e.focus = getboolean(f) diff --git a/Lib/urllib/robotparser.py b/Lib/urllib/robotparser.py --- a/Lib/urllib/robotparser.py +++ b/Lib/urllib/robotparser.py @@ -132,7 +132,7 @@ return True # Until the robots.txt file has been read or found not # to exist, we must assume that no url is allowable. - # This prevents false positives when a user erronenously + # This prevents false positives when a user erroneously # calls can_fetch() before calling read(). if not self.last_checked: return False diff --git a/Mac/BuildScript/scripts/postflight.patch-profile b/Mac/BuildScript/scripts/postflight.patch-profile --- a/Mac/BuildScript/scripts/postflight.patch-profile +++ b/Mac/BuildScript/scripts/postflight.patch-profile @@ -58,7 +58,7 @@ fi echo "" >> "${RC}" echo "# Setting PATH for Python ${PYVER}" >> "${RC}" - echo "# The orginal version is saved in .cshrc.pysave" >> "${RC}" + echo "# The original version is saved in .cshrc.pysave" >> "${RC}" echo "set path=(${PYTHON_ROOT}/bin "'$path'")" >> "${RC}" if [ `id -ur` = 0 ]; then chown "${USER}" "${RC}" @@ -90,7 +90,7 @@ fi echo "" >> "${PR}" echo "# Setting PATH for Python ${PYVER}" >> "${PR}" -echo "# The orginal version is saved in `basename ${PR}`.pysave" >> "${PR}" +echo "# The original version is saved in `basename ${PR}`.pysave" >> "${PR}" echo 'PATH="'"${PYTHON_ROOT}/bin"':${PATH}"' >> "${PR}" echo 'export PATH' >> "${PR}" if [ `id -ur` = 0 ]; then diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -2674,7 +2674,7 @@ is run with pythonw.exe. - Issue #21775: shutil.copytree(): fix crash when copying to VFAT. An exception - handler assumed that that OSError objects always have a 'winerror' attribute. + handler assumed that OSError objects always have a 'winerror' attribute. That is not the case, so the exception handler itself raised AttributeError when run on Linux (and, presumably, any other non-Windows OS). Patch by Greg Ward. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 8 09:18:26 2016 From: python-checkins at python.org (martin.panter) Date: Sun, 08 May 2016 13:18:26 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Corrections_fo?= =?utf-8?q?r_a/an_in_code_comments_and_documentation?= Message-ID: <20160508131826.22577.62002.6B67603F@psf.io> https://hg.python.org/cpython/rev/1b4320232e61 changeset: 101267:1b4320232e61 branch: 2.7 user: Martin Panter date: Sun May 08 13:45:55 2016 +0000 summary: Corrections for a/an in code comments and documentation files: Demo/metaclasses/index.html | 2 +- Doc/c-api/string.rst | 2 +- Doc/library/codecs.rst | 2 +- Doc/library/ctypes.rst | 2 +- Doc/library/imageop.rst | 2 +- Doc/library/stdtypes.rst | 2 +- Include/memoryobject.h | 2 +- Include/pythonrun.h | 2 +- Lib/lib-tk/Tkinter.py | 2 +- Lib/test/test_imageop.py | 2 +- Mac/README | 2 +- Misc/cheatsheet | 2 +- Modules/audioop.c | 6 +++--- Objects/floatobject.c | 2 +- Objects/stringlib/formatter.h | 4 ++-- PC/pyconfig.h | 2 +- 16 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Demo/metaclasses/index.html b/Demo/metaclasses/index.html --- a/Demo/metaclasses/index.html +++ b/Demo/metaclasses/index.html @@ -222,7 +222,7 @@ means calling the metainstance, and this will return a real instance. And what class is that an instance of? Conceptually, it is of course an instance of our metainstance; but in most cases the Python runtime -system will see it as an instance of a a helper class used by the +system will see it as an instance of a helper class used by the metaclass to implement its (non-meta) instances...

Hopefully an example will make things clearer. Let's presume we diff --git a/Doc/c-api/string.rst b/Doc/c-api/string.rst --- a/Doc/c-api/string.rst +++ b/Doc/c-api/string.rst @@ -88,7 +88,7 @@ | :attr:`%%` | *n/a* | The literal % character. | +-------------------+---------------+--------------------------------+ | :attr:`%c` | int | A single character, | - | | | represented as an C int. | + | | | represented as a C int. | +-------------------+---------------+--------------------------------+ | :attr:`%d` | int | Exactly equivalent to | | | | ``printf("%d")``. | diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst --- a/Doc/library/codecs.rst +++ b/Doc/library/codecs.rst @@ -909,7 +909,7 @@ * an ISO 8859 codeset -* a Microsoft Windows code page, which is typically derived from a 8859 codeset, +* a Microsoft Windows code page, which is typically derived from an 8859 codeset, but replaces control characters with additional graphic characters * an IBM EBCDIC code page diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst --- a/Doc/library/ctypes.rst +++ b/Doc/library/ctypes.rst @@ -1873,7 +1873,7 @@ 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 a unicode string + If the first parameter is an 8-bit string, it is converted into a unicode string according to ctypes conversion rules. diff --git a/Doc/library/imageop.rst b/Doc/library/imageop.rst --- a/Doc/library/imageop.rst +++ b/Doc/library/imageop.rst @@ -49,7 +49,7 @@ .. function:: grey2mono(image, width, height, threshold) - Convert a 8-bit deep greyscale image to a 1-bit deep image by thresholding all + Convert an 8-bit deep greyscale image to a 1-bit deep image by thresholding all the pixels. The resulting image is tightly packed and is probably only useful as an argument to :func:`mono2grey`. diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2749,7 +2749,7 @@ .. attribute:: shape A tuple of integers the length of :attr:`ndim` giving the shape of the - memory as a N-dimensional array. + memory as an N-dimensional array. .. attribute:: ndim diff --git a/Include/memoryobject.h b/Include/memoryobject.h --- a/Include/memoryobject.h +++ b/Include/memoryobject.h @@ -33,7 +33,7 @@ original buffer if a copy must be made. If buffertype is PyBUF_WRITE and the buffer is not contiguous an error will be raised. In this circumstance, the user can use - PyBUF_SHADOW to ensure that a a writable temporary + PyBUF_SHADOW to ensure that a writable temporary contiguous buffer is returned. The contents of this contiguous buffer will be copied back into the original object after the memoryview object is deleted as long as diff --git a/Include/pythonrun.h b/Include/pythonrun.h --- a/Include/pythonrun.h +++ b/Include/pythonrun.h @@ -155,7 +155,7 @@ /* Stack size, in "pointers" (so we get extra safety margins on 64-bit platforms). On a 32-bit platform, this translates - to a 8k margin. */ + to an 8k margin. */ #define PYOS_STACK_MARGIN 2048 #if defined(WIN32) && !defined(MS_WIN64) && defined(_MSC_VER) && _MSC_VER >= 1300 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 @@ -1252,7 +1252,7 @@ # time field: "valid for events that contain a time field" # width field: Configure, ConfigureRequest, Create, ResizeRequest, # and Expose events only - # x field: "valid for events that contain a x field" + # x field: "valid for events that contain an x field" # y field: "valid for events that contain a y field" # keysym as decimal: KeyPress and KeyRelease events only # x_root, y_root fields: ButtonPress, ButtonRelease, KeyPress, diff --git a/Lib/test/test_imageop.py b/Lib/test/test_imageop.py --- a/Lib/test/test_imageop.py +++ b/Lib/test/test_imageop.py @@ -121,7 +121,7 @@ print 'grey2rgb' image = imageop.grey2rgb(greyimage, width, height) - # Convert a 8-bit deep greyscale image to a 1-bit deep image by + # Convert an 8-bit deep greyscale image to a 1-bit deep image by # thresholding all the pixels. The resulting image is tightly packed # and is probably only useful as an argument to mono2grey. if verbose: diff --git a/Mac/README b/Mac/README --- a/Mac/README +++ b/Mac/README @@ -125,7 +125,7 @@ To build a universal binary that includes a 64-bit architecture, you must build on a system running OS X 10.5 or later. The ``all`` and ``64-bit`` flavors can -only be built with an 10.5 SDK because ``ppc64`` support was only included with +only be built with a 10.5 SDK because ``ppc64`` support was only included with OS X 10.5. Although legacy ``ppc`` support was included with Xcode 3 on OS X 10.6, it was removed in Xcode 4, versions of which were released on OS X 10.6 and which is the standard for OS X 10.7. To summarize, the diff --git a/Misc/cheatsheet b/Misc/cheatsheet --- a/Misc/cheatsheet +++ b/Misc/cheatsheet @@ -1053,7 +1053,7 @@ recommanded to use the following form:if isinstance(x, types.StringType): etc... unichr(code) code. -unicode(string[, Creates a Unicode string from a 8-bit string, using +unicode(string[, Creates a Unicode string from an 8-bit string, using encoding[, error thegiven encoding name and error treatment ('strict', ]]]) 'ignore',or 'replace'}. Without arguments, returns a dictionary correspondingto the diff --git a/Modules/audioop.c b/Modules/audioop.c --- a/Modules/audioop.c +++ b/Modules/audioop.c @@ -55,7 +55,7 @@ */ #define BIAS 0x84 /* define the add-in bias for 16 bit samples */ #define CLIP 32635 -#define SIGN_BIT (0x80) /* Sign bit for a A-law byte. */ +#define SIGN_BIT (0x80) /* Sign bit for an A-law byte. */ #define QUANT_MASK (0xf) /* Quantization field mask. */ #define SEG_SHIFT (4) /* Left shift for segment number. */ #define SEG_MASK (0x70) /* Segment field mask. */ @@ -229,8 +229,8 @@ }; /* - * linear2alaw() accepts an 13-bit signed integer and encodes it as A-law data - * stored in a unsigned char. This function should only be called with + * linear2alaw() accepts a 13-bit signed integer and encodes it as A-law data + * stored in an unsigned char. This function should only be called with * the data shifted such that it only contains information in the lower * 13-bits. * diff --git a/Objects/floatobject.c b/Objects/floatobject.c --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -407,7 +407,7 @@ * may lose info from fractional bits. Converting the integer to a double * also has two failure modes: (1) a long int may trigger overflow (too * large to fit in the dynamic range of a C double); (2) even a C long may have - * more bits than fit in a C double (e.g., on a a 64-bit box long may have + * more bits than fit in a C double (e.g., on a 64-bit box long may have * 63 bits of precision, but a C double probably has only 53), and then * we can falsely claim equality when low-order integer bits are lost by * coercion to double. So this part is painful too. diff --git a/Objects/stringlib/formatter.h b/Objects/stringlib/formatter.h --- a/Objects/stringlib/formatter.h +++ b/Objects/stringlib/formatter.h @@ -995,7 +995,7 @@ if (precision < 0) precision = default_precision; - /* Cast "type", because if we're in unicode we need to pass a + /* Cast "type", because if we're in unicode we need to pass an 8-bit char. This is safe, because we've restricted what "type" can be. */ buf = PyOS_double_to_string(val, (char)type, precision, flags, @@ -1175,7 +1175,7 @@ if (precision < 0) precision = default_precision; - /* Cast "type", because if we're in unicode we need to pass a + /* Cast "type", because if we're in unicode we need to pass an 8-bit char. This is safe, because we've restricted what "type" can be. */ re_buf = PyOS_double_to_string(re, (char)type, precision, flags, diff --git a/PC/pyconfig.h b/PC/pyconfig.h --- a/PC/pyconfig.h +++ b/PC/pyconfig.h @@ -368,7 +368,7 @@ # define SIZEOF_FPOS_T 8 # define SIZEOF_HKEY 4 # define SIZEOF_SIZE_T 4 - /* MS VS2005 changes time_t to an 64-bit type on all platforms */ + /* MS VS2005 changes time_t to a 64-bit type on all platforms */ # if defined(_MSC_VER) && _MSC_VER >= 1400 # define SIZEOF_TIME_T 8 # else -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 8 09:18:27 2016 From: python-checkins at python.org (martin.panter) Date: Sun, 08 May 2016 13:18:27 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Fix_typos_in_c?= =?utf-8?q?omments=2C_documentation_and_test_method_names?= Message-ID: <20160508131826.130972.80695.25A174C6@psf.io> https://hg.python.org/cpython/rev/5efcd5e9470f changeset: 101266:5efcd5e9470f branch: 2.7 parent: 101264:a69805edfadd user: Martin Panter date: Sun May 08 13:18:25 2016 +0000 summary: Fix typos in comments, documentation and test method names files: Doc/howto/logging-cookbook.rst | 2 +- Doc/library/logging.handlers.rst | 2 +- Lib/_LWPCookieJar.py | 2 +- Lib/idlelib/ChangeLog | 2 +- Lib/lib-tk/Tkinter.py | 4 ++-- Lib/robotparser.py | 2 +- Lib/test/test_descr.py | 2 +- Mac/BuildScript/scripts/postflight.patch-profile | 4 ++-- Misc/HISTORY | 2 +- 9 files changed, 11 insertions(+), 11 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 @@ -1247,7 +1247,7 @@ The example script has a simple function, ``foo``, which just cycles through all the logging levels, writing to ``sys.stderr`` to say what level it's about -to log at, and then actually logging a message that that level. You can pass a +to log at, and then actually logging a message at that level. You can pass a parameter to ``foo`` which, if true, will log at ERROR and CRITICAL levels - otherwise, it only logs at DEBUG, INFO and WARNING levels. diff --git a/Doc/library/logging.handlers.rst b/Doc/library/logging.handlers.rst --- a/Doc/library/logging.handlers.rst +++ b/Doc/library/logging.handlers.rst @@ -349,7 +349,7 @@ .. method:: createSocket() Tries to create a socket; on failure, uses an exponential back-off - algorithm. On intial failure, the handler will drop the message it was + algorithm. On initial failure, the handler will drop the message it was trying to send. When subsequent messages are handled by the same instance, it will not try connecting until some time has passed. The default parameters are such that the initial delay is one second, and if diff --git a/Lib/_LWPCookieJar.py b/Lib/_LWPCookieJar.py --- a/Lib/_LWPCookieJar.py +++ b/Lib/_LWPCookieJar.py @@ -49,7 +49,7 @@ class LWPCookieJar(FileCookieJar): """ The LWPCookieJar saves a sequence of "Set-Cookie3" lines. - "Set-Cookie3" is the format used by the libwww-perl libary, not known + "Set-Cookie3" is the format used by the libwww-perl library, not known to be compatible with any browser, but which is easy to read and doesn't lose information about RFC 2965 cookies. diff --git a/Lib/idlelib/ChangeLog b/Lib/idlelib/ChangeLog --- a/Lib/idlelib/ChangeLog +++ b/Lib/idlelib/ChangeLog @@ -1574,7 +1574,7 @@ * Attic/PopupMenu.py: Pass a root to the help window. * SearchBinding.py: - Add parent argument to 'to to line number' dialog box. + Add parent argument to 'go to line number' dialog box. Sat Oct 10 19:15:32 1998 Guido van Rossum 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 @@ -1244,7 +1244,7 @@ nsign, b, f, h, k, s, t, w, x, y, A, E, K, N, W, T, X, Y, D = args # Missing: (a, c, d, m, o, v, B, R) e = Event() - # serial field: valid vor all events + # serial field: valid for all events # number of button: ButtonPress and ButtonRelease events only # height field: Configure, ConfigureRequest, Create, # ResizeRequest, and Expose events only @@ -1256,7 +1256,7 @@ # y field: "valid for events that contain a y field" # keysym as decimal: KeyPress and KeyRelease events only # x_root, y_root fields: ButtonPress, ButtonRelease, KeyPress, - # KeyRelease,and Motion events + # KeyRelease, and Motion events e.serial = getint(nsign) e.num = getint_event(b) try: e.focus = getboolean(f) diff --git a/Lib/robotparser.py b/Lib/robotparser.py --- a/Lib/robotparser.py +++ b/Lib/robotparser.py @@ -136,7 +136,7 @@ # Until the robots.txt file has been read or found not # to exist, we must assume that no url is allowable. - # This prevents false positives when a user erronenously + # This prevents false positives when a user erroneously # calls can_fetch() before calling read(). if not self.last_checked: return False diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -3723,7 +3723,7 @@ b.a = a z = deepcopy(a) # This blew up before - def test_unintialized_modules(self): + def test_uninitialized_modules(self): # Testing uninitialized module objects... from types import ModuleType as M m = M.__new__(M) diff --git a/Mac/BuildScript/scripts/postflight.patch-profile b/Mac/BuildScript/scripts/postflight.patch-profile --- a/Mac/BuildScript/scripts/postflight.patch-profile +++ b/Mac/BuildScript/scripts/postflight.patch-profile @@ -58,7 +58,7 @@ fi echo "" >> "${RC}" echo "# Setting PATH for Python ${PYVER}" >> "${RC}" - echo "# The orginal version is saved in .cshrc.pysave" >> "${RC}" + echo "# The original version is saved in .cshrc.pysave" >> "${RC}" echo "set path=(${PYTHON_ROOT}/bin "'$path'")" >> "${RC}" if [ `id -ur` = 0 ]; then chown "${USER}" "${RC}" @@ -90,7 +90,7 @@ fi echo "" >> "${PR}" echo "# Setting PATH for Python ${PYVER}" >> "${PR}" -echo "# The orginal version is saved in `basename ${PR}`.pysave" >> "${PR}" +echo "# The original version is saved in `basename ${PR}`.pysave" >> "${PR}" echo 'PATH="'"${PYTHON_ROOT}/bin"':${PATH}"' >> "${PR}" echo 'export PATH' >> "${PR}" if [ `id -ur` = 0 ]; then diff --git a/Misc/HISTORY b/Misc/HISTORY --- a/Misc/HISTORY +++ b/Misc/HISTORY @@ -3134,7 +3134,7 @@ - When method objects have an attribute that can be satisfied either by the function object or by the method object, the function object's attribute usually wins. Christian Tismer pointed out that - that this is really a mistake, because this only happens for special + this is really a mistake, because this only happens for special methods (like __reduce__) where the method object's version is really more appropriate than the function's attribute. So from now on, all method attributes will have precedence over function -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 8 09:18:27 2016 From: python-checkins at python.org (martin.panter) Date: Sun, 08 May 2016 13:18:27 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_Corrections_fo?= =?utf-8?q?r_a/an_in_code_comments_and_documentation?= Message-ID: <20160508131826.9140.29560.88BC59A6@psf.io> https://hg.python.org/cpython/rev/d783cbef73fb changeset: 101269:d783cbef73fb branch: 3.5 user: Martin Panter date: Sun May 08 13:53:41 2016 +0000 summary: Corrections for a/an in code comments and documentation files: Doc/library/codecs.rst | 2 +- Include/pythonrun.h | 2 +- Lib/pickletools.py | 8 ++++---- Lib/tkinter/__init__.py | 2 +- Mac/README | 2 +- Modules/arraymodule.c | 2 +- Modules/audioop.c | 4 ++-- PC/pyconfig.h | 2 +- Python/formatter_unicode.c | 4 ++-- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst --- a/Doc/library/codecs.rst +++ b/Doc/library/codecs.rst @@ -977,7 +977,7 @@ * an ISO 8859 codeset -* a Microsoft Windows code page, which is typically derived from a 8859 codeset, +* a Microsoft Windows code page, which is typically derived from an 8859 codeset, but replaces control characters with additional graphic characters * an IBM EBCDIC code page diff --git a/Include/pythonrun.h b/Include/pythonrun.h --- a/Include/pythonrun.h +++ b/Include/pythonrun.h @@ -176,7 +176,7 @@ /* Stack size, in "pointers" (so we get extra safety margins on 64-bit platforms). On a 32-bit platform, this translates - to a 8k margin. */ + to an 8k margin. */ #define PYOS_STACK_MARGIN 2048 #if defined(WIN32) && !defined(MS_WIN64) && defined(_MSC_VER) && _MSC_VER >= 1300 diff --git a/Lib/pickletools.py b/Lib/pickletools.py --- a/Lib/pickletools.py +++ b/Lib/pickletools.py @@ -590,7 +590,7 @@ reader=read_bytes8, doc="""A counted bytes string. - The first argument is a 8-byte little-endian unsigned int giving + The first argument is an 8-byte little-endian unsigned int giving the number of bytes, and the second argument is that many bytes. """) @@ -734,7 +734,7 @@ reader=read_unicodestring8, doc="""A counted Unicode string. - The first argument is a 8-byte little-endian signed int + The first argument is an 8-byte little-endian signed int giving the number of bytes in the string, and the second argument-- the UTF-8 encoding of the Unicode string -- contains that many bytes. @@ -1330,7 +1330,7 @@ proto=4, doc="""Push a Python bytes object. - There are two arguments: the first is a 8-byte unsigned int giving + There are two arguments: the first is an 8-byte unsigned int giving the number of bytes in the string, and the second is that many bytes, which are taken literally as the string content. """), @@ -1417,7 +1417,7 @@ proto=4, doc="""Push a Python Unicode string object. - There are two arguments: the first is a 8-byte little-endian signed int + There are two arguments: the first is an 8-byte little-endian signed int giving the number of bytes in the string. The second is that many bytes, and is the UTF-8 encoding of the Unicode string. """), diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -1257,7 +1257,7 @@ # time field: "valid for events that contain a time field" # width field: Configure, ConfigureRequest, Create, ResizeRequest, # and Expose events only - # x field: "valid for events that contain a x field" + # x field: "valid for events that contain an x field" # y field: "valid for events that contain a y field" # keysym as decimal: KeyPress and KeyRelease events only # x_root, y_root fields: ButtonPress, ButtonRelease, KeyPress, diff --git a/Mac/README b/Mac/README --- a/Mac/README +++ b/Mac/README @@ -126,7 +126,7 @@ To build a universal binary that includes a 64-bit architecture, you must build on a system running OS X 10.5 or later. The ``all`` and ``64-bit`` flavors can -only be built with an 10.5 SDK because ``ppc64`` support was only included with +only be built with a 10.5 SDK because ``ppc64`` support was only included with OS X 10.5. Although legacy ``ppc`` support was included with Xcode 3 on OS X 10.6, it was removed in Xcode 4, versions of which were released on OS X 10.6 and which is the standard for OS X 10.7. To summarize, the diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -2090,7 +2090,7 @@ * that fits better. This may result in an array with narrower * or wider elements. * - * For example, if a 32-bit machine pickles a L-code array of + * For example, if a 32-bit machine pickles an L-code array of * unsigned longs, then the array will be unpickled by 64-bit * machine as an I-code array of unsigned ints. * diff --git a/Modules/audioop.c b/Modules/audioop.c --- a/Modules/audioop.c +++ b/Modules/audioop.c @@ -46,7 +46,7 @@ */ #define BIAS 0x84 /* define the add-in bias for 16 bit samples */ #define CLIP 32635 -#define SIGN_BIT (0x80) /* Sign bit for a A-law byte. */ +#define SIGN_BIT (0x80) /* Sign bit for an A-law byte. */ #define QUANT_MASK (0xf) /* Quantization field mask. */ #define SEG_SHIFT (4) /* Left shift for segment number. */ #define SEG_MASK (0x70) /* Segment field mask. */ @@ -217,7 +217,7 @@ }; /* - * linear2alaw() accepts an 13-bit signed integer and encodes it as A-law data + * linear2alaw() accepts a 13-bit signed integer and encodes it as A-law data * stored in an unsigned char. This function should only be called with * the data shifted such that it only contains information in the lower * 13-bits. diff --git a/PC/pyconfig.h b/PC/pyconfig.h --- a/PC/pyconfig.h +++ b/PC/pyconfig.h @@ -347,7 +347,7 @@ # define SIZEOF_FPOS_T 8 # define SIZEOF_HKEY 4 # define SIZEOF_SIZE_T 4 - /* MS VS2005 changes time_t to an 64-bit type on all platforms */ + /* MS VS2005 changes time_t to a 64-bit type on all platforms */ # if defined(_MSC_VER) && _MSC_VER >= 1400 # define SIZEOF_TIME_T 8 # else diff --git a/Python/formatter_unicode.c b/Python/formatter_unicode.c --- a/Python/formatter_unicode.c +++ b/Python/formatter_unicode.c @@ -1042,7 +1042,7 @@ else if (type == 'r') type = 'g'; - /* Cast "type", because if we're in unicode we need to pass a + /* Cast "type", because if we're in unicode we need to pass an 8-bit char. This is safe, because we've restricted what "type" can be. */ buf = PyOS_double_to_string(val, (char)type, precision, flags, @@ -1221,7 +1221,7 @@ else if (type == 'r') type = 'g'; - /* Cast "type", because if we're in unicode we need to pass a + /* Cast "type", because if we're in unicode we need to pass an 8-bit char. This is safe, because we've restricted what "type" can be. */ re_buf = PyOS_double_to_string(re, (char)type, precision, flags, -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 8 09:18:27 2016 From: python-checkins at python.org (martin.panter) Date: Sun, 08 May 2016 13:18:27 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Merge_typo_fixes_from_3=2E5?= Message-ID: <20160508131826.123432.90696.B465744D@psf.io> https://hg.python.org/cpython/rev/c61d2c43d22e changeset: 101270:c61d2c43d22e parent: 101265:2bf4a02f3570 parent: 101269:d783cbef73fb user: Martin Panter date: Sun May 08 14:02:35 2016 +0000 summary: Merge typo fixes from 3.5 files: Doc/howto/logging-cookbook.rst | 2 +- Doc/library/codecs.rst | 2 +- Doc/reference/simple_stmts.rst | 2 +- Include/pythonrun.h | 2 +- Lib/http/cookiejar.py | 2 +- Lib/idlelib/ChangeLog | 2 +- Lib/pickletools.py | 8 ++++---- Lib/test/test_descr.py | 2 +- Lib/test/test_module.py | 2 +- Lib/tkinter/__init__.py | 6 +++--- Lib/urllib/robotparser.py | 2 +- Mac/BuildScript/scripts/postflight.patch-profile | 4 ++-- Mac/README | 2 +- Misc/NEWS | 2 +- Modules/arraymodule.c | 2 +- Modules/audioop.c | 4 ++-- PC/pyconfig.h | 2 +- Python/formatter_unicode.c | 4 ++-- 18 files changed, 26 insertions(+), 26 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 @@ -2231,7 +2231,7 @@ The example script has a simple function, ``foo``, which just cycles through all the logging levels, writing to ``sys.stderr`` to say what level it's about -to log at, and then actually logging a message that that level. You can pass a +to log at, and then actually logging a message at that level. You can pass a parameter to ``foo`` which, if true, will log at ERROR and CRITICAL levels - otherwise, it only logs at DEBUG, INFO and WARNING levels. diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst --- a/Doc/library/codecs.rst +++ b/Doc/library/codecs.rst @@ -977,7 +977,7 @@ * an ISO 8859 codeset -* a Microsoft Windows code page, which is typically derived from a 8859 codeset, +* a Microsoft Windows code page, which is typically derived from an 8859 codeset, but replaces control characters with additional graphic characters * an IBM EBCDIC code page diff --git a/Doc/reference/simple_stmts.rst b/Doc/reference/simple_stmts.rst --- a/Doc/reference/simple_stmts.rst +++ b/Doc/reference/simple_stmts.rst @@ -237,7 +237,7 @@ phase, causing less detailed error messages. Although the definition of assignment implies that overlaps between the -left-hand side and the right-hand side are 'simultanenous' (for example ``a, b = +left-hand side and the right-hand side are 'simultaneous' (for example ``a, b = b, a`` swaps two variables), overlaps *within* the collection of assigned-to variables occur left-to-right, sometimes resulting in confusion. For instance, the following program prints ``[0, 2]``:: diff --git a/Include/pythonrun.h b/Include/pythonrun.h --- a/Include/pythonrun.h +++ b/Include/pythonrun.h @@ -176,7 +176,7 @@ /* Stack size, in "pointers" (so we get extra safety margins on 64-bit platforms). On a 32-bit platform, this translates - to a 8k margin. */ + to an 8k margin. */ #define PYOS_STACK_MARGIN 2048 #if defined(WIN32) && !defined(MS_WIN64) && defined(_MSC_VER) && _MSC_VER >= 1300 diff --git a/Lib/http/cookiejar.py b/Lib/http/cookiejar.py --- a/Lib/http/cookiejar.py +++ b/Lib/http/cookiejar.py @@ -1841,7 +1841,7 @@ class LWPCookieJar(FileCookieJar): """ The LWPCookieJar saves a sequence of "Set-Cookie3" lines. - "Set-Cookie3" is the format used by the libwww-perl libary, not known + "Set-Cookie3" is the format used by the libwww-perl library, not known to be compatible with any browser, but which is easy to read and doesn't lose information about RFC 2965 cookies. diff --git a/Lib/idlelib/ChangeLog b/Lib/idlelib/ChangeLog --- a/Lib/idlelib/ChangeLog +++ b/Lib/idlelib/ChangeLog @@ -1574,7 +1574,7 @@ * Attic/PopupMenu.py: Pass a root to the help window. * SearchBinding.py: - Add parent argument to 'to to line number' dialog box. + Add parent argument to 'go to line number' dialog box. Sat Oct 10 19:15:32 1998 Guido van Rossum diff --git a/Lib/pickletools.py b/Lib/pickletools.py --- a/Lib/pickletools.py +++ b/Lib/pickletools.py @@ -590,7 +590,7 @@ reader=read_bytes8, doc="""A counted bytes string. - The first argument is a 8-byte little-endian unsigned int giving + The first argument is an 8-byte little-endian unsigned int giving the number of bytes, and the second argument is that many bytes. """) @@ -734,7 +734,7 @@ reader=read_unicodestring8, doc="""A counted Unicode string. - The first argument is a 8-byte little-endian signed int + The first argument is an 8-byte little-endian signed int giving the number of bytes in the string, and the second argument-- the UTF-8 encoding of the Unicode string -- contains that many bytes. @@ -1330,7 +1330,7 @@ proto=4, doc="""Push a Python bytes object. - There are two arguments: the first is a 8-byte unsigned int giving + There are two arguments: the first is an 8-byte unsigned int giving the number of bytes in the string, and the second is that many bytes, which are taken literally as the string content. """), @@ -1417,7 +1417,7 @@ proto=4, doc="""Push a Python Unicode string object. - There are two arguments: the first is a 8-byte little-endian signed int + There are two arguments: the first is an 8-byte little-endian signed int giving the number of bytes in the string. The second is that many bytes, and is the UTF-8 encoding of the Unicode string. """), diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -3489,7 +3489,7 @@ b.a = a z = deepcopy(a) # This blew up before - def test_unintialized_modules(self): + def test_uninitialized_modules(self): # Testing uninitialized module objects... from types import ModuleType as M m = M.__new__(M) diff --git a/Lib/test/test_module.py b/Lib/test/test_module.py --- a/Lib/test/test_module.py +++ b/Lib/test/test_module.py @@ -30,7 +30,7 @@ pass self.assertEqual(foo.__doc__, ModuleType.__doc__) - def test_unintialized_missing_getattr(self): + def test_uninitialized_missing_getattr(self): # Issue 8297 # test the text in the AttributeError of an uninitialized module foo = ModuleType.__new__(ModuleType) diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -1248,7 +1248,7 @@ nsign, b, f, h, k, s, t, w, x, y, A, E, K, N, W, T, X, Y, D = args # Missing: (a, c, d, m, o, v, B, R) e = Event() - # serial field: valid vor all events + # serial field: valid for all events # number of button: ButtonPress and ButtonRelease events only # height field: Configure, ConfigureRequest, Create, # ResizeRequest, and Expose events only @@ -1256,11 +1256,11 @@ # time field: "valid for events that contain a time field" # width field: Configure, ConfigureRequest, Create, ResizeRequest, # and Expose events only - # x field: "valid for events that contain a x field" + # x field: "valid for events that contain an x field" # y field: "valid for events that contain a y field" # keysym as decimal: KeyPress and KeyRelease events only # x_root, y_root fields: ButtonPress, ButtonRelease, KeyPress, - # KeyRelease,and Motion events + # KeyRelease, and Motion events e.serial = getint(nsign) e.num = getint_event(b) try: e.focus = getboolean(f) diff --git a/Lib/urllib/robotparser.py b/Lib/urllib/robotparser.py --- a/Lib/urllib/robotparser.py +++ b/Lib/urllib/robotparser.py @@ -153,7 +153,7 @@ return True # Until the robots.txt file has been read or found not # to exist, we must assume that no url is allowable. - # This prevents false positives when a user erronenously + # This prevents false positives when a user erroneously # calls can_fetch() before calling read(). if not self.last_checked: return False diff --git a/Mac/BuildScript/scripts/postflight.patch-profile b/Mac/BuildScript/scripts/postflight.patch-profile --- a/Mac/BuildScript/scripts/postflight.patch-profile +++ b/Mac/BuildScript/scripts/postflight.patch-profile @@ -58,7 +58,7 @@ fi echo "" >> "${RC}" echo "# Setting PATH for Python ${PYVER}" >> "${RC}" - echo "# The orginal version is saved in .cshrc.pysave" >> "${RC}" + echo "# The original version is saved in .cshrc.pysave" >> "${RC}" echo "set path=(${PYTHON_ROOT}/bin "'$path'")" >> "${RC}" if [ `id -ur` = 0 ]; then chown "${USER}" "${RC}" @@ -90,7 +90,7 @@ fi echo "" >> "${PR}" echo "# Setting PATH for Python ${PYVER}" >> "${PR}" -echo "# The orginal version is saved in `basename ${PR}`.pysave" >> "${PR}" +echo "# The original version is saved in `basename ${PR}`.pysave" >> "${PR}" echo 'PATH="'"${PYTHON_ROOT}/bin"':${PATH}"' >> "${PR}" echo 'export PATH' >> "${PR}" if [ `id -ur` = 0 ]; then diff --git a/Mac/README b/Mac/README --- a/Mac/README +++ b/Mac/README @@ -126,7 +126,7 @@ To build a universal binary that includes a 64-bit architecture, you must build on a system running OS X 10.5 or later. The ``all`` and ``64-bit`` flavors can -only be built with an 10.5 SDK because ``ppc64`` support was only included with +only be built with a 10.5 SDK because ``ppc64`` support was only included with OS X 10.5. Although legacy ``ppc`` support was included with Xcode 3 on OS X 10.6, it was removed in Xcode 4, versions of which were released on OS X 10.6 and which is the standard for OS X 10.7. To summarize, the diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -3308,7 +3308,7 @@ is run with pythonw.exe. - Issue #21775: shutil.copytree(): fix crash when copying to VFAT. An exception - handler assumed that that OSError objects always have a 'winerror' attribute. + handler assumed that OSError objects always have a 'winerror' attribute. That is not the case, so the exception handler itself raised AttributeError when run on Linux (and, presumably, any other non-Windows OS). Patch by Greg Ward. diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -2090,7 +2090,7 @@ * that fits better. This may result in an array with narrower * or wider elements. * - * For example, if a 32-bit machine pickles a L-code array of + * For example, if a 32-bit machine pickles an L-code array of * unsigned longs, then the array will be unpickled by 64-bit * machine as an I-code array of unsigned ints. * diff --git a/Modules/audioop.c b/Modules/audioop.c --- a/Modules/audioop.c +++ b/Modules/audioop.c @@ -46,7 +46,7 @@ */ #define BIAS 0x84 /* define the add-in bias for 16 bit samples */ #define CLIP 32635 -#define SIGN_BIT (0x80) /* Sign bit for a A-law byte. */ +#define SIGN_BIT (0x80) /* Sign bit for an A-law byte. */ #define QUANT_MASK (0xf) /* Quantization field mask. */ #define SEG_SHIFT (4) /* Left shift for segment number. */ #define SEG_MASK (0x70) /* Segment field mask. */ @@ -219,7 +219,7 @@ }; /* - * linear2alaw() accepts an 13-bit signed integer and encodes it as A-law data + * linear2alaw() accepts a 13-bit signed integer and encodes it as A-law data * stored in an unsigned char. This function should only be called with * the data shifted such that it only contains information in the lower * 13-bits. diff --git a/PC/pyconfig.h b/PC/pyconfig.h --- a/PC/pyconfig.h +++ b/PC/pyconfig.h @@ -347,7 +347,7 @@ # define SIZEOF_FPOS_T 8 # define SIZEOF_HKEY 4 # define SIZEOF_SIZE_T 4 - /* MS VS2005 changes time_t to an 64-bit type on all platforms */ + /* MS VS2005 changes time_t to a 64-bit type on all platforms */ # if defined(_MSC_VER) && _MSC_VER >= 1400 # define SIZEOF_TIME_T 8 # else diff --git a/Python/formatter_unicode.c b/Python/formatter_unicode.c --- a/Python/formatter_unicode.c +++ b/Python/formatter_unicode.c @@ -1042,7 +1042,7 @@ else if (type == 'r') type = 'g'; - /* Cast "type", because if we're in unicode we need to pass a + /* Cast "type", because if we're in unicode we need to pass an 8-bit char. This is safe, because we've restricted what "type" can be. */ buf = PyOS_double_to_string(val, (char)type, precision, flags, @@ -1221,7 +1221,7 @@ else if (type == 'r') type = 'g'; - /* Cast "type", because if we're in unicode we need to pass a + /* Cast "type", because if we're in unicode we need to pass an 8-bit char. This is safe, because we've restricted what "type" can be. */ re_buf = PyOS_double_to_string(re, (char)type, precision, flags, -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 8 13:47:16 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 08 May 2016 17:47:16 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2323815=3A_Fixed_crashes_related_to_directly_crea?= =?utf-8?q?ted_instances_of_types_in?= Message-ID: <20160508174716.42347.65620.E90813F2@psf.io> https://hg.python.org/cpython/rev/1c6326e81c33 changeset: 101272:1c6326e81c33 parent: 101270:c61d2c43d22e parent: 101271:cd25508c62fc user: Serhiy Storchaka date: Sun May 08 20:46:55 2016 +0300 summary: Issue #23815: Fixed crashes related to directly created instances of types in _tkinter and curses.panel modules. files: Lib/test/test_curses.py | 4 ++++ Lib/test/test_tcl.py | 2 ++ Misc/NEWS | 3 +++ Modules/_curses_panel.c | 7 ++++--- Modules/_tkinter.c | 3 +++ 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py --- a/Lib/test/test_curses.py +++ b/Lib/test/test_curses.py @@ -285,6 +285,10 @@ panel.set_userptr(A()) panel.set_userptr(None) + def test_new_curses_panel(self): + panel = curses.panel.new_panel(self.stdscr) + self.assertRaises(TypeError, type(panel)) + @unittest.skipUnless(hasattr(curses, 'resizeterm'), 'resizeterm not available') def test_resize_term(self): diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py --- a/Lib/test/test_tcl.py +++ b/Lib/test/test_tcl.py @@ -649,6 +649,8 @@ expected = {'a': (1, 2, 3), 'something': 'foo', 'status': ''} self.assertEqual(splitdict(tcl, arg), expected) + def test_new_tcl_obj(self): + self.assertRaises(TypeError, _tkinter.Tcl_Obj) class BigmemTclTest(unittest.TestCase): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -265,6 +265,9 @@ Library ------- +- Issue #23815: Fixed crashes related to directly created instances of types in + _tkinter and curses.panel modules. + - Issue #17765: weakref.ref() no longer silently ignores keyword arguments. Patch by Georg Brandl. diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -506,10 +506,11 @@ d = PyModule_GetDict(m); /* Initialize object type */ - _curses_panelstate(m)->PyCursesPanel_Type = \ - PyType_FromSpec(&PyCursesPanel_Type_spec); - if (_curses_panelstate(m)->PyCursesPanel_Type == NULL) + v = PyType_FromSpec(&PyCursesPanel_Type_spec); + if (v == NULL) goto fail; + ((PyTypeObject *)v)->tp_new = NULL; + _curses_panelstate(m)->PyCursesPanel_Type = v; import_curses(); if (PyErr_Occurred()) diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -3544,6 +3544,7 @@ Py_DECREF(m); return NULL; } + ((PyTypeObject *)o)->tp_new = NULL; if (PyModule_AddObject(m, "TkappType", o)) { Py_DECREF(o); Py_DECREF(m); @@ -3556,6 +3557,7 @@ Py_DECREF(m); return NULL; } + ((PyTypeObject *)o)->tp_new = NULL; if (PyModule_AddObject(m, "TkttType", o)) { Py_DECREF(o); Py_DECREF(m); @@ -3568,6 +3570,7 @@ Py_DECREF(m); return NULL; } + ((PyTypeObject *)o)->tp_new = NULL; if (PyModule_AddObject(m, "Tcl_Obj", o)) { Py_DECREF(o); Py_DECREF(m); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 8 13:47:16 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 08 May 2016 17:47:16 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzIzODE1?= =?utf-8?q?=3A_Fixed_crashes_related_to_directly_created_instances_of_type?= =?utf-8?q?s_in?= Message-ID: <20160508174716.42377.82705.92F4727C@psf.io> https://hg.python.org/cpython/rev/cd25508c62fc changeset: 101271:cd25508c62fc branch: 3.5 parent: 101269:d783cbef73fb user: Serhiy Storchaka date: Sun May 08 20:46:22 2016 +0300 summary: Issue #23815: Fixed crashes related to directly created instances of types in _tkinter and curses.panel modules. files: Lib/test/test_curses.py | 4 ++++ Lib/test/test_tcl.py | 2 ++ Misc/NEWS | 3 +++ Modules/_curses_panel.c | 7 ++++--- Modules/_tkinter.c | 3 +++ 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py --- a/Lib/test/test_curses.py +++ b/Lib/test/test_curses.py @@ -285,6 +285,10 @@ panel.set_userptr(A()) panel.set_userptr(None) + def test_new_curses_panel(self): + panel = curses.panel.new_panel(self.stdscr) + self.assertRaises(TypeError, type(panel)) + @unittest.skipUnless(hasattr(curses, 'resizeterm'), 'resizeterm not available') def test_resize_term(self): diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py --- a/Lib/test/test_tcl.py +++ b/Lib/test/test_tcl.py @@ -649,6 +649,8 @@ expected = {'a': (1, 2, 3), 'something': 'foo', 'status': ''} self.assertEqual(splitdict(tcl, arg), expected) + def test_new_tcl_obj(self): + self.assertRaises(TypeError, _tkinter.Tcl_Obj) class BigmemTclTest(unittest.TestCase): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -116,6 +116,9 @@ Library ------- +- Issue #23815: Fixed crashes related to directly created instances of types in + _tkinter and curses.panel modules. + - Issue #17765: weakref.ref() no longer silently ignores keyword arguments. Patch by Georg Brandl. diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -506,10 +506,11 @@ d = PyModule_GetDict(m); /* Initialize object type */ - _curses_panelstate(m)->PyCursesPanel_Type = \ - PyType_FromSpec(&PyCursesPanel_Type_spec); - if (_curses_panelstate(m)->PyCursesPanel_Type == NULL) + v = PyType_FromSpec(&PyCursesPanel_Type_spec); + if (v == NULL) goto fail; + ((PyTypeObject *)v)->tp_new = NULL; + _curses_panelstate(m)->PyCursesPanel_Type = v; import_curses(); if (PyErr_Occurred()) diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -3551,6 +3551,7 @@ Py_DECREF(m); return NULL; } + ((PyTypeObject *)o)->tp_new = NULL; if (PyModule_AddObject(m, "TkappType", o)) { Py_DECREF(o); Py_DECREF(m); @@ -3563,6 +3564,7 @@ Py_DECREF(m); return NULL; } + ((PyTypeObject *)o)->tp_new = NULL; if (PyModule_AddObject(m, "TkttType", o)) { Py_DECREF(o); Py_DECREF(m); @@ -3575,6 +3577,7 @@ Py_DECREF(m); return NULL; } + ((PyTypeObject *)o)->tp_new = NULL; if (PyModule_AddObject(m, "Tcl_Obj", o)) { Py_DECREF(o); Py_DECREF(m); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 8 15:00:26 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 08 May 2016 19:00:26 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326156=3A_Make_expressions_grammar_description_m?= =?utf-8?q?ore_semantically_correct=2E?= Message-ID: <20160508190026.21011.70748.D8059AEA@psf.io> https://hg.python.org/cpython/rev/61e3160310ae changeset: 101274:61e3160310ae parent: 101272:1c6326e81c33 parent: 101273:e876ff4e9e95 user: Serhiy Storchaka date: Sun May 08 22:00:09 2016 +0300 summary: Issue #26156: Make expressions grammar description more semantically correct. files: Doc/reference/expressions.rst | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -821,7 +821,7 @@ Can only be used inside a :term:`coroutine function`. .. productionlist:: - await: ["await"] `primary` + await_expr: "await" `primary` .. versionadded:: 3.5 @@ -835,7 +835,7 @@ less tightly than unary operators on its right. The syntax is: .. productionlist:: - power: `await` ["**" `u_expr`] + power: ( `await_expr` | `primary` ) ["**" `u_expr`] Thus, in an unparenthesized sequence of power and unary operators, the operators are evaluated from right to left (this does not constrain the evaluation order -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 8 15:00:26 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 08 May 2016 19:00:26 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2MTU2?= =?utf-8?q?=3A_Make_expressions_grammar_description_more_semantically_corr?= =?utf-8?q?ect=2E?= Message-ID: <20160508190026.31201.63880.07BFDBA2@psf.io> https://hg.python.org/cpython/rev/e876ff4e9e95 changeset: 101273:e876ff4e9e95 branch: 3.5 parent: 101271:cd25508c62fc user: Serhiy Storchaka date: Sun May 08 21:59:46 2016 +0300 summary: Issue #26156: Make expressions grammar description more semantically correct. files: Doc/reference/expressions.rst | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -821,7 +821,7 @@ Can only be used inside a :term:`coroutine function`. .. productionlist:: - await: ["await"] `primary` + await_expr: "await" `primary` .. versionadded:: 3.5 @@ -835,7 +835,7 @@ less tightly than unary operators on its right. The syntax is: .. productionlist:: - power: `await` ["**" `u_expr`] + power: ( `await_expr` | `primary` ) ["**" `u_expr`] Thus, in an unparenthesized sequence of power and unary operators, the operators are evaluated from right to left (this does not constrain the evaluation order -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 8 16:37:05 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 08 May 2016 20:37:05 +0000 Subject: [Python-checkins] =?utf-8?q?cpython=3A_Issue_=2318531=3A_Single_v?= =?utf-8?q?ar-keyword_argument_of_dict_subtype_was_passed?= Message-ID: <20160508203704.31189.45642.B5339F02@psf.io> https://hg.python.org/cpython/rev/e4835b1ed7b1 changeset: 101275:e4835b1ed7b1 user: Serhiy Storchaka date: Sun May 08 23:36:44 2016 +0300 summary: Issue #18531: Single var-keyword argument of dict subtype was passed unscathed to the C-defined function. Now it is converted to exact dict. files: Lib/test/test_getargs2.py | 56 +++++++++++++++++++++++++++ Misc/NEWS | 3 + Modules/_testcapimodule.c | 22 ++++++++++ Python/ceval.c | 2 +- 4 files changed, 82 insertions(+), 1 deletions(-) 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 @@ -70,6 +70,12 @@ def __int__(self): return True +class TupleSubclass(tuple): + pass + +class DictSubclass(dict): + pass + class Unsigned_TestCase(unittest.TestCase): def test_b(self): @@ -321,6 +327,33 @@ class Tuple_TestCase(unittest.TestCase): + def test_args(self): + from _testcapi import get_args + + ret = get_args(1, 2) + self.assertEqual(ret, (1, 2)) + self.assertIs(type(ret), tuple) + + ret = get_args(1, *(2, 3)) + self.assertEqual(ret, (1, 2, 3)) + self.assertIs(type(ret), tuple) + + ret = get_args(*[1, 2]) + self.assertEqual(ret, (1, 2)) + self.assertIs(type(ret), tuple) + + ret = get_args(*TupleSubclass([1, 2])) + self.assertEqual(ret, (1, 2)) + self.assertIs(type(ret), tuple) + + ret = get_args() + self.assertIn(ret, ((), None)) + self.assertIn(type(ret), (tuple, type(None))) + + ret = get_args(*()) + self.assertIn(ret, ((), None)) + self.assertIn(type(ret), (tuple, type(None))) + def test_tuple(self): from _testcapi import getargs_tuple @@ -336,6 +369,29 @@ self.assertRaises(TypeError, getargs_tuple, 1, seq()) class Keywords_TestCase(unittest.TestCase): + def test_kwargs(self): + from _testcapi import get_kwargs + + ret = get_kwargs(a=1, b=2) + self.assertEqual(ret, {'a': 1, 'b': 2}) + self.assertIs(type(ret), dict) + + ret = get_kwargs(a=1, **{'b': 2, 'c': 3}) + self.assertEqual(ret, {'a': 1, 'b': 2, 'c': 3}) + self.assertIs(type(ret), dict) + + ret = get_kwargs(**DictSubclass({'a': 1, 'b': 2})) + self.assertEqual(ret, {'a': 1, 'b': 2}) + self.assertIs(type(ret), dict) + + ret = get_kwargs() + self.assertIn(ret, ({}, None)) + self.assertIn(type(ret), (dict, type(None))) + + ret = get_kwargs(**{}) + self.assertIn(ret, ({}, None)) + self.assertIn(type(ret), (dict, type(None))) + def test_positional_args(self): # using all positional args self.assertEqual( diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #18531: Single var-keyword argument of dict subtype was passed + unscathed to the C-defined function. Now it is converted to exact dict. + - Issue #26811: gc.get_objects() no longer contains a broken tuple with NULL pointer. diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -872,6 +872,26 @@ #endif /* ifdef HAVE_LONG_LONG */ +static PyObject * +get_args(PyObject *self, PyObject *args) +{ + if (args == NULL) { + args = Py_None; + } + Py_INCREF(args); + return args; +} + +static PyObject * +get_kwargs(PyObject *self, PyObject *args, PyObject *kwargs) +{ + if (kwargs == NULL) { + kwargs = Py_None; + } + Py_INCREF(kwargs); + return kwargs; +} + /* Test tuple argument processing */ static PyObject * getargs_tuple(PyObject *self, PyObject *args) @@ -3784,6 +3804,8 @@ {"test_pep3118_obsolete_write_locks", (PyCFunction)test_pep3118_obsolete_write_locks, METH_NOARGS}, #endif {"getbuffer_with_null_view", getbuffer_with_null_view, METH_O}, + {"get_args", get_args, METH_VARARGS}, + {"get_kwargs", (PyCFunction)get_kwargs, METH_VARARGS|METH_KEYWORDS}, {"getargs_tuple", getargs_tuple, METH_VARARGS}, {"getargs_keywords", (PyCFunction)getargs_keywords, METH_VARARGS|METH_KEYWORDS}, diff --git a/Python/ceval.c b/Python/ceval.c --- a/Python/ceval.c +++ b/Python/ceval.c @@ -4993,7 +4993,7 @@ if (flags & CALL_FLAG_KW) { kwdict = EXT_POP(*pp_stack); - if (!PyDict_Check(kwdict)) { + if (!PyDict_CheckExact(kwdict)) { PyObject *d; d = PyDict_New(); if (d == NULL) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 8 16:46:20 2016 From: python-checkins at python.org (brett.cannon) Date: Sun, 08 May 2016 20:46:20 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Update_status_of_GH_migration?= Message-ID: <20160508204620.42351.7225.3BDB0BB0@psf.io> https://hg.python.org/peps/rev/5b67d0028fc7 changeset: 6314:5b67d0028fc7 user: Brett Cannon date: Sun May 08 13:46:14 2016 -0700 summary: Update status of GH migration files: pep-0512.txt | 98 +++++++++++++++++++++++++++++++++++++-- 1 files changed, 93 insertions(+), 5 deletions(-) diff --git a/pep-0512.txt b/pep-0512.txt --- a/pep-0512.txt +++ b/pep-0512.txt @@ -12,6 +12,7 @@ Abstract ======== + This PEP outlines the steps required to migrate Python's development process from Mercurial [#hg]_ as hosted at hg.python.org [#h.p.o]_ to Git [#git]_ on GitHub [#GitHub]_. Meeting @@ -19,8 +20,10 @@ process of Python to be as productive as it currently is, and meeting its extended goals should improve it. + Rationale ========= + In 2014, it became obvious that Python's custom development process was becoming a hindrance. As an example, for an external contributor to submit a fix for a bug that eventually was committed, @@ -104,8 +107,10 @@ that if an external contributor chooses not to use GitHub then they will continue to have that option. + Repositories to Migrate ======================= + While hg.python.org [#h.p.o]_ hosts many repositories, there are only five key repositories that should move: @@ -122,6 +127,7 @@ Migration Plan ============== + The migration plan is separated into sections based on what is required to migrate the repositories listed in the `Repositories to Migrate`_ section. Completion of requirements @@ -129,16 +135,20 @@ repositories. The sections are expected to be completed in order, but not necessarily the requirements within a section. + Requirements for Code-Only Repositories --------------------------------------- + Completion of the requirements in this section will allow the devinabox and benchmarks repositories to move to GitHub. While devinabox has a sufficiently descriptive name, the benchmarks repository does not; therefore, it will be named "python-benchmarks". + Create a 'Python core' team ''''''''''''''''''''''''''' + To manage permissions, a 'Python core' team will be created as part of the python organization [#github-python-org]_. Any repository that is moved will have the 'Python core' team added to it with write @@ -146,15 +156,19 @@ manage SSH keys on hg.python.org will become a team maintainer for the 'Python core' team. + Define commands to move a Mercurial repository to Git ''''''''''''''''''''''''''''''''''''''''''''''''''''' + Since moving to GitHub also entails moving to Git [#git]_, we must decide what tools and commands we will run to translate a Mercurial repository to Git. The exact tools and steps to use are an open issue; see `Tools and commands to move from Mercurial to Git`_. + CLA enforcement ''''''''''''''' + A key part of any open source project is making sure that its source code can be properly licensed. This requires making sure all people making contributions have signed a contributor license agreement @@ -165,8 +179,10 @@ off with automated checking and enforcement of contributors signing the CLA. + Adding GitHub username support to bugs.python.org +++++++++++++++++++++++++++++++++++++++++++++++++ + To keep tracking of CLA signing under the direct control of the PSF, tracking who has signed the PSF CLA will be continued by marking that fact as part of someone's bugs.python.org user profile. What this @@ -185,8 +201,10 @@ and a ``true`` value if they have sigend the CLA, ``false`` if they have not, and ``null`` if no corresponding GitHub username was found. + A bot to enforce CLA signing ++++++++++++++++++++++++++++ + With an association between someone's GitHub account and their bugs.python.org [#b.p.o]_ account, which has the data as to whether someone has signed the CLA, a bot can monitor pull requests on @@ -211,8 +229,10 @@ showcase for asynchronous programming. The code for the bot is hosted in the Knights Who Say Ni project [#ni]_. + Requirements for Web-Related Repositories ----------------------------------------- + Due to their use for generating webpages, the devguide [#devguide-repo]_ and peps [#peps-repo]_ repositories need their respective processes updated to pull from their new Git @@ -223,16 +243,20 @@ when viewed in isolation from the python organization [#github-python-org]_. + Requirements for the cpython Repository --------------------------------------- + Obviously the most active and important repository currently hosted at hg.python.org [#h.p.o]_ is the cpython repository [#cpython-repo]_. Because of its importance and high- frequency use, it requires more tooling before being moved to GitHub compared to the other repositories mentioned in this PEP. + Document steps to commit a pull request ''''''''''''''''''''''''''''''''''''''' + During the process of choosing a new development workflow, it was decided that a linear history is desired. People preferred having a single commit representing a single change instead of having a set of @@ -262,8 +286,10 @@ core developers is an open issue: `Git CLI commands for committing a pull request to cpython`_. + Handling Misc/NEWS '''''''''''''''''' + Traditionally the ``Misc/NEWS`` file [#news-file]_ has been problematic for changes which spanned Python releases. Often times there will be merge conflicts when committing a change between e.g., 3.5 and 3.6 @@ -278,8 +304,10 @@ ``Misc/NEWS`` problem which are discussed in an open issue: `How to handle the Misc/NEWS file`_. + Handling Misc/ACKS '''''''''''''''''' + Traditionally the ``Misc/ACKS`` file [#acks-file]_ has been managed by hand. But thanks to Git supporting an ``author`` value as well as a ``committer`` value per commit, authorship of a commit can be part @@ -305,8 +333,10 @@ start of the message led to a comment being posted to the issue linking to the commit. + Linking a pull request to an issue ++++++++++++++++++++++++++++++++++ + An association between a pull request and an issue is needed to track when a fix has been proposed. The association needs to be many-to-one as there can take multiple pull requests to solve a single issue @@ -324,13 +354,17 @@ could lead to incorrect associations if the wrong issue or referencing another issue was done, but these are rare occasions. + Notify the issue if the pull request is committed +++++++++++++++++++++++++++++++++++++++++++++++++ + Once a pull request is closed (merged or not), the issue should be updated to reflect this fact. + Update linking service for mapping commit IDs to URLs ''''''''''''''''''''''''''''''''''''''''''''''''''''' + Currently you can use https://hg.python.org/lookup/ with a revision ID from either the Subversion or Mercurial copies of the cpython repo [#cpython-repo]_ to get redirected to the URL for that @@ -338,14 +372,18 @@ be updated to redirect to the Git repository and to support the new revision IDs created for the Git repository. + Create https://git.python.org ''''''''''''''''''''''''''''' + Just as hg.python.org [#h.p.o]_ currently points to the Mercurial repository for Python, git.python.org should do the equivalent for the Git repository. + Backup of pull request data ''''''''''''''''''''''''''' + Since GitHub [#github]_ is going to be used for code hosting and code review, those two things need to be backed up. In the case of code hosting, the backup is implicit as all non-shallow Git [#git]_ clones @@ -359,25 +397,33 @@ GitHub to some other code review system is feasible were GitHub to disappear overnight. + Deprecate sys._mercurial '''''''''''''''''''''''' + Once Python is no longer kept in Mercurial, the ``sys._mercurial`` attribute will need to be changed to return ``('CPython', '', '')``. An equivalent ``sys._git`` attribute will be added which fulfills the same use-cases. + Update the devguide ''''''''''''''''''' + The devguide will need to be updated with details of the new workflow. Mostly likely work will take place in a separate branch until the migration actually occurs. + Update PEP 101 '''''''''''''' + The release process will need to be updated as necessary. + Optional, Planned Features -------------------------- + Once the cpython repository [#cpython-repo]_ is migrated, all repositories will have been moved to GitHub [#github]_ and the development process should be on equal footing as before. But a key @@ -389,8 +435,10 @@ bugs.python.org [#b.p.o]_ -- which includes plans independent of this migration -- are tracked on their own wiki page [#tracker-plans]_. + Bot to handle pull request merging '''''''''''''''''''''''''''''''''' + As stated in the section entitled "`Document steps to commit a pull request`_", the desire is to maintain a linear history for cpython. Unfortunately, @@ -419,8 +467,10 @@ The name given to this bot in order to give it commands is an open issue: `Naming the bots`_. + Continuous integration per pull request ''''''''''''''''''''''''''''''''''''''' + To help speed up pull request approvals, continuous integration testing should be used. This helps mitigate the need for a core developer to download a patch simply to run the test suite against @@ -429,8 +479,10 @@ Which free CI service to use is an open issue: `Choosing a CI service`_. + Test coverage report '''''''''''''''''''' + Getting an up-to-date test coverage report for Python's standard library would be extremely beneficial as generating such a report can take quite a while to produce. @@ -439,8 +491,10 @@ coverage for open source projects. Which option is best is an open issue: `Choosing a test coverage service`_. + Notifying issues of pull request comments ''''''''''''''''''''''''''''''''''''''''' + The current development process does not include notifying an issue on bugs.python.org [#b.p.o]_ when a review comment is left on Rietveld [#rietveld]_. It would be nice to fix this so that people @@ -454,14 +508,18 @@ notifications while still making sure that those only following bugs.python.org know when there might be a review comment to address. + Allow bugs.python.org to use GitHub as a login provider ''''''''''''''''''''''''''''''''''''''''''''''''''''''' + As of right now, bugs.python.org [#b.p.o]_ allows people to log in using Google, Launchpad, or OpenID credentials. It would be good to expand this to GitHub credentials. + Web hooks for re-generating web content ''''''''''''''''''''''''''''''''''''''' + The content at https://docs.python.org/, https://docs.python.org/devguide, and https://www.python.org/dev/peps/ are all derived from files kept in @@ -470,16 +528,20 @@ rebuilding the appropriate web content when the files they are based on change instead of having to wait for, e.g., a cronjob to trigger. + Link web content back to files that it is generated from '''''''''''''''''''''''''''''''''''''''''''''''''''''''' + It would be helpful for people who find issues with any of the documentation that is generated from a file to have a link on each page which points back to the file on GitHub [#github]_ that stores the content of the page. That would allow for quick pull requests to fix simple things such as spelling mistakes. + Splitting out parts of the documentation into their own repositories '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + While certain parts of the documentation at https://docs.python.org change with the code, other parts are fairly static and are not tightly bound to the CPython code itself. The following sections of @@ -505,15 +567,19 @@ What's New (potentially through a label added to PRs, like "What's New needed"). + Backup of Git repositories '''''''''''''''''''''''''' + While not necessary, it would be good to have official backups of the various Git repositories for disaster protection. It will be up to the PSF infrastructure committee to decide if this is worthwhile or unnecessary. + Identify potential new core developers '''''''''''''''''''''''''''''''''''''' + The Python development team has long-standing guidelines for selecting new core developers. The key part of the guidelines is that a person needs to have contributed multiple patches which have been @@ -528,14 +594,10 @@ Status ====== + Requirements for migrating the devinabox [#devinabox-repo]_ and benchmarks [#benchmarks-repo]_ repositories: -* In progress - - - `Define commands to move a Mercurial repository to Git`_: - https://github.com/orsenthil/cpython-hg-to-git (Senthil Kumaran) - * Completed - `Adding GitHub username support to bugs.python.org`_ @@ -543,6 +605,8 @@ - `A bot to enforce CLA signing`_: https://github.com/python/the-knights-who-say-ni (Brett Cannon) - `Create a 'Python core' team`_ + - `Define commands to move a Mercurial repository to Git`_: + https://github.com/orsenthil/cpython-hg-to-git (Senthil Kumaran) Repositories whose build steps need updating: @@ -606,15 +670,19 @@ - None + Open Issues =========== + For this PEP, open issues are ones where a decision needs to be made to how to approach or solve a problem. Open issues do not entail coordination issues such as who is going to write a certain bit of code. + The fate of hg.python.org ------------------------- + With the code repositories moving over to Git [#git]_, there is no technical need to keep hg.python.org [#h.p.o]_ running. Having said that, some in the community would like to have it stay functioning as @@ -630,8 +698,10 @@ either be forced to migration or they can choose to simply stay on hg.python.org. + Tools and commands to move from Mercurial to Git ------------------------------------------------ + A decision needs to be made on exactly what tooling and what commands involving those tools will be used to convert a Mercurial repository to Git. Currently a suggestion has been made to use @@ -639,8 +709,10 @@ https://github.com/felipec/git-remote-hg. Finally, http://hg-git.github.io/ has been suggested. + Git CLI commands for committing a pull request to cpython --------------------------------------------------------- + Because Git [#git]_ may be a new version control system for core developers, the commands people are expected to run will need to be written down. These commands also need to keep a linear history while @@ -651,8 +723,10 @@ history will be kept implicitly, but it will need to make sure to keep/add attribution. + How to handle the Misc/NEWS file -------------------------------- + There are three competing approaches to handling ``Misc/NEWS`` [#news-file]_. One is to add a news entry for issues on bugs.python.org [#b.p.o]_. This would mean an issue that is marked @@ -701,8 +775,10 @@ run the risk, though, of failure and thus blocking a commit until it can be manually resolved. + Naming the bots --------------- + As naming things can lead to bikeshedding of epic proportions, Brett Cannon will choose the final name of the various bots (the name of the project for the bots themselves can be anything, this is purely @@ -713,6 +789,7 @@ Choosing a CI service --------------------- + There are various CI services that provide free support for open source projects hosted on GitHub [#github]_. Two such examples are Travis [#travis]_ and Codeship [#codeship]_. Whatever solution is @@ -726,8 +803,10 @@ bugs.python.org [#b.p.o]_. The results can be viewed at https://ci.centos.org/job/cPython-build-patch/ . + Choosing a test coverage service -------------------------------- + Getting basic test coverage of Python's standard library can be created simply by using coverage.py [#coverage]_. Getting thorough test coverage is actually quite tricky, with the details @@ -738,10 +817,13 @@ Free test coverage services include Coveralls [#coveralls]_ and Codecov [#codecov]_. + Rejected Ideas ============== + Separate Python 2 and Python 3 repositories ------------------------------------------- + It was discussed whether separate repositories for Python 2 and Python 3 were desired. The thinking was that this would shrink the overall repository size which benefits people with slow Internet @@ -750,8 +832,10 @@ In the end it was decided that it was easier logistically to simply keep all of CPython's history in a single repository. + Commit multi-release changes in bugfix branch first --------------------------------------------------- + As the current development process has changes committed in the oldest branch first and then merged up to the default branch, the question came up as to whether this workflow should be perpetuated. @@ -776,8 +860,10 @@ Cherry-picking should decouple this so that you don't have to rush your multi-branch changes as the cherry-pick can be done separately. + Deriving ``Misc/NEWS`` from the commit logs ------------------------------------------- + As part of the discussion surrounding `Handling Misc/NEWS`_, the suggestion has come up of deriving the file from the commit logs itself. In this scenario, the first line of a commit message would be @@ -793,6 +879,7 @@ References ========== + .. [#h.p.o] https://hg.python.org .. [#GitHub] GitHub (https://github.com) @@ -889,6 +976,7 @@ .. [#ni] The Knights Who Say Ni project (https://github.com/python/the-knights-who-say-ni) + Copyright ========= -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Sun May 8 17:02:31 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 08 May 2016 21:02:31 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI2ODgx?= =?utf-8?q?=3A_modulefinder_now_works_with_bytecode_with_extended_args=2E?= Message-ID: <20160508210231.130799.30873.5DF177A4@psf.io> https://hg.python.org/cpython/rev/f06baed1bb0c changeset: 101278:f06baed1bb0c branch: 2.7 parent: 101267:1b4320232e61 user: Serhiy Storchaka date: Mon May 09 00:02:06 2016 +0300 summary: Issue #26881: modulefinder now works with bytecode with extended args. files: Lib/modulefinder.py | 83 ++++++++++++---------- Lib/test/test_modulefinder.py | 13 +++ Misc/NEWS | 2 + 3 files changed, 60 insertions(+), 38 deletions(-) diff --git a/Lib/modulefinder.py b/Lib/modulefinder.py --- a/Lib/modulefinder.py +++ b/Lib/modulefinder.py @@ -16,12 +16,32 @@ # remain compatible with Python < 2.3 READ_MODE = "r" -LOAD_CONST = chr(dis.opname.index('LOAD_CONST')) -IMPORT_NAME = chr(dis.opname.index('IMPORT_NAME')) -STORE_NAME = chr(dis.opname.index('STORE_NAME')) -STORE_GLOBAL = chr(dis.opname.index('STORE_GLOBAL')) -STORE_OPS = [STORE_NAME, STORE_GLOBAL] -HAVE_ARGUMENT = chr(dis.HAVE_ARGUMENT) +LOAD_CONST = dis.opmap['LOAD_CONST'] +IMPORT_NAME = dis.opmap['IMPORT_NAME'] +STORE_NAME = dis.opmap['STORE_NAME'] +STORE_GLOBAL = dis.opmap['STORE_GLOBAL'] +STORE_OPS = STORE_NAME, STORE_GLOBAL +HAVE_ARGUMENT = dis.HAVE_ARGUMENT +EXTENDED_ARG = dis.EXTENDED_ARG + +def _unpack_opargs(code): + # enumerate() is not an option, since we sometimes process + # multiple elements on a single pass through the loop + extended_arg = 0 + n = len(code) + i = 0 + while i < n: + op = ord(code[i]) + offset = i + i = i+1 + arg = None + if op >= HAVE_ARGUMENT: + arg = ord(code[i]) + ord(code[i+1])*256 + extended_arg + extended_arg = 0 + i = i+2 + if op == EXTENDED_ARG: + extended_arg = arg*65536 + yield (offset, op, arg) # Modulefinder does a good job at simulating Python's, but it can not # handle __path__ modifications packages make at runtime. Therefore there @@ -344,53 +364,40 @@ code = co.co_code names = co.co_names consts = co.co_consts - while code: - c = code[0] + opargs = [(op, arg) for _, op, arg in _unpack_opargs(code) + if op != EXTENDED_ARG] + for i, (op, oparg) in enumerate(opargs): if c in STORE_OPS: - oparg, = unpack('= 1 + and opargs[i-1][0] == LOAD_CONST): + fromlist = consts[opargs[i-1][1]] + yield "import", (fromlist, names[oparg]) continue - if c >= HAVE_ARGUMENT: - code = code[3:] - else: - code = code[1:] - def scan_opcodes_25(self, co, - unpack = struct.unpack): + def scan_opcodes_25(self, co): # Scan the code, and yield 'interesting' opcode combinations - # Python 2.5 version (has absolute and relative imports) code = co.co_code names = co.co_names consts = co.co_consts - LOAD_LOAD_AND_IMPORT = LOAD_CONST + LOAD_CONST + IMPORT_NAME - while code: - c = code[0] - if c in STORE_OPS: - oparg, = unpack('= 2 + and opargs[i-1][0] == opargs[i-2][0] == LOAD_CONST): + level = consts[opargs[i-2][1]] + fromlist = consts[opargs[i-1][1]] if level == -1: # normal import - yield "import", (consts[oparg_2], names[oparg_3]) + yield "import", (fromlist, names[oparg]) elif level == 0: # absolute import - yield "absolute_import", (consts[oparg_2], names[oparg_3]) + yield "absolute_import", (fromlist, names[oparg]) else: # relative import - yield "relative_import", (level, consts[oparg_2], names[oparg_3]) - code = code[9:] + yield "relative_import", (level, fromlist, names[oparg]) continue - if c >= HAVE_ARGUMENT: - code = code[3:] - else: - code = code[1:] def scan_code(self, co, m): code = co.co_code diff --git a/Lib/test/test_modulefinder.py b/Lib/test/test_modulefinder.py --- a/Lib/test/test_modulefinder.py +++ b/Lib/test/test_modulefinder.py @@ -278,6 +278,19 @@ def test_relative_imports_3(self): self._do_test(relative_import_test_3) + def test_extended_opargs(self): + extended_opargs_test = [ + "a", + ["a", "b"], + [], [], + """\ +a.py + %r + import b +b.py +""" % range(2**16)] # 2**16 constants + self._do_test(extended_opargs_test) + def test_main(): distutils.log.set_threshold(distutils.log.WARN) test_support.run_unittest(ModuleFinderTest) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -77,6 +77,8 @@ Library ------- +- Issue #26881: modulefinder now works with bytecode with extended args. + - Issue #17765: weakref.ref() no longer silently ignores keyword arguments. Patch by Georg Brandl. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 8 17:02:30 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 08 May 2016 21:02:30 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2ODgx?= =?utf-8?q?=3A_The_modulefinder_module_now_supports_extended_opcode_argume?= =?utf-8?q?nts=2E?= Message-ID: <20160508210230.13775.7624.48E076DE@psf.io> https://hg.python.org/cpython/rev/3579cdaf56d9 changeset: 101276:3579cdaf56d9 branch: 3.5 parent: 101273:e876ff4e9e95 user: Serhiy Storchaka date: Sun May 08 23:43:50 2016 +0300 summary: Issue #26881: The modulefinder module now supports extended opcode arguments. files: Lib/dis.py | 59 ++++++++++------------ Lib/modulefinder.py | 45 +++++++---------- Lib/test/test_modulefinder.py | 13 +++++ Misc/NEWS | 4 + 4 files changed, 63 insertions(+), 58 deletions(-) diff --git a/Lib/dis.py b/Lib/dis.py --- a/Lib/dis.py +++ b/Lib/dis.py @@ -275,31 +275,17 @@ """ labels = findlabels(code) - extended_arg = 0 starts_line = None free = None - # enumerate() is not an option, since we sometimes process - # multiple elements on a single pass through the loop - n = len(code) - i = 0 - while i < n: - op = code[i] - offset = i + for offset, op, arg in _unpack_opargs(code): if linestarts is not None: - starts_line = linestarts.get(i, None) + starts_line = linestarts.get(offset, None) if starts_line is not None: starts_line += line_offset - is_jump_target = i in labels - i = i+1 - arg = None + is_jump_target = offset in labels argval = None argrepr = '' - if op >= HAVE_ARGUMENT: - arg = code[i] + code[i+1]*256 + extended_arg - extended_arg = 0 - i = i+2 - if op == EXTENDED_ARG: - extended_arg = arg*65536 + if arg is not None: # Set argval to the dereferenced value of the argument when # availabe, and argrepr to the string representation of argval. # _disassemble_bytes needs the string repr of the @@ -310,7 +296,7 @@ elif op in hasname: argval, argrepr = _get_name_info(arg, names) elif op in hasjrel: - argval = i + arg + argval = offset + 3 + arg argrepr = "to " + repr(argval) elif op in haslocal: argval, argrepr = _get_name_info(arg, varnames) @@ -320,7 +306,7 @@ elif op in hasfree: argval, argrepr = _get_name_info(arg, cells) elif op in hasnargs: - argrepr = "%d positional, %d keyword pair" % (code[i-2], code[i-1]) + argrepr = "%d positional, %d keyword pair" % (arg%256, arg//256) yield Instruction(opname[op], op, arg, argval, argrepr, offset, starts_line, is_jump_target) @@ -356,6 +342,25 @@ disco = disassemble # XXX For backwards compatibility +def _unpack_opargs(code): + # enumerate() is not an option, since we sometimes process + # multiple elements on a single pass through the loop + extended_arg = 0 + n = len(code) + i = 0 + while i < n: + op = code[i] + offset = i + i = i+1 + arg = None + if op >= HAVE_ARGUMENT: + arg = code[i] + code[i+1]*256 + extended_arg + extended_arg = 0 + i = i+2 + if op == EXTENDED_ARG: + extended_arg = arg*65536 + yield (offset, op, arg) + def findlabels(code): """Detect all offsets in a byte code which are jump targets. @@ -363,19 +368,11 @@ """ labels = [] - # enumerate() is not an option, since we sometimes process - # multiple elements on a single pass through the loop - n = len(code) - i = 0 - while i < n: - op = code[i] - i = i+1 - if op >= HAVE_ARGUMENT: - arg = code[i] + code[i+1]*256 - i = i+2 + for offset, op, arg in _unpack_opargs(code): + if arg is not None: label = -1 if op in hasjrel: - label = i+arg + label = offset + 3 + arg elif op in hasjabs: label = arg if label >= 0: diff --git a/Lib/modulefinder.py b/Lib/modulefinder.py --- a/Lib/modulefinder.py +++ b/Lib/modulefinder.py @@ -13,13 +13,12 @@ warnings.simplefilter('ignore', PendingDeprecationWarning) import imp -# XXX Clean up once str8's cstor matches bytes. -LOAD_CONST = bytes([dis.opname.index('LOAD_CONST')]) -IMPORT_NAME = bytes([dis.opname.index('IMPORT_NAME')]) -STORE_NAME = bytes([dis.opname.index('STORE_NAME')]) -STORE_GLOBAL = bytes([dis.opname.index('STORE_GLOBAL')]) -STORE_OPS = [STORE_NAME, STORE_GLOBAL] -HAVE_ARGUMENT = bytes([dis.HAVE_ARGUMENT]) +LOAD_CONST = dis.opmap['LOAD_CONST'] +IMPORT_NAME = dis.opmap['IMPORT_NAME'] +STORE_NAME = dis.opmap['STORE_NAME'] +STORE_GLOBAL = dis.opmap['STORE_GLOBAL'] +STORE_OPS = STORE_NAME, STORE_GLOBAL +EXTENDED_ARG = dis.EXTENDED_ARG # Modulefinder does a good job at simulating Python's, but it can not # handle __path__ modifications packages make at runtime. Therefore there @@ -337,38 +336,30 @@ fullname = name + "." + sub self._add_badmodule(fullname, caller) - def scan_opcodes_25(self, co, - unpack = struct.unpack): + def scan_opcodes(self, co): # Scan the code, and yield 'interesting' opcode combinations - # Python 2.5 version (has absolute and relative imports) code = co.co_code names = co.co_names consts = co.co_consts - LOAD_LOAD_AND_IMPORT = LOAD_CONST + LOAD_CONST + IMPORT_NAME - while code: - c = bytes([code[0]]) - if c in STORE_OPS: - oparg, = unpack('= 2 + and opargs[i-1][0] == opargs[i-2][0] == LOAD_CONST): + level = consts[opargs[i-2][1]] + fromlist = consts[opargs[i-1][1]] if level == 0: # absolute import - yield "absolute_import", (consts[oparg_2], names[oparg_3]) + yield "absolute_import", (fromlist, names[oparg]) else: # relative import - yield "relative_import", (level, consts[oparg_2], names[oparg_3]) - code = code[9:] + yield "relative_import", (level, fromlist, names[oparg]) continue - if c >= HAVE_ARGUMENT: - code = code[3:] - else: - code = code[1:] def scan_code(self, co, m): code = co.co_code - scanner = self.scan_opcodes_25 + scanner = self.scan_opcodes for what, args in scanner(co): if what == "store": name, = args diff --git a/Lib/test/test_modulefinder.py b/Lib/test/test_modulefinder.py --- a/Lib/test/test_modulefinder.py +++ b/Lib/test/test_modulefinder.py @@ -319,6 +319,19 @@ expected = "co_filename %r changed to %r" % (old_path, new_path) self.assertIn(expected, output) + def test_extended_opargs(self): + extended_opargs_test = [ + "a", + ["a", "b"], + [], [], + """\ +a.py + %r + import b +b.py +""" % list(range(2**16))] # 2**16 constants + self._do_test(extended_opargs_test) + if __name__ == "__main__": unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -116,6 +116,8 @@ Library ------- +- Issue #26881: The modulefinder module now supports extended opcode arguments. + - Issue #23815: Fixed crashes related to directly created instances of types in _tkinter and curses.panel modules. @@ -125,6 +127,8 @@ - Issue #26873: xmlrpc now raises ResponseError on unsupported type tags instead of silently return incorrect result. +- Issue #26881: modulefinder now works with bytecode with extended args. + - Issue #26711: Fixed the comparison of plistlib.Data with other types. - Issue #24114: Fix an uninitialized variable in `ctypes.util`. -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 8 17:02:31 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 08 May 2016 21:02:31 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2326881=3A_The_modulefinder_module_now_supports_e?= =?utf-8?q?xtended_opcode_arguments=2E?= Message-ID: <20160508210230.67143.42535.A22B1878@psf.io> https://hg.python.org/cpython/rev/c27e3773d0f9 changeset: 101277:c27e3773d0f9 parent: 101275:e4835b1ed7b1 parent: 101276:3579cdaf56d9 user: Serhiy Storchaka date: Sun May 08 23:44:54 2016 +0300 summary: Issue #26881: The modulefinder module now supports extended opcode arguments. files: Lib/dis.py | 59 ++++++++++------------ Lib/modulefinder.py | 43 ++++++---------- Lib/test/test_modulefinder.py | 13 +++++ Misc/NEWS | 4 + 4 files changed, 62 insertions(+), 57 deletions(-) diff --git a/Lib/dis.py b/Lib/dis.py --- a/Lib/dis.py +++ b/Lib/dis.py @@ -284,31 +284,17 @@ """ labels = findlabels(code) - extended_arg = 0 starts_line = None free = None - # enumerate() is not an option, since we sometimes process - # multiple elements on a single pass through the loop - n = len(code) - i = 0 - while i < n: - op = code[i] - offset = i + for offset, op, arg in _unpack_opargs(code): if linestarts is not None: - starts_line = linestarts.get(i, None) + starts_line = linestarts.get(offset, None) if starts_line is not None: starts_line += line_offset - is_jump_target = i in labels - i = i+1 - arg = None + is_jump_target = offset in labels argval = None argrepr = '' - if op >= HAVE_ARGUMENT: - arg = code[i] + code[i+1]*256 + extended_arg - extended_arg = 0 - i = i+2 - if op == EXTENDED_ARG: - extended_arg = arg*65536 + if arg is not None: # Set argval to the dereferenced value of the argument when # availabe, and argrepr to the string representation of argval. # _disassemble_bytes needs the string repr of the @@ -319,7 +305,7 @@ elif op in hasname: argval, argrepr = _get_name_info(arg, names) elif op in hasjrel: - argval = i + arg + argval = offset + 3 + arg argrepr = "to " + repr(argval) elif op in haslocal: argval, argrepr = _get_name_info(arg, varnames) @@ -329,7 +315,7 @@ elif op in hasfree: argval, argrepr = _get_name_info(arg, cells) elif op in hasnargs: - argrepr = "%d positional, %d keyword pair" % (code[i-2], code[i-1]) + argrepr = "%d positional, %d keyword pair" % (arg%256, arg//256) yield Instruction(opname[op], op, arg, argval, argrepr, offset, starts_line, is_jump_target) @@ -365,6 +351,25 @@ disco = disassemble # XXX For backwards compatibility +def _unpack_opargs(code): + # enumerate() is not an option, since we sometimes process + # multiple elements on a single pass through the loop + extended_arg = 0 + n = len(code) + i = 0 + while i < n: + op = code[i] + offset = i + i = i+1 + arg = None + if op >= HAVE_ARGUMENT: + arg = code[i] + code[i+1]*256 + extended_arg + extended_arg = 0 + i = i+2 + if op == EXTENDED_ARG: + extended_arg = arg*65536 + yield (offset, op, arg) + def findlabels(code): """Detect all offsets in a byte code which are jump targets. @@ -372,19 +377,11 @@ """ labels = [] - # enumerate() is not an option, since we sometimes process - # multiple elements on a single pass through the loop - n = len(code) - i = 0 - while i < n: - op = code[i] - i = i+1 - if op >= HAVE_ARGUMENT: - arg = code[i] + code[i+1]*256 - i = i+2 + for offset, op, arg in _unpack_opargs(code): + if arg is not None: label = -1 if op in hasjrel: - label = i+arg + label = offset + 3 + arg elif op in hasjabs: label = arg if label >= 0: diff --git a/Lib/modulefinder.py b/Lib/modulefinder.py --- a/Lib/modulefinder.py +++ b/Lib/modulefinder.py @@ -13,13 +13,12 @@ warnings.simplefilter('ignore', DeprecationWarning) import imp -# XXX Clean up once str8's cstor matches bytes. -LOAD_CONST = bytes([dis.opmap['LOAD_CONST']]) -IMPORT_NAME = bytes([dis.opmap['IMPORT_NAME']]) -STORE_NAME = bytes([dis.opmap['STORE_NAME']]) -STORE_GLOBAL = bytes([dis.opmap['STORE_GLOBAL']]) +LOAD_CONST = dis.opmap['LOAD_CONST'] +IMPORT_NAME = dis.opmap['IMPORT_NAME'] +STORE_NAME = dis.opmap['STORE_NAME'] +STORE_GLOBAL = dis.opmap['STORE_GLOBAL'] STORE_OPS = STORE_NAME, STORE_GLOBAL -HAVE_ARGUMENT = bytes([dis.HAVE_ARGUMENT]) +EXTENDED_ARG = dis.EXTENDED_ARG # Modulefinder does a good job at simulating Python's, but it can not # handle __path__ modifications packages make at runtime. Therefore there @@ -337,38 +336,30 @@ fullname = name + "." + sub self._add_badmodule(fullname, caller) - def scan_opcodes_25(self, co, - unpack = struct.unpack): + def scan_opcodes(self, co): # Scan the code, and yield 'interesting' opcode combinations - # Python 2.5 version (has absolute and relative imports) code = co.co_code names = co.co_names consts = co.co_consts - LOAD_LOAD_AND_IMPORT = LOAD_CONST + LOAD_CONST + IMPORT_NAME - while code: - c = bytes([code[0]]) - if c in STORE_OPS: - oparg, = unpack('= 2 + and opargs[i-1][0] == opargs[i-2][0] == LOAD_CONST): + level = consts[opargs[i-2][1]] + fromlist = consts[opargs[i-1][1]] if level == 0: # absolute import - yield "absolute_import", (consts[oparg_2], names[oparg_3]) + yield "absolute_import", (fromlist, names[oparg]) else: # relative import - yield "relative_import", (level, consts[oparg_2], names[oparg_3]) - code = code[9:] + yield "relative_import", (level, fromlist, names[oparg]) continue - if c >= HAVE_ARGUMENT: - code = code[3:] - else: - code = code[1:] def scan_code(self, co, m): code = co.co_code - scanner = self.scan_opcodes_25 + scanner = self.scan_opcodes for what, args in scanner(co): if what == "store": name, = args diff --git a/Lib/test/test_modulefinder.py b/Lib/test/test_modulefinder.py --- a/Lib/test/test_modulefinder.py +++ b/Lib/test/test_modulefinder.py @@ -319,6 +319,19 @@ expected = "co_filename %r changed to %r" % (old_path, new_path) self.assertIn(expected, output) + def test_extended_opargs(self): + extended_opargs_test = [ + "a", + ["a", "b"], + [], [], + """\ +a.py + %r + import b +b.py +""" % list(range(2**16))] # 2**16 constants + self._do_test(extended_opargs_test) + if __name__ == "__main__": unittest.main() diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -268,6 +268,8 @@ Library ------- +- Issue #26881: The modulefinder module now supports extended opcode arguments. + - Issue #23815: Fixed crashes related to directly created instances of types in _tkinter and curses.panel modules. @@ -277,6 +279,8 @@ - Issue #26873: xmlrpc now raises ResponseError on unsupported type tags instead of silently return incorrect result. +- Issue #26881: modulefinder now works with bytecode with extended args. + - Issue #26915: The __contains__ methods in the collections ABCs now check for identity before checking equality. This better matches the behavior of the concrete classes, allows sensible handling of NaNs, and makes it -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 8 17:14:46 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 08 May 2016 21:14:46 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2325745=3A_Fixed_leaking_a_userptr_in_curses_pane?= =?utf-8?q?l_destructor=2E?= Message-ID: <20160508211446.15122.93605.49D34A23@psf.io> https://hg.python.org/cpython/rev/50a94e1cabe0 changeset: 101281:50a94e1cabe0 parent: 101277:c27e3773d0f9 parent: 101279:afed12943ddd user: Serhiy Storchaka date: Mon May 09 00:14:22 2016 +0300 summary: Issue #25745: Fixed leaking a userptr in curses panel destructor. files: Misc/NEWS | 2 ++ Modules/_curses_panel.c | 5 +++++ 2 files changed, 7 insertions(+), 0 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -268,6 +268,8 @@ Library ------- +- Issue #25745: Fixed leaking a userptr in curses panel destructor. + - Issue #26881: The modulefinder module now supports extended opcode arguments. - Issue #23815: Fixed crashes related to directly created instances of types in diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -220,6 +220,11 @@ static void PyCursesPanel_Dealloc(PyCursesPanelObject *po) { + PyObject *obj = (PyObject *) panel_userptr(po->pan); + if (obj) { + (void)set_panel_userptr(po->pan, NULL); + Py_DECREF(obj); + } (void)del_panel(po->pan); if (po->wo != NULL) { Py_DECREF(po->wo); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 8 17:14:46 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 08 May 2016 21:14:46 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMi43KTogSXNzdWUgIzI1NzQ1?= =?utf-8?q?=3A_Fixed_leaking_a_userptr_in_curses_panel_destructor=2E?= Message-ID: <20160508211446.22565.71096.954D0147@psf.io> https://hg.python.org/cpython/rev/1662b41e1663 changeset: 101280:1662b41e1663 branch: 2.7 parent: 101278:f06baed1bb0c user: Serhiy Storchaka date: Mon May 09 00:11:59 2016 +0300 summary: Issue #25745: Fixed leaking a userptr in curses panel destructor. files: Misc/NEWS | 2 +- Modules/_curses_panel.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -77,7 +77,7 @@ Library ------- -- Issue #26881: modulefinder now works with bytecode with extended args. +- Issue #25745: Fixed leaking a userptr in curses panel destructor. - Issue #17765: weakref.ref() no longer silently ignores keyword arguments. Patch by Georg Brandl. diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -191,6 +191,11 @@ static void PyCursesPanel_Dealloc(PyCursesPanelObject *po) { + PyObject *obj = (PyObject *) panel_userptr(po->pan); + if (obj) { + (void)set_panel_userptr(po->pan, NULL); + Py_DECREF(obj); + } (void)del_panel(po->pan); if (po->wo != NULL) { Py_DECREF(po->wo); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 8 17:14:47 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Sun, 08 May 2016 21:14:47 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI1NzQ1?= =?utf-8?q?=3A_Fixed_leaking_a_userptr_in_curses_panel_destructor=2E?= Message-ID: <20160508211446.130791.91256.A5D48D0F@psf.io> https://hg.python.org/cpython/rev/afed12943ddd changeset: 101279:afed12943ddd branch: 3.5 parent: 101276:3579cdaf56d9 user: Serhiy Storchaka date: Mon May 09 00:11:59 2016 +0300 summary: Issue #25745: Fixed leaking a userptr in curses panel destructor. files: Misc/NEWS | 2 ++ Modules/_curses_panel.c | 5 +++++ 2 files changed, 7 insertions(+), 0 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -116,6 +116,8 @@ Library ------- +- Issue #25745: Fixed leaking a userptr in curses panel destructor. + - Issue #26881: The modulefinder module now supports extended opcode arguments. - Issue #23815: Fixed crashes related to directly created instances of types in diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -220,6 +220,11 @@ static void PyCursesPanel_Dealloc(PyCursesPanelObject *po) { + PyObject *obj = (PyObject *) panel_userptr(po->pan); + if (obj) { + (void)set_panel_userptr(po->pan, NULL); + Py_DECREF(obj); + } (void)del_panel(po->pan); if (po->wo != NULL) { Py_DECREF(po->wo); -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Sun May 8 21:56:54 2016 From: python-checkins at python.org (brett.cannon) Date: Mon, 09 May 2016 01:56:54 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Mention_reno_as_a_possible_so?= =?utf-8?q?lution_to_the_NEWS_problem?= Message-ID: <20160509015654.21029.14652.2E5AD78D@psf.io> https://hg.python.org/peps/rev/f852badca865 changeset: 6315:f852badca865 user: Brett Cannon date: Sun May 08 18:56:47 2016 -0700 summary: Mention reno as a possible solution to the NEWS problem files: pep-0512.txt | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pep-0512.txt b/pep-0512.txt --- a/pep-0512.txt +++ b/pep-0512.txt @@ -767,8 +767,9 @@ line of the commit message if no specific news entry was specified). Code for this approach has been written previously for the Mercurial workflow at http://bugs.python.org/issue18967. There is also tools -from the community like https://pypi.python.org/pypi/towncrier and -https://github.com/twisted/newsbuilder . +from the community like https://pypi.python.org/pypi/towncrier, +https://github.com/twisted/newsbuilder, and +http://docs.openstack.org/developer/reno/. A yet third option is a merge script to handle the conflicts. This approach allows for keeping the NEWS file as a single file. It does -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Mon May 9 02:20:34 2016 From: python-checkins at python.org (benjamin.peterson) Date: Mon, 09 May 2016 06:20:34 +0000 Subject: [Python-checkins] =?utf-8?b?cGVwczogMi43LjEy?= Message-ID: <20160509061951.22581.39559.C5EEEF47@psf.io> https://hg.python.org/peps/rev/06e939c5adae changeset: 6316:06e939c5adae user: Benjamin Peterson date: Sun May 08 23:19:46 2016 -0700 summary: 2.7.12 files: pep-0373.txt | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/pep-0373.txt b/pep-0373.txt --- a/pep-0373.txt +++ b/pep-0373.txt @@ -56,7 +56,8 @@ Planned future release dates: -- 2.7.12 May 2016ish +- 2.7.12rc1 2016-06-12 +- 2.7.12 2016-06-25 - beyond this date, releases as needed Dates of previous maintenance releases: -- Repository URL: https://hg.python.org/peps From solipsis at pitrou.net Mon May 9 04:50:03 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Mon, 09 May 2016 08:50:03 +0000 Subject: [Python-checkins] Daily reference leaks (50a94e1cabe0): sum=4 Message-ID: <20160509085002.42555.60654.800F0003@psf.io> results for 50a94e1cabe0 on branch "default" -------------------------------------------- test_collections leaked [0, 4, -4] memory blocks, sum=0 test_functools leaked [0, 3, 1] memory blocks, sum=4 test_multiprocessing_spawn leaked [0, -2, 2] memory blocks, sum=0 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogcdMp3l', '--timeout', '7200'] From lp_benchmark_robot at intel.com Mon May 9 10:03:39 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Mon, 9 May 2016 15:03:39 +0100 Subject: [Python-checkins] GOOD Benchmark Results for Python Default 2016-05-09 Message-ID: Results for project Python default, build date 2016-05-09 02:02:23 +0000 commit: 50a94e1cabe0 previous commit: 66a1fbdbe4bb revision date: 2016-05-08 21:14:22 +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.27% 1.60% 10.87% 14.33% :-| pybench 0.08% 1.06% 1.65% 5.99% :-( regex_v8 2.84% -0.45% -2.29% 4.84% :-) nbody 0.12% 2.63% 0.25% 8.42% :-| json_dump_v2 0.38% -0.03% -1.40% 10.63% :-| normal_startup 0.77% -0.06% 0.94% 5.81% ---------------------------------------------------------------------------------- * 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-05-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 lp_benchmark_robot at intel.com Mon May 9 10:05:09 2016 From: lp_benchmark_robot at intel.com (lp_benchmark_robot at intel.com) Date: Mon, 9 May 2016 15:05:09 +0100 Subject: [Python-checkins] GOOD Benchmark Results for Python 2.7 2016-05-09 Message-ID: <8e5ce8d2-90da-4e89-b5d0-7ee355df0778@irsmsx102.ger.corp.intel.com> Results for project Python 2.7, build date 2016-05-09 02:46:45 +0000 commit: 1662b41e1663 previous commit: 4462e193f089 revision date: 2016-05-08 21:11: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.10% -0.51% 6.08% 5.09% :-) pybench 0.11% 0.54% 6.19% 4.18% :-( regex_v8 0.69% 0.01% -2.17% 10.55% :-) nbody 0.14% 2.93% 9.58% 0.27% :-) json_dump_v2 0.52% -0.46% 2.01% 11.97% :-( normal_startup 1.81% 0.71% -4.91% 2.24% :-) ssbench 0.19% 0.46% 2.67% 1.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-2-7-2016-05-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 python-checkins at python.org Mon May 9 15:50:49 2016 From: python-checkins at python.org (zach.ware) Date: Mon, 09 May 2016 19:50:49 +0000 Subject: [Python-checkins] =?utf-8?b?Y3B5dGhvbiAoMy41KTogSXNzdWUgIzI2OTg3?= =?utf-8?q?=3A_Correct_implementation_to_match_comment?= Message-ID: <20160509195046.57780.69015.5300C756@psf.io> https://hg.python.org/cpython/rev/8842c02c02a2 changeset: 101282:8842c02c02a2 branch: 3.5 parent: 101279:afed12943ddd user: Zachary Ware date: Mon May 09 14:49:31 2016 -0500 summary: Issue #26987: Correct implementation to match comment This was inadvertently changed in 644b677c2ae5 to use self._stderr instead of _sys.stderr. files: Lib/threading.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/threading.py b/Lib/threading.py --- a/Lib/threading.py +++ b/Lib/threading.py @@ -921,7 +921,7 @@ # self. if _sys and _sys.stderr is not None: print("Exception in thread %s:\n%s" % - (self.name, _format_exc()), file=self._stderr) + (self.name, _format_exc()), file=_sys.stderr) elif self._stderr is not None: # Do the best job possible w/o a huge amt. of code to # approximate a traceback (code ideas from -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon May 9 15:50:55 2016 From: python-checkins at python.org (zach.ware) Date: Mon, 09 May 2016 19:50:55 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Closes_=2326987=3A_Merge_with_3=2E5?= Message-ID: <20160509195046.5594.23335.F2C793D4@psf.io> https://hg.python.org/cpython/rev/694dadd9f7bd changeset: 101283:694dadd9f7bd parent: 101281:50a94e1cabe0 parent: 101282:8842c02c02a2 user: Zachary Ware date: Mon May 09 14:50:36 2016 -0500 summary: Closes #26987: Merge with 3.5 files: Lib/threading.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Lib/threading.py b/Lib/threading.py --- a/Lib/threading.py +++ b/Lib/threading.py @@ -923,7 +923,7 @@ # self. if _sys and _sys.stderr is not None: print("Exception in thread %s:\n%s" % - (self.name, _format_exc()), file=self._stderr) + (self.name, _format_exc()), file=_sys.stderr) elif self._stderr is not None: # Do the best job possible w/o a huge amt. of code to # approximate a traceback (code ideas from -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Mon May 9 23:14:21 2016 From: python-checkins at python.org (nick.coghlan) Date: Tue, 10 May 2016 03:14:21 +0000 Subject: [Python-checkins] =?utf-8?q?devguide=3A_Clarify_a_point_on_the_mo?= =?utf-8?q?tivations_page?= Message-ID: <20160510031421.17976.15504.3130CF93@psf.io> https://hg.python.org/devguide/rev/969de4441485 changeset: 803:969de4441485 user: Nick Coghlan date: Tue May 10 13:14:12 2016 +1000 summary: Clarify a point on the motivations page files: motivations.rst | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/motivations.rst b/motivations.rst --- a/motivations.rst +++ b/motivations.rst @@ -150,10 +150,11 @@ Include an "Available for " (or activities) bullet point with a link if you'd like to be contacted for professional training, consulting or - contract work. A link to a page with additional details is preferred to a - direct email address or contact phone number, as this is a global site, and - folks may not be familiar with the relevant practical details that apply to - this kind of work in a contributor's country of residence. + contract work, or other employment opportunities. A link to a page with + additional details is preferred to a direct email address or contact phone + number, as this is a global site, and folks may not be familiar with the + relevant practical details that apply to this kind of work in a contributor's + country of residence. Include a "Crowdfunding" bullet point with a link if you'd like to highlight crowdfunding services (e.g. Patreon) that folks can use to support your core -- Repository URL: https://hg.python.org/devguide From python-checkins at python.org Mon May 9 23:42:52 2016 From: python-checkins at python.org (guido.van.rossum) Date: Tue, 10 May 2016 03:42:52 +0000 Subject: [Python-checkins] =?utf-8?q?peps=3A_Fix_some_cursive_markup=2E?= Message-ID: <20160510034252.57780.58031.28A7CD76@psf.io> https://hg.python.org/peps/rev/538ca691a576 changeset: 6317:538ca691a576 user: Guido van Rossum date: Mon May 09 20:42:47 2016 -0700 summary: Fix some cursive markup. files: pep-0484.txt | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pep-0484.txt b/pep-0484.txt --- a/pep-0484.txt +++ b/pep-0484.txt @@ -634,14 +634,14 @@ reject such a call: the function might append an ``Employee`` instance to the list, which would violate the variable's type in the caller. -It turns out such an argument acts _contravariantly_, whereas the +It turns out such an argument acts *contravariantly*, whereas the intuitive answer (which is correct in case the function doesn't mutate -its argument!) requires the argument to act _covariantly_. A longer +its argument!) requires the argument to act *covariantly*. A longer introduction to these concepts can be found on Wikipedia [wiki-variance]_; here we just show how to control a type checker's behavior. -By default type variables are considered _invariant_, which means that +By default type variables are considered *invariant*, which means that arguments for arguments annotated with types like ``List[Employee]`` must exactly match the type annotation -- no subclasses or superclasses of the type parameter (in this example ``Employee``) are -- Repository URL: https://hg.python.org/peps From python-checkins at python.org Tue May 10 02:44:35 2016 From: python-checkins at python.org (benjamin.peterson) Date: Tue, 10 May 2016 06:44:35 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=283=2E5=29=3A_improve_PyFunc?= =?utf-8?q?tion=5FNew_docs_=28closes_=2326986=29?= Message-ID: <20160510064435.13775.42527.7A150D72@psf.io> https://hg.python.org/cpython/rev/bfc4c57a0986 changeset: 101284:bfc4c57a0986 branch: 3.5 parent: 101282:8842c02c02a2 user: Benjamin Peterson date: Mon May 09 23:43:53 2016 -0700 summary: improve PyFunction_New docs (closes #26986) Patch from Xiang Zhang. files: Doc/c-api/function.rst | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) 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 @@ -34,8 +34,9 @@ Return a new function object associated with the code object *code*. *globals* must be a dictionary with the global variables accessible to the function. - The function's docstring, name and *__module__* are retrieved from the code - object, the argument defaults and closure are set to *NULL*. + The function's docstring and name are retrieved from the code object. *__module__* + is retrieved from *globals*. The argument defaults, annotations and closure are + set to *NULL*. *__qualname__* is set to the same value as the function's name. .. c:function:: PyObject* PyFunction_NewWithQualName(PyObject *code, PyObject *globals, PyObject *qualname) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue May 10 02:44:36 2016 From: python-checkins at python.org (benjamin.peterson) Date: Tue, 10 May 2016 06:44:36 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?b?KTogbWVyZ2UgMy41ICgjMjY5ODYp?= Message-ID: <20160510064435.121389.5880.6E471211@psf.io> https://hg.python.org/cpython/rev/71afeb15f617 changeset: 101285:71afeb15f617 parent: 101283:694dadd9f7bd parent: 101284:bfc4c57a0986 user: Benjamin Peterson date: Mon May 09 23:44:30 2016 -0700 summary: merge 3.5 (#26986) files: Doc/c-api/function.rst | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) 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 @@ -34,8 +34,9 @@ Return a new function object associated with the code object *code*. *globals* must be a dictionary with the global variables accessible to the function. - The function's docstring, name and *__module__* are retrieved from the code - object, the argument defaults and closure are set to *NULL*. + The function's docstring and name are retrieved from the code object. *__module__* + is retrieved from *globals*. The argument defaults, annotations and closure are + set to *NULL*. *__qualname__* is set to the same value as the function's name. .. c:function:: PyObject* PyFunction_NewWithQualName(PyObject *code, PyObject *globals, PyObject *qualname) -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue May 10 04:13:03 2016 From: python-checkins at python.org (senthil.kumaran) Date: Tue, 10 May 2016 08:13:03 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Closes_issue26?= =?utf-8?q?960=2E?= Message-ID: <20160510081301.89249.28076.D7C2E32D@psf.io> https://hg.python.org/cpython/rev/44d02a5d59fb changeset: 101286:44d02a5d59fb branch: 2.7 parent: 101280:1662b41e1663 user: Senthil Kumaran date: Tue May 10 01:12:55 2016 -0700 summary: Closes issue26960. Backport issue16270: Fix for urllib hanging with ftp urls. files: Lib/urllib.py | 6 ------ 1 files changed, 0 insertions(+), 6 deletions(-) diff --git a/Lib/urllib.py b/Lib/urllib.py --- a/Lib/urllib.py +++ b/Lib/urllib.py @@ -932,13 +932,7 @@ return (ftpobj, retrlen) def endtransfer(self): - if not self.busy: - return self.busy = 0 - try: - self.ftp.voidresp() - except ftperrors(): - pass def close(self): self.keepalive = False -- Repository URL: https://hg.python.org/cpython From python-checkins at python.org Tue May 10 04:29:39 2016 From: python-checkins at python.org (senthil.kumaran) Date: Tue, 10 May 2016 08:29:39 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=282=2E7=29=3A_Add_NEWS_entry?= =?utf-8?q?_for_issue26960=2E?= Message-ID: <20160510082939.88912.5995.B91F2AAE@psf.io> https://hg.python.org/cpython/rev/3388e249389d changeset: 101287:3388e249389d branch: 2.7 user: Senthil Kumaran date: Tue May 10 01:29:34 2016 -0700 summary: Add NEWS entry for issue26960. files: Misc/NEWS | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -77,6 +77,9 @@ Library ------- +- Issue #26960: Backported #16270 from Python 3 to Python 2, to prevent urllib + from hanging when retrieving certain FTP files. + - Issue #25745: Fixed leaking a userptr in curses panel destructor. - Issue #17765: weakref.ref() no longer silently ignores keyword arguments. -- Repository URL: https://hg.python.org/cpython From solipsis at pitrou.net Tue May 10 04:54:47 2016 From: solipsis at pitrou.net (solipsis at pitrou.net) Date: Tue, 10 May 2016 08:54:47 +0000 Subject: [Python-checkins] Daily reference leaks (694dadd9f7bd): sum=7 Message-ID: <20160510085447.6907.66588.764CCF5F@psf.io> results for 694dadd9f7bd on branch "default" -------------------------------------------- test_asyncio leaked [0, 0, 3] memory blocks, sum=3 test_collections leaked [4, -4, 0] memory blocks, sum=0 test_functools leaked [0, 3, 1] memory blocks, sum=4 Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/psf-users/antoine/refleaks/reflogXa21mt', '--timeout', '7200'] From python-checkins at python.org Tue May 10 05:02:52 2016 From: python-checkins at python.org (serhiy.storchaka) Date: Tue, 10 May 2016 09:02:52 +0000 Subject: [Python-checkins] =?utf-8?q?cpython_=28merge_3=2E5_-=3E_default?= =?utf-8?q?=29=3A_Issue_=2323921=3A_Standardized_documentation_whitespace_?= =?utf-8?q?formatting=2E?= Message-ID: <20160510090249.22575.93316.46212454@psf.io> https://hg.python.org/cpython/rev/909099686e6e changeset: 101289:909099686e6e parent: 101285:71afeb15f617 parent: 101288:2b492ea961c1 user: Serhiy Storchaka date: Tue May 10 12:01:56 2016 +0300 summary: Issue #23921: Standardized documentation whitespace formatting. Original patch by James Edwards. files: Doc/distutils/apiref.rst | 4 +- Doc/faq/design.rst | 18 +- Doc/faq/library.rst | 17 +- Doc/faq/programming.rst | 39 +- Doc/howto/descriptor.rst | 64 ++-- Doc/howto/functional.rst | 10 +- Doc/howto/logging-cookbook.rst | 56 ++-- Doc/howto/logging.rst | 4 +- Doc/howto/regex.rst | 12 +- Doc/howto/unicode.rst | 2 +- Doc/howto/urllib2.rst | 12 +- Doc/library/argparse.rst | 18 +- Doc/library/asynchat.rst | 2 +- Doc/library/asyncio-sync.rst | 6 +- Doc/library/asyncore.rst | 4 +- Doc/library/audioop.rst | 2 +- Doc/library/collections.abc.rst | 29 +- Doc/library/collections.rst | 2 +- Doc/library/concurrent.futures.rst | 4 +- Doc/library/configparser.rst | 10 +- Doc/library/contextlib.rst | 2 +- Doc/library/crypt.rst | 2 +- Doc/library/ctypes.rst | 64 ++-- Doc/library/email.headerregistry.rst | 2 +- Doc/library/getopt.rst | 2 +- Doc/library/html.parser.rst | 10 +- Doc/library/http.client.rst | 2 +- Doc/library/inspect.rst | 2 +- Doc/library/ipaddress.rst | 2 +- Doc/library/locale.rst | 10 +- Doc/library/mailcap.rst | 2 +- Doc/library/mmap.rst | 2 +- Doc/library/multiprocessing.rst | 8 +- Doc/library/optparse.rst | 32 +- Doc/library/re.rst | 30 +- Doc/library/shelve.rst | 33 +- Doc/library/ssl.rst | 2 +- Doc/library/string.rst | 12 +- Doc/library/threading.rst | 2 +- Doc/library/tkinter.rst | 2 +- Doc/library/tokenize.rst | 6 +- Doc/library/types.rst | 2 + Doc/library/unittest.rst | 26 +- Doc/library/urllib.request.rst | 2 +- Doc/library/wsgiref.rst | 8 +- Doc/library/xml.dom.minidom.rst | 4 +- Doc/library/xml.etree.elementtree.rst | 26 +- Doc/library/xmlrpc.client.rst | 7 +- Doc/reference/datamodel.rst | 6 +- Doc/reference/expressions.rst | 2 +- Doc/reference/simple_stmts.rst | 4 +- Doc/tutorial/appendix.rst | 2 +- Doc/tutorial/classes.rst | 12 +- Doc/tutorial/controlflow.rst | 4 +- Doc/tutorial/errors.rst | 16 +- Doc/tutorial/inputoutput.rst | 4 +- Doc/tutorial/introduction.rst | 8 +- Doc/tutorial/modules.rst | 2 +- Doc/tutorial/stdlib.rst | 2 +- Doc/tutorial/stdlib2.rst | 1 + Doc/whatsnew/3.2.rst | 170 +++++++------ Doc/whatsnew/3.3.rst | 6 +- Doc/whatsnew/3.4.rst | 2 +- 63 files changed, 448 insertions(+), 412 deletions(-) diff --git a/Doc/distutils/apiref.rst b/Doc/distutils/apiref.rst --- a/Doc/distutils/apiref.rst +++ b/Doc/distutils/apiref.rst @@ -1907,9 +1907,9 @@ that is designed to run with both Python 2.x and 3.x, add:: try: - from distutils.command.build_py import build_py_2to3 as build_py + from distutils.command.build_py import build_py_2to3 as build_py except ImportError: - from distutils.command.build_py import build_py + from distutils.command.build_py import build_py to your setup.py, and later:: diff --git a/Doc/faq/design.rst b/Doc/faq/design.rst --- a/Doc/faq/design.rst +++ b/Doc/faq/design.rst @@ -158,7 +158,7 @@ line = f.readline() if not line: break - ... # do something with line + ... # do something with line The reason for not allowing assignment in Python expressions is a common, hard-to-find bug in those other languages, caused by this construct: @@ -190,7 +190,7 @@ line = f.readline() while line: - ... # do something with line... + ... # do something with line... line = f.readline() The problem with this is that if you change your mind about exactly how you get @@ -203,7 +203,7 @@ ` support the iterator protocol, so you can write simply:: for line in f: - ... # do something with line... + ... # do something with line... @@ -577,8 +577,10 @@ class ListWrapper: def __init__(self, the_list): self.the_list = the_list + def __eq__(self, other): return self.the_list == other.the_list + def __hash__(self): l = self.the_list result = 98767 - len(l)*555 @@ -619,7 +621,7 @@ dictionary in sorted order:: for key in sorted(mydict): - ... # do whatever with mydict[key]... + ... # do whatever with mydict[key]... How do you specify and enforce an interface spec in Python? @@ -675,11 +677,11 @@ class label(Exception): pass # declare a label try: - ... - if condition: raise label() # goto label - ... + ... + if condition: raise label() # goto label + ... except label: # where to goto - pass + pass ... This doesn't allow you to jump into the middle of a loop, but that's usually diff --git a/Doc/faq/library.rst b/Doc/faq/library.rst --- a/Doc/faq/library.rst +++ b/Doc/faq/library.rst @@ -257,7 +257,8 @@ import threading, time def thread_task(name, n): - for i in range(n): print(name, i) + for i in range(n): + print(name, i) for i in range(10): T = threading.Thread(target=thread_task, args=(str(i), i)) @@ -273,7 +274,8 @@ def thread_task(name, n): time.sleep(0.001) # <--------------------! - for i in range(n): print(name, i) + for i in range(n): + print(name, i) for i in range(10): T = threading.Thread(target=thread_task, args=(str(i), i)) @@ -502,8 +504,8 @@ import struct with open(filename, "rb") as f: - s = f.read(8) - x, y, z = struct.unpack(">hhl", s) + s = f.read(8) + x, y, z = struct.unpack(">hhl", s) The '>' in the format string forces big-endian data; the letter 'h' reads one "short integer" (2 bytes), and 'l' reads one "long integer" (4 bytes) from the @@ -681,10 +683,10 @@ import urllib.request - ### build the query string + # build the query string qs = "First=Josephine&MI=Q&Last=Public" - ### connect and send the server a path + # connect and send the server a path req = urllib.request.urlopen('http://www.some-server.out-there' '/cgi-bin/some-cgi-script', data=qs) with req: @@ -740,8 +742,9 @@ ``/usr/sbin/sendmail``. The sendmail manual page will help you out. Here's some sample code:: + import os + SENDMAIL = "/usr/sbin/sendmail" # sendmail location - import os p = os.popen("%s -t -i" % SENDMAIL, "w") p.write("To: receiver at example.com\n") p.write("Subject: test\n") diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -207,7 +207,7 @@ >>> squares = [] >>> for x in range(5): - ... squares.append(lambda: x**2) + ... squares.append(lambda: x**2) This gives you a list that contains 5 lambdas that calculate ``x**2``. You might expect that, when called, they would return, respectively, ``0``, ``1``, @@ -234,7 +234,7 @@ >>> squares = [] >>> for x in range(5): - ... squares.append(lambda n=x: n**2) + ... squares.append(lambda n=x: n**2) Here, ``n=x`` creates a new variable ``n`` local to the lambda and computed when the lambda is defined so that it has the same value that ``x`` had at @@ -539,7 +539,7 @@ args['a'] = 'new-value' # args is a mutable dictionary args['b'] = args['b'] + 1 # change it in-place - args = {'a':' old-value', 'b': 99} + args = {'a': 'old-value', 'b': 99} func3(args) print(args['a'], args['b']) @@ -655,16 +655,15 @@ ``def`` and ``class`` statements, but in that case the value is a callable. Consider the following code:: - class A: - pass - - B = A - - a = B() - b = a - print(b) + >>> class A: + ... pass + ... + >>> B = A + >>> a = B() + >>> b = a + >>> print(b) <__main__.A object at 0x16D07CC> - print(a) + >>> print(a) <__main__.A object at 0x16D07CC> Arguably the class has a name: even though it is bound to two names and invoked @@ -1100,7 +1099,7 @@ Use the :func:`reversed` built-in function, which is new in Python 2.4:: for x in reversed(sequence): - ... # do something with x... + ... # do something with x ... This won't touch your original sequence, but build a new copy with reversed order to iterate over. @@ -1108,7 +1107,7 @@ With Python 2.3, you can use an extended slice syntax:: for x in sequence[::-1]: - ... # do something with x... + ... # do something with x ... How do you remove duplicates from a list? @@ -1406,7 +1405,7 @@ definition:: class C: - def meth (self, arg): + def meth(self, arg): return arg * 2 + self.attribute @@ -1439,9 +1438,9 @@ def search(obj): if isinstance(obj, Mailbox): - # ... code to search a mailbox + ... # code to search a mailbox elif isinstance(obj, Document): - # ... code to search a document + ... # code to search a document elif ... A better approach is to define a ``search()`` method on all the classes and just @@ -1449,11 +1448,11 @@ class Mailbox: def search(self): - # ... code to search a mailbox + ... # code to search a mailbox class Document: def search(self): - # ... code to search a document + ... # code to search a document obj.search() @@ -1510,7 +1509,7 @@ Use the built-in :func:`super` function:: class Derived(Base): - def meth (self): + def meth(self): super(Derived, self).meth() For version prior to 3.0, you may be using classic classes: For a class diff --git a/Doc/howto/descriptor.rst b/Doc/howto/descriptor.rst --- a/Doc/howto/descriptor.rst +++ b/Doc/howto/descriptor.rst @@ -104,7 +104,7 @@ "Emulate type_getattro() in Objects/typeobject.c" v = object.__getattribute__(self, key) if hasattr(v, '__get__'): - return v.__get__(None, self) + return v.__get__(None, self) return v The important points to remember are: @@ -163,9 +163,9 @@ self.val = val >>> class MyClass(object): - x = RevealAccess(10, 'var "x"') - y = 5 - + ... x = RevealAccess(10, 'var "x"') + ... y = 5 + ... >>> m = MyClass() >>> m.x Retrieving var "x" @@ -287,15 +287,15 @@ Running the interpreter shows how the function descriptor works in practice:: >>> class D(object): - def f(self, x): - return x - + ... def f(self, x): + ... return x + ... >>> d = D() - >>> D.__dict__['f'] # Stored internally as a function + >>> D.__dict__['f'] # Stored internally as a function - >>> D.f # Get from a class becomes an unbound method + >>> D.f # Get from a class becomes an unbound method - >>> d.f # Get from an instance becomes a bound method + >>> d.f # Get from an instance becomes a bound method > The output suggests that bound and unbound methods are two different types. @@ -358,10 +358,10 @@ calls are unexciting:: >>> class E(object): - def f(x): - print(x) - f = staticmethod(f) - + ... def f(x): + ... print(x) + ... f = staticmethod(f) + ... >>> print(E.f(3)) 3 >>> print(E().f(3)) @@ -371,23 +371,23 @@ :func:`staticmethod` would look like this:: class StaticMethod(object): - "Emulate PyStaticMethod_Type() in Objects/funcobject.c" + "Emulate PyStaticMethod_Type() in Objects/funcobject.c" - def __init__(self, f): - self.f = f + def __init__(self, f): + self.f = f - def __get__(self, obj, objtype=None): - return self.f + def __get__(self, obj, objtype=None): + return self.f Unlike static methods, class methods prepend the class reference to the argument list before calling the function. This format is the same for whether the caller is an object or a class:: >>> class E(object): - def f(klass, x): - return klass.__name__, x - f = classmethod(f) - + ... def f(klass, x): + ... return klass.__name__, x + ... f = classmethod(f) + ... >>> print(E.f(3)) ('E', 3) >>> print(E().f(3)) @@ -419,15 +419,15 @@ :func:`classmethod` would look like this:: class ClassMethod(object): - "Emulate PyClassMethod_Type() in Objects/funcobject.c" + "Emulate PyClassMethod_Type() in Objects/funcobject.c" - def __init__(self, f): - self.f = f + def __init__(self, f): + self.f = f - def __get__(self, obj, klass=None): - if klass is None: - klass = type(obj) - def newfunc(*args): - return self.f(klass, *args) - return newfunc + def __get__(self, obj, klass=None): + if klass is None: + klass = type(obj) + def newfunc(*args): + return self.f(klass, *args) + return newfunc diff --git a/Doc/howto/functional.rst b/Doc/howto/functional.rst --- a/Doc/howto/functional.rst +++ b/Doc/howto/functional.rst @@ -395,14 +395,14 @@ continue # Skip this element for expr2 in sequence2: if not (condition2): - continue # Skip this element + continue # Skip this element ... for exprN in sequenceN: - if not (conditionN): - continue # Skip this element + if not (conditionN): + continue # Skip this element - # Output the value of - # the expression. + # Output the value of + # the expression. This means that when there are multiple ``for...in`` clauses but no ``if`` clauses, the length of the resulting output will be equal to the product of the 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 @@ -63,6 +63,7 @@ def __init__(self): self.logger = logging.getLogger('spam_application.auxiliary.Auxiliary') self.logger.info('creating an instance of Auxiliary') + def do_something(self): self.logger.info('doing something') a = 1 + 1 @@ -360,7 +361,7 @@ An example of using these two classes follows (imports omitted):: - que = queue.Queue(-1) # no limit on size + que = queue.Queue(-1) # no limit on size queue_handler = QueueHandler(que) handler = logging.StreamHandler() listener = QueueListener(que, handler) @@ -656,21 +657,21 @@ return True if __name__ == '__main__': - levels = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL) - logging.basicConfig(level=logging.DEBUG, - format='%(asctime)-15s %(name)-5s %(levelname)-8s IP: %(ip)-15s User: %(user)-8s %(message)s') - a1 = logging.getLogger('a.b.c') - a2 = logging.getLogger('d.e.f') - - f = ContextFilter() - a1.addFilter(f) - a2.addFilter(f) - a1.debug('A debug message') - a1.info('An info message with %s', 'some parameters') - for x in range(10): - lvl = choice(levels) - lvlname = logging.getLevelName(lvl) - a2.log(lvl, 'A message at %s level with %d %s', lvlname, 2, 'parameters') + levels = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL) + logging.basicConfig(level=logging.DEBUG, + format='%(asctime)-15s %(name)-5s %(levelname)-8s IP: %(ip)-15s User: %(user)-8s %(message)s') + a1 = logging.getLogger('a.b.c') + a2 = logging.getLogger('d.e.f') + + f = ContextFilter() + a1.addFilter(f) + a2.addFilter(f) + a1.debug('A debug message') + a1.info('An info message with %s', 'some parameters') + for x in range(10): + lvl = choice(levels) + lvlname = logging.getLevelName(lvl) + a2.log(lvl, 'A message at %s level with %d %s', lvlname, 2, 'parameters') which, when run, produces something like:: @@ -764,10 +765,10 @@ while True: try: record = queue.get() - if record is None: # We send this as a sentinel to tell the listener to quit. + if record is None: # We send this as a sentinel to tell the listener to quit. break logger = logging.getLogger(record.name) - logger.handle(record) # No level or filter logic applied - just do it! + logger.handle(record) # No level or filter logic applied - just do it! except Exception: import sys, traceback print('Whoops! Problem:', file=sys.stderr) @@ -790,10 +791,11 @@ # Note that on Windows you can't rely on fork semantics, so each process # will run the logging configuration code when it starts. def worker_configurer(queue): - h = logging.handlers.QueueHandler(queue) # Just the one handler needed + h = logging.handlers.QueueHandler(queue) # Just the one handler needed root = logging.getLogger() root.addHandler(h) - root.setLevel(logging.DEBUG) # send all messages, for demo; no other level or filter logic applied. + # send all messages, for demo; no other level or filter logic applied. + root.setLevel(logging.DEBUG) # This is the worker process top-level loop, which just logs ten events with # random intervening delays before terminating. @@ -821,7 +823,7 @@ workers = [] for i in range(10): worker = multiprocessing.Process(target=worker_process, - args=(queue, worker_configurer)) + args=(queue, worker_configurer)) workers.append(worker) worker.start() for w in workers: @@ -1245,12 +1247,12 @@ of queues, for example a ZeroMQ 'publish' socket. In the example below,the socket is created separately and passed to the handler (as its 'queue'):: - import zmq # using pyzmq, the Python binding for ZeroMQ - import json # for serializing records portably + import zmq # using pyzmq, the Python binding for ZeroMQ + import json # for serializing records portably ctx = zmq.Context() - sock = zmq.Socket(ctx, zmq.PUB) # or zmq.PUSH, or other suitable value - sock.bind('tcp://*:5556') # or wherever + sock = zmq.Socket(ctx, zmq.PUB) # or zmq.PUSH, or other suitable value + sock.bind('tcp://*:5556') # or wherever class ZeroMQSocketHandler(QueueHandler): def enqueue(self, record): @@ -1288,7 +1290,7 @@ def __init__(self, uri, *handlers, **kwargs): self.ctx = kwargs.get('ctx') or zmq.Context() socket = zmq.Socket(self.ctx, zmq.SUB) - socket.setsockopt(zmq.SUBSCRIBE, '') # subscribe to everything + socket.setsockopt(zmq.SUBSCRIBE, '') # subscribe to everything socket.connect(uri) def dequeue(self): @@ -2116,7 +2118,7 @@ Format an exception so that it prints on a single line. """ result = super(OneLineExceptionFormatter, self).formatException(exc_info) - return repr(result) # or format into one line however you want to + return repr(result) # or format into one line however you want to def format(self, record): s = super(OneLineExceptionFormatter, self).format(record) diff --git a/Doc/howto/logging.rst b/Doc/howto/logging.rst --- a/Doc/howto/logging.rst +++ b/Doc/howto/logging.rst @@ -103,8 +103,8 @@ A very simple example is:: import logging - logging.warning('Watch out!') # will print a message to the console - logging.info('I told you so') # will not print anything + logging.warning('Watch out!') # will print a message to the console + logging.info('I told you so') # will not print anything If you type these lines into a script and run it, you'll see:: diff --git a/Doc/howto/regex.rst b/Doc/howto/regex.rst --- a/Doc/howto/regex.rst +++ b/Doc/howto/regex.rst @@ -1115,19 +1115,19 @@ Here's a simple example of using the :meth:`sub` method. It replaces colour names with the word ``colour``:: - >>> p = re.compile( '(blue|white|red)') - >>> p.sub( 'colour', 'blue socks and red shoes') + >>> p = re.compile('(blue|white|red)') + >>> p.sub('colour', 'blue socks and red shoes') 'colour socks and colour shoes' - >>> p.sub( 'colour', 'blue socks and red shoes', count=1) + >>> p.sub('colour', 'blue socks and red shoes', count=1) 'colour socks and red shoes' The :meth:`subn` method does the same work, but returns a 2-tuple containing the new string value and the number of replacements that were performed:: - >>> p = re.compile( '(blue|white|red)') - >>> p.subn( 'colour', 'blue socks and red shoes') + >>> p = re.compile('(blue|white|red)') + >>> p.subn('colour', 'blue socks and red shoes') ('colour socks and colour shoes', 2) - >>> p.subn( 'colour', 'no colours at all') + >>> p.subn('colour', 'no colours at all') ('no colours at all', 0) Empty matches are replaced only when they're not adjacent to a previous match. diff --git a/Doc/howto/unicode.rst b/Doc/howto/unicode.rst --- a/Doc/howto/unicode.rst +++ b/Doc/howto/unicode.rst @@ -687,7 +687,7 @@ # make changes to the string 'data' with open(fname + '.new', 'w', - encoding="ascii", errors="surrogateescape") as f: + encoding="ascii", errors="surrogateescape") as f: f.write(data) The ``surrogateescape`` error handler will decode any non-ASCII bytes diff --git a/Doc/howto/urllib2.rst b/Doc/howto/urllib2.rst --- a/Doc/howto/urllib2.rst +++ b/Doc/howto/urllib2.rst @@ -175,10 +175,10 @@ url = 'http://www.someserver.com/cgi-bin/register.cgi' user_agent = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64)' - values = {'name' : 'Michael Foord', - 'location' : 'Northampton', - 'language' : 'Python' } - headers = { 'User-Agent' : user_agent } + values = {'name': 'Michael Foord', + 'location': 'Northampton', + 'language': 'Python' } + headers = {'User-Agent': user_agent} data = urllib.parse.urlencode(values) data = data.encode('ascii') @@ -215,7 +215,7 @@ >>> req = urllib.request.Request('http://www.pretend_server.org') >>> try: urllib.request.urlopen(req) ... except urllib.error.URLError as e: - ... print(e.reason) #doctest: +SKIP + ... print(e.reason) #doctest: +SKIP ... (4, 'getaddrinfo failed') @@ -372,7 +372,7 @@ :: from urllib.request import Request, urlopen - from urllib.error import URLError + from urllib.error import URLError req = Request(someurl) try: response = urlopen(req) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -35,10 +35,10 @@ parser = argparse.ArgumentParser(description='Process some integers.') parser.add_argument('integers', metavar='N', type=int, nargs='+', - help='an integer for the accumulator') + help='an integer for the accumulator') parser.add_argument('--sum', dest='accumulate', action='store_const', - const=sum, default=max, - help='sum the integers (default: find the max)') + const=sum, default=max, + help='sum the integers (default: find the max)') args = parser.parse_args() print(args.accumulate(args.integers)) @@ -488,7 +488,7 @@ arguments they contain. For example:: >>> with open('args.txt', 'w') as fp: - ... fp.write('-f\nbar') + ... fp.write('-f\nbar') >>> parser = argparse.ArgumentParser(fromfile_prefix_chars='@') >>> parser.add_argument('-f') >>> parser.parse_args(['-f', 'foo', '@args.txt']) @@ -1109,9 +1109,9 @@ >>> parser = argparse.ArgumentParser(prog='frobble') >>> parser.add_argument('--foo', action='store_true', - ... help='foo the bars before frobbling') + ... help='foo the bars before frobbling') >>> parser.add_argument('bar', nargs='+', - ... help='one of the bars to be frobbled') + ... help='one of the bars to be frobbled') >>> parser.parse_args(['-h']) usage: frobble [-h] [--foo] bar [bar ...] @@ -1129,7 +1129,7 @@ >>> parser = argparse.ArgumentParser(prog='frobble') >>> parser.add_argument('bar', nargs='?', type=int, default=42, - ... help='the bar to %(prog)s (default: %(default)s)') + ... help='the bar to %(prog)s (default: %(default)s)') >>> parser.print_help() usage: frobble [-h] [bar] @@ -1468,10 +1468,10 @@ >>> parser = argparse.ArgumentParser() >>> parser.add_argument( ... 'integers', metavar='int', type=int, choices=range(10), - ... nargs='+', help='an integer in the range 0..9') + ... nargs='+', help='an integer in the range 0..9') >>> parser.add_argument( ... '--sum', dest='accumulate', action='store_const', const=sum, - ... default=max, help='sum the integers (default: find the max)') + ... default=max, help='sum the integers (default: find the max)') >>> parser.parse_args(['1', '2', '3', '4']) Namespace(accumulate=, integers=[1, 2, 3, 4]) >>> parser.parse_args(['1', '2', '3', '4', '--sum']) diff --git a/Doc/library/asynchat.rst b/Doc/library/asynchat.rst --- a/Doc/library/asynchat.rst +++ b/Doc/library/asynchat.rst @@ -202,7 +202,7 @@ self.set_terminator(None) self.handle_request() elif not self.handling: - self.set_terminator(None) # browsers sometimes over-send + self.set_terminator(None) # browsers sometimes over-send self.cgi_data = parse(self.headers, b"".join(self.ibuffer)) self.handling = True self.ibuffer = [] diff --git a/Doc/library/asyncio-sync.rst b/Doc/library/asyncio-sync.rst --- a/Doc/library/asyncio-sync.rst +++ b/Doc/library/asyncio-sync.rst @@ -71,14 +71,14 @@ lock = Lock() ... with (yield from lock): - ... + ... Lock objects can be tested for locking state:: if not lock.locked(): - yield from lock + yield from lock else: - # lock is acquired + # lock is acquired ... .. method:: locked() diff --git a/Doc/library/asyncore.rst b/Doc/library/asyncore.rst --- a/Doc/library/asyncore.rst +++ b/Doc/library/asyncore.rst @@ -315,8 +315,8 @@ self.buffer = self.buffer[sent:] - client = HTTPClient('www.python.org', '/') - asyncore.loop() + client = HTTPClient('www.python.org', '/') + asyncore.loop() .. _asyncore-example-2: diff --git a/Doc/library/audioop.rst b/Doc/library/audioop.rst --- a/Doc/library/audioop.rst +++ b/Doc/library/audioop.rst @@ -276,6 +276,6 @@ # out_test) prefill = '\0'*(pos+ipos)*2 postfill = '\0'*(len(inputdata)-len(prefill)-len(outputdata)) - outputdata = prefill + audioop.mul(outputdata,2,-factor) + postfill + outputdata = prefill + audioop.mul(outputdata, 2, -factor) + postfill return audioop.add(inputdata, outputdata, 2) diff --git a/Doc/library/collections.abc.rst b/Doc/library/collections.abc.rst --- a/Doc/library/collections.abc.rst +++ b/Doc/library/collections.abc.rst @@ -225,19 +225,22 @@ :meth:`isdisjoint`:: class ListBasedSet(collections.abc.Set): - ''' Alternate set implementation favoring space over speed - and not requiring the set elements to be hashable. ''' - def __init__(self, iterable): - self.elements = lst = [] - for value in iterable: - if value not in lst: - lst.append(value) - def __iter__(self): - return iter(self.elements) - def __contains__(self, value): - return value in self.elements - def __len__(self): - return len(self.elements) + ''' Alternate set implementation favoring space over speed + and not requiring the set elements to be hashable. ''' + def __init__(self, iterable): + self.elements = lst = [] + for value in iterable: + if value not in lst: + lst.append(value) + + def __iter__(self): + return iter(self.elements) + + def __contains__(self, value): + return value in self.elements + + def __len__(self): + return len(self.elements) s1 = ListBasedSet('abcdef') s2 = ListBasedSet('defghi') diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst --- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -1032,7 +1032,7 @@ in conjunction with sorting to make a sorted dictionary:: >>> # regular unsorted dictionary - >>> d = {'banana': 3, 'apple':4, 'pear': 1, 'orange': 2} + >>> d = {'banana': 3, 'apple': 4, 'pear': 1, 'orange': 2} >>> # dictionary sorted by key >>> OrderedDict(sorted(d.items(), key=lambda t: t[0])) diff --git a/Doc/library/concurrent.futures.rst b/Doc/library/concurrent.futures.rst --- a/Doc/library/concurrent.futures.rst +++ b/Doc/library/concurrent.futures.rst @@ -99,12 +99,12 @@ import time def wait_on_b(): time.sleep(5) - print(b.result()) # b will never complete because it is waiting on a. + print(b.result()) # b will never complete because it is waiting on a. return 5 def wait_on_a(): time.sleep(5) - print(a.result()) # a will never complete because it is waiting on b. + print(a.result()) # a will never complete because it is waiting on b. return 6 diff --git a/Doc/library/configparser.rst b/Doc/library/configparser.rst --- a/Doc/library/configparser.rst +++ b/Doc/library/configparser.rst @@ -833,13 +833,13 @@ # Set the optional *raw* argument of get() to True if you wish to disable # interpolation in a single get operation. - print(cfg.get('Section1', 'foo', raw=False)) # -> "Python is fun!" - print(cfg.get('Section1', 'foo', raw=True)) # -> "%(bar)s is %(baz)s!" + print(cfg.get('Section1', 'foo', raw=False)) # -> "Python is fun!" + print(cfg.get('Section1', 'foo', raw=True)) # -> "%(bar)s is %(baz)s!" # The optional *vars* argument is a dict with members that will take # precedence in interpolation. print(cfg.get('Section1', 'foo', vars={'bar': 'Documentation', - 'baz': 'evil'})) + 'baz': 'evil'})) # The optional *fallback* argument can be used to provide a fallback value print(cfg.get('Section1', 'foo')) @@ -866,10 +866,10 @@ config = configparser.ConfigParser({'bar': 'Life', 'baz': 'hard'}) config.read('example.cfg') - print(config.get('Section1', 'foo')) # -> "Python is fun!" + print(config.get('Section1', 'foo')) # -> "Python is fun!" config.remove_option('Section1', 'bar') config.remove_option('Section1', 'baz') - print(config.get('Section1', 'foo')) # -> "Life is hard!" + print(config.get('Section1', 'foo')) # -> "Life is hard!" .. _configparser-objects: diff --git a/Doc/library/contextlib.rst b/Doc/library/contextlib.rst --- a/Doc/library/contextlib.rst +++ b/Doc/library/contextlib.rst @@ -656,7 +656,7 @@ Before After >>> with cm: - ... pass + ... pass ... Traceback (most recent call last): ... diff --git a/Doc/library/crypt.rst b/Doc/library/crypt.rst --- a/Doc/library/crypt.rst +++ b/Doc/library/crypt.rst @@ -149,4 +149,4 @@ hashed = crypt.crypt(plaintext) if not compare_hash(hashed, crypt.crypt(plaintext, hashed)): - raise ValueError("hashed version doesn't validate against original") + raise ValueError("hashed version doesn't validate against original") diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst --- a/Doc/library/ctypes.rst +++ b/Doc/library/ctypes.rst @@ -52,11 +52,11 @@ convention:: >>> from ctypes import * - >>> print(windll.kernel32) # doctest: +WINDOWS + >>> print(windll.kernel32) # doctest: +WINDOWS - >>> print(cdll.msvcrt) # doctest: +WINDOWS + >>> print(cdll.msvcrt) # doctest: +WINDOWS - >>> libc = cdll.msvcrt # doctest: +WINDOWS + >>> libc = cdll.msvcrt # doctest: +WINDOWS >>> Windows appends the usual ``.dll`` file suffix automatically. @@ -72,10 +72,10 @@ :meth:`LoadLibrary` method of the dll loaders should be used, or you should load the library by creating an instance of CDLL by calling the constructor:: - >>> cdll.LoadLibrary("libc.so.6") # doctest: +LINUX + >>> cdll.LoadLibrary("libc.so.6") # doctest: +LINUX - >>> libc = CDLL("libc.so.6") # doctest: +LINUX - >>> libc # doctest: +LINUX + >>> libc = CDLL("libc.so.6") # doctest: +LINUX + >>> libc # doctest: +LINUX >>> @@ -92,9 +92,9 @@ >>> from ctypes import * >>> libc.printf <_FuncPtr object at 0x...> - >>> print(windll.kernel32.GetModuleHandleA) # doctest: +WINDOWS + >>> print(windll.kernel32.GetModuleHandleA) # doctest: +WINDOWS <_FuncPtr object at 0x...> - >>> print(windll.kernel32.MyOwnFunction) # doctest: +WINDOWS + >>> print(windll.kernel32.MyOwnFunction) # doctest: +WINDOWS Traceback (most recent call last): File "", line 1, in ? File "ctypes.py", line 239, in __getattr__ @@ -123,16 +123,16 @@ identifiers, like ``"??2 at YAPAXI@Z"``. In this case you have to use :func:`getattr` to retrieve the function:: - >>> getattr(cdll.msvcrt, "??2 at YAPAXI@Z") # doctest: +WINDOWS + >>> getattr(cdll.msvcrt, "??2 at YAPAXI@Z") # doctest: +WINDOWS <_FuncPtr object at 0x...> >>> On Windows, some dlls export functions not by name but by ordinal. These functions can be accessed by indexing the dll object with the ordinal number:: - >>> cdll.kernel32[1] # doctest: +WINDOWS + >>> cdll.kernel32[1] # doctest: +WINDOWS <_FuncPtr object at 0x...> - >>> cdll.kernel32[0] # doctest: +WINDOWS + >>> cdll.kernel32[0] # doctest: +WINDOWS Traceback (most recent call last): File "", line 1, in ? File "ctypes.py", line 310, in __getitem__ @@ -154,9 +154,9 @@ This example calls both functions with a NULL pointer (``None`` should be used as the NULL pointer):: - >>> print(libc.time(None)) # doctest: +SKIP + >>> print(libc.time(None)) # doctest: +SKIP 1150640792 - >>> print(hex(windll.kernel32.GetModuleHandleA(None))) # doctest: +WINDOWS + >>> print(hex(windll.kernel32.GetModuleHandleA(None))) # doctest: +WINDOWS 0x1d000000 >>> @@ -165,11 +165,11 @@ Windows. It does this by examining the stack after the function returns, so although an error is raised the function *has* been called:: - >>> windll.kernel32.GetModuleHandleA() # doctest: +WINDOWS + >>> windll.kernel32.GetModuleHandleA() # doctest: +WINDOWS Traceback (most recent call last): File "", line 1, in ? ValueError: Procedure probably called with not enough arguments (4 bytes missing) - >>> windll.kernel32.GetModuleHandleA(0, 0) # doctest: +WINDOWS + >>> windll.kernel32.GetModuleHandleA(0, 0) # doctest: +WINDOWS Traceback (most recent call last): File "", line 1, in ? ValueError: Procedure probably called with too many arguments (4 bytes in excess) @@ -178,13 +178,13 @@ The same exception is raised when you call an ``stdcall`` function with the ``cdecl`` calling convention, or vice versa:: - >>> cdll.kernel32.GetModuleHandleA(None) # doctest: +WINDOWS + >>> cdll.kernel32.GetModuleHandleA(None) # doctest: +WINDOWS Traceback (most recent call last): File "", line 1, in ? ValueError: Procedure probably called with not enough arguments (4 bytes missing) >>> - >>> windll.msvcrt.printf(b"spam") # doctest: +WINDOWS + >>> windll.msvcrt.printf(b"spam") # doctest: +WINDOWS Traceback (most recent call last): File "", line 1, in ? ValueError: Procedure probably called with too many arguments (4 bytes in excess) @@ -197,7 +197,7 @@ crashes from general protection faults when functions are called with invalid argument values:: - >>> windll.kernel32.GetModuleHandleA(32) # doctest: +WINDOWS + >>> windll.kernel32.GetModuleHandleA(32) # doctest: +WINDOWS Traceback (most recent call last): File "", line 1, in ? OSError: exception: access violation reading 0x00000020 @@ -462,9 +462,9 @@ a string pointer and a char, and returns a pointer to a string:: >>> strchr = libc.strchr - >>> strchr(b"abcdef", ord("d")) # doctest: +SKIP + >>> strchr(b"abcdef", ord("d")) # doctest: +SKIP 8059983 - >>> strchr.restype = c_char_p # c_char_p is a pointer to a string + >>> strchr.restype = c_char_p # c_char_p is a pointer to a string >>> strchr(b"abcdef", ord("d")) b'def' >>> print(strchr(b"abcdef", ord("x"))) @@ -495,17 +495,17 @@ result of this call will be used as the result of your function call. This is useful to check for error return values and automatically raise an exception:: - >>> GetModuleHandle = windll.kernel32.GetModuleHandleA # doctest: +WINDOWS + >>> GetModuleHandle = windll.kernel32.GetModuleHandleA # doctest: +WINDOWS >>> def ValidHandle(value): ... if value == 0: ... raise WinError() ... return value ... >>> - >>> GetModuleHandle.restype = ValidHandle # doctest: +WINDOWS - >>> GetModuleHandle(None) # doctest: +WINDOWS + >>> GetModuleHandle.restype = ValidHandle # doctest: +WINDOWS + >>> GetModuleHandle(None) # doctest: +WINDOWS 486539264 - >>> GetModuleHandle("something silly") # doctest: +WINDOWS + >>> GetModuleHandle("something silly") # doctest: +WINDOWS Traceback (most recent call last): File "", line 1, in ? File "", line 3, in ValidHandle @@ -676,12 +676,12 @@ >>> from ctypes import * >>> class POINT(Structure): - ... _fields_ = ("x", c_int), ("y", c_int) + ... _fields_ = ("x", c_int), ("y", c_int) ... >>> class MyStruct(Structure): - ... _fields_ = [("a", c_int), - ... ("b", c_float), - ... ("point_array", POINT * 4)] + ... _fields_ = [("a", c_int), + ... ("b", c_float), + ... ("point_array", POINT * 4)] >>> >>> print(len(MyStruct().point_array)) 4 @@ -998,7 +998,7 @@ The result:: - >>> qsort(ia, len(ia), sizeof(c_int), cmp_func) # doctest: +LINUX + >>> qsort(ia, len(ia), sizeof(c_int), cmp_func) # doctest: +LINUX py_cmp_func 5 1 py_cmp_func 33 99 py_cmp_func 7 33 @@ -1100,9 +1100,9 @@ hit the NULL entry:: >>> for item in table: - ... print(item.name, item.size) - ... if item.name is None: - ... break + ... print(item.name, item.size) + ... if item.name is None: + ... break ... __hello__ 104 __phello__ -104 diff --git a/Doc/library/email.headerregistry.rst b/Doc/library/email.headerregistry.rst --- a/Doc/library/email.headerregistry.rst +++ b/Doc/library/email.headerregistry.rst @@ -171,7 +171,7 @@ :class:`~datetime.datetime` instance. This means, for example, that the following code is valid and does what one would expect:: - msg['Date'] = datetime(2011, 7, 15, 21) + msg['Date'] = datetime(2011, 7, 15, 21) Because this is a naive ``datetime`` it will be interpreted as a UTC timestamp, and the resulting value will have a timezone of ``-0000``. Much diff --git a/Doc/library/getopt.rst b/Doc/library/getopt.rst --- a/Doc/library/getopt.rst +++ b/Doc/library/getopt.rst @@ -124,7 +124,7 @@ opts, args = getopt.getopt(sys.argv[1:], "ho:v", ["help", "output="]) except getopt.GetoptError as err: # print help information and exit: - print(err) # will print something like "option -a not recognized" + print(err) # will print something like "option -a not recognized" usage() sys.exit(2) output = None diff --git a/Doc/library/html.parser.rst b/Doc/library/html.parser.rst --- a/Doc/library/html.parser.rst +++ b/Doc/library/html.parser.rst @@ -51,8 +51,10 @@ class MyHTMLParser(HTMLParser): def handle_starttag(self, tag, attrs): print("Encountered a start tag:", tag) + def handle_endtag(self, tag): print("Encountered an end tag :", tag) + def handle_data(self, data): print("Encountered some data :", data) @@ -237,21 +239,27 @@ print("Start tag:", tag) for attr in attrs: print(" attr:", attr) + def handle_endtag(self, tag): print("End tag :", tag) + def handle_data(self, data): print("Data :", data) + def handle_comment(self, data): print("Comment :", data) + def handle_entityref(self, name): c = chr(name2codepoint[name]) print("Named ent:", c) + def handle_charref(self, name): if name.startswith('x'): c = chr(int(name[1:], 16)) else: c = chr(int(name)) print("Num ent :", c) + def handle_decl(self, data): print("Decl :", data) @@ -283,7 +291,7 @@ attr: ('type', 'text/css') Data : #python { color: green } End tag : style - >>> + >>> parser.feed('') Start tag: script 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 @@ -441,7 +441,7 @@ >>> conn.request("GET", "/") >>> r1 = conn.getresponse() >>> while not r1.closed: - ... print(r1.read(200)) # 200 bytes + ... print(r1.read(200)) # 200 bytes b'\n