Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
0a4eabb
Add is_reading() method to _UnixReadPipeTransport
Nov 4, 2019
6552563
bpo-38684: haslib: fix build when Blake2 not enabled in OpenSSL (#17043)
commodo Nov 4, 2019
f7cd057
📜🤖 Added by blurb_it.
blurb-it[bot] Nov 4, 2019
f4b1e3d
bpo-38644: Add Py_EnterRecursiveCall() to the limited API (GH-17046)
vstinner Nov 4, 2019
4ef4d51
Update Misc/NEWS.d/next/Library/2019-11-04-17-20-43.bpo-38314.zWz6_P.rst
calluw Nov 4, 2019
be434dc
bpo-38644: Pass tstate to Py_EnterRecursiveCall() (GH-16997)
vstinner Nov 4, 2019
1726909
bpo-38644: Pass tstate to _Py_CheckFunctionResult() (GH-17050)
vstinner Nov 5, 2019
25fa3ec
Fix a typo in wave module docstring (GH-17009)
micha2718l Nov 5, 2019
62161ce
closes bpo-37633: Reëxport some function compatibility wrappers for m…
benjaminp Nov 5, 2019
fbbfcce
_json.c: use Py_UNUSED() macro (GH-17053)
vstinner Nov 5, 2019
5e01a65
Update interpreter.rst (GH-17059)
Seluj78 Nov 5, 2019
b396663
bpo-35381 Remove all static state from posixmodule (GH-15892)
eduardo-elizondo Nov 5, 2019
bf17d41
bpo-37645: add new function _PyObject_FunctionStr() (GH-14890)
jdemeyer Nov 5, 2019
56698d5
bpo-38696: Fix usage example of HTTPStatus (GH-17066)
ammaraskar Nov 5, 2019
6c4c45e
bpo-38692: Add os.pidfd_open. (GH-17063)
benjaminp Nov 6, 2019
5c0c325
closes bpo-38713: Expose P_PIDFD in os if it's defined. (GH-17071)
benjaminp Nov 6, 2019
519cb87
bpo-38716: stop rotating handlers from setting inherited namer and ro…
l0rb Nov 6, 2019
7f46049
bpo-38382: Document the early-out behavior for a zero (GH-17037)
rhettinger Nov 7, 2019
9def81a
bpo-36876: Moved Parser/listnode.c statics to interpreter state. (GH-…
vsajip Nov 7, 2019
991b02d
update a deprecated assert in logging tests (GH-17079)
l0rb Nov 7, 2019
d12d0e7
bpo-38733: PyErr_Occurred() caller must hold the GIL (GH-17080)
vstinner Nov 7, 2019
6cbc84f
bpo-38613: Optimize set operations of dict keys. (GH-16961)
methane Nov 7, 2019
befa032
bpo-22367: Add tests for fcntl.lockf(). (GH-17010)
corona10 Nov 7, 2019
7e43373
bpo-38644: Add _PyObject_VectorcallTstate() (GH-17052)
vstinner Nov 8, 2019
fc6b1bf
Clarify amount of dots between package and subpackage (GH-17092)
susan-shu-c Nov 8, 2019
e27449d
bpo-38635: Simplify decoding the ZIP64 extra field and make it tolera…
serhiy-storchaka Nov 9, 2019
af46450
Minor readability improvement for argument handling in itertools.repe…
rhettinger Nov 10, 2019
84ac437
bpo-38761: Register WeakSet as a MutableSet (GH-17104)
rhettinger Nov 11, 2019
a0ed99b
bpo-38438: Simplify argparse "star nargs" usage. (GH-17106)
brandtbucher Nov 11, 2019
98480ce
bpo-38771: Explict test for None in code example (GH-17108)
jonathan-scholbach Nov 12, 2019
051ff52
bpo-38565: add new cache_parameters method for lru_cache (GH-16916)
Zheaoli Nov 12, 2019
733b9a3
bpo-38385: Fix iterator/iterable terminology in statistics docs (GH-1…
rhettinger Nov 12, 2019
1b5aa07
Add is_reading() method to _UnixReadPipeTransport
Nov 4, 2019
1dbad62
Add new test case file for UNIX pipe transport functional tests
Nov 12, 2019
dd3c0d3
Merge branch 'fix-issue-38314' of github.com:callumquick/cpython into…
Nov 12, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions Doc/c-api/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ Querying the error indicator
own a reference to the return value, so you do not need to :c:func:`Py_DECREF`
it.

The caller must hold the GIL.

.. note::

Do not compare the return value to a specific exception; use
Expand Down Expand Up @@ -715,15 +717,21 @@ recursion depth automatically).
case, a :exc:`RecursionError` is set and a nonzero value is returned.
Otherwise, zero is returned.

*where* should be a string such as ``" in instance check"`` to be
concatenated to the :exc:`RecursionError` message caused by the recursion
*where* should be a UTF-8 encoded string such as ``" in instance check"`` to
be concatenated to the :exc:`RecursionError` message caused by the recursion
depth limit.

.. c:function:: void Py_LeaveRecursiveCall()
.. versionchanged:: 3.9
This function is now also available in the limited API.

.. c:function:: void Py_LeaveRecursiveCall(void)

Ends a :c:func:`Py_EnterRecursiveCall`. Must be called once for each
*successful* invocation of :c:func:`Py_EnterRecursiveCall`.

.. versionchanged:: 3.9
This function is now also available in the limited API.

Properly implementing :c:member:`~PyTypeObject.tp_repr` for container types requires
special recursion handling. In addition to protecting the stack,
:c:member:`~PyTypeObject.tp_repr` also needs to track objects to prevent cycles. The
Expand Down
1 change: 1 addition & 0 deletions Doc/c-api/object.rst
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ Object Protocol
This function now includes a debug assertion to help ensure that it
does not silently discard an active exception.


.. c:function:: PyObject* PyObject_Bytes(PyObject *o)

.. index:: builtin: bytes
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/argparse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ default values to each of the argument help messages::
>>> parser.add_argument('--foo', type=int, default=42, help='FOO!')
>>> parser.add_argument('bar', nargs='*', default=[1, 2, 3], help='BAR!')
>>> parser.print_help()
usage: PROG [-h] [--foo FOO] [bar [bar ...]]
usage: PROG [-h] [--foo FOO] [bar ...]

positional arguments:
bar BAR! (default: [1, 2, 3])
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/collections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ environment variables which in turn take precedence over default values::
parser.add_argument('-u', '--user')
parser.add_argument('-c', '--color')
namespace = parser.parse_args()
command_line_args = {k:v for k, v in vars(namespace).items() if v}
command_line_args = {k: v for k, v in vars(namespace).items() if v is not None}

combined = ChainMap(command_line_args, os.environ, defaults)
print(combined['color'])
Expand Down
8 changes: 8 additions & 0 deletions Doc/library/functools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ The :mod:`functools` module defines the following functions:
cached separately. For example, ``f(3)`` and ``f(3.0)`` will be treated
as distinct calls with distinct results.

The wrapped function is instrumented with a :func:`cache_parameters`
function that returns a new :class:`dict` showing the values for *maxsize*
and *typed*. This is for information purposes only. Mutating the values
has no effect.

To help measure the effectiveness of the cache and tune the *maxsize*
parameter, the wrapped function is instrumented with a :func:`cache_info`
function that returns a :term:`named tuple` showing *hits*, *misses*,
Expand Down Expand Up @@ -178,6 +183,9 @@ The :mod:`functools` module defines the following functions:
.. versionchanged:: 3.8
Added the *user_function* option.

.. versionadded:: 3.9
Added the function :func:`cache_parameters`

.. decorator:: total_ordering

Given a class defining one or more rich comparison ordering methods, this
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/http.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ associated messages through the :class:`http.HTTPStatus` enum:
<HTTPStatus.OK: 200>
>>> HTTPStatus.OK == 200
True
>>> http.HTTPStatus.OK.value
>>> HTTPStatus.OK.value
200
>>> HTTPStatus.OK.phrase
'OK'
Expand Down
25 changes: 24 additions & 1 deletion Doc/library/os.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3539,6 +3539,19 @@ written in Python, such as a mail server's external command delivery program.
.. availability:: Unix.


.. function:: pidfd_open(pid, flags=0)

Return a file descriptor referring to the process *pid*. This descriptor can
be used to perform process management without races and signals. The *flags*
argument is provided for future extensions; no flag values are currently
defined.

See the :manpage:`pidfd_open(2)` man page for more details.

.. availability:: Linux 5.3+
.. versionadded:: 3.9


.. function:: plock(op)

Lock program segments into memory. The value of *op* (defined in
Expand Down Expand Up @@ -3908,7 +3921,8 @@ written in Python, such as a mail server's external command delivery program.
.. function:: waitid(idtype, id, options)

Wait for the completion of one or more child processes.
*idtype* can be :data:`P_PID`, :data:`P_PGID` or :data:`P_ALL`.
*idtype* can be :data:`P_PID`, :data:`P_PGID`, :data:`P_ALL`, or
:data:`P_PIDFD` on Linux.
*id* specifies the pid to wait on.
*options* is constructed from the ORing of one or more of :data:`WEXITED`,
:data:`WSTOPPED` or :data:`WCONTINUED` and additionally may be ORed with
Expand All @@ -3933,6 +3947,15 @@ written in Python, such as a mail server's external command delivery program.

.. versionadded:: 3.3

.. data:: P_PIDFD

This is a Linux-specific *idtype* that indicates that *id* is a file
descriptor that refers to a process.

.. availability:: Linux 5.4+

.. versionadded:: 3.9

.. data:: WEXITED
WSTOPPED
WNOWAIT
Expand Down
6 changes: 3 additions & 3 deletions Doc/library/pdb.rst
Original file line number Diff line number Diff line change
Expand Up @@ -296,20 +296,20 @@ by the local file.
Temporary breakpoint, which is removed automatically when it is first hit.
The arguments are the same as for :pdbcmd:`break`.

.. pdbcommand:: cl(ear) [filename:lineno | bpnumber [bpnumber ...]]
.. pdbcommand:: cl(ear) [filename:lineno | bpnumber ...]

With a *filename:lineno* argument, clear all the breakpoints at this line.
With a space separated list of breakpoint numbers, clear those breakpoints.
Without argument, clear all breaks (but first ask confirmation).

.. pdbcommand:: disable [bpnumber [bpnumber ...]]
.. pdbcommand:: disable [bpnumber ...]

Disable the breakpoints given as a space separated list of breakpoint
numbers. Disabling a breakpoint means it cannot cause the program to stop
execution, but unlike clearing a breakpoint, it remains in the list of
breakpoints and can be (re-)enabled.

.. pdbcommand:: enable [bpnumber [bpnumber ...]]
.. pdbcommand:: enable [bpnumber ...]

Enable the breakpoints specified.

Expand Down
25 changes: 15 additions & 10 deletions Doc/library/statistics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ However, for reading convenience, most of the examples show sorted sequences.

.. function:: mean(data)

Return the sample arithmetic mean of *data* which can be a sequence or iterator.
Return the sample arithmetic mean of *data* which can be a sequence or iterable.

The arithmetic mean is the sum of the data divided by the number of data
points. It is commonly called "the average", although it is only one of many
Expand Down Expand Up @@ -122,7 +122,7 @@ However, for reading convenience, most of the examples show sorted sequences.
Convert *data* to floats and compute the arithmetic mean.

This runs faster than the :func:`mean` function and it always returns a
:class:`float`. The *data* may be a sequence or iterator. If the input
:class:`float`. The *data* may be a sequence or iterable. If the input
dataset is empty, raises a :exc:`StatisticsError`.

.. doctest::
Expand All @@ -143,7 +143,7 @@ However, for reading convenience, most of the examples show sorted sequences.

Raises a :exc:`StatisticsError` if the input dataset is empty,
if it contains a zero, or if it contains a negative value.
The *data* may be a sequence or iterator.
The *data* may be a sequence or iterable.

No special efforts are made to achieve exact results.
(However, this may change in the future.)
Expand All @@ -158,13 +158,14 @@ However, for reading convenience, most of the examples show sorted sequences.

.. function:: harmonic_mean(data)

Return the harmonic mean of *data*, a sequence or iterator of
Return the harmonic mean of *data*, a sequence or iterable of
real-valued numbers.

The harmonic mean, sometimes called the subcontrary mean, is the
reciprocal of the arithmetic :func:`mean` of the reciprocals of the
data. For example, the harmonic mean of three values *a*, *b* and *c*
will be equivalent to ``3/(1/a + 1/b + 1/c)``.
will be equivalent to ``3/(1/a + 1/b + 1/c)``. If one of the values
is zero, the result will be zero.

The harmonic mean is a type of average, a measure of the central
location of the data. It is often appropriate when averaging
Expand All @@ -190,14 +191,18 @@ However, for reading convenience, most of the examples show sorted sequences.
:exc:`StatisticsError` is raised if *data* is empty, or any element
is less than zero.

The current algorithm has an early-out when it encounters a zero
in the input. This means that the subsequent inputs are not tested
for validity. (This behavior may change in the future.)

.. versionadded:: 3.6


.. function:: median(data)

Return the median (middle value) of numeric data, using the common "mean of
middle two" method. If *data* is empty, :exc:`StatisticsError` is raised.
*data* can be a sequence or iterator.
*data* can be a sequence or iterable.

The median is a robust measure of central location and is less affected by
the presence of outliers. When the number of data points is odd, the
Expand Down Expand Up @@ -226,7 +231,7 @@ However, for reading convenience, most of the examples show sorted sequences.
.. function:: median_low(data)

Return the low median of numeric data. If *data* is empty,
:exc:`StatisticsError` is raised. *data* can be a sequence or iterator.
:exc:`StatisticsError` is raised. *data* can be a sequence or iterable.

The low median is always a member of the data set. When the number of data
points is odd, the middle value is returned. When it is even, the smaller of
Expand All @@ -246,7 +251,7 @@ However, for reading convenience, most of the examples show sorted sequences.
.. function:: median_high(data)

Return the high median of data. If *data* is empty, :exc:`StatisticsError`
is raised. *data* can be a sequence or iterator.
is raised. *data* can be a sequence or iterable.

The high median is always a member of the data set. When the number of data
points is odd, the middle value is returned. When it is even, the larger of
Expand All @@ -267,7 +272,7 @@ However, for reading convenience, most of the examples show sorted sequences.

Return the median of grouped continuous data, calculated as the 50th
percentile, using interpolation. If *data* is empty, :exc:`StatisticsError`
is raised. *data* can be a sequence or iterator.
is raised. *data* can be a sequence or iterable.

.. doctest::

Expand Down Expand Up @@ -376,7 +381,7 @@ However, for reading convenience, most of the examples show sorted sequences.

.. function:: pvariance(data, mu=None)

Return the population variance of *data*, a non-empty sequence or iterator
Return the population variance of *data*, a non-empty sequence or iterable
of real-valued numbers. Variance, or second moment about the mean, is a
measure of the variability (spread or dispersion) of data. A large
variance indicates that the data is spread out; a small variance indicates
Expand Down
2 changes: 1 addition & 1 deletion Doc/reference/import.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ module. Specifically, any module that contains a ``__path__`` attribute is
considered a package.

All modules have a name. Subpackage names are separated from their parent
package name by dots, akin to Python's standard attribute access syntax. Thus
package name by a dot, akin to Python's standard attribute access syntax. Thus
you might have a module called :mod:`sys` and a package called :mod:`email`,
which in turn has a subpackage called :mod:`email.mime` and a module within
that subpackage called :mod:`email.mime.text`.
Expand Down
2 changes: 1 addition & 1 deletion Doc/tutorial/interpreter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ is an installation option, other places are possible; check with your local
Python guru or system administrator. (E.g., :file:`/usr/local/python` is a
popular alternative location.)

On Windows machines where you have installed from the :ref:`Microsoft Store
On Windows machines where you have installed Python from the :ref:`Microsoft Store
<windows-store>`, the :file:`python3.9` command will be available. If you have
the :ref:`py.exe launcher <launcher>` installed, you can use the :file:`py`
command. See :ref:`setting-envvars` for other ways to launch Python.
Expand Down
10 changes: 10 additions & 0 deletions Doc/whatsnew/3.9.rst
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ os
Added :data:`~os.CLD_KILLED` and :data:`~os.CLD_STOPPED` for :attr:`si_code`.
(Contributed by Dong-hee Na in :issue:`38493`.)

Exposed the Linux-specific :func:`os.pidfd_open` (:issue:`38692`) and
:data:`os.P_PIDFD` (:issue:`38713`) for process management with file
descriptors.

threading
---------

Expand Down Expand Up @@ -197,6 +201,12 @@ Optimizations
Build and C API Changes
=======================

* Provide :c:func:`Py_EnterRecursiveCall` and :c:func:`Py_LeaveRecursiveCall`
as regular functions for the limited API. Previously, there were defined as
macros, but these macros didn't work with the limited API which cannot access
``PyThreadState.recursion_depth`` field. Remove ``_Py_CheckRecursionLimit``
from the stable ABI.
(Contributed by Victor Stinner in :issue:`38644`.)
* Add a new public :c:func:`PyObject_CallNoArgs` function to the C API, which
calls a callable Python object without any arguments. It is the most efficient
way to call a callable Python object without any argument.
Expand Down
43 changes: 8 additions & 35 deletions Include/ceval.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,41 +85,8 @@ PyAPI_FUNC(int) Py_MakePendingCalls(void);
PyAPI_FUNC(void) Py_SetRecursionLimit(int);
PyAPI_FUNC(int) Py_GetRecursionLimit(void);

#define Py_EnterRecursiveCall(where) \
(_Py_MakeRecCheck(PyThreadState_GET()->recursion_depth) && \
_Py_CheckRecursiveCall(where))
#define Py_LeaveRecursiveCall() \
do{ if(_Py_MakeEndRecCheck(PyThreadState_GET()->recursion_depth)) \
PyThreadState_GET()->overflowed = 0; \
} while(0)
PyAPI_FUNC(int) _Py_CheckRecursiveCall(const char *where);

/* Due to the macros in which it's used, _Py_CheckRecursionLimit is in
the stable ABI. It should be removed therefrom when possible.
*/
PyAPI_DATA(int) _Py_CheckRecursionLimit;

#ifdef USE_STACKCHECK
/* With USE_STACKCHECK, trigger stack checks in _Py_CheckRecursiveCall()
on every 64th call to Py_EnterRecursiveCall.
*/
# define _Py_MakeRecCheck(x) \
(++(x) > _Py_CheckRecursionLimit || \
++(PyThreadState_GET()->stackcheck_counter) > 64)
#else
# define _Py_MakeRecCheck(x) (++(x) > _Py_CheckRecursionLimit)
#endif

/* Compute the "lower-water mark" for a recursion limit. When
* Py_LeaveRecursiveCall() is called with a recursion depth below this mark,
* the overflowed flag is reset to 0. */
#define _Py_RecursionLimitLowerWaterMark(limit) \
(((limit) > 200) \
? ((limit) - 50) \
: (3 * ((limit) >> 2)))

#define _Py_MakeEndRecCheck(x) \
(--(x) < _Py_RecursionLimitLowerWaterMark(_Py_CheckRecursionLimit))
PyAPI_FUNC(int) Py_EnterRecursiveCall(const char *where);
PyAPI_FUNC(void) Py_LeaveRecursiveCall(void);

#define Py_ALLOW_RECURSION \
do { unsigned char _old = PyThreadState_GET()->recursion_critical;\
Expand Down Expand Up @@ -224,6 +191,12 @@ PyAPI_FUNC(int) _PyEval_SliceIndexNotNone(PyObject *, Py_ssize_t *);
#define FVS_MASK 0x4
#define FVS_HAVE_SPEC 0x4

#ifndef Py_LIMITED_API
# define Py_CPYTHON_CEVAL_H
# include "cpython/ceval.h"
# undef Py_CPYTHON_CEVAL_H
#endif

#ifdef __cplusplus
}
#endif
Expand Down
Loading