Skip to content

Commit

Permalink
Merge branch 'main' into pythongh-100479-add-makepath
Browse files Browse the repository at this point in the history
  • Loading branch information
barneygale committed Jan 5, 2023
2 parents 99eb8b1 + 7fba99e commit 4759d01
Show file tree
Hide file tree
Showing 212 changed files with 3,171 additions and 8,760 deletions.
5 changes: 1 addition & 4 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Expand Up @@ -63,7 +63,7 @@ Python/traceback.c @iritkatriel
# bytecode.
**/*import*.c @brettcannon @encukou @ericsnowcurrently @ncoghlan @warsaw
**/*import*.py @brettcannon @encukou @ericsnowcurrently @ncoghlan @warsaw
**/*importlib/resources/* @jaraco @warsaw @brettcannon @FFY00
**/*importlib/resources/* @jaraco @warsaw @FFY00
**/importlib/metadata/* @jaraco @warsaw

# Dates and times
Expand Down Expand Up @@ -152,8 +152,5 @@ Lib/ast.py @isidentical
/Mac/ @python/macos-team
**/*osx_support* @python/macos-team

# pathlib
**/*pathlib* @brettcannon

# zipfile.Path
**/*zipfile/*_path.py @jaraco
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Expand Up @@ -235,7 +235,7 @@ jobs:
strategy:
fail-fast: false
matrix:
openssl_ver: [1.1.1s, 3.0.7]
openssl_ver: [1.1.1s, 3.0.7, 3.1.0-beta1]
env:
OPENSSL_VER: ${{ matrix.openssl_ver }}
MULTISSL_DIR: ${{ github.workspace }}/multissl
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Expand Up @@ -15,7 +15,7 @@ jobs:

steps:
- name: "Check PRs"
uses: actions/stale@v6
uses: actions/stale@v7
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-pr-message: 'This PR is stale because it has been open for 30 days with no activity.'
Expand Down
4 changes: 2 additions & 2 deletions Doc/c-api/init.rst
Expand Up @@ -1049,7 +1049,7 @@ code, or when embedding the Python interpreter:
.. versionchanged:: 3.2
This function cannot be called before :c:func:`Py_Initialize()` anymore.
.. deprecated-removed:: 3.9 3.11
.. deprecated:: 3.9
.. index:: module: _thread
Expand All @@ -1063,7 +1063,7 @@ code, or when embedding the Python interpreter:
.. versionchanged:: 3.7
The :term:`GIL` is now initialized by :c:func:`Py_Initialize()`.
.. deprecated-removed:: 3.9 3.11
.. deprecated:: 3.9
.. c:function:: PyThreadState* PyEval_SaveThread()
Expand Down
3 changes: 2 additions & 1 deletion Doc/c-api/typeobj.rst
Expand Up @@ -452,6 +452,7 @@ slot typedefs
| | | |
| | :c:type:`PyObject` * | |
| | :c:type:`Py_ssize_t` | |
| | :c:type:`PyObject` * | |
+-----------------------------+-----------------------------+----------------------+
| :c:type:`objobjproc` | .. line-block:: | int |
| | | |
Expand Down Expand Up @@ -2633,7 +2634,7 @@ Slot Type typedefs
.. c:type:: PyObject *(*ssizeargfunc)(PyObject *, Py_ssize_t)
.. c:type:: int (*ssizeobjargproc)(PyObject *, Py_ssize_t)
.. c:type:: int (*ssizeobjargproc)(PyObject *, Py_ssize_t, PyObject *)
.. c:type:: int (*objobjproc)(PyObject *, PyObject *)
Expand Down
40 changes: 40 additions & 0 deletions Doc/faq/programming.rst
Expand Up @@ -1026,6 +1026,46 @@ What does 'UnicodeDecodeError' or 'UnicodeEncodeError' error mean?
See the :ref:`unicode-howto`.


.. _faq-programming-raw-string-backslash:

Can I end a raw string with an odd number of backslashes?
---------------------------------------------------------

A raw string ending with an odd number of backslashes will escape the string's quote::

>>> r'C:\this\will\not\work\'
File "<stdin>", line 1
r'C:\this\will\not\work\'
^
SyntaxError: unterminated string literal (detected at line 1)

There are several workarounds for this. One is to use regular strings and double
the backslashes::

>>> 'C:\\this\\will\\work\\'
'C:\\this\\will\\work\\'

Another is to concatenate a regular string containing an escaped backslash to the
raw string::

>>> r'C:\this\will\work' '\\'
'C:\\this\\will\\work\\'

It is also possible to use :func:`os.path.join` to append a backslash on Windows::

>>> os.path.join(r'C:\this\will\work', '')
'C:\\this\\will\\work\\'

Note that while a backslash will "escape" a quote for the purposes of
determining where the raw string ends, no escaping occurs when interpreting the
value of the raw string. That is, the backslash remains present in the value of
the raw string::

>>> r'backslash\'preserved'
"backslash\\'preserved"

Also see the specification in the :ref:`language reference <strings>`.

Performance
===========

Expand Down
6 changes: 6 additions & 0 deletions Doc/howto/annotations.rst
Expand Up @@ -57,6 +57,12 @@ Accessing The Annotations Dict Of An Object In Python 3.10 And Newer
newer is to call :func:`getattr` with three arguments,
for example ``getattr(o, '__annotations__', None)``.

Before Python 3.10, accessing ``__annotations__`` on a class that
defines no annotations but that has a parent class with
annotations would return the parent's ``__annotations__``.
In Python 3.10 and newer, the child class's annotations
will be an empty dict instead.


Accessing The Annotations Dict Of An Object In Python 3.9 And Older
===================================================================
Expand Down
12 changes: 6 additions & 6 deletions Doc/library/argparse.rst
Expand Up @@ -765,7 +765,7 @@ The add_argument() method

* type_ - The type to which the command-line argument should be converted.

* choices_ - A container of the allowable values for the argument.
* choices_ - A sequence of the allowable values for the argument.

* required_ - Whether or not the command-line option may be omitted
(optionals only).
Expand Down Expand Up @@ -1209,7 +1209,7 @@ choices
^^^^^^^

Some command-line arguments should be selected from a restricted set of values.
These can be handled by passing a container object as the *choices* keyword
These can be handled by passing a sequence object as the *choices* keyword
argument to :meth:`~ArgumentParser.add_argument`. When the command line is
parsed, argument values will be checked, and an error message will be displayed
if the argument was not one of the acceptable values::
Expand All @@ -1223,9 +1223,9 @@ if the argument was not one of the acceptable values::
game.py: error: argument move: invalid choice: 'fire' (choose from 'rock',
'paper', 'scissors')

Note that inclusion in the *choices* container is checked after any type_
Note that inclusion in the *choices* sequence is checked after any type_
conversions have been performed, so the type of the objects in the *choices*
container should match the type_ specified::
sequence should match the type_ specified::

>>> parser = argparse.ArgumentParser(prog='doors.py')
>>> parser.add_argument('door', type=int, choices=range(1, 4))
Expand All @@ -1235,8 +1235,8 @@ container should match the type_ specified::
usage: doors.py [-h] {1,2,3}
doors.py: error: argument door: invalid choice: 4 (choose from 1, 2, 3)

Any container can be passed as the *choices* value, so :class:`list` objects,
:class:`set` objects, and custom containers are all supported.
Any sequence can be passed as the *choices* value, so :class:`list` objects,
:class:`tuple` objects, and custom sequences are all supported.

Use of :class:`enum.Enum` is not recommended because it is difficult to
control its appearance in usage, help, and error messages.
Expand Down
4 changes: 2 additions & 2 deletions Doc/library/compileall.rst
Expand Up @@ -199,7 +199,7 @@ Public functions

The *stripdir*, *prependdir* and *limit_sl_dest* arguments correspond to
the ``-s``, ``-p`` and ``-e`` options described above.
They may be specified as ``str``, ``bytes`` or :py:class:`os.PathLike`.
They may be specified as ``str`` or :py:class:`os.PathLike`.

If *hardlink_dupes* is true and two ``.pyc`` files with different optimization
level have the same content, use hard links to consolidate duplicate files.
Expand Down Expand Up @@ -269,7 +269,7 @@ Public functions

The *stripdir*, *prependdir* and *limit_sl_dest* arguments correspond to
the ``-s``, ``-p`` and ``-e`` options described above.
They may be specified as ``str``, ``bytes`` or :py:class:`os.PathLike`.
They may be specified as ``str`` or :py:class:`os.PathLike`.

If *hardlink_dupes* is true and two ``.pyc`` files with different optimization
level have the same content, use hard links to consolidate duplicate files.
Expand Down
6 changes: 3 additions & 3 deletions Doc/library/curses.rst
Expand Up @@ -1297,11 +1297,11 @@ the following methods and attributes:
:meth:`refresh`.


.. method:: window.vline(ch, n)
window.vline(y, x, ch, n)
.. method:: window.vline(ch, n[, attr])
window.vline(y, x, ch, n[, attr])

Display a vertical line starting at ``(y, x)`` with length *n* consisting of the
character *ch*.
character *ch* with attributes *attr*.


Constants
Expand Down
39 changes: 16 additions & 23 deletions Doc/library/dis.rst
Expand Up @@ -607,15 +607,6 @@ the original TOS1.
.. versionadded:: 3.12


.. opcode:: STOPITERATION_ERROR

Handles a StopIteration raised in a generator or coroutine.
If TOS is an instance of :exc:`StopIteration`, or :exc:`StopAsyncIteration`
replace it with a :exc:`RuntimeError`.

.. versionadded:: 3.12


.. opcode:: BEFORE_ASYNC_WITH

Resolves ``__aenter__`` and ``__aexit__`` from the object on top of the
Expand All @@ -627,13 +618,6 @@ the original TOS1.

**Miscellaneous opcodes**

.. opcode:: PRINT_EXPR

Implements the expression statement for the interactive mode. TOS is removed
from the stack and printed. In non-interactive mode, an expression statement
is terminated with :opcode:`POP_TOP`.


.. opcode:: SET_ADD (i)

Calls ``set.add(TOS1[-i], TOS)``. Used to implement set comprehensions.
Expand Down Expand Up @@ -682,13 +666,6 @@ iterations of the loop.
.. versionadded:: 3.6


.. opcode:: IMPORT_STAR

Loads all symbols not starting with ``'_'`` directly from the module TOS to
the local namespace. The module is popped after loading all names. This
opcode implements ``from module import *``.


.. opcode:: POP_EXCEPT

Pops a value from the stack, which is used to restore the exception state.
Expand Down Expand Up @@ -1422,6 +1399,22 @@ iterations of the loop.
they use their arg.


.. opcode:: CALL_INTRINSIC_1

Calls an intrinsic function with one argument. Passes the TOS as the argument
and sets TOS to the result. Used to implement functionality that is necessary
but not performance critical.

The operand determines which intrinsic function is called:

* ``0`` Not valid
* ``1`` Prints the argument to standard out. Used in the REPL.
* ``2`` Performs ``import *`` for the named module.
* ``3`` Extracts the return value from a ``StopIteration`` exception.

.. versionadded:: 3.12


**Pseudo-instructions**

These opcodes do not appear in python bytecode, they are used by the compiler
Expand Down
6 changes: 3 additions & 3 deletions Doc/library/enum.rst
Expand Up @@ -807,9 +807,9 @@ Utilities and Decorators
call an *Enum*'s :meth:`_generate_next_value_` to get an appropriate value.
For *Enum* and *IntEnum* that appropriate value will be the last value plus
one; for *Flag* and *IntFlag* it will be the first power-of-two greater
than the last value; for *StrEnum* it will be the lower-cased version of the
member's name. Care must be taken if mixing *auto()* with manually specified
values.
than the highest value; for *StrEnum* it will be the lower-cased version of
the member's name. Care must be taken if mixing *auto()* with manually
specified values.

*auto* instances are only resolved when at the top level of an assignment:

Expand Down
6 changes: 6 additions & 0 deletions Doc/library/fractions.rst
Expand Up @@ -117,6 +117,12 @@ another rational number, or from a string.

.. versionadded:: 3.8

.. method:: is_integer()

Return ``True`` if the Fraction is an integer.

.. versionadded:: 3.12

.. classmethod:: from_float(flt)

Alternative constructor which only accepts instances of
Expand Down
11 changes: 5 additions & 6 deletions Doc/library/ftplib.rst
Expand Up @@ -85,7 +85,8 @@ The module defines the following items:
The *encoding* parameter was added, and the default was changed from
Latin-1 to UTF-8 to follow :rfc:`2640`.

.. class:: FTP_TLS(host='', user='', passwd='', acct='', keyfile=None, certfile=None, context=None, timeout=None, source_address=None, *, encoding='utf-8')
.. class:: FTP_TLS(host='', user='', passwd='', acct='', *, context=None,
timeout=None, source_address=None, encoding='utf-8')

A :class:`FTP` subclass which adds TLS support to FTP as described in
:rfc:`4217`.
Expand All @@ -96,10 +97,6 @@ The module defines the following items:
options, certificates and private keys into a single (potentially
long-lived) structure. Please read :ref:`ssl-security` for best practices.

*keyfile* and *certfile* are a legacy alternative to *context* -- they
can point to PEM-formatted private key and certificate chain files
(respectively) for the SSL connection.

.. versionadded:: 3.2

.. versionchanged:: 3.3
Expand All @@ -111,7 +108,6 @@ The module defines the following items:
:data:`ssl.HAS_SNI`).

.. deprecated:: 3.6

*keyfile* and *certfile* are deprecated in favor of *context*.
Please use :meth:`ssl.SSLContext.load_cert_chain` instead, or let
:func:`ssl.create_default_context` select the system's trusted CA
Expand All @@ -123,6 +119,9 @@ The module defines the following items:
The *encoding* parameter was added, and the default was changed from
Latin-1 to UTF-8 to follow :rfc:`2640`.

.. versionchanged:: 3.12
The deprecated *keyfile* and *certfile* parameters have been removed.

Here's a sample session using the :class:`FTP_TLS` class::

>>> ftps = FTP_TLS('ftp.pureftpd.org')
Expand Down

0 comments on commit 4759d01

Please sign in to comment.