Skip to content

Commit

Permalink
Merge branch 'main' into supermon
Browse files Browse the repository at this point in the history
* main: (26 commits)
  pythongh-104028: Reduce object creation while calling callback function from gc (pythongh-104030)
  pythongh-104036: Fix direct invocation of test_typing (python#104037)
  pythongh-102213: Optimize the performance of `__getattr__` (pythonGH-103761)
  pythongh-103895: Improve how invalid `Exception.__notes__` are displayed (python#103897)
  Adjust expression from `==` to `!=` in alignment with the meaning of the paragraph. (pythonGH-104021)
  pythongh-88496: Fix IDLE test hang on macOS (python#104025)
  Improve int test coverage (python#104024)
  pythongh-88773: Added teleport method to Turtle library (python#103974)
  pythongh-104015: Fix direct invocation of `test_dataclasses` (python#104017)
  pythongh-104012: Ensure test_calendar.CalendarTestCase.test_deprecation_warning consistently passes (python#104014)
  pythongh-103977: compile re expressions in platform.py only if required (python#103981)
  pythongh-98003: Inline call frames for CALL_FUNCTION_EX (pythonGH-98004)
  Replace Netlify with Read the Docs build previews (python#103843)
  Update name in acknowledgements and add mailmap (python#103696)
  pythongh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (python#103927)
  Remove non-existing tools from Sundry skiplist (python#103991)
  pythongh-103793: Defer formatting task name (python#103767)
  pythongh-87092: change assembler to use instruction sequence instead of CFG (python#103933)
  pythongh-103636: issue warning for deprecated calendar constants (python#103833)
  Various small fixes to dis docs (python#103923)
  ...
  • Loading branch information
carljm committed May 1, 2023
2 parents 9f1db4a + e147694 commit 159b2aa
Show file tree
Hide file tree
Showing 82 changed files with 898 additions and 1,931 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/documentation-links.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Read the Docs PR preview
# Automatically edits a pull request's descriptions with a link
# to the documentation's preview on Read the Docs.

on:
pull_request_target:
types:
- opened
paths:
- 'Doc/**'
- '.github/workflows/doc.yml'

permissions:
pull-requests: write

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
documentation-links:
runs-on: ubuntu-latest
steps:
- uses: readthedocs/actions/preview@v1
with:
project-slug: "cpython-previews"
single-version: "true"
3 changes: 3 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This file sets the canonical name for contributors to the repository.
# Documentation: https://git-scm.com/docs/gitmailmap
Amethyst Reese <amethyst@n7.gg> <john@noswap.com>
18 changes: 18 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Project page: https://readthedocs.org/projects/cpython-previews/

version: 2

sphinx:
configuration: Doc/conf.py

build:
os: ubuntu-22.04
tools:
python: "3"

commands:
- make -C Doc venv html
- mkdir _readthedocs
- mv Doc/build/html _readthedocs/html
2 changes: 2 additions & 0 deletions Doc/c-api/import.rst
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ Importing Modules
.. versionchanged:: 3.3
Uses :func:`imp.source_from_cache()` in calculating the source path if
only the bytecode path is provided.
.. versionchanged:: 3.12
No longer uses the removed ``imp`` module.
.. c:function:: long PyImport_GetMagicNumber()
Expand Down
11 changes: 6 additions & 5 deletions Doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,13 @@
# Short title used e.g. for <title> HTML tags.
html_short_title = '%s Documentation' % release

# Deployment preview information, from Netlify
# (See netlify.toml and https://docs.netlify.com/configure-builds/environment-variables/#git-metadata)
# Deployment preview information
# (See .readthedocs.yml and https://docs.readthedocs.io/en/stable/reference/environment-variables.html)
repository_url = os.getenv("READTHEDOCS_GIT_CLONE_URL")
html_context = {
"is_deployment_preview": os.getenv("IS_DEPLOYMENT_PREVIEW"),
"repository_url": os.getenv("REPOSITORY_URL"),
"pr_id": os.getenv("REVIEW_ID")
"is_deployment_preview": os.getenv("READTHEDOCS_VERSION_TYPE") == "external",
"repository_url": repository_url.removesuffix(".git") if repository_url else None,
"pr_id": os.getenv("READTHEDOCS_VERSION")
}

# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
Expand Down
52 changes: 52 additions & 0 deletions Doc/library/calendar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,58 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is
2 BC, and so on.


.. class:: Day

Enumeration defining the days of the week as integer constants, from 0 to 6.

.. attribute:: MONDAY

.. attribute:: TUESDAY

.. attribute:: WEDNESDAY

.. attribute:: THURSDAY

.. attribute:: FRIDAY

.. attribute:: SATURDAY

.. attribute:: SUNDAY

.. versionadded:: 3.12


.. class:: Month

Enumeration defining months of the year as integer constants, from 1 to 12.

.. attribute:: JANUARY

.. attribute:: FEBRUARY

.. attribute:: MARCH

.. attribute:: APRIL

.. attribute:: MAY

.. attribute:: JUNE

.. attribute:: JULY

.. attribute:: AUGUST

.. attribute:: SEPTEMBER

.. attribute:: OCTOBER

.. attribute:: NOVEMBER

.. attribute:: DECEMBER

.. versionadded:: 3.12


.. class:: Calendar(firstweekday=0)

Creates a :class:`Calendar` object. *firstweekday* is an integer specifying the
Expand Down
45 changes: 23 additions & 22 deletions Doc/library/dataclasses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -437,19 +437,19 @@ Module contents

The newly returned object is created by calling the :meth:`~object.__init__`
method of the dataclass. This ensures that
:ref:`__post_init__ <post-init-processing>`, if present, is also called.
:meth:`__post_init__`, if present, is also called.

Init-only variables without default values, if any exist, must be
specified on the call to :func:`replace` so that they can be passed to
:meth:`~object.__init__` and :ref:`__post_init__ <post-init-processing>`.
:meth:`~object.__init__` and :meth:`__post_init__`.

It is an error for ``changes`` to contain any fields that are
defined as having ``init=False``. A :exc:`ValueError` will be raised
in this case.

Be forewarned about how ``init=False`` fields work during a call to
:func:`replace`. They are not copied from the source object, but
rather are initialized in :ref:`__post_init__ <post-init-processing>`, if they're
rather are initialized in :meth:`__post_init__`, if they're
initialized at all. It is expected that ``init=False`` fields will
be rarely and judiciously used. If they are used, it might be wise
to have alternate class constructors, or perhaps a custom
Expand Down Expand Up @@ -510,30 +510,31 @@ Module contents
Post-init processing
--------------------

The generated :meth:`~object.__init__` code will call a method named
:meth:`!__post_init__`, if :meth:`!__post_init__` is defined on the
class. It will normally be called as ``self.__post_init__()``.
However, if any ``InitVar`` fields are defined, they will also be
passed to :meth:`!__post_init__` in the order they were defined in the
class. If no :meth:`~object.__init__` method is generated, then
:meth:`!__post_init__` will not automatically be called.
.. function:: __post_init__()

Among other uses, this allows for initializing field values that
depend on one or more other fields. For example::
When defined on the class, it will be called by the generated
:meth:`~object.__init__`, normally as ``self.__post_init__()``.
However, if any ``InitVar`` fields are defined, they will also be
passed to :meth:`__post_init__` in the order they were defined in the
class. If no :meth:`~object.__init__` method is generated, then
:meth:`__post_init__` will not automatically be called.

@dataclass
class C:
a: float
b: float
c: float = field(init=False)
Among other uses, this allows for initializing field values that
depend on one or more other fields. For example::

def __post_init__(self):
self.c = self.a + self.b
@dataclass
class C:
a: float
b: float
c: float = field(init=False)

def __post_init__(self):
self.c = self.a + self.b

The :meth:`~object.__init__` method generated by :func:`dataclass` does not call base
class :meth:`~object.__init__` methods. If the base class has an :meth:`~object.__init__` method
that has to be called, it is common to call this method in a
:meth:`!__post_init__` method::
:meth:`__post_init__` method::

@dataclass
class Rectangle:
Expand All @@ -552,7 +553,7 @@ don't need to be called, since the derived dataclass will take care of
initializing all fields of any base class that is a dataclass itself.

See the section below on init-only variables for ways to pass
parameters to :meth:`!__post_init__`. Also see the warning about how
parameters to :meth:`__post_init__`. Also see the warning about how
:func:`replace` handles ``init=False`` fields.

Class variables
Expand All @@ -576,7 +577,7 @@ is an ``InitVar``, it is considered a pseudo-field called an init-only
field. As it is not a true field, it is not returned by the
module-level :func:`fields` function. Init-only fields are added as
parameters to the generated :meth:`~object.__init__` method, and are passed to
the optional :ref:`__post_init__ <post-init-processing>` method. They are not otherwise used
the optional :meth:`__post_init__` method. They are not otherwise used
by dataclasses.

For example, suppose a field will be initialized from a database, if a
Expand Down
Loading

0 comments on commit 159b2aa

Please sign in to comment.