From e1391a0d68b063adfb13a48756938d19cc67c7e0 Mon Sep 17 00:00:00 2001 From: Zachary Ware Date: Fri, 22 Nov 2013 13:58:34 -0600 Subject: [PATCH 1/5] Issue #18326: Clarify that list.sort's arguments are keyword-only. Also, attempt to reduce confusion in the glossary by not saying there are different "types" of arguments and parameters. --- Doc/glossary.rst | 6 ++++-- Doc/library/stdtypes.rst | 3 +++ Misc/NEWS | 7 +++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Doc/glossary.rst b/Doc/glossary.rst index b4465ac51ce..71e46860202 100644 --- a/Doc/glossary.rst +++ b/Doc/glossary.rst @@ -41,7 +41,7 @@ Glossary argument A value passed to a :term:`function` (or :term:`method`) when calling the - function. There are two types of arguments: + function. There are two kinds of argument: * :dfn:`keyword argument`: an argument preceded by an identifier (e.g. ``name=``) in a function call or passed as a value in a dictionary @@ -592,7 +592,7 @@ Glossary parameter A named entity in a :term:`function` (or method) definition that specifies an :term:`argument` (or in some cases, arguments) that the - function can accept. There are five types of parameters: + function can accept. There are five kinds of parameter: * :dfn:`positional-or-keyword`: specifies an argument that can be passed either :term:`positionally ` or as a :term:`keyword argument @@ -606,6 +606,8 @@ Glossary parameters. However, some built-in functions have positional-only parameters (e.g. :func:`abs`). + .. _keyword-only_parameter: + * :dfn:`keyword-only`: specifies an argument that can be supplied only by keyword. Keyword-only parameters can be defined by including a single var-positional parameter or bare ``*`` in the parameter list diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index fa58a0d235a..db3ef88e663 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1149,6 +1149,9 @@ application). fail, the entire sort operation will fail (and the list will likely be left in a partially modified state). + :meth:`sort` accepts two arguments that can only be passed by keyword + (:ref:`keyword-only arguments `): + *key* specifies a function of one argument that is used to extract a comparison key from each list element (for example, ``key=str.lower``). The key corresponding to each item in the list is calculated once and diff --git a/Misc/NEWS b/Misc/NEWS index 12f3b526230..2a8057ad801 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -68,6 +68,13 @@ Tests - Issue #19085: Added basic tests for all tkinter widget options. +Documentation +------------- + +- Issue #18326: Clarify that list.sort's arguments are keyword-only. Also, + attempt to reduce confusion in the glossary by not saying there are + different "types" of arguments and parameters. + Build ----- From 4da459c4885a953103f1fd322036d9e20a5e4795 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Fri, 22 Nov 2013 12:27:45 -0800 Subject: [PATCH 2/5] Fix markup of notes recommending asyncio. --- Doc/library/asynchat.rst | 6 ++++-- Doc/library/asyncore.rst | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Doc/library/asynchat.rst b/Doc/library/asynchat.rst index 7050f0c5a3b..7b8107434a7 100644 --- a/Doc/library/asynchat.rst +++ b/Doc/library/asynchat.rst @@ -10,8 +10,10 @@ -------------- -Note: This module exists for backwards compatibility only. For new code we -recommend using :module:`asyncio`. +.. note:: + + This module exists for backwards compatibility only. For new code we + recommend using :mod:`asyncio`. This module builds on the :mod:`asyncore` infrastructure, simplifying asynchronous clients and servers and making it easier to handle protocols diff --git a/Doc/library/asyncore.rst b/Doc/library/asyncore.rst index d0a30f8ae6c..61079c5b34c 100644 --- a/Doc/library/asyncore.rst +++ b/Doc/library/asyncore.rst @@ -13,8 +13,10 @@ -------------- -Note: This module exists for backwards compatibility only. For new code we -recommend using :module:`asyncio`. +.. note:: + + This module exists for backwards compatibility only. For new code we + recommend using :mod:`asyncio`. This module provides the basic infrastructure for writing asynchronous socket service clients and servers. From 9121f8d94b178bd65d7adfa621028a1bcb579818 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Fri, 22 Nov 2013 15:31:35 -0500 Subject: [PATCH 3/5] Issue 19555 for distutils, plus a little clean up (pyflakes, line lengths). --- Lib/distutils/sysconfig.py | 8 +++++ Lib/distutils/tests/test_sysconfig.py | 43 ++++++++++++++++++++------- Misc/NEWS | 7 +++-- 3 files changed, 44 insertions(+), 14 deletions(-) diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py index d9c9d658188..392d63d1d9e 100644 --- a/Lib/distutils/sysconfig.py +++ b/Lib/distutils/sysconfig.py @@ -518,6 +518,11 @@ def get_config_vars(*args): _config_vars['prefix'] = PREFIX _config_vars['exec_prefix'] = EXEC_PREFIX + # For backward compatibility, see issue19555 + SO = _config_vars.get('EXT_SUFFIX') + if SO is not None: + _config_vars['SO'] = SO + # Always convert srcdir to an absolute path srcdir = _config_vars.get('srcdir', project_base) if os.name == 'posix': @@ -568,4 +573,7 @@ def get_config_var(name): returned by 'get_config_vars()'. Equivalent to get_config_vars().get(name) """ + if name == 'SO': + import warnings + warnings.warn('SO is deprecated, use EXT_SUFFIX', DeprecationWarning) return get_config_vars().get(name) diff --git a/Lib/distutils/tests/test_sysconfig.py b/Lib/distutils/tests/test_sysconfig.py index 07812d80fc4..e14646edf72 100644 --- a/Lib/distutils/tests/test_sysconfig.py +++ b/Lib/distutils/tests/test_sysconfig.py @@ -1,7 +1,6 @@ """Tests for distutils.sysconfig.""" import os import shutil -import test import unittest from distutils import sysconfig @@ -9,8 +8,7 @@ from distutils.ccompiler import get_default_compiler from distutils.tests import support from test.support import TESTFN, run_unittest -class SysconfigTestCase(support.EnvironGuard, - unittest.TestCase): +class SysconfigTestCase(support.EnvironGuard, unittest.TestCase): def setUp(self): super(SysconfigTestCase, self).setUp() self.makefile = None @@ -32,7 +30,6 @@ class SysconfigTestCase(support.EnvironGuard, self.assertTrue(os.path.isfile(config_h), config_h) def test_get_python_lib(self): - lib_dir = sysconfig.get_python_lib() # XXX doesn't work on Linux when Python was never installed before #self.assertTrue(os.path.isdir(lib_dir), lib_dir) # test for pythonxx.lib? @@ -67,8 +64,9 @@ class SysconfigTestCase(support.EnvironGuard, self.assertTrue(os.path.exists(Python_h), Python_h) self.assertTrue(sysconfig._is_python_source_dir(srcdir)) elif os.name == 'posix': - self.assertEqual(os.path.dirname(sysconfig.get_makefile_filename()), - srcdir) + self.assertEqual( + os.path.dirname(sysconfig.get_makefile_filename()), + srcdir) def test_srcdir_independent_of_cwd(self): # srcdir should be independent of the current working directory @@ -129,10 +127,13 @@ class SysconfigTestCase(support.EnvironGuard, def test_sysconfig_module(self): import sysconfig as global_sysconfig - self.assertEqual(global_sysconfig.get_config_var('CFLAGS'), sysconfig.get_config_var('CFLAGS')) - self.assertEqual(global_sysconfig.get_config_var('LDFLAGS'), sysconfig.get_config_var('LDFLAGS')) + self.assertEqual(global_sysconfig.get_config_var('CFLAGS'), + sysconfig.get_config_var('CFLAGS')) + self.assertEqual(global_sysconfig.get_config_var('LDFLAGS'), + sysconfig.get_config_var('LDFLAGS')) - @unittest.skipIf(sysconfig.get_config_var('CUSTOMIZED_OSX_COMPILER'),'compiler flags customized') + @unittest.skipIf(sysconfig.get_config_var('CUSTOMIZED_OSX_COMPILER'), + 'compiler flags customized') def test_sysconfig_compiler_vars(self): # On OS X, binary installers support extension module building on # various levels of the operating system with differing Xcode @@ -151,9 +152,29 @@ class SysconfigTestCase(support.EnvironGuard, import sysconfig as global_sysconfig if sysconfig.get_config_var('CUSTOMIZED_OSX_COMPILER'): return - self.assertEqual(global_sysconfig.get_config_var('LDSHARED'), sysconfig.get_config_var('LDSHARED')) - self.assertEqual(global_sysconfig.get_config_var('CC'), sysconfig.get_config_var('CC')) + self.assertEqual(global_sysconfig.get_config_var('LDSHARED'), + sysconfig.get_config_var('LDSHARED')) + self.assertEqual(global_sysconfig.get_config_var('CC'), + sysconfig.get_config_var('CC')) + @unittest.skipIf(sysconfig.get_config_var('EXT_SUFFIX') is None, + 'EXT_SUFFIX required for this test') + def test_SO_deprecation(self): + self.assertWarns(DeprecationWarning, + sysconfig.get_config_var, 'SO') + + @unittest.skipIf(sysconfig.get_config_var('EXT_SUFFIX') is None, + 'EXT_SUFFIX required for this test') + def test_SO_value(self): + self.assertEqual(sysconfig.get_config_var('SO'), + sysconfig.get_config_var('EXT_SUFFIX')) + + @unittest.skipIf(sysconfig.get_config_var('EXT_SUFFIX') is None, + 'EXT_SUFFIX required for this test') + def test_SO_in_vars(self): + vars = sysconfig.get_config_vars() + self.assertIsNotNone(vars['SO']) + self.assertEqual(vars['SO'], vars['EXT_SUFFIX']) def test_suite(): diff --git a/Misc/NEWS b/Misc/NEWS index 27c31df75d8..bdc527ecc90 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,7 +10,8 @@ Projected release date: 2013-11-24 Core and Builtins ----------------- -- Use the repr of a module name in more places in import, especially exceptions. +- Use the repr of a module name in more places in import, especially + exceptions. - Issue #19619: str.encode, bytes.decode and bytearray.decode now use an internal API to throw LookupError for known non-text encodings, rather @@ -79,8 +80,8 @@ Library CRL enumeration are now two functions. enum_certificates() also returns purpose flags as set of OIDs. -- Issue #19555: Restore sysconfig.get_config_var('SO'), with a - DeprecationWarning pointing people at $EXT_SUFFIX. +- Issue #19555: Restore sysconfig.get_config_var('SO'), (and the distutils + equivalent) with a DeprecationWarning pointing people at $EXT_SUFFIX. - Issue #8813: Add SSLContext.verify_flags to change the verification flags of the context in order to enable certification revocation list (CRL) From 7a4e2d1751e7b261cd13685d488504e6d5a7ebee Mon Sep 17 00:00:00 2001 From: Andrew Kuchling Date: Fri, 22 Nov 2013 15:45:02 -0500 Subject: [PATCH 4/5] Wording changes to pathlib docs. Only possibly-controversial change: joinpath() was described as: "Calling this method is equivalent to indexing the path with each of the *other* arguments in turn." 'Indexing' is an odd word to use, because you can't subscript Path or PurePath objects, so I changed it to "combining". --- Doc/library/pathlib.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst index 04f6c422d1a..7582315a4f6 100644 --- a/Doc/library/pathlib.rst +++ b/Doc/library/pathlib.rst @@ -20,7 +20,7 @@ The main point of entry is the :class:`Path` class, which will instantiate a :ref:`concrete path ` for the current platform. .. note:: - This module module has been included in the standard library on a + This module has been included in the standard library on a :term:`provisional basis `. Backwards incompatible changes (up to and including removal of the package) may occur if deemed necessary by the core developers. @@ -250,7 +250,7 @@ property: Methods and properties ^^^^^^^^^^^^^^^^^^^^^^ -Pure paths provide the following methods an properties: +Pure paths provide the following methods and properties: .. data:: PurePath.drive @@ -454,7 +454,7 @@ Pure paths provide the following methods an properties: .. method:: PurePath.joinpath(*other) - Calling this method is equivalent to indexing the path with each of + Calling this method is equivalent to combining the path with each of the *other* arguments in turn:: >>> PurePosixPath('/etc').joinpath('passwd') @@ -871,4 +871,3 @@ call fails (for example because the path doesn't exist): Remove this file or symbolic link. If the path points to a directory, use :func:`Path.rmdir` instead. - From 2ba66ebc20347671082094aac538f13e1fa1fcca Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Fri, 22 Nov 2013 13:55:23 -0700 Subject: [PATCH 5/5] Issue #19724: clear out colliding temp module. --- Lib/test/test_pkgutil.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lib/test/test_pkgutil.py b/Lib/test/test_pkgutil.py index 52dd0bc73c9..d73b2117d3c 100644 --- a/Lib/test/test_pkgutil.py +++ b/Lib/test/test_pkgutil.py @@ -200,6 +200,8 @@ class ExtendPathTests(unittest.TestCase): dirname = self.create_init(pkgname) pathitem = os.path.join(dirname, pkgname) fullname = '{}.{}'.format(pkgname, modname) + sys.modules.pop(fullname, None) + sys.modules.pop(pkgname, None) try: self.create_submodule(dirname, pkgname, modname, 0)