Python-checkins
Threads by month
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
November 2013
- 13 participants
- 969 discussions
peps: Add brief explanation and web pointers to README.txt. Fixes issue 19822.
by guido.van.rossum 29 Nov '13
by guido.van.rossum 29 Nov '13
29 Nov '13
http://hg.python.org/peps/rev/34cb64cdbf7b
changeset: 5325:34cb64cdbf7b
user: Guido van Rossum <guido(a)dropbox.com>
date: Fri Nov 29 10:26:55 2013 -0800
summary:
Add brief explanation and web pointers to README.txt. Fixes issue 19822.
files:
README.txt | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/README.txt b/README.txt
--- a/README.txt
+++ b/README.txt
@@ -1,12 +1,23 @@
+Python Enhancement Proposals
+============================
+
+The PEPs in this repo are published automatically on the web at
+http://www.python.org/dev/peps/. To learn more about the purpose of
+PEPs and how to go about writing a PEP, please start reading at PEP 1
+(pep-0001.txt in this repo). Note that PEP 0, the index PEP, is now
+automatically generated, and not committed to the repo.
+
+
reStructuredText for PEPs
=========================
Original PEP source may be written using two standard formats, a
mildly idiomatic plaintext format and the reStructuredText format
-(also, technically plaintext). These two formats are described in PEP
-9 and PEP 12 respectively. The pep2html.py processing and
+(also, technically plaintext). These two formats are described in
+PEP 9 and PEP 12 respectively. The pep2html.py processing and
installation script knows how to produce the HTML for either PEP
format.
For processing reStructuredText format PEPs, you need the docutils
-package, which is available from PyPI.
+package, which is available from PyPI (http://pypi.python.org).
+If you have pip, "pip install docutils" should install it.
--
Repository URL: http://hg.python.org/peps
1
0
http://hg.python.org/cpython/rev/dfe327390cc2
changeset: 87637:dfe327390cc2
user: Guido van Rossum <guido(a)python.org>
date: Fri Nov 29 09:29:00 2013 -0800
summary:
asyncio: Add 'shield' to __all__.
files:
Lib/asyncio/tasks.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py
--- a/Lib/asyncio/tasks.py
+++ b/Lib/asyncio/tasks.py
@@ -3,7 +3,7 @@
__all__ = ['coroutine', 'Task',
'FIRST_COMPLETED', 'FIRST_EXCEPTION', 'ALL_COMPLETED',
'wait', 'wait_for', 'as_completed', 'sleep', 'async',
- 'gather',
+ 'gather', 'shield',
]
import collections
--
Repository URL: http://hg.python.org/cpython
1
0
cpython: Issue #19698: Remove exec_module() from the built-in and extension
by brett.cannon 29 Nov '13
by brett.cannon 29 Nov '13
29 Nov '13
http://hg.python.org/cpython/rev/b5bbd47a9bc4
changeset: 87636:b5bbd47a9bc4
user: Brett Cannon <brett(a)python.org>
date: Fri Nov 29 11:00:11 2013 -0500
summary:
Issue #19698: Remove exec_module() from the built-in and extension
module loaders.
Due to the fact that the call signatures for extension modules and
built-in modules does not allow for the specifying of what module to
initialize and that on Windows all extension modules are built-in
modules, work to clean up built-in and extension module initialization
will have to wait until Python 3.5. Because of this the semantics of
exec_module() would be incorrect, so removing the methods for now is
the best option; load_module() is still used as a fallback by
importlib and so this won't affect semantics.
files:
Lib/importlib/_bootstrap.py | 63 +-
Lib/test/test_importlib/builtin/test_loader.py | 72 -
Lib/test/test_importlib/extension/test_loader.py | 65 -
Misc/NEWS | 3 +
Python/importlib.h | 8369 +++++----
5 files changed, 4241 insertions(+), 4331 deletions(-)
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -133,6 +133,24 @@
_code_type = type(_wrap.__code__)
+
+class _ManageReload:
+
+ """Manages the possible clean-up of sys.modules for load_module()."""
+
+ def __init__(self, name):
+ self._name = name
+
+ def __enter__(self):
+ self._is_reload = self._name in sys.modules
+
+ def __exit__(self, *args):
+ if any(arg is not None for arg in args) and not self._is_reload:
+ try:
+ del sys.modules[self._name]
+ except KeyError:
+ pass
+
# Module-level locking ########################################################
# A dict mapping module names to weakrefs of _ModuleLock instances
@@ -1242,23 +1260,15 @@
spec = cls.find_spec(fullname, path)
return spec.loader if spec is not None else None
- @staticmethod
- def exec_module(module):
- spec = module.__spec__
- name = spec.name
- if not _imp.is_builtin(name):
- raise ImportError('{!r} is not a built-in module'.format(name),
- name=name)
- _call_with_frames_removed(_imp.init_builtin, name)
- # Have to manually initialize attributes since init_builtin() is not
- # going to do it for us.
- # XXX: Create _imp.exec_builtin(module)
- _SpecMethods(spec).init_module_attrs(sys.modules[name])
-
@classmethod
+ @_requires_builtin
def load_module(cls, fullname):
"""Load a built-in module."""
- return _load_module_shim(cls, fullname)
+ with _ManageReload(fullname):
+ module = _call_with_frames_removed(_imp.init_builtin, fullname)
+ module.__loader__ = cls
+ module.__package__ = ''
+ return module
@classmethod
@_requires_builtin
@@ -1639,22 +1649,21 @@
self.name = name
self.path = path
- def exec_module(self, module):
- # XXX create _imp.exec_dynamic()
- spec = module.__spec__
- fullname = spec.name
- module = _call_with_frames_removed(_imp.load_dynamic,
- fullname, self.path)
- _verbose_message('extension module loaded from {!r}', self.path)
- if self.is_package(fullname) and not hasattr(module, '__path__'):
- module.__path__ = [_path_split(self.path)[0]]
- _SpecMethods(spec).init_module_attrs(module)
-
- # XXX deprecate
@_check_name
def load_module(self, fullname):
"""Load an extension module."""
- return _load_module_shim(self, fullname)
+ with _ManageReload(fullname):
+ module = _call_with_frames_removed(_imp.load_dynamic,
+ fullname, self.path)
+ _verbose_message('extension module loaded from {!r}', self.path)
+ is_package = self.is_package(fullname)
+ if is_package and not hasattr(module, '__path__'):
+ module.__path__ = [_path_split(self.path)[0]]
+ module.__loader__ = self
+ module.__package__ = module.__name__
+ if not is_package:
+ module.__package__ = module.__package__.rpartition('.')[0]
+ return module
def is_package(self, fullname):
"""Return True if the extension module is a package."""
diff --git a/Lib/test/test_importlib/builtin/test_loader.py b/Lib/test/test_importlib/builtin/test_loader.py
--- a/Lib/test/test_importlib/builtin/test_loader.py
+++ b/Lib/test/test_importlib/builtin/test_loader.py
@@ -9,78 +9,6 @@
import unittest
-class ExecModTests(abc.LoaderTests):
-
- """Test exec_module() for built-in modules."""
-
- @classmethod
- def setUpClass(cls):
- cls.verification = {'__name__': 'errno', '__package__': '',
- '__loader__': cls.machinery.BuiltinImporter}
-
- def verify(self, module):
- """Verify that the module matches against what it should have."""
- self.assertIsInstance(module, types.ModuleType)
- for attr, value in self.verification.items():
- self.assertEqual(getattr(module, attr), value)
- self.assertIn(module.__name__, sys.modules)
- self.assertTrue(hasattr(module, '__spec__'))
- self.assertEqual(module.__spec__.origin, 'built-in')
-
- def load_spec(self, name):
- spec = self.machinery.ModuleSpec(name, self.machinery.BuiltinImporter,
- origin='built-in')
- module = types.ModuleType(name)
- module.__spec__ = spec
- self.machinery.BuiltinImporter.exec_module(module)
- # Strictly not what exec_module() is supposed to do, but since
- # _imp.init_builtin() does this we can't get around it.
- return sys.modules[name]
-
- def test_module(self):
- # Common case.
- with util.uncache(builtin_util.NAME):
- module = self.load_spec(builtin_util.NAME)
- self.verify(module)
- self.assertIn('built-in', str(module))
-
- # Built-in modules cannot be a package.
- test_package = None
-
- # Built-in modules cannot be a package.
- test_lacking_parent = None
-
- # Not way to force an import failure.
- test_state_after_failure = None
-
- def test_unloadable(self):
- name = 'dssdsdfff'
- assert name not in sys.builtin_module_names
- with self.assertRaises(ImportError) as cm:
- self.load_spec(name)
- self.assertEqual(cm.exception.name, name)
-
- def test_already_imported(self):
- # Using the name of a module already imported but not a built-in should
- # still fail.
- module_name = 'builtin_reload_test'
- assert module_name not in sys.builtin_module_names
- with util.uncache(module_name):
- module = types.ModuleType(module_name)
- spec = self.machinery.ModuleSpec(module_name,
- self.machinery.BuiltinImporter,
- origin='built-in')
- module.__spec__ = spec
- sys.modules[module_name] = module
- with self.assertRaises(ImportError) as cm:
- self.machinery.BuiltinImporter.exec_module(module)
- self.assertEqual(cm.exception.name, module_name)
-
-
-Frozen_ExecModTests, Source_ExecModTests = util.test_both(ExecModTests,
- machinery=[frozen_machinery, source_machinery])
-
-
class LoaderTests(abc.LoaderTests):
"""Test load_module() for built-in modules."""
diff --git a/Lib/test/test_importlib/extension/test_loader.py b/Lib/test/test_importlib/extension/test_loader.py
--- a/Lib/test/test_importlib/extension/test_loader.py
+++ b/Lib/test/test_importlib/extension/test_loader.py
@@ -10,71 +10,6 @@
import unittest
-class ExecModuleTests(abc.LoaderTests):
-
- """Test load_module() for extension modules."""
-
- def setUp(self):
- self.loader = self.machinery.ExtensionFileLoader(ext_util.NAME,
- ext_util.FILEPATH)
-
- def exec_module(self, fullname):
- module = types.ModuleType(fullname)
- module.__spec__ = self.machinery.ModuleSpec(fullname, self.loader)
- self.loader.exec_module(module)
- return sys.modules[fullname]
-
- def test_exec_module_API(self):
- with self.assertRaises(ImportError):
- self.exec_module('XXX')
-
-
- def test_module(self):
- with util.uncache(ext_util.NAME):
- module = self.exec_module(ext_util.NAME)
- for attr, value in [('__name__', ext_util.NAME),
- ('__file__', ext_util.FILEPATH),
- ('__package__', '')]:
- given = getattr(module, attr)
- self.assertEqual(given, value,
- '{}: {!r} != {!r}'.format(attr, given, value))
- self.assertIn(ext_util.NAME, sys.modules)
- self.assertIsInstance(module.__loader__,
- self.machinery.ExtensionFileLoader)
-
- # No extension module as __init__ available for testing.
- test_package = None
-
- # No extension module in a package available for testing.
- test_lacking_parent = None
-
- def test_module_reuse(self):
- with util.uncache(ext_util.NAME):
- module1 = self.exec_module(ext_util.NAME)
- module2 = self.exec_module(ext_util.NAME)
- self.assertIs(module1, module2)
-
- def test_state_after_failure(self):
- # No easy way to trigger a failure after a successful import.
- pass
-
- def test_unloadable(self):
- name = 'asdfjkl;'
- with self.assertRaises(ImportError) as cm:
- self.exec_module(name)
- self.assertEqual(cm.exception.name, name)
-
- def test_is_package(self):
- self.assertFalse(self.loader.is_package(ext_util.NAME))
- for suffix in self.machinery.EXTENSION_SUFFIXES:
- path = os.path.join('some', 'path', 'pkg', '__init__' + suffix)
- loader = self.machinery.ExtensionFileLoader('pkg', path)
- self.assertTrue(loader.is_package('pkg'))
-
-Frozen_ExecModuleTests, Source_ExecModuleTests = util.test_both(
- ExecModuleTests, machinery=machinery)
-
-
class LoaderTests(abc.LoaderTests):
"""Test load_module() for extension modules."""
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -18,6 +18,9 @@
Library
-------
+- Issue #19698: Removed exec_module() methods from
+ importlib.machinery.BuiltinImporter and ExtensionFileLoader.
+
- ssl.create_default_context() sets OP_NO_COMPRESSION to prevent CRIME.
- Issue #19802: Add socket.SO_PRIORITY.
diff --git a/Python/importlib.h b/Python/importlib.h
--- a/Python/importlib.h
+++ b/Python/importlib.h
[stripped]
--
Repository URL: http://hg.python.org/cpython
1
0
cpython (merge 3.3 -> default): Issue #19795: Improved markup of True/False constants.
by serhiy.storchaka 29 Nov '13
by serhiy.storchaka 29 Nov '13
29 Nov '13
http://hg.python.org/cpython/rev/6a3e09cd96f3
changeset: 87635:6a3e09cd96f3
parent: 87632:d829111a27e5
parent: 87634:b2066bc8cab9
user: Serhiy Storchaka <storchaka(a)gmail.com>
date: Fri Nov 29 12:19:53 2013 +0200
summary:
Issue #19795: Improved markup of True/False constants.
files:
Doc/howto/curses.rst | 2 +-
Doc/howto/functional.rst | 4 ++--
Doc/library/ast.rst | 2 +-
Doc/library/bdb.rst | 8 ++++----
Doc/library/bz2.rst | 2 +-
Doc/library/ctypes.rst | 2 +-
Doc/library/difflib.rst | 2 +-
Doc/library/dis.rst | 2 +-
Doc/library/email.message.rst | 2 +-
Doc/library/functions.rst | 8 ++++----
Doc/library/gc.rst | 4 ++--
Doc/library/http.client.rst | 2 +-
Doc/library/http.cookiejar.rst | 16 ++++++++--------
Doc/library/imp.rst | 4 ++--
Doc/library/importlib.rst | 4 ++--
Doc/library/io.rst | 2 +-
Doc/library/itertools.rst | 2 +-
Doc/library/logging.handlers.rst | 2 +-
Doc/library/logging.rst | 6 +++---
Doc/library/lzma.rst | 2 +-
Doc/library/mmap.rst | 2 +-
Doc/library/nntplib.rst | 4 ++--
Doc/library/os.path.rst | 6 +++---
Doc/library/os.rst | 2 +-
Doc/library/pickle.rst | 12 ++++++------
Doc/library/plistlib.rst | 2 +-
Doc/library/sched.rst | 2 +-
Doc/library/sqlite3.rst | 8 ++++----
Doc/library/ssl.rst | 8 ++++----
Doc/library/stdtypes.rst | 2 +-
Doc/library/struct.rst | 2 +-
Doc/library/subprocess.rst | 4 ++--
Doc/library/sys.rst | 2 +-
Doc/library/tarfile.rst | 2 +-
Doc/library/tkinter.ttk.rst | 8 ++++----
Doc/library/turtle.rst | 6 +++---
Doc/library/unittest.mock.rst | 6 +++---
Doc/library/urllib.request.rst | 4 ++--
Doc/library/venv.rst | 6 +++---
Doc/library/zipfile.rst | 2 +-
Doc/library/zipimport.rst | 2 +-
Doc/reference/datamodel.rst | 2 +-
Doc/whatsnew/3.3.rst | 2 +-
Misc/NEWS | 6 ++++++
44 files changed, 93 insertions(+), 87 deletions(-)
diff --git a/Doc/howto/curses.rst b/Doc/howto/curses.rst
--- a/Doc/howto/curses.rst
+++ b/Doc/howto/curses.rst
@@ -422,7 +422,7 @@
blue or any other color you like. Unfortunately, the Linux console doesn't
support this, so I'm unable to try it out, and can't provide any examples. You
can check if your terminal can do this by calling
-:func:`~curses.can_change_color`, which returns True if the capability is
+:func:`~curses.can_change_color`, which returns ``True`` if the capability is
there. If you're lucky enough to have such a talented terminal, consult your
system's man pages for more information.
diff --git a/Doc/howto/functional.rst b/Doc/howto/functional.rst
--- a/Doc/howto/functional.rst
+++ b/Doc/howto/functional.rst
@@ -689,8 +689,8 @@
The :func:`any(iter) <any>` and :func:`all(iter) <all>` built-ins look at the
-truth values of an iterable's contents. :func:`any` returns True if any element
-in the iterable is a true value, and :func:`all` returns True if all of the
+truth values of an iterable's contents. :func:`any` returns ``True`` if any element
+in the iterable is a true value, and :func:`all` returns ``True`` if all of the
elements are true values:
>>> any([0,1,0])
diff --git a/Doc/library/ast.rst b/Doc/library/ast.rst
--- a/Doc/library/ast.rst
+++ b/Doc/library/ast.rst
@@ -244,6 +244,6 @@
Return a formatted dump of the tree in *node*. This is mainly useful for
debugging purposes. The returned string will show the names and the values
for fields. This makes the code impossible to evaluate, so if evaluation is
- wanted *annotate_fields* must be set to False. Attributes such as line
+ wanted *annotate_fields* must be set to ``False``. Attributes such as line
numbers and column offsets are not dumped by default. If this is wanted,
*include_attributes* can be set to ``True``.
diff --git a/Doc/library/bdb.rst b/Doc/library/bdb.rst
--- a/Doc/library/bdb.rst
+++ b/Doc/library/bdb.rst
@@ -194,17 +194,17 @@
.. method:: user_line(frame)
This method is called from :meth:`dispatch_line` when either
- :meth:`stop_here` or :meth:`break_here` yields True.
+ :meth:`stop_here` or :meth:`break_here` yields ``True``.
.. method:: user_return(frame, return_value)
This method is called from :meth:`dispatch_return` when :meth:`stop_here`
- yields True.
+ yields ``True``.
.. method:: user_exception(frame, exc_info)
This method is called from :meth:`dispatch_exception` when
- :meth:`stop_here` yields True.
+ :meth:`stop_here` yields ``True``.
.. method:: do_clear(arg)
@@ -245,7 +245,7 @@
.. method:: set_quit()
- Set the :attr:`quitting` attribute to True. This raises :exc:`BdbQuit` in
+ Set the :attr:`quitting` attribute to ``True``. This raises :exc:`BdbQuit` in
the next call to one of the :meth:`dispatch_\*` methods.
diff --git a/Doc/library/bz2.rst b/Doc/library/bz2.rst
--- a/Doc/library/bz2.rst
+++ b/Doc/library/bz2.rst
@@ -169,7 +169,7 @@
.. attribute:: eof
- True if the end-of-stream marker has been reached.
+ ``True`` if the end-of-stream marker has been reached.
.. versionadded:: 3.3
diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst
--- a/Doc/library/ctypes.rst
+++ b/Doc/library/ctypes.rst
@@ -2242,7 +2242,7 @@
.. class:: c_bool
Represent the C :c:type:`bool` datatype (more accurately, :c:type:`_Bool` from
- C99). Its value can be True or False, and the constructor accepts any object
+ C99). Its value can be ``True`` or ``False``, and the constructor accepts any object
that has a truth value.
diff --git a/Doc/library/difflib.rst b/Doc/library/difflib.rst
--- a/Doc/library/difflib.rst
+++ b/Doc/library/difflib.rst
@@ -359,7 +359,7 @@
The *autojunk* parameter.
SequenceMatcher objects get three data attributes: *bjunk* is the
- set of elements of *b* for which *isjunk* is True; *bpopular* is the set of
+ set of elements of *b* for which *isjunk* is ``True``; *bpopular* is the set of
non-junk elements considered popular by the heuristic (if it is not
disabled); *b2j* is a dict mapping the remaining elements of *b* to a list
of positions where they occur. All three are reset whenever *b* is reset
diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst
--- a/Doc/library/dis.rst
+++ b/Doc/library/dis.rst
@@ -274,7 +274,7 @@
.. data:: is_jump_target
- True if other code jumps to here, otherwise False
+ ``True`` if other code jumps to here, otherwise ``False``
.. versionadded:: 3.4
diff --git a/Doc/library/email.message.rst b/Doc/library/email.message.rst
--- a/Doc/library/email.message.rst
+++ b/Doc/library/email.message.rst
@@ -131,7 +131,7 @@
Return ``True`` if the message's payload is a list of sub-\
:class:`Message` objects, otherwise return ``False``. When
- :meth:`is_multipart` returns False, the payload should be a string object.
+ :meth:`is_multipart` returns ``False``, the payload should be a string object.
.. method:: set_unixfrom(unixfrom)
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -48,7 +48,7 @@
.. function:: all(iterable)
- Return True if all elements of the *iterable* are true (or if the iterable
+ Return ``True`` if all elements of the *iterable* are true (or if the iterable
is empty). Equivalent to::
def all(iterable):
@@ -60,8 +60,8 @@
.. function:: any(iterable)
- Return True if any element of the *iterable* is true. If the iterable
- is empty, return False. Equivalent to::
+ Return ``True`` if any element of the *iterable* is true. If the iterable
+ is empty, return ``False``. Equivalent to::
def any(iterable):
for element in iterable:
@@ -905,7 +905,7 @@
the buffer will typically be 4096 or 8192 bytes long.
* "Interactive" text files (files for which :meth:`~io.IOBase.isatty`
- returns True) use line buffering. Other text files use the policy
+ returns ``True``) use line buffering. Other text files use the policy
described above for binary files.
*encoding* is the name of the encoding used to decode or encode the file.
diff --git a/Doc/library/gc.rst b/Doc/library/gc.rst
--- a/Doc/library/gc.rst
+++ b/Doc/library/gc.rst
@@ -148,8 +148,8 @@
.. function:: is_tracked(obj)
- Returns True if the object is currently tracked by the garbage collector,
- False otherwise. As a general rule, instances of atomic types aren't
+ Returns ``True`` if the object is currently tracked by the garbage collector,
+ ``False`` otherwise. As a general rule, instances of atomic types aren't
tracked and instances of non-atomic types (containers, user-defined
objects...) are. However, some type-specific optimizations can be present
in order to suppress the garbage collector footprint of simple instances
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
@@ -573,7 +573,7 @@
.. attribute:: HTTPResponse.closed
- Is True if the stream is closed.
+ Is ``True`` if the stream is closed.
Examples
--------
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
@@ -90,7 +90,7 @@
Netscape and RFC 2965 cookies. By default, RFC 2109 cookies (ie. cookies
received in a :mailheader:`Set-Cookie` header with a version cookie-attribute of
1) are treated according to the RFC 2965 rules. However, if RFC 2965 handling
- is turned off or :attr:`rfc2109_as_netscape` is True, RFC 2109 cookies are
+ is turned off or :attr:`rfc2109_as_netscape` is ``True``, RFC 2109 cookies are
'downgraded' by the :class:`CookieJar` instance to Netscape cookies, by
setting the :attr:`version` attribute of the :class:`Cookie` instance to 0.
:class:`DefaultCookiePolicy` also provides some parameters to allow some
@@ -644,7 +644,7 @@
.. attribute:: Cookie.secure
- True if cookie should only be returned over a secure connection.
+ ``True`` if cookie should only be returned over a secure connection.
.. attribute:: Cookie.expires
@@ -655,7 +655,7 @@
.. attribute:: Cookie.discard
- True if this is a session cookie.
+ ``True`` if this is a session cookie.
.. attribute:: Cookie.comment
@@ -672,7 +672,7 @@
.. attribute:: Cookie.rfc2109
- True if this cookie was received as an RFC 2109 cookie (ie. the cookie
+ ``True`` if this cookie was received as an RFC 2109 cookie (ie. the cookie
arrived in a :mailheader:`Set-Cookie` header, and the value of the Version
cookie-attribute in that header was 1). This attribute is provided because
:mod:`http.cookiejar` may 'downgrade' RFC 2109 cookies to Netscape cookies, in
@@ -681,18 +681,18 @@
.. attribute:: Cookie.port_specified
- True if a port or set of ports was explicitly specified by the server (in the
+ ``True`` if a port or set of ports was explicitly specified by the server (in the
:mailheader:`Set-Cookie` / :mailheader:`Set-Cookie2` header).
.. attribute:: Cookie.domain_specified
- True if a domain was explicitly specified by the server.
+ ``True`` if a domain was explicitly specified by the server.
.. attribute:: Cookie.domain_initial_dot
- True if the domain explicitly specified by the server began with a dot
+ ``True`` if the domain explicitly specified by the server began with a dot
(``'.'``).
Cookies may have additional non-standard cookie-attributes. These may be
@@ -719,7 +719,7 @@
.. method:: Cookie.is_expired(now=None)
- True if cookie has passed the time at which the server requested it should
+ ``True`` if cookie has passed the time at which the server requested it should
expire. If *now* is given (in seconds since the epoch), return whether the
cookie has expired at the specified time.
diff --git a/Doc/library/imp.rst b/Doc/library/imp.rst
--- a/Doc/library/imp.rst
+++ b/Doc/library/imp.rst
@@ -200,8 +200,8 @@
The ``cpython-32`` string comes from the current magic tag (see
:func:`get_tag`; if :attr:`sys.implementation.cache_tag` is not defined then
:exc:`NotImplementedError` will be raised). The returned path will end in
- ``.pyc`` when ``__debug__`` is True or ``.pyo`` for an optimized Python
- (i.e. ``__debug__`` is False). By passing in True or False for
+ ``.pyc`` when ``__debug__`` is ``True`` or ``.pyo`` for an optimized Python
+ (i.e. ``__debug__`` is ``False``). By passing in ``True`` or ``False`` for
*debug_override* you can override the system's value for ``__debug__`` for
extension selection.
diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst
--- a/Doc/library/importlib.rst
+++ b/Doc/library/importlib.rst
@@ -928,8 +928,8 @@
The ``cpython-32`` string comes from the current magic tag (see
:func:`get_tag`; if :attr:`sys.implementation.cache_tag` is not defined then
:exc:`NotImplementedError` will be raised). The returned path will end in
- ``.pyc`` when ``__debug__`` is True or ``.pyo`` for an optimized Python
- (i.e. ``__debug__`` is False). By passing in True or False for
+ ``.pyc`` when ``__debug__`` is ``True`` or ``.pyo`` for an optimized Python
+ (i.e. ``__debug__`` is ``False``). By passing in ``True`` or ``False`` for
*debug_override* you can override the system's value for ``__debug__`` for
extension selection.
diff --git a/Doc/library/io.rst b/Doc/library/io.rst
--- a/Doc/library/io.rst
+++ b/Doc/library/io.rst
@@ -280,7 +280,7 @@
.. method:: readable()
- Return ``True`` if the stream can be read from. If False, :meth:`read`
+ Return ``True`` if the stream can be read from. If ``False``, :meth:`read`
will raise :exc:`OSError`.
.. method:: readline(size=-1)
diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst
--- a/Doc/library/itertools.rst
+++ b/Doc/library/itertools.rst
@@ -51,7 +51,7 @@
chain.from_iterable iterable p0, p1, ... plast, q0, q1, ... ``chain.from_iterable(['ABC', 'DEF']) --> A B C D E F``
:func:`compress` data, selectors (d[0] if s[0]), (d[1] if s[1]), ... ``compress('ABCDEF', [1,0,1,0,1,1]) --> A C E F``
:func:`dropwhile` pred, seq seq[n], seq[n+1], starting when pred fails ``dropwhile(lambda x: x<5, [1,4,6,4,1]) --> 6 4 1``
-:func:`filterfalse` pred, seq elements of seq where pred(elem) is False ``filterfalse(lambda x: x%2, range(10)) --> 0 2 4 6 8``
+:func:`filterfalse` pred, seq elements of seq where pred(elem) is false ``filterfalse(lambda x: x%2, range(10)) --> 0 2 4 6 8``
:func:`groupby` iterable[, keyfunc] sub-iterators grouped by value of keyfunc(v)
:func:`islice` seq, [start,] stop [, step] elements from seq[start:stop:step] ``islice('ABCDEFG', 2, None) --> C D E F G``
:func:`starmap` func, seq func(\*seq[0]), func(\*seq[1]), ... ``starmap(pow, [(2,5), (3,2), (10,3)]) --> 32 9 1000``
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
@@ -843,7 +843,7 @@
Returns a new instance of the :class:`HTTPHandler` class. The *host* can be
of the form ``host:port``, should you need to use a specific port number.
- If no *method* is specified, ``GET`` is used. If *secure* is True, an HTTPS
+ If no *method* is specified, ``GET`` is used. If *secure* is true, an HTTPS
connection will be used. If *credentials* is specified, it should be a
2-tuple consisting of userid and password, which will be placed in an HTTP
'Authorization' header using Basic authentication. If you specify
diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst
--- a/Doc/library/logging.rst
+++ b/Doc/library/logging.rst
@@ -160,7 +160,7 @@
is called to get the exception information.
The second optional keyword argument is *stack_info*, which defaults to
- False. If specified as True, stack information is added to the logging
+ ``False``. If true, stack information is added to the logging
message, including the actual logging call. Note that this is not the same
stack information as that displayed through specifying *exc_info*: The
former is stack frames from the bottom of the stack up to the logging call
@@ -308,7 +308,7 @@
Checks to see if this logger has any handlers configured. This is done by
looking for handlers in this logger and its parents in the logger hierarchy.
- Returns True if a handler was found, else False. The method stops searching
+ Returns ``True`` if a handler was found, else ``False``. The method stops searching
up the hierarchy whenever a logger with the 'propagate' attribute set to
False is found - that will be the last logger which is checked for the
existence of handlers.
@@ -878,7 +878,7 @@
is called to get the exception information.
The second optional keyword argument is *stack_info*, which defaults to
- False. If specified as True, stack information is added to the logging
+ ``False``. If true, stack information is added to the logging
message, including the actual logging call. Note that this is not the same
stack information as that displayed through specifying *exc_info*: The
former is stack frames from the bottom of the stack up to the logging call
diff --git a/Doc/library/lzma.rst b/Doc/library/lzma.rst
--- a/Doc/library/lzma.rst
+++ b/Doc/library/lzma.rst
@@ -232,7 +232,7 @@
.. attribute:: eof
- True if the end-of-stream marker has been reached.
+ ``True`` if the end-of-stream marker has been reached.
.. attribute:: unused_data
diff --git a/Doc/library/mmap.rst b/Doc/library/mmap.rst
--- a/Doc/library/mmap.rst
+++ b/Doc/library/mmap.rst
@@ -162,7 +162,7 @@
.. attribute:: closed
- True if the file is closed.
+ ``True`` if the file is closed.
.. versionadded:: 3.2
diff --git a/Doc/library/nntplib.rst b/Doc/library/nntplib.rst
--- a/Doc/library/nntplib.rst
+++ b/Doc/library/nntplib.rst
@@ -82,7 +82,7 @@
.. versionchanged:: 3.2
- *usenetrc* is now False by default.
+ *usenetrc* is now ``False`` by default.
.. versionchanged:: 3.3
Support for the :keyword:`with` statement was added.
@@ -216,7 +216,7 @@
.. method:: NNTP.login(user=None, password=None, usenetrc=True)
Send ``AUTHINFO`` commands with the user name and password. If *user*
- and *password* are None and *usenetrc* is True, credentials from
+ and *password* are None and *usenetrc* is true, credentials from
``~/.netrc`` will be used if possible.
Unless intentionally delayed, login is normally performed during the
diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst
--- a/Doc/library/os.path.rst
+++ b/Doc/library/os.path.rst
@@ -137,7 +137,7 @@
the number of seconds since the epoch (see the :mod:`time` module). Raise
:exc:`OSError` if the file does not exist or is inaccessible.
- If :func:`os.stat_float_times` returns True, the result is a floating point
+ If :func:`os.stat_float_times` returns ``True``, the result is a floating point
number.
@@ -147,7 +147,7 @@
giving the number of seconds since the epoch (see the :mod:`time` module).
Raise :exc:`OSError` if the file does not exist or is inaccessible.
- If :func:`os.stat_float_times` returns True, the result is a floating point
+ If :func:`os.stat_float_times` returns ``True``, the result is a floating point
number.
@@ -340,5 +340,5 @@
.. data:: supports_unicode_filenames
- True if arbitrary Unicode strings can be used as file names (within limitations
+ ``True`` if arbitrary Unicode strings can be used as file names (within limitations
imposed by the file system).
diff --git a/Doc/library/os.rst b/Doc/library/os.rst
--- a/Doc/library/os.rst
+++ b/Doc/library/os.rst
@@ -551,7 +551,7 @@
.. data:: supports_bytes_environ
- True if the native OS type of the environment is bytes (eg. False on
+ ``True`` if the native OS type of the environment is bytes (eg. ``False`` on
Windows).
.. versionadded:: 3.2
diff --git a/Doc/library/pickle.rst b/Doc/library/pickle.rst
--- a/Doc/library/pickle.rst
+++ b/Doc/library/pickle.rst
@@ -161,7 +161,7 @@
:class:`io.BytesIO` instance, or any other custom object that meets this
interface.
- If *fix_imports* is True and *protocol* is less than 3, pickle will try to
+ If *fix_imports* is true and *protocol* is less than 3, pickle will try to
map the new Python 3.x names to the old module names used in Python 2.x,
so that the pickle data stream is readable with Python 2.x.
@@ -178,7 +178,7 @@
supported. The higher the protocol used, the more recent the version of
Python needed to read the pickle produced.
- If *fix_imports* is True and *protocol* is less than 3, pickle will try to
+ If *fix_imports* is true and *protocol* is less than 3, pickle will try to
map the new Python 3.x names to the old module names used in Python 2.x,
so that the pickle data stream is readable with Python 2.x.
@@ -200,7 +200,7 @@
Optional keyword arguments are *fix_imports*, *encoding* and *errors*,
which are used to control compatibility support for pickle stream generated
- by Python 2.x. If *fix_imports* is True, pickle will try to map the old
+ by Python 2.x. If *fix_imports* is true, pickle will try to map the old
Python 2.x names to the new names used in Python 3.x. The *encoding* and
*errors* tell pickle how to decode 8-bit string instances pickled by Python
2.x; these default to 'ASCII' and 'strict', respectively.
@@ -216,7 +216,7 @@
Optional keyword arguments are *fix_imports*, *encoding* and *errors*,
which are used to control compatibility support for pickle stream generated
- by Python 2.x. If *fix_imports* is True, pickle will try to map the old
+ by Python 2.x. If *fix_imports* is true, pickle will try to map the old
Python 2.x names to the new names used in Python 3.x. The *encoding* and
*errors* tell pickle how to decode 8-bit string instances pickled by Python
2.x; these default to 'ASCII' and 'strict', respectively.
@@ -266,7 +266,7 @@
argument. It can thus be an on-disk file opened for binary writing, a
:class:`io.BytesIO` instance, or any other custom object that meets this interface.
- If *fix_imports* is True and *protocol* is less than 3, pickle will try to
+ If *fix_imports* is true and *protocol* is less than 3, pickle will try to
map the new Python 3.x names to the old module names used in Python 2.x,
so that the pickle data stream is readable with Python 2.x.
@@ -336,7 +336,7 @@
Optional keyword arguments are *fix_imports*, *encoding* and *errors*,
which are used to control compatibility support for pickle stream generated
- by Python 2.x. If *fix_imports* is True, pickle will try to map the old
+ by Python 2.x. If *fix_imports* is true, pickle will try to map the old
Python 2.x names to the new names used in Python 3.x. The *encoding* and
*errors* tell pickle how to decode 8-bit string instances pickled by Python
2.x; these default to 'ASCII' and 'strict', respectively.
diff --git a/Doc/library/plistlib.rst b/Doc/library/plistlib.rst
--- a/Doc/library/plistlib.rst
+++ b/Doc/library/plistlib.rst
@@ -54,7 +54,7 @@
* :data:`FMT_BINARY`: Binary plist format
- If *use_builtin_types* is True (the default) binary data will be returned
+ If *use_builtin_types* is true (the default) binary data will be returned
as instances of :class:`bytes`, otherwise it is returned as instances of
:class:`Data`.
diff --git a/Doc/library/sched.rst b/Doc/library/sched.rst
--- a/Doc/library/sched.rst
+++ b/Doc/library/sched.rst
@@ -113,7 +113,7 @@
function passed to the constructor) for the next event, then execute it and so
on until there are no more scheduled events.
- If *blocking* is False executes the scheduled events due to expire soonest
+ If *blocking* is false executes the scheduled events due to expire soonest
(if any) and then return the deadline of the next scheduled call in the
scheduler (if any).
diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst
--- a/Doc/library/sqlite3.rst
+++ b/Doc/library/sqlite3.rst
@@ -241,10 +241,10 @@
.. function:: enable_callback_tracebacks(flag)
By default you will not get any tracebacks in user-defined functions,
- aggregates, converters, authorizer callbacks etc. If you want to debug them, you
- can call this function with *flag* as True. Afterwards, you will get tracebacks
- from callbacks on ``sys.stderr``. Use :const:`False` to disable the feature
- again.
+ aggregates, converters, authorizer callbacks etc. If you want to debug them,
+ you can call this function with *flag* set to ``True``. Afterwards, you will
+ get tracebacks from callbacks on ``sys.stderr``. Use :const:`False` to
+ disable the feature again.
.. _sqlite3-connection-objects:
diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst
--- a/Doc/library/ssl.rst
+++ b/Doc/library/ssl.rst
@@ -287,7 +287,7 @@
.. function:: RAND_pseudo_bytes(num)
Returns (bytes, is_cryptographic): bytes are *num* pseudo-random bytes,
- is_cryptographic is True if the bytes generated are cryptographically
+ is_cryptographic is ``True`` if the bytes generated are cryptographically
strong. Raises an :class:`SSLError` if the operation is not supported by the
current RAND method.
@@ -300,8 +300,8 @@
.. function:: RAND_status()
- Returns True if the SSL pseudo-random number generator has been seeded with
- 'enough' randomness, and False otherwise. You can use :func:`ssl.RAND_egd`
+ Returns ``True`` if the SSL pseudo-random number generator has been seeded with
+ 'enough' randomness, and ``False`` otherwise. You can use :func:`ssl.RAND_egd`
and :func:`ssl.RAND_add` to increase the randomness of the pseudo-random
number generator.
@@ -1173,7 +1173,7 @@
.. method:: SSLContext.get_ca_certs(binary_form=False)
Returns a list of dicts with information of loaded CA certs. If the
- optional argument is True, returns a DER-encoded copy of the CA
+ optional argument is true, returns a DER-encoded copy of the CA
certificate.
.. note::
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -2851,7 +2851,7 @@
.. method:: isdisjoint(other)
- Return True if the set has no elements in common with *other*. Sets are
+ Return ``True`` if the set has no elements in common with *other*. Sets are
disjoint if and only if their intersection is the empty set.
.. method:: issubset(other)
diff --git a/Doc/library/struct.rst b/Doc/library/struct.rst
--- a/Doc/library/struct.rst
+++ b/Doc/library/struct.rst
@@ -295,7 +295,7 @@
For the ``'?'`` format character, the return value is either :const:`True` or
:const:`False`. When packing, the truth value of the argument object is used.
Either 0 or 1 in the native or standard bool representation will be packed, and
-any non-zero value will be True when unpacking.
+any non-zero value will be ``True`` when unpacking.
diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst
--- a/Doc/library/subprocess.rst
+++ b/Doc/library/subprocess.rst
@@ -522,7 +522,7 @@
*executable* (or for the first item in *args*) relative to *cwd* if the
executable path is a relative path.
- If *restore_signals* is True (the default) all signals that Python has set to
+ If *restore_signals* is true (the default) all signals that Python has set to
SIG_IGN are restored to SIG_DFL in the child process before the exec.
Currently this includes the SIGPIPE, SIGXFZ and SIGXFSZ signals.
(Unix only)
@@ -530,7 +530,7 @@
.. versionchanged:: 3.2
*restore_signals* was added.
- If *start_new_session* is True the setsid() system call will be made in the
+ If *start_new_session* is true the setsid() system call will be made in the
child process prior to the execution of the subprocess. (Unix only)
.. versionchanged:: 3.2
diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst
--- a/Doc/library/sys.rst
+++ b/Doc/library/sys.rst
@@ -1067,7 +1067,7 @@
:func:`open` function. Their parameters are chosen as follows:
* The character encoding is platform-dependent. Under Windows, if the stream
- is interactive (that is, if its :meth:`isatty` method returns True), the
+ is interactive (that is, if its :meth:`isatty` method returns ``True``), the
console codepage is used, otherwise the ANSI code page. Under other
platforms, the locale encoding is used (see :meth:`locale.getpreferredencoding`).
diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst
--- a/Doc/library/tarfile.rst
+++ b/Doc/library/tarfile.rst
@@ -359,7 +359,7 @@
full name. Its file information is extracted as accurately as possible. *member*
may be a filename or a :class:`TarInfo` object. You can specify a different
directory using *path*. File attributes (owner, mtime, mode) are set unless
- *set_attrs* is False.
+ *set_attrs* is false.
.. note::
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
@@ -272,8 +272,8 @@
.. method:: instate(statespec, callback=None, *args, **kw)
- Test the widget's state. If a callback is not specified, returns True
- if the widget state matches *statespec* and False otherwise. If callback
+ Test the widget's state. If a callback is not specified, returns ``True``
+ if the widget state matches *statespec* and ``False`` otherwise. If callback
is specified then it is called with args if widget state matches
*statespec*.
@@ -938,7 +938,7 @@
.. method:: exists(item)
- Returns True if the specified *item* is present in the tree.
+ Returns ``True`` if the specified *item* is present in the tree.
.. method:: focus(item=None)
@@ -1084,7 +1084,7 @@
Ensure that *item* is visible.
- Sets all of *item*'s ancestors open option to True, and scrolls the
+ Sets all of *item*'s ancestors open option to ``True``, and scrolls the
widget if necessary so that *item* is within the visible portion of
the tree.
diff --git a/Doc/library/turtle.rst b/Doc/library/turtle.rst
--- a/Doc/library/turtle.rst
+++ b/Doc/library/turtle.rst
@@ -1055,8 +1055,8 @@
Write text - the string representation of *arg* - at the current turtle
position according to *align* ("left", "center" or right") and with the given
- font. If *move* is True, the pen is moved to the bottom-right corner of the
- text. By default, *move* is False.
+ font. If *move* is true, the pen is moved to the bottom-right corner of the
+ text. By default, *move* is ``False``.
>>> turtle.write("Home = ", True, align="center")
>>> turtle.write((0,0), True)
@@ -1092,7 +1092,7 @@
.. function:: isvisible()
- Return True if the Turtle is shown, False if it's hidden.
+ Return ``True`` if the Turtle is shown, ``False`` if it's hidden.
>>> turtle.hideturtle()
>>> turtle.isvisible()
diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst
--- a/Doc/library/unittest.mock.rst
+++ b/Doc/library/unittest.mock.rst
@@ -298,11 +298,11 @@
assert the mock has been called with the specified calls.
The `mock_calls` list is checked for the calls.
- If `any_order` is False (the default) then the calls must be
+ If `any_order` is false (the default) then the calls must be
sequential. There can be extra calls before or after the
specified calls.
- If `any_order` is True then the calls can be in any order, but
+ If `any_order` is true then the calls can be in any order, but
they must all appear in :attr:`mock_calls`.
>>> mock = Mock(return_value=None)
@@ -1200,7 +1200,7 @@
`values` can be a dictionary of values to set in the dictionary. `values`
can also be an iterable of `(key, value)` pairs.
- If `clear` is True then the dictionary will be cleared before the new
+ If `clear` is true then the dictionary will be cleared before the new
values are set.
`patch.dict` can also be called with arbitrary keyword arguments to set
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
@@ -59,7 +59,7 @@
some non-Windows platforms.
.. warning::
- If neither *cafile* nor *capath* is specified, and *cadefault* is False,
+ If neither *cafile* nor *capath* is specified, and *cadefault* is ``False``,
an HTTPS request will not do any verification of the server's
certificate.
@@ -211,7 +211,7 @@
containing the image.
*unverifiable* should indicate whether the request is unverifiable,
- as defined by RFC 2965. It defaults to False. An unverifiable
+ as defined by RFC 2965. It defaults to ``False``. An unverifiable
request is one whose URL the user did not have the option to
approve. For example, if the request is for an image in an HTML
document, and the user had no option to approve the automatic
diff --git a/Doc/library/venv.rst b/Doc/library/venv.rst
--- a/Doc/library/venv.rst
+++ b/Doc/library/venv.rst
@@ -94,7 +94,7 @@
* ``system_site_packages`` -- a Boolean value indicating that the system Python
site-packages should be available to the environment (defaults to ``False``).
- * ``clear`` -- a Boolean value which, if True, will delete the contents of
+ * ``clear`` -- a Boolean value which, if true, will delete the contents of
any existing target directory, before creating the environment.
* ``symlinks`` -- a Boolean value indicating whether to attempt to symlink the
@@ -102,11 +102,11 @@
e.g. ``pythonw.exe``), rather than copying. Defaults to ``True`` on Linux and
Unix systems, but ``False`` on Windows.
- * ``upgrade`` -- a Boolean value which, if True, will upgrade an existing
+ * ``upgrade`` -- a Boolean value which, if true, will upgrade an existing
environment with the running Python - for use when that Python has been
upgraded in-place (defaults to ``False``).
- * ``with_pip`` -- a Boolean value which, if True, ensures pip is
+ * ``with_pip`` -- a Boolean value which, if true, ensures pip is
installed in the virtual environment
.. versionchanged:: 3.4
diff --git a/Doc/library/zipfile.rst b/Doc/library/zipfile.rst
--- a/Doc/library/zipfile.rst
+++ b/Doc/library/zipfile.rst
@@ -411,7 +411,7 @@
name as a file path, and if any subdirectories are package directories,
all of these are added recursively. *basename* is intended for internal
use only. When *filterfunc(pathname)* is given, it will be called for every
- invocation. When it returns a False value, that path and its subpaths will
+ invocation. When it returns a false value, that path and its subpaths will
be ignored.
The :meth:`writepy` method makes archives with file names like
this::
diff --git a/Doc/library/zipimport.rst b/Doc/library/zipimport.rst
--- a/Doc/library/zipimport.rst
+++ b/Doc/library/zipimport.rst
@@ -111,7 +111,7 @@
.. method:: is_package(fullname)
- Return True if the module specified by *fullname* is a package. Raise
+ Return ``True`` if the module specified by *fullname* is a package. Raise
:exc:`ZipImportError` if the module couldn't be found.
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -201,7 +201,7 @@
single: True
These represent the truth values False and True. The two objects representing
- the values False and True are the only Boolean objects. The Boolean type is a
+ the values ``False`` and ``True`` are the only Boolean objects. The Boolean type is a
subtype of the integer type, and Boolean values behave like the values 0 and 1,
respectively, in almost all contexts, the exception being that when converted to
a string, the strings ``"False"`` or ``"True"`` are returned, respectively.
diff --git a/Doc/whatsnew/3.3.rst b/Doc/whatsnew/3.3.rst
--- a/Doc/whatsnew/3.3.rst
+++ b/Doc/whatsnew/3.3.rst
@@ -1125,7 +1125,7 @@
* If Python is compiled without threads, the C version automatically
disables the expensive thread local context machinery. In this case,
- the variable :data:`~decimal.HAVE_THREADS` is set to False.
+ the variable :data:`~decimal.HAVE_THREADS` is set to ``False``.
API changes
~~~~~~~~~~~
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -45,6 +45,12 @@
pythoncore sub-project. This should prevent build errors due a previous
build's python(_d).exe still running.
+Documentation
+-------------
+
+- Issue #19795: Improved markup of True/False constants.
+
+
What's New in Python 3.4.0 Beta 1?
==================================
--
Repository URL: http://hg.python.org/cpython
1
0
cpython (3.3): Issue #19795: Improved markup of True/False constants.
by serhiy.storchaka 29 Nov '13
by serhiy.storchaka 29 Nov '13
29 Nov '13
http://hg.python.org/cpython/rev/b2066bc8cab9
changeset: 87634:b2066bc8cab9
branch: 3.3
parent: 87626:712ebde527c2
user: Serhiy Storchaka <storchaka(a)gmail.com>
date: Fri Nov 29 12:17:13 2013 +0200
summary:
Issue #19795: Improved markup of True/False constants.
files:
Doc/howto/curses.rst | 2 +-
Doc/howto/functional.rst | 4 ++--
Doc/library/ast.rst | 2 +-
Doc/library/bdb.rst | 8 ++++----
Doc/library/bz2.rst | 2 +-
Doc/library/ctypes.rst | 2 +-
Doc/library/difflib.rst | 2 +-
Doc/library/email.message.rst | 2 +-
Doc/library/functions.rst | 8 ++++----
Doc/library/gc.rst | 4 ++--
Doc/library/http.client.rst | 2 +-
Doc/library/http.cookiejar.rst | 16 ++++++++--------
Doc/library/imp.rst | 4 ++--
Doc/library/importlib.rst | 10 ++++++++++
Doc/library/io.rst | 2 +-
Doc/library/itertools.rst | 2 +-
Doc/library/logging.handlers.rst | 2 +-
Doc/library/logging.rst | 6 +++---
Doc/library/lzma.rst | 2 +-
Doc/library/mmap.rst | 2 +-
Doc/library/nntplib.rst | 4 ++--
Doc/library/os.path.rst | 6 +++---
Doc/library/os.rst | 2 +-
Doc/library/pickle.rst | 12 ++++++------
Doc/library/sched.rst | 2 +-
Doc/library/sqlite3.rst | 8 ++++----
Doc/library/ssl.rst | 6 +++---
Doc/library/stdtypes.rst | 2 +-
Doc/library/struct.rst | 2 +-
Doc/library/subprocess.rst | 4 ++--
Doc/library/sys.rst | 2 +-
Doc/library/tarfile.rst | 2 +-
Doc/library/tkinter.ttk.rst | 8 ++++----
Doc/library/turtle.rst | 6 +++---
Doc/library/unittest.mock.rst | 6 +++---
Doc/library/urllib.request.rst | 4 ++--
Doc/library/venv.rst | 4 ++--
Doc/library/zipimport.rst | 2 +-
Doc/reference/datamodel.rst | 2 +-
Doc/whatsnew/3.3.rst | 2 +-
Misc/NEWS | 2 ++
41 files changed, 92 insertions(+), 80 deletions(-)
diff --git a/Doc/howto/curses.rst b/Doc/howto/curses.rst
--- a/Doc/howto/curses.rst
+++ b/Doc/howto/curses.rst
@@ -422,7 +422,7 @@
blue or any other color you like. Unfortunately, the Linux console doesn't
support this, so I'm unable to try it out, and can't provide any examples. You
can check if your terminal can do this by calling
-:func:`~curses.can_change_color`, which returns True if the capability is
+:func:`~curses.can_change_color`, which returns ``True`` if the capability is
there. If you're lucky enough to have such a talented terminal, consult your
system's man pages for more information.
diff --git a/Doc/howto/functional.rst b/Doc/howto/functional.rst
--- a/Doc/howto/functional.rst
+++ b/Doc/howto/functional.rst
@@ -687,8 +687,8 @@
The :func:`any(iter) <any>` and :func:`all(iter) <all>` built-ins look at the
-truth values of an iterable's contents. :func:`any` returns True if any element
-in the iterable is a true value, and :func:`all` returns True if all of the
+truth values of an iterable's contents. :func:`any` returns ``True`` if any element
+in the iterable is a true value, and :func:`all` returns ``True`` if all of the
elements are true values:
>>> any([0,1,0])
diff --git a/Doc/library/ast.rst b/Doc/library/ast.rst
--- a/Doc/library/ast.rst
+++ b/Doc/library/ast.rst
@@ -244,6 +244,6 @@
Return a formatted dump of the tree in *node*. This is mainly useful for
debugging purposes. The returned string will show the names and the values
for fields. This makes the code impossible to evaluate, so if evaluation is
- wanted *annotate_fields* must be set to False. Attributes such as line
+ wanted *annotate_fields* must be set to ``False``. Attributes such as line
numbers and column offsets are not dumped by default. If this is wanted,
*include_attributes* can be set to ``True``.
diff --git a/Doc/library/bdb.rst b/Doc/library/bdb.rst
--- a/Doc/library/bdb.rst
+++ b/Doc/library/bdb.rst
@@ -194,17 +194,17 @@
.. method:: user_line(frame)
This method is called from :meth:`dispatch_line` when either
- :meth:`stop_here` or :meth:`break_here` yields True.
+ :meth:`stop_here` or :meth:`break_here` yields ``True``.
.. method:: user_return(frame, return_value)
This method is called from :meth:`dispatch_return` when :meth:`stop_here`
- yields True.
+ yields ``True``.
.. method:: user_exception(frame, exc_info)
This method is called from :meth:`dispatch_exception` when
- :meth:`stop_here` yields True.
+ :meth:`stop_here` yields ``True``.
.. method:: do_clear(arg)
@@ -245,7 +245,7 @@
.. method:: set_quit()
- Set the :attr:`quitting` attribute to True. This raises :exc:`BdbQuit` in
+ Set the :attr:`quitting` attribute to ``True``. This raises :exc:`BdbQuit` in
the next call to one of the :meth:`dispatch_\*` methods.
diff --git a/Doc/library/bz2.rst b/Doc/library/bz2.rst
--- a/Doc/library/bz2.rst
+++ b/Doc/library/bz2.rst
@@ -162,7 +162,7 @@
.. attribute:: eof
- True if the end-of-stream marker has been reached.
+ ``True`` if the end-of-stream marker has been reached.
.. versionadded:: 3.3
diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst
--- a/Doc/library/ctypes.rst
+++ b/Doc/library/ctypes.rst
@@ -2242,7 +2242,7 @@
.. class:: c_bool
Represent the C :c:type:`bool` datatype (more accurately, :c:type:`_Bool` from
- C99). Its value can be True or False, and the constructor accepts any object
+ C99). Its value can be ``True`` or ``False``, and the constructor accepts any object
that has a truth value.
diff --git a/Doc/library/difflib.rst b/Doc/library/difflib.rst
--- a/Doc/library/difflib.rst
+++ b/Doc/library/difflib.rst
@@ -359,7 +359,7 @@
The *autojunk* parameter.
SequenceMatcher objects get three data attributes: *bjunk* is the
- set of elements of *b* for which *isjunk* is True; *bpopular* is the set of
+ set of elements of *b* for which *isjunk* is ``True``; *bpopular* is the set of
non-junk elements considered popular by the heuristic (if it is not
disabled); *b2j* is a dict mapping the remaining elements of *b* to a list
of positions where they occur. All three are reset whenever *b* is reset
diff --git a/Doc/library/email.message.rst b/Doc/library/email.message.rst
--- a/Doc/library/email.message.rst
+++ b/Doc/library/email.message.rst
@@ -75,7 +75,7 @@
Return ``True`` if the message's payload is a list of sub-\
:class:`Message` objects, otherwise return ``False``. When
- :meth:`is_multipart` returns False, the payload should be a string object.
+ :meth:`is_multipart` returns ``False``, the payload should be a string object.
.. method:: set_unixfrom(unixfrom)
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -48,7 +48,7 @@
.. function:: all(iterable)
- Return True if all elements of the *iterable* are true (or if the iterable
+ Return ``True`` if all elements of the *iterable* are true (or if the iterable
is empty). Equivalent to::
def all(iterable):
@@ -60,8 +60,8 @@
.. function:: any(iterable)
- Return True if any element of the *iterable* is true. If the iterable
- is empty, return False. Equivalent to::
+ Return ``True`` if any element of the *iterable* is true. If the iterable
+ is empty, return ``False``. Equivalent to::
def any(iterable):
for element in iterable:
@@ -890,7 +890,7 @@
the buffer will typically be 4096 or 8192 bytes long.
* "Interactive" text files (files for which :meth:`~io.IOBase.isatty`
- returns True) use line buffering. Other text files use the policy
+ returns ``True``) use line buffering. Other text files use the policy
described above for binary files.
*encoding* is the name of the encoding used to decode or encode the file.
diff --git a/Doc/library/gc.rst b/Doc/library/gc.rst
--- a/Doc/library/gc.rst
+++ b/Doc/library/gc.rst
@@ -130,8 +130,8 @@
.. function:: is_tracked(obj)
- Returns True if the object is currently tracked by the garbage collector,
- False otherwise. As a general rule, instances of atomic types aren't
+ Returns ``True`` if the object is currently tracked by the garbage collector,
+ ``False`` otherwise. As a general rule, instances of atomic types aren't
tracked and instances of non-atomic types (containers, user-defined
objects...) are. However, some type-specific optimizations can be present
in order to suppress the garbage collector footprint of simple instances
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
@@ -573,7 +573,7 @@
.. attribute:: HTTPResponse.closed
- Is True if the stream is closed.
+ Is ``True`` if the stream is closed.
Examples
--------
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
@@ -90,7 +90,7 @@
Netscape and RFC 2965 cookies. By default, RFC 2109 cookies (ie. cookies
received in a :mailheader:`Set-Cookie` header with a version cookie-attribute of
1) are treated according to the RFC 2965 rules. However, if RFC 2965 handling
- is turned off or :attr:`rfc2109_as_netscape` is True, RFC 2109 cookies are
+ is turned off or :attr:`rfc2109_as_netscape` is ``True``, RFC 2109 cookies are
'downgraded' by the :class:`CookieJar` instance to Netscape cookies, by
setting the :attr:`version` attribute of the :class:`Cookie` instance to 0.
:class:`DefaultCookiePolicy` also provides some parameters to allow some
@@ -644,7 +644,7 @@
.. attribute:: Cookie.secure
- True if cookie should only be returned over a secure connection.
+ ``True`` if cookie should only be returned over a secure connection.
.. attribute:: Cookie.expires
@@ -655,7 +655,7 @@
.. attribute:: Cookie.discard
- True if this is a session cookie.
+ ``True`` if this is a session cookie.
.. attribute:: Cookie.comment
@@ -672,7 +672,7 @@
.. attribute:: Cookie.rfc2109
- True if this cookie was received as an RFC 2109 cookie (ie. the cookie
+ ``True`` if this cookie was received as an RFC 2109 cookie (ie. the cookie
arrived in a :mailheader:`Set-Cookie` header, and the value of the Version
cookie-attribute in that header was 1). This attribute is provided because
:mod:`http.cookiejar` may 'downgrade' RFC 2109 cookies to Netscape cookies, in
@@ -681,18 +681,18 @@
.. attribute:: Cookie.port_specified
- True if a port or set of ports was explicitly specified by the server (in the
+ ``True`` if a port or set of ports was explicitly specified by the server (in the
:mailheader:`Set-Cookie` / :mailheader:`Set-Cookie2` header).
.. attribute:: Cookie.domain_specified
- True if a domain was explicitly specified by the server.
+ ``True`` if a domain was explicitly specified by the server.
.. attribute:: Cookie.domain_initial_dot
- True if the domain explicitly specified by the server began with a dot
+ ``True`` if the domain explicitly specified by the server began with a dot
(``'.'``).
Cookies may have additional non-standard cookie-attributes. These may be
@@ -719,7 +719,7 @@
.. method:: Cookie.is_expired(now=None)
- True if cookie has passed the time at which the server requested it should
+ ``True`` if cookie has passed the time at which the server requested it should
expire. If *now* is given (in seconds since the epoch), return whether the
cookie has expired at the specified time.
diff --git a/Doc/library/imp.rst b/Doc/library/imp.rst
--- a/Doc/library/imp.rst
+++ b/Doc/library/imp.rst
@@ -190,8 +190,8 @@
The ``cpython-32`` string comes from the current magic tag (see
:func:`get_tag`; if :attr:`sys.implementation.cache_tag` is not defined then
:exc:`NotImplementedError` will be raised). The returned path will end in
- ``.pyc`` when ``__debug__`` is True or ``.pyo`` for an optimized Python
- (i.e. ``__debug__`` is False). By passing in True or False for
+ ``.pyc`` when ``__debug__`` is ``True`` or ``.pyo`` for an optimized Python
+ (i.e. ``__debug__`` is ``False``). By passing in ``True`` or ``False`` for
*debug_override* you can override the system's value for ``__debug__`` for
extension selection.
diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst
--- a/Doc/library/importlib.rst
+++ b/Doc/library/importlib.rst
@@ -918,8 +918,18 @@
Reliance on this decorator is discouraged when it is possible to set
:attr:`__package__` before importing. By
setting it beforehand the code for the module is executed with the
+<<<<<<<
attribute set and thus can be used by global level code during
initialization.
+=======
+ The ``cpython-32`` string comes from the current magic tag (see
+ :func:`get_tag`; if :attr:`sys.implementation.cache_tag` is not defined then
+ :exc:`NotImplementedError` will be raised). The returned path will end in
+ ``.pyc`` when ``__debug__`` is ``True`` or ``.pyo`` for an optimized Python
+ (i.e. ``__debug__`` is ``False``). By passing in ``True`` or ``False`` for
+ *debug_override* you can override the system's value for ``__debug__`` for
+ extension selection.
+>>>>>>>
.. note::
diff --git a/Doc/library/io.rst b/Doc/library/io.rst
--- a/Doc/library/io.rst
+++ b/Doc/library/io.rst
@@ -280,7 +280,7 @@
.. method:: readable()
- Return ``True`` if the stream can be read from. If False, :meth:`read`
+ Return ``True`` if the stream can be read from. If ``False``, :meth:`read`
will raise :exc:`OSError`.
.. method:: readline(limit=-1)
diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst
--- a/Doc/library/itertools.rst
+++ b/Doc/library/itertools.rst
@@ -51,7 +51,7 @@
chain.from_iterable iterable p0, p1, ... plast, q0, q1, ... ``chain.from_iterable(['ABC', 'DEF']) --> A B C D E F``
:func:`compress` data, selectors (d[0] if s[0]), (d[1] if s[1]), ... ``compress('ABCDEF', [1,0,1,0,1,1]) --> A C E F``
:func:`dropwhile` pred, seq seq[n], seq[n+1], starting when pred fails ``dropwhile(lambda x: x<5, [1,4,6,4,1]) --> 6 4 1``
-:func:`filterfalse` pred, seq elements of seq where pred(elem) is False ``filterfalse(lambda x: x%2, range(10)) --> 0 2 4 6 8``
+:func:`filterfalse` pred, seq elements of seq where pred(elem) is false ``filterfalse(lambda x: x%2, range(10)) --> 0 2 4 6 8``
:func:`groupby` iterable[, keyfunc] sub-iterators grouped by value of keyfunc(v)
:func:`islice` seq, [start,] stop [, step] elements from seq[start:stop:step] ``islice('ABCDEFG', 2, None) --> C D E F G``
:func:`starmap` func, seq func(\*seq[0]), func(\*seq[1]), ... ``starmap(pow, [(2,5), (3,2), (10,3)]) --> 32 9 1000``
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
@@ -831,7 +831,7 @@
Returns a new instance of the :class:`HTTPHandler` class. The *host* can be
of the form ``host:port``, should you need to use a specific port number.
- If no *method* is specified, ``GET`` is used. If *secure* is True, an HTTPS
+ If no *method* is specified, ``GET`` is used. If *secure* is true, an HTTPS
connection will be used. If *credentials* is specified, it should be a
2-tuple consisting of userid and password, which will be placed in an HTTP
'Authorization' header using Basic authentication. If you specify
diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst
--- a/Doc/library/logging.rst
+++ b/Doc/library/logging.rst
@@ -160,7 +160,7 @@
is called to get the exception information.
The second optional keyword argument is *stack_info*, which defaults to
- False. If specified as True, stack information is added to the logging
+ ``False``. If true, stack information is added to the logging
message, including the actual logging call. Note that this is not the same
stack information as that displayed through specifying *exc_info*: The
former is stack frames from the bottom of the stack up to the logging call
@@ -308,7 +308,7 @@
Checks to see if this logger has any handlers configured. This is done by
looking for handlers in this logger and its parents in the logger hierarchy.
- Returns True if a handler was found, else False. The method stops searching
+ Returns ``True`` if a handler was found, else ``False``. The method stops searching
up the hierarchy whenever a logger with the 'propagate' attribute set to
False is found - that will be the last logger which is checked for the
existence of handlers.
@@ -878,7 +878,7 @@
is called to get the exception information.
The second optional keyword argument is *stack_info*, which defaults to
- False. If specified as True, stack information is added to the logging
+ ``False``. If true, stack information is added to the logging
message, including the actual logging call. Note that this is not the same
stack information as that displayed through specifying *exc_info*: The
former is stack frames from the bottom of the stack up to the logging call
diff --git a/Doc/library/lzma.rst b/Doc/library/lzma.rst
--- a/Doc/library/lzma.rst
+++ b/Doc/library/lzma.rst
@@ -225,7 +225,7 @@
.. attribute:: eof
- True if the end-of-stream marker has been reached.
+ ``True`` if the end-of-stream marker has been reached.
.. attribute:: unused_data
diff --git a/Doc/library/mmap.rst b/Doc/library/mmap.rst
--- a/Doc/library/mmap.rst
+++ b/Doc/library/mmap.rst
@@ -162,7 +162,7 @@
.. attribute:: closed
- True if the file is closed.
+ ``True`` if the file is closed.
.. versionadded:: 3.2
diff --git a/Doc/library/nntplib.rst b/Doc/library/nntplib.rst
--- a/Doc/library/nntplib.rst
+++ b/Doc/library/nntplib.rst
@@ -83,7 +83,7 @@
.. versionchanged:: 3.2
- *usenetrc* is now False by default.
+ *usenetrc* is now ``False`` by default.
.. versionchanged:: 3.3
Support for the :keyword:`with` statement was added.
@@ -217,7 +217,7 @@
.. method:: NNTP.login(user=None, password=None, usenetrc=True)
Send ``AUTHINFO`` commands with the user name and password. If *user*
- and *password* are None and *usenetrc* is True, credentials from
+ and *password* are None and *usenetrc* is true, credentials from
``~/.netrc`` will be used if possible.
Unless intentionally delayed, login is normally performed during the
diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst
--- a/Doc/library/os.path.rst
+++ b/Doc/library/os.path.rst
@@ -133,7 +133,7 @@
the number of seconds since the epoch (see the :mod:`time` module). Raise
:exc:`OSError` if the file does not exist or is inaccessible.
- If :func:`os.stat_float_times` returns True, the result is a floating point
+ If :func:`os.stat_float_times` returns ``True``, the result is a floating point
number.
@@ -143,7 +143,7 @@
giving the number of seconds since the epoch (see the :mod:`time` module).
Raise :exc:`OSError` if the file does not exist or is inaccessible.
- If :func:`os.stat_float_times` returns True, the result is a floating point
+ If :func:`os.stat_float_times` returns ``True``, the result is a floating point
number.
@@ -334,5 +334,5 @@
.. data:: supports_unicode_filenames
- True if arbitrary Unicode strings can be used as file names (within limitations
+ ``True`` if arbitrary Unicode strings can be used as file names (within limitations
imposed by the file system).
diff --git a/Doc/library/os.rst b/Doc/library/os.rst
--- a/Doc/library/os.rst
+++ b/Doc/library/os.rst
@@ -551,7 +551,7 @@
.. data:: supports_bytes_environ
- True if the native OS type of the environment is bytes (eg. False on
+ ``True`` if the native OS type of the environment is bytes (eg. ``False`` on
Windows).
.. versionadded:: 3.2
diff --git a/Doc/library/pickle.rst b/Doc/library/pickle.rst
--- a/Doc/library/pickle.rst
+++ b/Doc/library/pickle.rst
@@ -161,7 +161,7 @@
:class:`io.BytesIO` instance, or any other custom object that meets this
interface.
- If *fix_imports* is True and *protocol* is less than 3, pickle will try to
+ If *fix_imports* is true and *protocol* is less than 3, pickle will try to
map the new Python 3.x names to the old module names used in Python 2.x,
so that the pickle data stream is readable with Python 2.x.
@@ -178,7 +178,7 @@
supported. The higher the protocol used, the more recent the version of
Python needed to read the pickle produced.
- If *fix_imports* is True and *protocol* is less than 3, pickle will try to
+ If *fix_imports* is true and *protocol* is less than 3, pickle will try to
map the new Python 3.x names to the old module names used in Python 2.x,
so that the pickle data stream is readable with Python 2.x.
@@ -200,7 +200,7 @@
Optional keyword arguments are *fix_imports*, *encoding* and *errors*,
which are used to control compatibility support for pickle stream generated
- by Python 2.x. If *fix_imports* is True, pickle will try to map the old
+ by Python 2.x. If *fix_imports* is true, pickle will try to map the old
Python 2.x names to the new names used in Python 3.x. The *encoding* and
*errors* tell pickle how to decode 8-bit string instances pickled by Python
2.x; these default to 'ASCII' and 'strict', respectively.
@@ -216,7 +216,7 @@
Optional keyword arguments are *fix_imports*, *encoding* and *errors*,
which are used to control compatibility support for pickle stream generated
- by Python 2.x. If *fix_imports* is True, pickle will try to map the old
+ by Python 2.x. If *fix_imports* is true, pickle will try to map the old
Python 2.x names to the new names used in Python 3.x. The *encoding* and
*errors* tell pickle how to decode 8-bit string instances pickled by Python
2.x; these default to 'ASCII' and 'strict', respectively.
@@ -266,7 +266,7 @@
argument. It can thus be an on-disk file opened for binary writing, a
:class:`io.BytesIO` instance, or any other custom object that meets this interface.
- If *fix_imports* is True and *protocol* is less than 3, pickle will try to
+ If *fix_imports* is true and *protocol* is less than 3, pickle will try to
map the new Python 3.x names to the old module names used in Python 2.x,
so that the pickle data stream is readable with Python 2.x.
@@ -336,7 +336,7 @@
Optional keyword arguments are *fix_imports*, *encoding* and *errors*,
which are used to control compatibility support for pickle stream generated
- by Python 2.x. If *fix_imports* is True, pickle will try to map the old
+ by Python 2.x. If *fix_imports* is true, pickle will try to map the old
Python 2.x names to the new names used in Python 3.x. The *encoding* and
*errors* tell pickle how to decode 8-bit string instances pickled by Python
2.x; these default to 'ASCII' and 'strict', respectively.
diff --git a/Doc/library/sched.rst b/Doc/library/sched.rst
--- a/Doc/library/sched.rst
+++ b/Doc/library/sched.rst
@@ -113,7 +113,7 @@
function passed to the constructor) for the next event, then execute it and so
on until there are no more scheduled events.
- If *blocking* is False executes the scheduled events due to expire soonest
+ If *blocking* is false executes the scheduled events due to expire soonest
(if any) and then return the deadline of the next scheduled call in the
scheduler (if any).
diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst
--- a/Doc/library/sqlite3.rst
+++ b/Doc/library/sqlite3.rst
@@ -229,10 +229,10 @@
.. function:: enable_callback_tracebacks(flag)
By default you will not get any tracebacks in user-defined functions,
- aggregates, converters, authorizer callbacks etc. If you want to debug them, you
- can call this function with *flag* as True. Afterwards, you will get tracebacks
- from callbacks on ``sys.stderr``. Use :const:`False` to disable the feature
- again.
+ aggregates, converters, authorizer callbacks etc. If you want to debug them,
+ you can call this function with *flag* set to ``True``. Afterwards, you will
+ get tracebacks from callbacks on ``sys.stderr``. Use :const:`False` to
+ disable the feature again.
.. _sqlite3-connection-objects:
diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst
--- a/Doc/library/ssl.rst
+++ b/Doc/library/ssl.rst
@@ -245,7 +245,7 @@
.. function:: RAND_pseudo_bytes(num)
Returns (bytes, is_cryptographic): bytes are *num* pseudo-random bytes,
- is_cryptographic is True if the bytes generated are cryptographically
+ is_cryptographic is ``True`` if the bytes generated are cryptographically
strong. Raises an :class:`SSLError` if the operation is not supported by the
current RAND method.
@@ -258,8 +258,8 @@
.. function:: RAND_status()
- Returns True if the SSL pseudo-random number generator has been seeded with
- 'enough' randomness, and False otherwise. You can use :func:`ssl.RAND_egd`
+ Returns ``True`` if the SSL pseudo-random number generator has been seeded with
+ 'enough' randomness, and ``False`` otherwise. You can use :func:`ssl.RAND_egd`
and :func:`ssl.RAND_add` to increase the randomness of the pseudo-random
number generator.
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -2847,7 +2847,7 @@
.. method:: isdisjoint(other)
- Return True if the set has no elements in common with *other*. Sets are
+ Return ``True`` if the set has no elements in common with *other*. Sets are
disjoint if and only if their intersection is the empty set.
.. method:: issubset(other)
diff --git a/Doc/library/struct.rst b/Doc/library/struct.rst
--- a/Doc/library/struct.rst
+++ b/Doc/library/struct.rst
@@ -282,7 +282,7 @@
For the ``'?'`` format character, the return value is either :const:`True` or
:const:`False`. When packing, the truth value of the argument object is used.
Either 0 or 1 in the native or standard bool representation will be packed, and
-any non-zero value will be True when unpacking.
+any non-zero value will be ``True`` when unpacking.
diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst
--- a/Doc/library/subprocess.rst
+++ b/Doc/library/subprocess.rst
@@ -512,7 +512,7 @@
*executable* (or for the first item in *args*) relative to *cwd* if the
executable path is a relative path.
- If *restore_signals* is True (the default) all signals that Python has set to
+ If *restore_signals* is true (the default) all signals that Python has set to
SIG_IGN are restored to SIG_DFL in the child process before the exec.
Currently this includes the SIGPIPE, SIGXFZ and SIGXFSZ signals.
(Unix only)
@@ -520,7 +520,7 @@
.. versionchanged:: 3.2
*restore_signals* was added.
- If *start_new_session* is True the setsid() system call will be made in the
+ If *start_new_session* is true the setsid() system call will be made in the
child process prior to the execution of the subprocess. (Unix only)
.. versionchanged:: 3.2
diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst
--- a/Doc/library/sys.rst
+++ b/Doc/library/sys.rst
@@ -1032,7 +1032,7 @@
:func:`open` function. Their parameters are chosen as follows:
* The character encoding is platform-dependent. Under Windows, if the stream
- is interactive (that is, if its :meth:`isatty` method returns True), the
+ is interactive (that is, if its :meth:`isatty` method returns ``True``), the
console codepage is used, otherwise the ANSI code page. Under other
platforms, the locale encoding is used (see :meth:`locale.getpreferredencoding`).
diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst
--- a/Doc/library/tarfile.rst
+++ b/Doc/library/tarfile.rst
@@ -359,7 +359,7 @@
full name. Its file information is extracted as accurately as possible. *member*
may be a filename or a :class:`TarInfo` object. You can specify a different
directory using *path*. File attributes (owner, mtime, mode) are set unless
- *set_attrs* is False.
+ *set_attrs* is false.
.. note::
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
@@ -272,8 +272,8 @@
.. method:: instate(statespec, callback=None, *args, **kw)
- Test the widget's state. If a callback is not specified, returns True
- if the widget state matches *statespec* and False otherwise. If callback
+ Test the widget's state. If a callback is not specified, returns ``True``
+ if the widget state matches *statespec* and ``False`` otherwise. If callback
is specified then it is called with args if widget state matches
*statespec*.
@@ -938,7 +938,7 @@
.. method:: exists(item)
- Returns True if the specified *item* is present in the tree.
+ Returns ``True`` if the specified *item* is present in the tree.
.. method:: focus(item=None)
@@ -1084,7 +1084,7 @@
Ensure that *item* is visible.
- Sets all of *item*'s ancestors open option to True, and scrolls the
+ Sets all of *item*'s ancestors open option to ``True``, and scrolls the
widget if necessary so that *item* is within the visible portion of
the tree.
diff --git a/Doc/library/turtle.rst b/Doc/library/turtle.rst
--- a/Doc/library/turtle.rst
+++ b/Doc/library/turtle.rst
@@ -1055,8 +1055,8 @@
Write text - the string representation of *arg* - at the current turtle
position according to *align* ("left", "center" or right") and with the given
- font. If *move* is True, the pen is moved to the bottom-right corner of the
- text. By default, *move* is False.
+ font. If *move* is true, the pen is moved to the bottom-right corner of the
+ text. By default, *move* is ``False``.
>>> turtle.write("Home = ", True, align="center")
>>> turtle.write((0,0), True)
@@ -1092,7 +1092,7 @@
.. function:: isvisible()
- Return True if the Turtle is shown, False if it's hidden.
+ Return ``True`` if the Turtle is shown, ``False`` if it's hidden.
>>> turtle.hideturtle()
>>> turtle.isvisible()
diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst
--- a/Doc/library/unittest.mock.rst
+++ b/Doc/library/unittest.mock.rst
@@ -299,11 +299,11 @@
assert the mock has been called with the specified calls.
The `mock_calls` list is checked for the calls.
- If `any_order` is False (the default) then the calls must be
+ If `any_order` is false (the default) then the calls must be
sequential. There can be extra calls before or after the
specified calls.
- If `any_order` is True then the calls can be in any order, but
+ If `any_order` is true then the calls can be in any order, but
they must all appear in :attr:`mock_calls`.
>>> mock = Mock(return_value=None)
@@ -1180,7 +1180,7 @@
`values` can be a dictionary of values to set in the dictionary. `values`
can also be an iterable of `(key, value)` pairs.
- If `clear` is True then the dictionary will be cleared before the new
+ If `clear` is true then the dictionary will be cleared before the new
values are set.
`patch.dict` can also be called with arbitrary keyword arguments to set
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
@@ -59,7 +59,7 @@
some non-Windows platforms.
.. warning::
- If neither *cafile* nor *capath* is specified, and *cadefault* is False,
+ If neither *cafile* nor *capath* is specified, and *cadefault* is ``False``,
an HTTPS request will not do any verification of the server's
certificate.
@@ -211,7 +211,7 @@
containing the image.
*unverifiable* should indicate whether the request is unverifiable,
- as defined by RFC 2965. It defaults to False. An unverifiable
+ as defined by RFC 2965. It defaults to ``False``. An unverifiable
request is one whose URL the user did not have the option to
approve. For example, if the request is for an image in an HTML
document, and the user had no option to approve the automatic
diff --git a/Doc/library/venv.rst b/Doc/library/venv.rst
--- a/Doc/library/venv.rst
+++ b/Doc/library/venv.rst
@@ -93,7 +93,7 @@
* ``system_site_packages`` -- a Boolean value indicating that the system Python
site-packages should be available to the environment (defaults to ``False``).
- * ``clear`` -- a Boolean value which, if True, will delete any existing target
+ * ``clear`` -- a Boolean value which, if true, will delete any existing target
directory instead of raising an exception (defaults to ``False``).
* ``symlinks`` -- a Boolean value indicating whether to attempt to symlink the
@@ -101,7 +101,7 @@
e.g. ``pythonw.exe``), rather than copying. Defaults to ``True`` on Linux and
Unix systems, but ``False`` on Windows.
- * ``upgrade`` -- a Boolean value which, if True, will upgrade an existing
+ * ``upgrade`` -- a Boolean value which, if true, will upgrade an existing
environment with the running Python - for use when that Python has been
upgraded in-place (defaults to ``False``).
diff --git a/Doc/library/zipimport.rst b/Doc/library/zipimport.rst
--- a/Doc/library/zipimport.rst
+++ b/Doc/library/zipimport.rst
@@ -111,7 +111,7 @@
.. method:: is_package(fullname)
- Return True if the module specified by *fullname* is a package. Raise
+ Return ``True`` if the module specified by *fullname* is a package. Raise
:exc:`ZipImportError` if the module couldn't be found.
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -201,7 +201,7 @@
single: True
These represent the truth values False and True. The two objects representing
- the values False and True are the only Boolean objects. The Boolean type is a
+ the values ``False`` and ``True`` are the only Boolean objects. The Boolean type is a
subtype of the integer type, and Boolean values behave like the values 0 and 1,
respectively, in almost all contexts, the exception being that when converted to
a string, the strings ``"False"`` or ``"True"`` are returned, respectively.
diff --git a/Doc/whatsnew/3.3.rst b/Doc/whatsnew/3.3.rst
--- a/Doc/whatsnew/3.3.rst
+++ b/Doc/whatsnew/3.3.rst
@@ -1125,7 +1125,7 @@
* If Python is compiled without threads, the C version automatically
disables the expensive thread local context machinery. In this case,
- the variable :data:`~decimal.HAVE_THREADS` is set to False.
+ the variable :data:`~decimal.HAVE_THREADS` is set to ``False``.
API changes
~~~~~~~~~~~
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -87,6 +87,8 @@
Documentation
-------------
+- Issue #19795: Improved markup of True/False constants.
+
- 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.
--
Repository URL: http://hg.python.org/cpython
1
0
cpython (2.7): Issue #19795: Improved markup of True/False constants.
by serhiy.storchaka 29 Nov '13
by serhiy.storchaka 29 Nov '13
29 Nov '13
http://hg.python.org/cpython/rev/f51ca196d77a
changeset: 87633:f51ca196d77a
branch: 2.7
parent: 87628:3a7a3def6503
user: Serhiy Storchaka <storchaka(a)gmail.com>
date: Fri Nov 29 12:16:53 2013 +0200
summary:
Issue #19795: Improved markup of True/False constants.
files:
Doc/howto/functional.rst | 4 ++--
Doc/library/ast.rst | 2 +-
Doc/library/bdb.rst | 8 ++++----
Doc/library/cookielib.rst | 16 ++++++++--------
Doc/library/ctypes.rst | 2 +-
Doc/library/email.message.rst | 2 +-
Doc/library/functions.rst | 6 +++---
Doc/library/gc.rst | 4 ++--
Doc/library/io.rst | 2 +-
Doc/library/itertools.rst | 4 ++--
Doc/library/os.path.rst | 6 +++---
Doc/library/sqlite3.rst | 8 ++++----
Doc/library/ssl.rst | 2 +-
Doc/library/stdtypes.rst | 2 +-
Doc/library/struct.rst | 2 +-
Doc/library/ttk.rst | 8 ++++----
Doc/library/turtle.rst | 6 +++---
Doc/library/urllib2.rst | 2 +-
Doc/library/zipimport.rst | 2 +-
Doc/reference/datamodel.rst | 2 +-
Misc/NEWS | 5 +++++
21 files changed, 50 insertions(+), 45 deletions(-)
diff --git a/Doc/howto/functional.rst b/Doc/howto/functional.rst
--- a/Doc/howto/functional.rst
+++ b/Doc/howto/functional.rst
@@ -743,8 +743,8 @@
Python wiki at http://wiki.python.org/moin/HowTo/Sorting.)
The ``any(iter)`` and ``all(iter)`` built-ins look at the truth values of an
-iterable's contents. :func:`any` returns True if any element in the iterable is
-a true value, and :func:`all` returns True if all of the elements are true
+iterable's contents. :func:`any` returns ``True`` if any element in the iterable is
+a true value, and :func:`all` returns ``True`` if all of the elements are true
values:
>>> any([0,1,0])
diff --git a/Doc/library/ast.rst b/Doc/library/ast.rst
--- a/Doc/library/ast.rst
+++ b/Doc/library/ast.rst
@@ -257,6 +257,6 @@
Return a formatted dump of the tree in *node*. This is mainly useful for
debugging purposes. The returned string will show the names and the values
for fields. This makes the code impossible to evaluate, so if evaluation is
- wanted *annotate_fields* must be set to False. Attributes such as line
+ wanted *annotate_fields* must be set to ``False``. Attributes such as line
numbers and column offsets are not dumped by default. If this is wanted,
*include_attributes* can be set to ``True``.
diff --git a/Doc/library/bdb.rst b/Doc/library/bdb.rst
--- a/Doc/library/bdb.rst
+++ b/Doc/library/bdb.rst
@@ -186,17 +186,17 @@
.. method:: user_line(frame)
This method is called from :meth:`dispatch_line` when either
- :meth:`stop_here` or :meth:`break_here` yields True.
+ :meth:`stop_here` or :meth:`break_here` yields ``True``.
.. method:: user_return(frame, return_value)
This method is called from :meth:`dispatch_return` when :meth:`stop_here`
- yields True.
+ yields ``True``.
.. method:: user_exception(frame, exc_info)
This method is called from :meth:`dispatch_exception` when
- :meth:`stop_here` yields True.
+ :meth:`stop_here` yields ``True``.
.. method:: do_clear(arg)
@@ -237,7 +237,7 @@
.. method:: set_quit()
- Set the :attr:`quitting` attribute to True. This raises :exc:`BdbQuit` in
+ Set the :attr:`quitting` attribute to ``True``. This raises :exc:`BdbQuit` in
the next call to one of the :meth:`dispatch_\*` methods.
diff --git a/Doc/library/cookielib.rst b/Doc/library/cookielib.rst
--- a/Doc/library/cookielib.rst
+++ b/Doc/library/cookielib.rst
@@ -98,7 +98,7 @@
Netscape and RFC 2965 cookies. By default, RFC 2109 cookies (ie. cookies
received in a :mailheader:`Set-Cookie` header with a version cookie-attribute of
1) are treated according to the RFC 2965 rules. However, if RFC 2965 handling
- is turned off or :attr:`rfc2109_as_netscape` is True, RFC 2109 cookies are
+ is turned off or :attr:`rfc2109_as_netscape` is ``True``, RFC 2109 cookies are
'downgraded' by the :class:`CookieJar` instance to Netscape cookies, by
setting the :attr:`version` attribute of the :class:`Cookie` instance to 0.
:class:`DefaultCookiePolicy` also provides some parameters to allow some
@@ -652,7 +652,7 @@
.. attribute:: Cookie.secure
- True if cookie should only be returned over a secure connection.
+ ``True`` if cookie should only be returned over a secure connection.
.. attribute:: Cookie.expires
@@ -663,7 +663,7 @@
.. attribute:: Cookie.discard
- True if this is a session cookie.
+ ``True`` if this is a session cookie.
.. attribute:: Cookie.comment
@@ -680,7 +680,7 @@
.. attribute:: Cookie.rfc2109
- True if this cookie was received as an RFC 2109 cookie (ie. the cookie
+ ``True`` if this cookie was received as an RFC 2109 cookie (ie. the cookie
arrived in a :mailheader:`Set-Cookie` header, and the value of the Version
cookie-attribute in that header was 1). This attribute is provided because
:mod:`cookielib` may 'downgrade' RFC 2109 cookies to Netscape cookies, in
@@ -691,18 +691,18 @@
.. attribute:: Cookie.port_specified
- True if a port or set of ports was explicitly specified by the server (in the
+ ``True`` if a port or set of ports was explicitly specified by the server (in the
:mailheader:`Set-Cookie` / :mailheader:`Set-Cookie2` header).
.. attribute:: Cookie.domain_specified
- True if a domain was explicitly specified by the server.
+ ``True`` if a domain was explicitly specified by the server.
.. attribute:: Cookie.domain_initial_dot
- True if the domain explicitly specified by the server began with a dot
+ ``True`` if the domain explicitly specified by the server began with a dot
(``'.'``).
Cookies may have additional non-standard cookie-attributes. These may be
@@ -729,7 +729,7 @@
.. method:: Cookie.is_expired([now=None])
- True if cookie has passed the time at which the server requested it should
+ ``True`` if cookie has passed the time at which the server requested it should
expire. If *now* is given (in seconds since the epoch), return whether the
cookie has expired at the specified time.
diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst
--- a/Doc/library/ctypes.rst
+++ b/Doc/library/ctypes.rst
@@ -2351,7 +2351,7 @@
.. class:: c_bool
Represent the C :c:type:`bool` datatype (more accurately, :c:type:`_Bool` from
- C99). Its value can be True or False, and the constructor accepts any object
+ C99). Its value can be ``True`` or ``False``, and the constructor accepts any object
that has a truth value.
.. versionadded:: 2.6
diff --git a/Doc/library/email.message.rst b/Doc/library/email.message.rst
--- a/Doc/library/email.message.rst
+++ b/Doc/library/email.message.rst
@@ -68,7 +68,7 @@
Return ``True`` if the message's payload is a list of sub-\
:class:`Message` objects, otherwise return ``False``. When
- :meth:`is_multipart` returns False, the payload should be a string object.
+ :meth:`is_multipart` returns ``False``, the payload should be a string object.
.. method:: set_unixfrom(unixfrom)
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -47,7 +47,7 @@
.. function:: all(iterable)
- Return True if all elements of the *iterable* are true (or if the iterable
+ Return ``True`` if all elements of the *iterable* are true (or if the iterable
is empty). Equivalent to::
def all(iterable):
@@ -61,8 +61,8 @@
.. function:: any(iterable)
- Return True if any element of the *iterable* is true. If the iterable
- is empty, return False. Equivalent to::
+ Return ``True`` if any element of the *iterable* is true. If the iterable
+ is empty, return ``False``. Equivalent to::
def any(iterable):
for element in iterable:
diff --git a/Doc/library/gc.rst b/Doc/library/gc.rst
--- a/Doc/library/gc.rst
+++ b/Doc/library/gc.rst
@@ -142,8 +142,8 @@
.. function:: is_tracked(obj)
- Returns True if the object is currently tracked by the garbage collector,
- False otherwise. As a general rule, instances of atomic types aren't
+ Returns ``True`` if the object is currently tracked by the garbage collector,
+ ``False`` otherwise. As a general rule, instances of atomic types aren't
tracked and instances of non-atomic types (containers, user-defined
objects...) are. However, some type-specific optimizations can be present
in order to suppress the garbage collector footprint of simple instances
diff --git a/Doc/library/io.rst b/Doc/library/io.rst
--- a/Doc/library/io.rst
+++ b/Doc/library/io.rst
@@ -278,7 +278,7 @@
.. method:: readable()
- Return ``True`` if the stream can be read from. If False, :meth:`read`
+ Return ``True`` if the stream can be read from. If ``False``, :meth:`read`
will raise :exc:`IOError`.
.. method:: readline(limit=-1)
diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst
--- a/Doc/library/itertools.rst
+++ b/Doc/library/itertools.rst
@@ -52,8 +52,8 @@
:func:`compress` data, selectors (d[0] if s[0]), (d[1] if s[1]), ... ``compress('ABCDEF', [1,0,1,0,1,1]) --> A C E F``
:func:`dropwhile` pred, seq seq[n], seq[n+1], starting when pred fails ``dropwhile(lambda x: x<5, [1,4,6,4,1]) --> 6 4 1``
:func:`groupby` iterable[, keyfunc] sub-iterators grouped by value of keyfunc(v)
-:func:`ifilter` pred, seq elements of seq where pred(elem) is True ``ifilter(lambda x: x%2, range(10)) --> 1 3 5 7 9``
-:func:`ifilterfalse` pred, seq elements of seq where pred(elem) is False ``ifilterfalse(lambda x: x%2, range(10)) --> 0 2 4 6 8``
+:func:`ifilter` pred, seq elements of seq where pred(elem) is true ``ifilter(lambda x: x%2, range(10)) --> 1 3 5 7 9``
+:func:`ifilterfalse` pred, seq elements of seq where pred(elem) is false ``ifilterfalse(lambda x: x%2, range(10)) --> 0 2 4 6 8``
:func:`islice` seq, [start,] stop [, step] elements from seq[start:stop:step] ``islice('ABCDEFG', 2, None) --> C D E F G``
:func:`imap` func, p, q, ... func(p0, q0), func(p1, q1), ... ``imap(pow, (2,3,10), (5,2,3)) --> 32 9 1000``
:func:`starmap` func, seq func(\*seq[0]), func(\*seq[1]), ... ``starmap(pow, [(2,5), (3,2), (10,3)]) --> 32 9 1000``
diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst
--- a/Doc/library/os.path.rst
+++ b/Doc/library/os.path.rst
@@ -127,7 +127,7 @@
.. versionadded:: 1.5.2
.. versionchanged:: 2.3
- If :func:`os.stat_float_times` returns True, the result is a floating point
+ If :func:`os.stat_float_times` returns ``True``, the result is a floating point
number.
@@ -140,7 +140,7 @@
.. versionadded:: 1.5.2
.. versionchanged:: 2.3
- If :func:`os.stat_float_times` returns True, the result is a floating point
+ If :func:`os.stat_float_times` returns ``True``, the result is a floating point
number.
@@ -345,7 +345,7 @@
.. data:: supports_unicode_filenames
- True if arbitrary Unicode strings can be used as file names (within limitations
+ ``True`` if arbitrary Unicode strings can be used as file names (within limitations
imposed by the file system).
.. versionadded:: 2.3
diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst
--- a/Doc/library/sqlite3.rst
+++ b/Doc/library/sqlite3.rst
@@ -234,10 +234,10 @@
.. function:: enable_callback_tracebacks(flag)
By default you will not get any tracebacks in user-defined functions,
- aggregates, converters, authorizer callbacks etc. If you want to debug them, you
- can call this function with *flag* as True. Afterwards, you will get tracebacks
- from callbacks on ``sys.stderr``. Use :const:`False` to disable the feature
- again.
+ aggregates, converters, authorizer callbacks etc. If you want to debug them,
+ you can call this function with *flag* set to ``True``. Afterwards, you will
+ get tracebacks from callbacks on ``sys.stderr``. Use :const:`False` to
+ disable the feature again.
.. _sqlite3-connection-objects:
diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst
--- a/Doc/library/ssl.rst
+++ b/Doc/library/ssl.rst
@@ -166,7 +166,7 @@
.. function:: RAND_status()
- Returns True if the SSL pseudo-random number generator has been seeded with
+ Returns ``True`` if the SSL pseudo-random number generator has been seeded with
'enough' randomness, and False otherwise. You can use :func:`ssl.RAND_egd`
and :func:`ssl.RAND_add` to increase the randomness of the pseudo-random
number generator.
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -1783,7 +1783,7 @@
.. method:: isdisjoint(other)
- Return True if the set has no elements in common with *other*. Sets are
+ Return ``True`` if the set has no elements in common with *other*. Sets are
disjoint if and only if their intersection is the empty set.
.. versionadded:: 2.6
diff --git a/Doc/library/struct.rst b/Doc/library/struct.rst
--- a/Doc/library/struct.rst
+++ b/Doc/library/struct.rst
@@ -284,7 +284,7 @@
For the ``'?'`` format character, the return value is either :const:`True` or
:const:`False`. When packing, the truth value of the argument object is used.
Either 0 or 1 in the native or standard bool representation will be packed, and
-any non-zero value will be True when unpacking.
+any non-zero value will be ``True`` when unpacking.
diff --git a/Doc/library/ttk.rst b/Doc/library/ttk.rst
--- a/Doc/library/ttk.rst
+++ b/Doc/library/ttk.rst
@@ -267,8 +267,8 @@
.. method:: instate(statespec, callback=None, *args, **kw)
- Test the widget's state. If a callback is not specified, returns True
- if the widget state matches *statespec* and False otherwise. If callback
+ Test the widget's state. If a callback is not specified, returns ``True``
+ if the widget state matches *statespec* and ``False`` otherwise. If callback
is specified then it is called with *args* if widget state matches
*statespec*.
@@ -919,7 +919,7 @@
.. method:: exists(item)
- Returns True if the specified *item* is present in the tree.
+ Returns ``True`` if the specified *item* is present in the tree.
.. method:: focus([item=None])
@@ -1065,7 +1065,7 @@
Ensure that *item* is visible.
- Sets all of *item*'s ancestors open option to True, and scrolls the
+ Sets all of *item*'s ancestors open option to ``True``, and scrolls the
widget if necessary so that *item* is within the visible portion of
the tree.
diff --git a/Doc/library/turtle.rst b/Doc/library/turtle.rst
--- a/Doc/library/turtle.rst
+++ b/Doc/library/turtle.rst
@@ -1049,8 +1049,8 @@
Write text - the string representation of *arg* - at the current turtle
position according to *align* ("left", "center" or right") and with the given
- font. If *move* is True, the pen is moved to the bottom-right corner of the
- text. By default, *move* is False.
+ font. If *move* is true, the pen is moved to the bottom-right corner of the
+ text. By default, *move* is ``False``.
>>> turtle.write("Home = ", True, align="center")
>>> turtle.write((0,0), True)
@@ -1086,7 +1086,7 @@
.. function:: isvisible()
- Return True if the Turtle is shown, False if it's hidden.
+ Return ``True`` if the Turtle is shown, ``False`` if it's hidden.
>>> turtle.hideturtle()
>>> turtle.isvisible()
diff --git a/Doc/library/urllib2.rst b/Doc/library/urllib2.rst
--- a/Doc/library/urllib2.rst
+++ b/Doc/library/urllib2.rst
@@ -166,7 +166,7 @@
should be the request-host of the request for the page containing the image.
*unverifiable* should indicate whether the request is unverifiable, as defined
- by RFC 2965. It defaults to False. An unverifiable request is one whose URL
+ by RFC 2965. It defaults to ``False``. An unverifiable request is one whose URL
the user did not have the option to approve. For example, if the request is for
an image in an HTML document, and the user had no option to approve the
automatic fetching of the image, this should be true.
diff --git a/Doc/library/zipimport.rst b/Doc/library/zipimport.rst
--- a/Doc/library/zipimport.rst
+++ b/Doc/library/zipimport.rst
@@ -115,7 +115,7 @@
.. method:: is_package(fullname)
- Return True if the module specified by *fullname* is a package. Raise
+ Return ``True`` if the module specified by *fullname* is a package. Raise
:exc:`ZipImportError` if the module couldn't be found.
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -207,7 +207,7 @@
single: True
These represent the truth values False and True. The two objects
- representing the values False and True are the only Boolean objects.
+ representing the values ``False`` and ``True`` are the only Boolean objects.
The Boolean type is a subtype of plain integers, and Boolean values
behave like the values 0 and 1, respectively, in almost all contexts,
the exception being that when converted to a string, the strings
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -67,6 +67,11 @@
- Issue #19085: Added basic tests for all tkinter widget options.
+Documentation
+-------------
+
+- Issue #19795: Improved markup of True/False constants.
+
Whats' New in Python 2.7.6?
===========================
--
Repository URL: http://hg.python.org/cpython
1
0
results for d829111a27e5 on branch "default"
--------------------------------------------
test_asyncio leaked [0, 4, 0] memory blocks, sum=4
test_site leaked [-2, 2, -2] references, sum=-2
test_site leaked [-2, 2, -2] memory blocks, sum=-2
Command line was: ['./python', '-m', 'test.regrtest', '-uall', '-R', '3:3:/home/antoine/cpython/refleaks/reflogwzGOWs', '-x']
1
0
cpython: Use PyDict_GetItemWithError instead of PyDict_GetItem in cpickle.
by alexandre.vassalotti 28 Nov '13
by alexandre.vassalotti 28 Nov '13
28 Nov '13
http://hg.python.org/cpython/rev/d829111a27e5
changeset: 87632:d829111a27e5
user: Alexandre Vassalotti <alexandre(a)peadrop.com>
date: Thu Nov 28 17:09:16 2013 -0800
summary:
Use PyDict_GetItemWithError instead of PyDict_GetItem in cpickle.
files:
Modules/_pickle.c | 47 ++++++++++++++++++++++++++--------
1 files changed, 35 insertions(+), 12 deletions(-)
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -1691,7 +1691,7 @@
key = PyLong_FromVoidPtr(obj);
if (key == NULL)
return 0;
- if (PyDict_GetItem(self->fast_memo, key)) {
+ if (PyDict_GetItemWithError(self->fast_memo, key)) {
Py_DECREF(key);
PyErr_Format(PyExc_ValueError,
"fast mode: can't pickle cyclic objects "
@@ -1700,6 +1700,9 @@
self->fast_nesting = -1;
return 0;
}
+ if (PyErr_Occurred()) {
+ return 0;
+ }
if (PyDict_SetItem(self->fast_memo, key, Py_None) < 0) {
Py_DECREF(key);
self->fast_nesting = -1;
@@ -3142,12 +3145,17 @@
if (extension_key == NULL) {
goto error;
}
- code_obj = PyDict_GetItem(st->extension_registry, extension_key);
+ code_obj = PyDict_GetItemWithError(st->extension_registry,
+ extension_key);
Py_DECREF(extension_key);
/* The object is not registered in the extension registry.
This is the most likely code path. */
- if (code_obj == NULL)
+ if (code_obj == NULL) {
+ if (PyErr_Occurred()) {
+ goto error;
+ }
goto gen_global;
+ }
/* XXX: pickle.py doesn't check neither the type, nor the range
of the value returned by the extension_registry. It should for
@@ -3712,12 +3720,21 @@
*/
if (self->dispatch_table == NULL) {
PickleState *st = _Pickle_GetGlobalState();
- reduce_func = PyDict_GetItem(st->dispatch_table, (PyObject *)type);
- /* PyDict_GetItem() unlike PyObject_GetItem() and
- PyObject_GetAttr() returns a borrowed ref */
- Py_XINCREF(reduce_func);
+ reduce_func = PyDict_GetItemWithError(st->dispatch_table,
+ (PyObject *)type);
+ if (reduce_func == NULL) {
+ if (PyErr_Occurred()) {
+ goto error;
+ }
+ } else {
+ /* PyDict_GetItemWithError() returns a borrowed reference.
+ Increase the reference count to be consistent with
+ PyObject_GetItem and _PyObject_GetAttrId used below. */
+ Py_INCREF(reduce_func);
+ }
} else {
- reduce_func = PyObject_GetItem(self->dispatch_table, (PyObject *)type);
+ reduce_func = PyObject_GetItem(self->dispatch_table,
+ (PyObject *)type);
if (reduce_func == NULL) {
if (PyErr_ExceptionMatches(PyExc_KeyError))
PyErr_Clear();
@@ -5564,20 +5581,26 @@
py_code = PyLong_FromLong(code);
if (py_code == NULL)
return -1;
- obj = PyDict_GetItem(st->extension_cache, py_code);
+ obj = PyDict_GetItemWithError(st->extension_cache, py_code);
if (obj != NULL) {
/* Bingo. */
Py_DECREF(py_code);
PDATA_APPEND(self->stack, obj, -1);
return 0;
}
+ if (PyErr_Occurred()) {
+ Py_DECREF(py_code);
+ return -1;
+ }
/* Look up the (module_name, class_name) pair. */
- pair = PyDict_GetItem(st->inverted_registry, py_code);
+ pair = PyDict_GetItemWithError(st->inverted_registry, py_code);
if (pair == NULL) {
Py_DECREF(py_code);
- PyErr_Format(PyExc_ValueError, "unregistered extension "
- "code %ld", code);
+ if (!PyErr_Occurred()) {
+ PyErr_Format(PyExc_ValueError, "unregistered extension "
+ "code %ld", code);
+ }
return -1;
}
/* Since the extension registry is manipulable via Python code,
--
Repository URL: http://hg.python.org/cpython
1
0
28 Nov '13
http://hg.python.org/cpython/rev/b44dbf07732e
changeset: 87631:b44dbf07732e
user: Alexandre Vassalotti <alexandre(a)peadrop.com>
date: Thu Nov 28 15:17:29 2013 -0800
summary:
Remove explicit empty tuple reuse in cpickle.
PyTuple_New(0) always returns the same empty tuple from its free list anyway,
so we are not saving much here. Plus, the code where this was used is on
uncommon run paths.
files:
Modules/_pickle.c | 18 ++++++------------
1 files changed, 6 insertions(+), 12 deletions(-)
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -166,9 +166,6 @@
/* codecs.encode, used for saving bytes in older protocols */
PyObject *codecs_encode;
-
- /* As the name says, an empty tuple. */
- PyObject *empty_tuple;
} PickleState;
/* Forward declaration of the _pickle module definition. */
@@ -205,7 +202,6 @@
Py_CLEAR(st->name_mapping_3to2);
Py_CLEAR(st->import_mapping_3to2);
Py_CLEAR(st->codecs_encode);
- Py_CLEAR(st->empty_tuple);
}
/* Initialize the given pickle module state. */
@@ -321,10 +317,6 @@
}
Py_CLEAR(codecs);
- st->empty_tuple = PyTuple_New(0);
- if (st->empty_tuple == NULL)
- goto error;
-
return 0;
error:
@@ -1137,8 +1129,9 @@
return -1;
if (n == READ_WHOLE_LINE) {
- PickleState *st = _Pickle_GetGlobalState();
- data = PyObject_Call(self->readline, st->empty_tuple, NULL);
+ PyObject *empty_tuple = PyTuple_New(0);
+ data = PyObject_Call(self->readline, empty_tuple, NULL);
+ Py_DECREF(empty_tuple);
}
else {
PyObject *len = PyLong_FromSsize_t(n);
@@ -3774,8 +3767,10 @@
/* Check for a __reduce__ method. */
reduce_func = _PyObject_GetAttrId(obj, &PyId___reduce__);
if (reduce_func != NULL) {
- reduce_value = PyObject_Call(reduce_func, st->empty_tuple,
+ PyObject *empty_tuple = PyTuple_New(0);
+ reduce_value = PyObject_Call(reduce_func, empty_tuple,
NULL);
+ Py_DECREF(empty_tuple);
}
else {
PyErr_Format(st->PicklingError,
@@ -7412,7 +7407,6 @@
Py_VISIT(st->name_mapping_3to2);
Py_VISIT(st->import_mapping_3to2);
Py_VISIT(st->codecs_encode);
- Py_VISIT(st->empty_tuple);
return 0;
}
--
Repository URL: http://hg.python.org/cpython
1
0
cpython: Remove the tuple reuse optimization in _Pickle_FastCall.
by alexandre.vassalotti 28 Nov '13
by alexandre.vassalotti 28 Nov '13
28 Nov '13
http://hg.python.org/cpython/rev/dd51b72cfb52
changeset: 87630:dd51b72cfb52
user: Alexandre Vassalotti <alexandre(a)peadrop.com>
date: Thu Nov 28 14:56:09 2013 -0800
summary:
Remove the tuple reuse optimization in _Pickle_FastCall.
I have noticed a race-condition occurring on one of the buildbots because of
this optimization. The function called may release the GIL which means
multiple threads may end up accessing the shared tuple. I could fix it up by
storing the tuple to the Pickler and Unipickler object again, but honestly it
really not worth the trouble.
I ran many benchmarks and the only time the optimization helps is when using a
fin-memory file, like io.BytesIO on which reads are super cheap, combined with
pickle protocol less than 4. Even in this contrived case, the speedup is a
about 5%. For everything else, this optimization does not provide any
noticable improvements.
files:
Modules/_pickle.c | 49 ++++++++++++----------------------
1 files changed, 17 insertions(+), 32 deletions(-)
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -169,8 +169,6 @@
/* As the name says, an empty tuple. */
PyObject *empty_tuple;
- /* Single argument tuple used by _Pickle_FastCall */
- PyObject *arg_tuple;
} PickleState;
/* Forward declaration of the _pickle module definition. */
@@ -208,7 +206,6 @@
Py_CLEAR(st->import_mapping_3to2);
Py_CLEAR(st->codecs_encode);
Py_CLEAR(st->empty_tuple);
- Py_CLEAR(st->arg_tuple);
}
/* Initialize the given pickle module state. */
@@ -328,8 +325,6 @@
if (st->empty_tuple == NULL)
goto error;
- st->arg_tuple = NULL;
-
return 0;
error:
@@ -342,40 +337,31 @@
/* Helper for calling a function with a single argument quickly.
- This has the performance advantage of reusing the argument tuple. This
- provides a nice performance boost with older pickle protocols where many
- unbuffered reads occurs.
-
This function steals the reference of the given argument. */
static PyObject *
_Pickle_FastCall(PyObject *func, PyObject *obj)
{
- PickleState *st = _Pickle_GetGlobalState();
- PyObject *arg_tuple;
PyObject *result;
-
- arg_tuple = st->arg_tuple;
+ PyObject *arg_tuple = PyTuple_New(1);
+
+ /* Note: this function used to reuse the argument tuple. This used to give
+ a slight performance boost with older pickle implementations where many
+ unbuffered reads occurred (thus needing many function calls).
+
+ However, this optimization was removed because it was too complicated
+ to get right. It abused the C API for tuples to mutate them which led
+ to subtle reference counting and concurrency bugs. Furthermore, the
+ introduction of protocol 4 and the prefetching optimization via peek()
+ significantly reduced the number of function calls we do. Thus, the
+ benefits became marginal at best. */
+
if (arg_tuple == NULL) {
- arg_tuple = PyTuple_New(1);
- if (arg_tuple == NULL) {
- Py_DECREF(obj);
- return NULL;
- }
- }
- assert(arg_tuple->ob_refcnt == 1);
- assert(PyTuple_GET_ITEM(arg_tuple, 0) == NULL);
-
+ Py_DECREF(obj);
+ return NULL;
+ }
PyTuple_SET_ITEM(arg_tuple, 0, obj);
result = PyObject_Call(func, arg_tuple, NULL);
-
- Py_CLEAR(PyTuple_GET_ITEM(arg_tuple, 0));
- if (arg_tuple->ob_refcnt > 1) {
- /* The function called saved a reference to our argument tuple.
- This means we cannot reuse it anymore. */
- Py_CLEAR(arg_tuple);
- }
- st->arg_tuple = arg_tuple;
-
+ Py_CLEAR(arg_tuple);
return result;
}
@@ -7427,7 +7413,6 @@
Py_VISIT(st->import_mapping_3to2);
Py_VISIT(st->codecs_encode);
Py_VISIT(st->empty_tuple);
- Py_VISIT(st->arg_tuple);
return 0;
}
--
Repository URL: http://hg.python.org/cpython
1
0