Skip to content

Commit

Permalink
Merge branch 'default'
Browse files Browse the repository at this point in the history
This commit merges 'default' at the root of branch '3.5'.
  • Loading branch information
Anselm Kruis committed Mar 18, 2017
2 parents 8243dfa + aca575c commit 4b9b363
Show file tree
Hide file tree
Showing 99 changed files with 10,059 additions and 3,570 deletions.
1 change: 1 addition & 0 deletions .hgtags
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,4 @@ b4cbecbc0781e89a309d03b60a1f75f8499250e6 v3.4.3
0337bd7ebcb6559d69679bc7025059ad1ce4f432 v3.5.0a2
82656e28b5e5c4ae48d8dd8b5f0d7968908a82b6 v3.5.0a3
413e0e0004f4f954331cb8122aa55fe208984955 v3.5.0a4
071fefbb5e3db770c6c19fba9994699f121b1cea v3.5.0b1
92 changes: 66 additions & 26 deletions Doc/c-api/module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ Module Objects

.. index:: object: module

There are only a few functions special to module objects.


.. c:var:: PyTypeObject PyModule_Type
Expand Down Expand Up @@ -109,6 +107,14 @@ There are only a few functions special to module objects.
unencodable filenames, use :c:func:`PyModule_GetFilenameObject` instead.
Per-interpreter module state
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Single-phase initialization creates singleton modules that can store additional
information as part of the interpreter, allow that state to be retrieved later
with only a reference to the module definition, rather than to the module
itself.
.. c:function:: void* PyModule_GetState(PyObject *module)
Return the "state" of the module, that is, a pointer to the block of memory
Expand Down Expand Up @@ -146,27 +152,6 @@ There are only a few functions special to module objects.
Initializing C modules
^^^^^^^^^^^^^^^^^^^^^^
These functions are usually used in the module initialization function.
.. c:function:: PyObject* PyModule_Create(PyModuleDef *module)
Create a new module object, given the definition in *module*. This behaves
like :c:func:`PyModule_Create2` with *module_api_version* set to
:const:`PYTHON_API_VERSION`.
.. c:function:: PyObject* PyModule_Create2(PyModuleDef *module, int module_api_version)
Create a new module object, given the definition in *module*, assuming the
API version *module_api_version*. If that version does not match the version
of the running interpreter, a :exc:`RuntimeWarning` is emitted.
.. note::
Most uses of this function should be using :c:func:`PyModule_Create`
instead; only use this if you are sure you need it.
.. c:type:: PyModuleDef
This struct holds all information that is needed to create a module object.
Expand Down Expand Up @@ -210,9 +195,10 @@ These functions are usually used in the module initialization function.
A pointer to a table of module-level functions, described by
:c:type:`PyMethodDef` values. Can be *NULL* if no functions are present.
.. c:member:: inquiry m_reload
.. c:member:: PyModuleDef_Slot* m_slots
Currently unused, should be *NULL*.
An array of slot definitions for multi-phase initialization, terminated by
a *NULL* entry.
.. c:member:: traverseproc m_traverse
Expand All @@ -229,14 +215,68 @@ These functions are usually used in the module initialization function.
A function to call during deallocation of the module object, or *NULL* if
not needed.
The module initialization function may create and return the module object
directly. This is referred to as "single-phase initialization", and uses one
of the following two module creation functions:
.. c:function:: PyObject* PyModule_Create(PyModuleDef *module)
Create a new module object, given the definition in *module*. This behaves
like :c:func:`PyModule_Create2` with *module_api_version* set to
:const:`PYTHON_API_VERSION`.
.. c:function:: PyObject* PyModule_Create2(PyModuleDef *module, int module_api_version)
Create a new module object, given the definition in *module*, assuming the
API version *module_api_version*. If that version does not match the version
of the running interpreter, a :exc:`RuntimeWarning` is emitted.
.. note::
Most uses of this function should be using :c:func:`PyModule_Create`
instead; only use this if you are sure you need it.
Alternatively, the module initialization function may instead return a
:c:type:`PyModuleDef` instance with a non-empty ``m_slots`` array. This is
referred to as "multi-phase initialization", and ``PyModuleDef`` instance
should be initialized with the following function:
.. c:function:: PyObject* PyModuleDef_Init(PyModuleDef *module)
Ensures a module definition is a properly initialized Python object that
correctly reports its type and reference count.
.. XXX (ncoghlan): It's not clear if it makes sense to document PyModule_ExecDef
PyModule_FromDefAndSpec or PyModule_FromDefAndSpec2 here, as end user code
generally shouldn't be calling those.
The module initialization function (if using single phase initialization) or
a function called from a module execution slot (if using multiphase
initialization), can use the following functions to help initialize the module
state:
.. c:function:: int PyModule_SetDocString(PyObject *module, const char *docstring)
Set the docstring for *module* to *docstring*. Return ``-1`` on error, ``0``
on success.
.. c:function:: int PyModule_AddFunctions(PyObject *module, PyMethodDef *functions)
Add the functions from the ``NULL`` terminated *functions* array to *module*.
Refer to the :c:type:`PyMethodDef` documentation for details on individual
entries (due to the lack of a shared module namespace, module level
"functions" implemented in C typically receive the module as their first
parameter, making them similar to instance methods on Python classes).
.. c:function:: int PyModule_AddObject(PyObject *module, const char *name, PyObject *value)
Add an object to *module* as *name*. This is a convenience function which can
be used from the module's initialization function. This steals a reference to
*value*. Return ``-1`` on error, ``0`` on success.
.. c:function:: int PyModule_AddIntConstant(PyObject *module, const char *name, long value)
Add an integer constant to *module* as *name*. This convenience function can be
Expand Down
14 changes: 14 additions & 0 deletions Doc/library/collections.abc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@ ABC Inherits from Abstract Methods Mixin

ABCs for read-only and mutable :term:`sequences <sequence>`.

Implementation note: Some of the mixin methods, such as
:meth:`__iter__`, :meth:`__reversed__` and :meth:`index`, make
repeated calls to the underlying :meth:`__getitem__` method.
Consequently, if :meth:`__getitem__` is implemented with constant
access speed, the mixin methods will have linear performance;
however, if the underlying method is linear (as it would be with a
linked list), the mixins will have quadratic performance and will
likely need to be overridden.

.. versionchanged:: 3.5
The index() method added support for *stop* and *start*
arguments.


.. class:: Set
MutableSet

Expand Down
11 changes: 6 additions & 5 deletions Doc/library/collections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ or subtracting from an empty counter.
Section 4.6.3, Exercise 19*.

* To enumerate all distinct multisets of a given size over a given set of
elements, see :func:`itertools.combinations_with_replacement`.
elements, see :func:`itertools.combinations_with_replacement`:

map(Counter, combinations_with_replacement('ABC', 2)) --> AA AB AC BB BC CC

Expand Down Expand Up @@ -464,10 +464,11 @@ or subtracting from an empty counter.
elements in the iterable argument.


.. method:: index(x[, start[, end]])
.. method:: index(x[, start[, stop]])

Return the position of *x* in the deque. Returns the first match
or raises :exc:`ValueError` if not found.
Return the position of *x* in the deque (at or after index *start*
and before index *stop*). Returns the first match or raises
:exc:`ValueError` if not found.

.. versionadded:: 3.5

Expand All @@ -493,7 +494,7 @@ or subtracting from an empty counter.

.. method:: remove(value)

Removed the first occurrence of *value*. If not found, raises a
Remove the first occurrence of *value*. If not found, raises a
:exc:`ValueError`.


Expand Down
1 change: 1 addition & 0 deletions Doc/library/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The list of modules described in this chapter is:

.. toctree::

typing.rst
pydoc.rst
doctest.rst
unittest.rst
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ are always available. They are listed here in alphabetical order.

.. class:: complex([real[, imag]])

Return a complex number with the value *real* + *imag*\*j or convert a string
Return a complex number with the value *real* + *imag*\*1j or convert a string
or number to a complex number. If the first parameter is a string, it will
be interpreted as a complex number and the function must be called without a
second parameter. The second parameter can never be a string. Each argument
Expand Down
28 changes: 19 additions & 9 deletions Doc/library/importlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ generically as an :term:`importer`) to participate in the import process.
:pep:`451`
A ModuleSpec Type for the Import System

:pep:`488`
Elimination of PYO files

:pep:`489`
Multi-phase extension module initialization

:pep:`3120`
Using UTF-8 as the Default Source Encoding

Expand Down Expand Up @@ -756,9 +762,9 @@ find and load modules.
Only class methods are defined by this class to alleviate the need for
instantiation.

.. note::
Due to limitations in the extension module C-API, for now
BuiltinImporter does not implement :meth:`Loader.exec_module`.
.. versionchanged:: 3.5
As part of :pep:`489`, the builtin importer now implements
:meth:`Loader.create_module` and :meth:`Loader.exec_module`


.. class:: FrozenImporter
Expand Down Expand Up @@ -973,14 +979,18 @@ find and load modules.

Path to the extension module.

.. method:: load_module(name=None)
.. method:: create_module(spec)

Creates the module object from the given specification in accordance
with :pep:`489`.

.. versionadded:: 3.5

.. method:: exec_module(module)

Loads the extension module if and only if *fullname* is the same as
:attr:`name` or is ``None``.
Initializes the given module object in accordance with :pep:`489`.

.. note::
Due to limitations in the extension module C-API, for now
ExtensionFileLoader does not implement :meth:`Loader.exec_module`.
.. versionadded:: 3.5

.. method:: is_package(fullname)

Expand Down
34 changes: 26 additions & 8 deletions Doc/library/inspect.rst
Original file line number Diff line number Diff line change
Expand Up @@ -793,8 +793,10 @@ Classes and functions
*n* elements listed in *args*.

.. deprecated:: 3.0
Use :func:`getfullargspec` instead, which provides information about
keyword-only arguments and annotations.
Use :func:`signature` and
:ref:`Signature Object <inspect-signature-object>`, which provide a
better introspecting API for callables. This function will be removed
in Python 3.6.


.. function:: getfullargspec(func)
Expand All @@ -815,15 +817,16 @@ Classes and functions

The first four items in the tuple correspond to :func:`getargspec`.

.. note::
Consider using the new :ref:`Signature Object <inspect-signature-object>`
interface, which provides a better way of introspecting functions.

.. versionchanged:: 3.4
This function is now based on :func:`signature`, but still ignores
``__wrapped__`` attributes and includes the already bound first
parameter in the signature output for bound methods.

.. deprecated:: 3.5
Use :func:`signature` and
:ref:`Signature Object <inspect-signature-object>`, which provide a
better introspecting API for callables.


.. function:: getargvalues(frame)

Expand All @@ -833,6 +836,11 @@ Classes and functions
are the names of the ``*`` and ``**`` arguments or ``None``. *locals* is the
locals dictionary of the given frame.

.. deprecated:: 3.5
Use :func:`signature` and
:ref:`Signature Object <inspect-signature-object>`, which provide a
better introspecting API for callables.


.. function:: formatargspec(args[, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations[, formatarg, formatvarargs, formatvarkw, formatvalue, formatreturns, formatannotations]])

Expand All @@ -855,13 +863,23 @@ Classes and functions
>>> formatargspec(*getfullargspec(f))
'(a: int, b: float)'

.. deprecated:: 3.5
Use :func:`signature` and
:ref:`Signature Object <inspect-signature-object>`, which provide a
better introspecting API for callables.


.. function:: formatargvalues(args[, varargs, varkw, locals, formatarg, formatvarargs, formatvarkw, formatvalue])

Format a pretty argument spec from the four values returned by
:func:`getargvalues`. The format\* arguments are the corresponding optional
formatting functions that are called to turn names and values into strings.

.. deprecated:: 3.5
Use :func:`signature` and
:ref:`Signature Object <inspect-signature-object>`, which provide a
better introspecting API for callables.


.. function:: getmro(cls)

Expand Down Expand Up @@ -896,8 +914,8 @@ Classes and functions

.. versionadded:: 3.2

.. note::
Consider using the new :meth:`Signature.bind` instead.
.. deprecated:: 3.5
Use :meth:`Signature.bind` and :meth:`Signature.bind_partial` instead.


.. function:: getclosurevars(func)
Expand Down
10 changes: 10 additions & 0 deletions Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1937,6 +1937,16 @@ expression support in the :mod:`re` module).
>>> 'www.example.com'.strip('cmowz.')
'example'

The outermost leading and trailing *chars* argument values are stripped
from the string. Characters are removed from the leading end until
reaching a string character that is not contained in the set of
characters in *chars*. A similar action takes place on the trailing end.
For example::

>>> comment_string = '#....... Section 3.2.1 Issue #32 .......'
>>> comment_string.strip('.#! ')
'Section 3.2.1 Issue #32'


.. method:: str.swapcase()

Expand Down
Loading

0 comments on commit 4b9b363

Please sign in to comment.