Skip to content

Commit

Permalink
Merge branch 'main' into pythongh-73435-pathlib-match-recursive
Browse files Browse the repository at this point in the history
  • Loading branch information
barneygale authored Feb 20, 2023
2 parents 0741950 + a99eb5c commit e1c9731
Show file tree
Hide file tree
Showing 69 changed files with 1,238 additions and 944 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,19 @@ jobs:
PYTHONSTRICTEXTENSIONBUILD: 1
steps:
- uses: actions/checkout@v3
- name: Prepare homebrew environment variables
- name: Install Homebrew dependencies
run: brew install pkg-config [email protected] xz gdbm tcl-tk
- name: Prepare Homebrew environment variables
run: |
echo "LDFLAGS=-L$(brew --prefix tcl-tk)/lib" >> $GITHUB_ENV
echo "CFLAGS=-I$(brew --prefix gdbm)/include -I$(brew --prefix xz)/include" >> $GITHUB_ENV
echo "LDFLAGS=-L$(brew --prefix gdbm)/lib -I$(brew --prefix xz)/lib" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=$(brew --prefix [email protected])/lib/pkgconfig:$(brew --prefix tcl-tk)/lib/pkgconfig" >> $GITHUB_ENV
- name: Configure CPython
run: ./configure --with-pydebug --prefix=/opt/python-dev
run: |
./configure \
--with-pydebug \
--prefix=/opt/python-dev \
--with-openssl="$(brew --prefix [email protected])"
- name: Build CPython
run: make -j4
- name: Display build info
Expand Down
49 changes: 17 additions & 32 deletions Doc/c-api/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -402,51 +402,36 @@ Querying the error indicator
.. c:function:: PyObject *PyErr_GetRaisedException(void)
Returns the exception currently being raised, clearing the exception at
the same time. Do not confuse this with the exception currently being
handled which can be accessed with :c:func:`PyErr_GetHandledException`.
Return the exception currently being raised, clearing the error indicator at
the same time.
.. note::
This function is used by code that needs to catch exceptions,
or code that needs to save and restore the error indicator temporarily.
This function is normally only used by code that needs to catch exceptions or
by code that needs to save and restore the error indicator temporarily, e.g.::
For example::
{
PyObject *exc = PyErr_GetRaisedException();
{
PyObject *exc = PyErr_GetRaisedException();
/* ... code that might produce other errors ... */
/* ... code that might produce other errors ... */
PyErr_SetRaisedException(exc);
}
PyErr_SetRaisedException(exc);
}
.. seealso:: :c:func:`PyErr_GetHandledException`,
to save the exception currently being handled.
.. versionadded:: 3.12
.. c:function:: void PyErr_SetRaisedException(PyObject *exc)
Sets the exception currently being raised ``exc``.
If the exception is already set, it is cleared first.
``exc`` must be a valid exception.
(Violating this rules will cause subtle problems later.)
This call consumes a reference to the ``exc`` object: you must own a
reference to that object before the call and after the call you no longer own
that reference.
(If you don't understand this, don't use this function. I warned you.)
Set *exc* as the exception currently being raised,
clearing the existing exception if one is set.
.. note::
This function is normally only used by code that needs to save and restore the
error indicator temporarily. Use :c:func:`PyErr_GetRaisedException` to save
the current exception, e.g.::
{
PyObject *exc = PyErr_GetRaisedException();
/* ... code that might produce other errors ... */
.. warning::
PyErr_SetRaisedException(exc);
}
This call steals a reference to *exc*, which must be a valid exception.
.. versionadded:: 3.12
Expand Down
3 changes: 3 additions & 0 deletions Doc/data/refcounts.dat
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,9 @@ PyErr_GetExcInfo:PyObject**:ptype:+1:
PyErr_GetExcInfo:PyObject**:pvalue:+1:
PyErr_GetExcInfo:PyObject**:ptraceback:+1:

PyErr_GetRaisedException:PyObject*::+1:
PyErr_SetRaisedException::::

PyErr_GivenExceptionMatches:int:::
PyErr_GivenExceptionMatches:PyObject*:given:0:
PyErr_GivenExceptionMatches:PyObject*:exc:0:
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/argparse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1867,7 +1867,7 @@ Sub-commands
...
>>> # create the top-level parser
>>> parser = argparse.ArgumentParser()
>>> subparsers = parser.add_subparsers()
>>> subparsers = parser.add_subparsers(required=True)
>>>
>>> # create the parser for the "foo" command
>>> parser_foo = subparsers.add_parser('foo')
Expand Down
12 changes: 10 additions & 2 deletions Doc/library/asyncio-stream.rst
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,20 @@ StreamReader

.. coroutinemethod:: read(n=-1)

Read up to *n* bytes. If *n* is not provided, or set to ``-1``,
read until EOF and return all read bytes.
Read up to *n* bytes from the stream.

If *n* is not provided or set to ``-1``,
read until EOF, then return all read :class:`bytes`.
If EOF was received and the internal buffer is empty,
return an empty ``bytes`` object.

If *n* is ``0``, return an empty ``bytes`` object immediately.

If *n* is positive, return at most *n* available ``bytes``
as soon as at least 1 byte is available in the internal buffer.
If EOF is received before any byte is read, return an empty
``bytes`` object.

.. coroutinemethod:: readline()

Read one line, where "line" is a sequence of bytes
Expand Down
66 changes: 38 additions & 28 deletions Doc/library/cmath.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,27 @@ the function is then applied to the result of the conversion.

.. note::

On platforms with hardware and system-level support for signed
zeros, functions involving branch cuts are continuous on *both*
sides of the branch cut: the sign of the zero distinguishes one
side of the branch cut from the other. On platforms that do not
support signed zeros the continuity is as specified below.
For functions involving branch cuts, we have the problem of deciding how to
define those functions on the cut itself. Following Kahan's "Branch cuts for
complex elementary functions" paper, as well as Annex G of C99 and later C
standards, we use the sign of zero to distinguish one side of the branch cut
from the other: for a branch cut along (a portion of) the real axis we look
at the sign of the imaginary part, while for a branch cut along the
imaginary axis we look at the sign of the real part.

For example, the :func:`cmath.sqrt` function has a branch cut along the
negative real axis. An argument of ``complex(-2.0, -0.0)`` is treated as
though it lies *below* the branch cut, and so gives a result on the negative
imaginary axis::

>>> cmath.sqrt(complex(-2.0, -0.0))
-1.4142135623730951j

But an argument of ``complex(-2.0, 0.0)`` is treated as though it lies above
the branch cut::

>>> cmath.sqrt(complex(-2.0, 0.0))
1.4142135623730951j


Conversions to and from polar coordinates
Expand All @@ -44,14 +60,11 @@ rectangular coordinates to polar coordinates and back.

.. function:: phase(x)

Return the phase of *x* (also known as the *argument* of *x*), as a
float. ``phase(x)`` is equivalent to ``math.atan2(x.imag,
x.real)``. The result lies in the range [-\ *π*, *π*], and the branch
cut for this operation lies along the negative real axis,
continuous from above. On systems with support for signed zeros
(which includes most systems in current use), this means that the
sign of the result is the same as the sign of ``x.imag``, even when
``x.imag`` is zero::
Return the phase of *x* (also known as the *argument* of *x*), as a float.
``phase(x)`` is equivalent to ``math.atan2(x.imag, x.real)``. The result
lies in the range [-\ *π*, *π*], and the branch cut for this operation lies
along the negative real axis. The sign of the result is the same as the
sign of ``x.imag``, even when ``x.imag`` is zero::

>>> phase(complex(-1.0, 0.0))
3.141592653589793
Expand Down Expand Up @@ -92,8 +105,8 @@ Power and logarithmic functions
.. function:: log(x[, base])

Returns the logarithm of *x* to the given *base*. If the *base* is not
specified, returns the natural logarithm of *x*. There is one branch cut, from 0
along the negative real axis to -∞, continuous from above.
specified, returns the natural logarithm of *x*. There is one branch cut,
from 0 along the negative real axis to -∞.


.. function:: log10(x)
Expand All @@ -112,9 +125,9 @@ Trigonometric functions

.. function:: acos(x)

Return the arc cosine of *x*. There are two branch cuts: One extends right from
1 along the real axis to ∞, continuous from below. The other extends left from
-1 along the real axis to -∞, continuous from above.
Return the arc cosine of *x*. There are two branch cuts: One extends right
from 1 along the real axis to ∞. The other extends left from -1 along the
real axis to -∞.


.. function:: asin(x)
Expand All @@ -125,9 +138,8 @@ Trigonometric functions
.. function:: atan(x)

Return the arc tangent of *x*. There are two branch cuts: One extends from
``1j`` along the imaginary axis to ``∞j``, continuous from the right. The
other extends from ``-1j`` along the imaginary axis to ``-∞j``, continuous
from the left.
``1j`` along the imaginary axis to ``∞j``. The other extends from ``-1j``
along the imaginary axis to ``-∞j``.


.. function:: cos(x)
Expand All @@ -151,23 +163,21 @@ Hyperbolic functions
.. function:: acosh(x)

Return the inverse hyperbolic cosine of *x*. There is one branch cut,
extending left from 1 along the real axis to -∞, continuous from above.
extending left from 1 along the real axis to -∞.


.. function:: asinh(x)

Return the inverse hyperbolic sine of *x*. There are two branch cuts:
One extends from ``1j`` along the imaginary axis to ``∞j``,
continuous from the right. The other extends from ``-1j`` along
the imaginary axis to ``-∞j``, continuous from the left.
One extends from ``1j`` along the imaginary axis to ``∞j``. The other
extends from ``-1j`` along the imaginary axis to ``-∞j``.


.. function:: atanh(x)

Return the inverse hyperbolic tangent of *x*. There are two branch cuts: One
extends from ``1`` along the real axis to ````, continuous from below. The
other extends from ``-1`` along the real axis to ``-∞``, continuous from
above.
extends from ``1`` along the real axis to ````. The other extends from
``-1`` along the real axis to ``-∞``.


.. function:: cosh(x)
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/csv.rst
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ Reader objects have the following public attributes:

DictReader objects have the following public attribute:

.. attribute:: csvreader.fieldnames
.. attribute:: DictReader.fieldnames

If not passed as a parameter when creating the object, this attribute is
initialized upon first access or when the first record is read from the
Expand Down
17 changes: 8 additions & 9 deletions Doc/library/enum.rst
Original file line number Diff line number Diff line change
Expand Up @@ -696,10 +696,9 @@ Data Types

.. attribute:: STRICT

Out-of-range values cause a :exc:`ValueError` to be raised. This is the
default for :class:`Flag`::
Out-of-range values cause a :exc:`ValueError` to be raised::

>>> from enum import Flag, STRICT
>>> from enum import Flag, STRICT, auto
>>> class StrictFlag(Flag, boundary=STRICT):
... RED = auto()
... GREEN = auto()
Expand All @@ -715,9 +714,9 @@ Data Types
.. attribute:: CONFORM

Out-of-range values have invalid values removed, leaving a valid *Flag*
value::
value. This is the default for :class:`Flag`::

>>> from enum import Flag, CONFORM
>>> from enum import Flag, CONFORM, auto
>>> class ConformFlag(Flag, boundary=CONFORM):
... RED = auto()
... GREEN = auto()
Expand All @@ -731,7 +730,7 @@ Data Types
Out-of-range values lose their *Flag* membership and revert to :class:`int`.
This is the default for :class:`IntFlag`::

>>> from enum import Flag, EJECT
>>> from enum import Flag, EJECT, auto
>>> class EjectFlag(Flag, boundary=EJECT):
... RED = auto()
... GREEN = auto()
Expand All @@ -742,10 +741,10 @@ Data Types

.. attribute:: KEEP

Out-of-range values are kept, and the *Flag* membership is kept. This is
used for some stdlib flags:
Out-of-range values are kept, and the *Flag* membership is kept. This is
used for some stdlib flags::

>>> from enum import Flag, KEEP
>>> from enum import Flag, KEEP, auto
>>> class KeepFlag(Flag, boundary=KEEP):
... RED = auto()
... GREEN = auto()
Expand Down
3 changes: 3 additions & 0 deletions Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1635,6 +1635,9 @@ are always available. They are listed here in alphabetical order.
example: ``a[start:stop:step]`` or ``a[start:stop, i]``. See
:func:`itertools.islice` for an alternate version that returns an iterator.

.. versionchanged:: 3.12
Slice objects are now :term:`hashable` (provided :attr:`~slice.start`,
:attr:`~slice.stop`, and :attr:`~slice.step` are hashable).

.. function:: sorted(iterable, /, *, key=None, reverse=False)

Expand Down
21 changes: 15 additions & 6 deletions Doc/library/plistlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ Examples

Generating a plist::

import datetime
import plistlib

pl = dict(
aString = "Doodah",
aList = ["A", "B", 12, 32.1, [1, 2, 3]],
Expand All @@ -172,13 +175,19 @@ Generating a plist::
),
someData = b"<binary gunk>",
someMoreData = b"<lots of binary gunk>" * 10,
aDate = datetime.datetime.fromtimestamp(time.mktime(time.gmtime())),
aDate = datetime.datetime.now()
)
with open(fileName, 'wb') as fp:
dump(pl, fp)
print(plistlib.dumps(pl).decode())

Parsing a plist::

with open(fileName, 'rb') as fp:
pl = load(fp)
print(pl["aKey"])
import plistlib

plist = b"""<plist version="1.0">
<dict>
<key>foo</key>
<string>bar</string>
</dict>
</plist>"""
pl = plistlib.loads(plist)
print(pl["foo"])
13 changes: 12 additions & 1 deletion Doc/library/urllib.error.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,19 @@ The following exceptions are raised by :mod:`urllib.error` as appropriate:
of :exc:`IOError`.


.. exception:: HTTPError
.. exception:: HTTPError(url, code, msg, hdrs, fp)

Though being an exception (a subclass of :exc:`URLError`), an
:exc:`HTTPError` can also function as a non-exceptional file-like return
value (the same thing that :func:`~urllib.request.urlopen` returns). This
is useful when handling exotic HTTP errors, such as requests for
authentication.

.. attribute:: url

Contains the request URL.
An alias for *filename* attribute.

.. attribute:: code

An HTTP status code as defined in :rfc:`2616`. This numeric value corresponds
Expand All @@ -48,14 +53,20 @@ The following exceptions are raised by :mod:`urllib.error` as appropriate:
.. attribute:: reason

This is usually a string explaining the reason for this error.
An alias for *msg* attribute.

.. attribute:: headers

The HTTP response headers for the HTTP request that caused the
:exc:`HTTPError`.
An alias for *hdrs* attribute.

.. versionadded:: 3.4

.. attribute:: fp

A file-like object where the HTTP error body can be read from.

.. exception:: ContentTooShortError(msg, content)

This exception is raised when the :func:`~urllib.request.urlretrieve`
Expand Down
Loading

0 comments on commit e1c9731

Please sign in to comment.