diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 000000000..5230b7695
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,15 @@
+root = true
+
+[*.{py,c,cpp,h,rst,md,yml}]
+trim_trailing_whitespace = true
+insert_final_newline = true
+indent_style = space
+
+[*.{py,c,cpp,h}]
+indent_size = 4
+
+[*.rst]
+indent_size = 3
+
+[*.{css,yml}]
+indent_size = 2
diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md
index 45402ea7f..235382276 100644
--- a/.github/CODE_OF_CONDUCT.md
+++ b/.github/CODE_OF_CONDUCT.md
@@ -4,9 +4,9 @@ Code of Conduct
Please note that all interactions on
[Python Software Foundation](https://www.python.org/psf-landing/)-supported
infrastructure is [covered](https://www.python.org/psf/records/board/minutes/2014-01-06/#management-of-the-psfs-web-properties)
-by the [PSF Code of Conduct](https://www.python.org/psf/conduct/),
+by the [PSF Code of Conduct](https://policies.python.org/python.org/code-of-conduct/),
which includes all infrastructure used in the development of Python itself
-(e.g. mailing lists, issue trackers, GitHub, etc.).
+(for example, mailing lists, issue trackers, GitHub, etc.).
In general this means everyone is expected to be open, considerate, and
respectful of others no matter what their position is within the project.
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index c54abaedc..028715319 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -29,17 +29,17 @@ our workflow that are not covered by a bot or status check are:
## Setting Expectations
-Due to the fact that this project is entirely volunteer-run (i.e. no one is paid
+Due to the fact that this project is entirely volunteer-run (that is, no one is paid
to work on Python full-time), we unfortunately can make no guarantees as to if
or when a core developer will get around to reviewing your pull request.
If no core developer has done a review or responded to changes made because of a
-"changes requested" review, please feel free to email [python-dev](https://mail.python.org/mailman3/lists/python-dev.python.org/) to ask if
-someone could take a look at your pull request.
+"changes requested" review, please consider seeking assistance through the
+[Core Development Discourse category](https://discuss.python.org/c/core-dev/23).
## Code of Conduct
All interactions for this project are covered by the
-[PSF Code of Conduct](https://www.python.org/psf/conduct/). Everyone is
+[PSF Code of Conduct](https://policies.python.org/python.org/code-of-conduct/). Everyone is
expected to be open, considerate, and respectful of others no matter their
position within the project.
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
deleted file mode 100644
index 78aa34d6b..000000000
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ /dev/null
@@ -1,25 +0,0 @@
----
-name: Bug report
-about: Create a report to help us improve
-title: ''
-labels: ''
-assignees: ''
-
----
-
-> Note: This repo is for the Python devguide. If you are requesting an
-enhancement for the Python language or CPython interpreter,
-then the CPython issue tracker is better
-suited for this report: https://github.com/python/cpython/issues
-
-**Describe the bug**
-A clear and concise description of what the bug is.
-
-**Expected behavior**
-A clear and concise description of what you expected to happen.
-
-**Screenshots**
-If applicable, add screenshots to help explain your problem.
-
-**Additional context**
-Add any other context about the problem here.
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
new file mode 100644
index 000000000..b160c6ea1
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -0,0 +1,39 @@
+name: "Bug report"
+description: Create a report to help us improve the Python devguide
+title: "Bug:
"
+labels: ["bug"]
+assignees: []
+
+body:
+ - type: markdown
+ attributes:
+ value: |
+ > [!NOTE]
+ > This repo is for the [Python developer's guide](https://devguide.python.org/).
+ > If you are reporting a bug for the Python language or
+ > CPython interpreter, then use the
+ > [CPython issue tracker](https://github.com/python/cpython/issues) instead.
+
+ - type: textarea
+ id: bug_description
+ attributes:
+ label: "Describe the bug"
+ description: A clear and concise description of what the bug is and, optionally, what you expected to happen.
+ validations:
+ required: true
+
+ - type: textarea
+ id: screenshots
+ attributes:
+ label: "Screenshots"
+ description: If applicable, add screenshots to help explain your problem.
+ validations:
+ required: false
+
+ - type: textarea
+ id: additional_context
+ attributes:
+ label: "Additional context"
+ description: Add any other context about the problem here.
+ validations:
+ required: false
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
new file mode 100644
index 000000000..cd8c31d2a
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -0,0 +1,14 @@
+blank_issues_enabled: false
+contact_links:
+ - name: CPython Documentation
+ url: https://docs.python.org/
+ about: Official CPython documentation - please check here before opening an issue.
+ - name: Python Website
+ url: https://python.org/
+ about: For all things Python
+ - name: PyPI Issues / Support
+ url: https://github.com/pypi/support
+ about: For issues with PyPI itself, PyPI accounts, or with packages hosted on PyPI.
+ - name: CPython Issues
+ url: https://github.com/python/cpython/issues
+ about: For issues with the CPython interpreter itself.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
deleted file mode 100644
index eff8cb8f7..000000000
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ /dev/null
@@ -1,22 +0,0 @@
----
-name: Feature request
-about: Suggest an idea for this project
-title: ''
-labels: ''
-assignees: ''
-
----
-
-> Note: This repo is for the Python devguide. If you are requesting an
-enhancement for the Python language or CPython interpreter,
-then the CPython issue tracker is better
-suited for this report: https://github.com/python/cpython/issues
-
-**Describe the enhancement or feature you'd like**
-A clear and concise description of what you want to happen.
-
-**Describe alternatives you've considered**
-A clear and concise description of any alternative solutions or features you've considered.
-
-**Additional context**
-Add any other context or screenshots about the feature request here.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml
new file mode 100644
index 000000000..a4413c137
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.yml
@@ -0,0 +1,39 @@
+name: "Feature request"
+description: Suggest an idea for the Python devguide
+title: "Feature: "
+labels: ["enhancement"]
+assignees: []
+
+body:
+ - type: markdown
+ attributes:
+ value: |
+ > [!NOTE]
+ > This repo is for the [Python developer's guide](https://devguide.python.org/).
+ > If you are requesting an enhancement for the Python language or
+ > CPython interpreter, then use the
+ > [CPython issue tracker](https://github.com/python/cpython/issues) instead.
+
+ - type: textarea
+ id: feature_description
+ attributes:
+ label: "Describe the enhancement or feature you would like"
+ description: A clear and concise description of what you want to happen.
+ validations:
+ required: true
+
+ - type: textarea
+ id: alternatives
+ attributes:
+ label: "Describe alternatives you have considered"
+ description: A clear and concise description of any alternative solutions or features you have considered.
+ validations:
+ required: false
+
+ - type: textarea
+ id: additional_context
+ attributes:
+ label: "Additional context"
+ description: Add any other context or screenshots about the feature request here.
+ validations:
+ required: false
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index 839471ed0..b1d63fbf3 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -8,4 +8,4 @@ It should describe the change to be made.
Most PRs will require an issue number. Trivial changes, like fixing a typo,
do not need an issue.
--->
\ No newline at end of file
+-->
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 7374643c3..22ad254eb 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -8,19 +8,18 @@ env:
jobs:
test:
name: Check build, markup, and links
-
runs-on: ubuntu-latest
+ timeout-minutes: 10
steps:
- - uses: actions/checkout@v3
- - uses: actions/setup-python@v4
+ - uses: actions/checkout@v4
+ - uses: actions/setup-python@v5
with:
- python-version: "3.10"
- cache: pip
+ python-version: "3"
+ - name: Install uv
+ uses: hynek/setup-cached-uv@v2
- name: Build docs
run: make html
- - name: Check markup
- run: make check
- name: Link check
run: make linkcheck
continue-on-error: true
diff --git a/.github/workflows/documentation-links.yml b/.github/workflows/documentation-links.yml
new file mode 100644
index 000000000..bacb37d07
--- /dev/null
+++ b/.github/workflows/documentation-links.yml
@@ -0,0 +1,18 @@
+name: Read the Docs PR preview
+on:
+ pull_request_target:
+ types:
+ - opened
+
+permissions:
+ pull-requests: write
+
+jobs:
+ documentation-links:
+ runs-on: ubuntu-latest
+ timeout-minutes: 10
+ steps:
+ - uses: readthedocs/actions/preview@v1
+ with:
+ project-slug: "cpython-devguide"
+ single-version: "true"
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
new file mode 100644
index 000000000..5c9caf026
--- /dev/null
+++ b/.github/workflows/lint.yml
@@ -0,0 +1,15 @@
+name: Lint
+
+on: [push, pull_request, workflow_dispatch]
+
+jobs:
+ lint:
+ runs-on: ubuntu-latest
+ timeout-minutes: 10
+
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-python@v4
+ with:
+ python-version: "3.x"
+ - uses: pre-commit/action@v3.0.0
diff --git a/.gitignore b/.gitignore
index c74e78d0f..b71249201 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,7 @@ __pycache__/
# Distribution / packaging
.Python
env/
+ENV/
venv/
build/
develop-eggs/
@@ -80,13 +81,14 @@ celerybeat-schedule
# dotenv
.env
-# virtualenv
-venv/
-ENV/
-venv/
-
# Spyder project settings
.spyderproject
# Rope project settings
.ropeproject
+
+# Generated CSV and SVG files
+include/branches.csv
+include/end-of-life.csv
+include/release-cycle.svg
+include/release-cycle-all.svg
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 000000000..ae27fd1f2
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,35 @@
+repos:
+ - repo: https://github.com/astral-sh/ruff-pre-commit
+ rev: v0.5.7
+ hooks:
+ - id: ruff
+ name: Run Ruff (lint)
+ args: [--exit-non-zero-on-fix]
+ - id: ruff-format
+ name: Run Ruff (format)
+ args: [--check]
+
+ - repo: https://github.com/pre-commit/pre-commit-hooks
+ rev: v4.5.0
+ hooks:
+ - id: check-case-conflict
+ - id: check-merge-conflict
+ - id: check-json
+ - id: check-yaml
+ - id: debug-statements
+ - id: end-of-file-fixer
+ - id: trailing-whitespace
+
+ - repo: https://github.com/sphinx-contrib/sphinx-lint
+ rev: v0.9.1
+ hooks:
+ - id: sphinx-lint
+ args: [--enable=default-role]
+
+ - repo: meta
+ hooks:
+ - id: check-hooks-apply
+ - id: check-useless-excludes
+
+ci:
+ autoupdate_schedule: quarterly
diff --git a/.readthedocs.yml b/.readthedocs.yml
index 8ccea3e0b..26e5be967 100644
--- a/.readthedocs.yml
+++ b/.readthedocs.yml
@@ -11,8 +11,11 @@ sphinx:
build:
os: ubuntu-22.04
tools:
- python: "3.10"
+ python: "3"
commands:
+ - asdf plugin add uv
+ - asdf install uv latest
+ - asdf global uv latest
- make dirhtml BUILDDIR=_readthedocs
- mv _readthedocs/dirhtml _readthedocs/html
diff --git a/.ruff.toml b/.ruff.toml
new file mode 100644
index 000000000..af448e5b6
--- /dev/null
+++ b/.ruff.toml
@@ -0,0 +1,35 @@
+target-version = "py310"
+fix = true
+output-format = "full"
+line-length = 88
+
+[lint]
+preview = true
+select = [
+ "C4", # flake8-comprehensions
+ "B", # flake8-bugbear
+ "E", # pycodestyle
+ "F", # pyflakes
+ "FA", # flake8-future-annotations
+ "FLY", # flynt
+ "FURB", # refurb
+ "G", # flake8-logging-format
+ "I", # isort
+ "ISC", # flake8-implicit-str-concat
+ "LOG", # flake8-logging
+ "PERF", # perflint
+ "PGH", # pygrep-hooks
+ "PT", # flake8-pytest-style
+ "TCH", # flake8-type-checking
+ "UP", # pyupgrade
+ "W", # pycodestyle
+ "YTT", # flake8-2020
+]
+ignore = [
+ "E501", # Ignore line length errors (we use auto-formatting)
+]
+
+[format]
+preview = true
+quote-style = "preserve"
+docstring-code-format = true
diff --git a/LICENSE b/LICENSE
index 28289e879..4594fb738 100644
--- a/LICENSE
+++ b/LICENSE
@@ -113,4 +113,4 @@ Affirmer's express Statement of Purpose.
CC0 or use of the Work.
For more information, please see
-
\ No newline at end of file
+
diff --git a/Makefile b/Makefile
index b64aecc45..3d485ae2d 100644
--- a/Makefile
+++ b/Makefile
@@ -2,46 +2,45 @@
#
# You can set these variables from the command line.
-PYTHON = python3
-VENVDIR = ./venv
-BUILDDIR = _build
-SPHINXOPTS = -W --keep-going -n
-SPHINXBUILD = $(VENVDIR)/bin/sphinx-build
-SPHINXLINT = $(VENVDIR)/bin/sphinx-lint
-PAPER =
+PYTHON = python3
+VENVDIR = ./venv
+UV = uv
+SPHINXBUILD = $(VENVDIR)/bin/sphinx-build
+# Temporary: while we are using ..include:: to show the reorganization,
+# there are duplicate labels. These cause warnings, which prevent the
+# build from finishing. Turn off --fail-on-warning so we can see the
+# finished results.
+#SPHINXOPTS = --fail-on-warning
+SPHINXOPTS =
+BUILDDIR = _build
+BUILDER = html
+JOBS = auto
+SPHINXLINT = $(VENVDIR)/bin/sphinx-lint
+REQUIREMENTS = requirements.txt
# Internal variables.
-PAPEROPT_a4 = -D latex_paper_size=a4
-PAPEROPT_letter = -D latex_paper_size=letter
-ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+_ALL_SPHINX_OPTS = --jobs $(JOBS) $(SPHINXOPTS)
+_RELEASE_CYCLE = include/branches.csv \
+ include/end-of-life.csv \
+ include/release-cycle-all.svg \
+ include/release-cycle.svg
.PHONY: help
help:
@echo "Please use \`make ' where is one of"
@echo " venv to create a venv with necessary tools"
@echo " html to make standalone HTML files"
+ @echo " linkcheck to check all external links for integrity"
@echo " htmlview to open the index page built by the html target in your browser"
+ @echo " htmllive to rebuild and reload HTML files in your browser"
@echo " clean to remove the venv and build files"
- @echo " dirhtml to make HTML files named index.html in directories"
- @echo " singlehtml to make a single large HTML file"
- @echo " pickle to make pickle files"
- @echo " json to make JSON files"
- @echo " htmlhelp to make HTML files and a HTML help project"
- @echo " qthelp to make HTML files and a qthelp project"
- @echo " devhelp to make HTML files and a Devhelp project"
- @echo " epub to make an epub"
- @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
- @echo " latexpdf to make LaTeX files and run them through pdflatex"
- @echo " text to make text files"
- @echo " man to make manual pages"
- @echo " changes to make an overview of all changed/added/deprecated items"
- @echo " linkcheck to check all external links for integrity"
- @echo " doctest to run all doctests embedded in the documentation (if enabled)"
@echo " check to run a check for frequent markup errors"
+ @echo " lint to lint all the files"
.PHONY: clean
clean: clean-venv
-rm -rf $(BUILDDIR)/*
+ -rm -rf $(_RELEASE_CYCLE)
.PHONY: clean-venv
clean-venv:
@@ -59,130 +58,62 @@ venv:
.PHONY: ensure-venv
ensure-venv:
@if [ ! -d $(VENVDIR) ] ; then \
- $(PYTHON) -m venv $(VENVDIR); \
- $(VENVDIR)/bin/python3 -m pip install --upgrade pip; \
- $(VENVDIR)/bin/python3 -m pip install -r requirements.txt; \
+ set -e; \
+ echo "Creating venv in $(VENVDIR)"; \
+ if $(UV) --version >/dev/null 2>&1; then \
+ $(UV) venv --python=$(PYTHON) $(VENVDIR); \
+ VIRTUAL_ENV=$(VENVDIR) $(UV) pip install -r $(REQUIREMENTS); \
+ else \
+ $(PYTHON) -m venv $(VENVDIR); \
+ $(VENVDIR)/bin/python3 -m pip install --upgrade pip; \
+ $(VENVDIR)/bin/python3 -m pip install -r $(REQUIREMENTS); \
+ fi; \
echo "The venv has been created in the $(VENVDIR) directory"; \
fi
-.PHONY: html
-html: ensure-venv
- $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
- @echo
- @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
-
-.PHONY: dirhtml
-dirhtml: ensure-venv
- $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
- @echo
- @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
-
-.PHONY: singlehtml
-singlehtml: ensure-venv
- $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
- @echo
- @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
-
-.PHONY: pickle
-pickle: ensure-venv
- $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
- @echo
- @echo "Build finished; now you can process the pickle files."
-
-.PHONY: json
-json: ensure-venv
- $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
- @echo
- @echo "Build finished; now you can process the JSON files."
-
-.PHONY: htmlhelp
-htmlhelp: ensure-venv
- $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
- @echo
- @echo "Build finished; now you can run HTML Help Workshop with the" \
- ".hhp project file in $(BUILDDIR)/htmlhelp."
-
-.PHONY: qthelp
-qthelp: ensure-venv
- $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
- @echo
- @echo "Build finished; now you can run "qcollectiongenerator" with the" \
- ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
- @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/PythonDevelopersGuide.qhcp"
- @echo "To view the help file:"
- @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/PythonDevelopersGuide.qhc"
-
-.PHONY: devhelp
-devhelp: ensure-venv
- $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
- @echo
- @echo "Build finished."
- @echo "To view the help file:"
- @echo "# mkdir -p $$HOME/.local/share/devhelp/PythonDevelopersGuide"
- @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/PythonDevelopersGuide"
- @echo "# devhelp"
-
-.PHONY: epub
-epub: ensure-venv
- $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
- @echo
- @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
-
-.PHONY: latex
-latex: ensure-venv
- $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
- @echo
- @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
- @echo "Run \`make' in that directory to run these through (pdf)latex" \
- "(use \`make latexpdf' here to do that automatically)."
-
-.PHONY: latexpdf
-latexpdf: ensure-venv
- $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
- @echo "Running LaTeX files through pdflatex..."
- make -C $(BUILDDIR)/latex all-pdf
- @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
-
-.PHONY: text
-text: ensure-venv
- $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
- @echo
- @echo "Build finished. The text files are in $(BUILDDIR)/text."
-
-.PHONY: man
-man: ensure-venv
- $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
- @echo
- @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
-
-.PHONY: changes
-changes: ensure-venv
- $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
- @echo
- @echo "The overview file is in $(BUILDDIR)/changes."
-
-linkcheck: ensure-venv
- $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
- @echo
- @echo "Link check complete; look for any errors in the above output " \
- "or in $(BUILDDIR)/linkcheck/output.txt."
-
-.PHONY: doctest
-doctest: ensure-venv
- $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
- @echo "Testing of doctests in the sources finished, look at the " \
- "results in $(BUILDDIR)/doctest/output.txt."
-
.PHONY: htmlview
htmlview: html
$(PYTHON) -c "import os, webbrowser; webbrowser.open('file://' + os.path.realpath('_build/html/index.html'))"
+.PHONY: htmllive
+htmllive: SPHINXBUILD = $(VENVDIR)/bin/sphinx-autobuild
+# Arbitrarily selected ephemeral port between 49152–65535
+# to avoid conflicts with other processes:
+htmllive: SPHINXOPTS = --open-browser --delay 0 --port 55301
+htmllive: html
+
.PHONY: check
check: ensure-venv
# Ignore the tools and venv dirs and check that the default role is not used.
$(SPHINXLINT) -i tools -i $(VENVDIR) --enable default-role
-.PHONY: serve
-serve:
- @echo "The 'serve' target was removed, use 'htmlview' instead" \
- "(see https://github.com/python/cpython/issues/80510)"
+.PHONY: _ensure-package
+_ensure-package: venv
+ if $(UV) --version >/dev/null 2>&1; then \
+ VIRTUAL_ENV=$(VENVDIR) $(UV) pip install $(PACKAGE); \
+ else \
+ $(VENVDIR)/bin/python3 -m pip install $(PACKAGE); \
+ fi
+
+.PHONY: _ensure-pre-commit
+_ensure-pre-commit:
+ make _ensure-package PACKAGE=pre-commit
+
+.PHONY: lint
+lint: _ensure-pre-commit
+ $(VENVDIR)/bin/python3 -m pre_commit run --all-files
+
+# Defined so that "include/release-cycle.json"
+# doesn't fall through to the catch-all target.
+include/release-cycle.json:
+ @exit
+
+$(_RELEASE_CYCLE): include/release-cycle.json
+ $(VENVDIR)/bin/python3 _tools/generate_release_cycle.py
+ @echo Release cycle data generated.
+
+# Catch-all target: route all unknown targets to Sphinx using the new
+# "make mode" option.
+.PHONY: Makefile
+%: Makefile ensure-venv $(_RELEASE_CYCLE)
+ $(SPHINXBUILD) -M $@ "." "$(BUILDDIR)" $(_ALL_SPHINX_OPTS)
diff --git a/README.rst b/README.rst
index f083d9d0f..e2f0c5617 100644
--- a/README.rst
+++ b/README.rst
@@ -17,15 +17,21 @@ The CPython Developer's Guide
This guide covers how to contribute to CPython. It is known by the
-nickname of "the devguide" by the Python core developers.
+nickname of "the devguide" by the Python core team.
The official home of this guide is https://devguide.python.org.
-Compilation
+Render HTML
-----------
-For the compilation of the devguide, you need to use a version of Python which
-supports the ``venv`` module, because the ``make html`` command will create a
-virtual environment and will install the ``Sphinx`` package::
+To render the devguide to HTML under ``_build/html``, run::
make html
+
+To render the devguide to HTML, and open the result in a browser, run::
+
+ make htmlview
+
+To maintain a live view of edits as they are saved, run::
+
+ make htmllive
diff --git a/_extensions/custom_roles.py b/_extensions/custom_roles.py
deleted file mode 100644
index ceba4909e..000000000
--- a/_extensions/custom_roles.py
+++ /dev/null
@@ -1,30 +0,0 @@
-"""Sphinx extension to add custom roles.
-
-Based on https://protips.readthedocs.io/link-roles.html
-"""
-import urllib.parse
-
-from docutils import nodes
-
-
-def setup(app):
- app.add_role(
- "gh-label",
- autolink("https://github.com/python/cpython/labels/%s"),
- )
- # Parallel safety:
- # https://www.sphinx-doc.org/en/master/extdev/index.html#extension-metadata
- return {"parallel_read_safe": True, "parallel_write_safe": True}
-
-
-def autolink(pattern):
- def role(name, rawtext, text, lineno, inliner, options={}, content=[]):
- if " " in text:
- url_text = urllib.parse.quote(f"{text}")
- else:
- url_text = text
- url = pattern % (url_text,)
- node = nodes.reference(rawtext, text, refuri=url, **options)
- return [node], []
-
- return role
diff --git a/_static/activate_tab.js b/_static/activate_tab.js
new file mode 100644
index 000000000..8b5fcbabd
--- /dev/null
+++ b/_static/activate_tab.js
@@ -0,0 +1,42 @@
+// Based on https://stackoverflow.com/a/38241481/724176
+function getOS() {
+ const userAgent = window.navigator.userAgent,
+ platform =
+ window.navigator?.userAgentData?.platform || window.navigator.platform,
+ macosPlatforms = ["macOS", "Macintosh", "MacIntel", "MacPPC", "Mac68K"],
+ windowsPlatforms = ["Win32", "Win64", "Windows", "WinCE"],
+ iosPlatforms = ["iPhone", "iPad", "iPod"];
+
+ if (macosPlatforms.includes(platform)) {
+ return "macOS";
+ } else if (iosPlatforms.includes(platform)) {
+ return "iOS";
+ } else if (windowsPlatforms.includes(platform)) {
+ return "Windows";
+ } else if (/Android/.test(userAgent)) {
+ return "Android";
+ } else if (/Linux/.test(platform)) {
+ return "Unix";
+ }
+
+ return "unknown";
+}
+
+function activateTab(tabName) {
+ // Find all label elements containing the specified tab name
+ const labels = document.querySelectorAll(".tab-label");
+
+ labels.forEach((label) => {
+ if (label.textContent.includes(tabName)) {
+ // Find the associated input element using the 'for' attribute
+ const tabInputId = label.getAttribute("for");
+ const tabInput = document.getElementById(tabInputId);
+
+ // Check if the input element exists before attempting to set the "checked" attribute
+ if (tabInput) {
+ // Activate the tab by setting its "checked" attribute to true
+ tabInput.checked = true;
+ }
+ }
+ });
+}
diff --git a/_static/devguide_overrides.css b/_static/devguide_overrides.css
index 8cafebebf..5b6d67b09 100644
--- a/_static/devguide_overrides.css
+++ b/_static/devguide_overrides.css
@@ -5,3 +5,121 @@
width: 111px;
height: 110px;
}
+
+/* Release cycle chart */
+
+.release-cycle-chart {
+ width: 100%;
+}
+
+.release-cycle-chart .release-cycle-year-line {
+ stroke: var(--color-foreground-primary);
+ stroke-width: 0.8px;
+ opacity: 75%;
+}
+
+.release-cycle-chart .release-cycle-year-text {
+ fill: var(--color-foreground-primary);
+}
+
+.release-cycle-chart .release-cycle-today-line {
+ stroke: var(--color-brand-primary);
+ stroke-width: 1.6px;
+}
+
+.release-cycle-chart .release-cycle-row-shade {
+ fill: var(--color-background-item);
+ opacity: 50%;
+}
+
+.release-cycle-chart .release-cycle-version-label {
+ fill: var(--color-foreground-primary);
+}
+
+.release-cycle-chart .release-cycle-blob {
+ stroke-width: 1.6px;
+ /* default colours, overridden below for individual statuses */
+ fill: var(--color-background-primary);
+ stroke: var(--color-foreground-primary);
+}
+
+.release-cycle-chart .release-cycle-blob-label {
+ /* white looks good on both light & dark */
+ fill: white;
+}
+
+.release-cycle-chart .release-cycle-blob-label.release-cycle-status-security,
+.release-cycle-chart .release-cycle-blob-label.release-cycle-status-bugfix {
+ /* but use black to improve contrast for lighter backgrounds */
+ fill: black;
+}
+
+.release-cycle-chart .release-cycle-blob-label.release-cycle-status-end-of-life,
+.release-cycle-chart .release-cycle-blob-label.release-cycle-status-prerelease,
+.release-cycle-chart .release-cycle-blob-label.release-cycle-status-feature {
+ /* and FG when it's not in a blob */
+ fill: var(--color-foreground-primary);
+}
+
+.release-cycle-chart .release-cycle-status-end-of-life {
+ --status-bg-color: #DD2200;
+ --status-border-color: #FF8888;
+}
+
+.release-cycle-chart .release-cycle-status-security {
+ --status-bg-color: #FFDD44;
+ --status-border-color: #FF8800;
+}
+
+.release-cycle-chart .release-cycle-status-bugfix {
+ --status-bg-color: #00DD22;
+ --status-border-color: #008844;
+}
+
+.release-cycle-chart .release-cycle-status-prerelease {
+ --status-bg-color: teal;
+ --status-border-color: darkgreen;
+}
+
+.release-cycle-chart .release-cycle-status-feature {
+ --status-bg-color: #2222EE;
+ --status-border-color: #008888;
+}
+
+.release-cycle-chart .release-cycle-blob {
+ fill: var(--status-bg-color);
+ stroke: transparent;
+}
+
+.release-cycle-chart .release-cycle-blob-full {
+ fill: var(--status-bg-color);
+ stroke: var(--status-border-color);
+}
+
+.release-cycle-chart .release-cycle-border {
+ fill: transparent;
+ stroke: var(--status-border-color);
+ stroke-width: 1.6px;
+}
+
+.good pre {
+ border-left: 3px solid rgba(74, 182, 93, 1);
+}
+.bad pre {
+ border-left: 3px solid rgb(244, 76, 78);
+}
+
+.extlink-cpy-file,
+.extlink-gh-label {
+ border: 1px solid var(--color-background-border);
+ border-radius: .2em;
+ font-family: var(--font-stack--monospace);
+ font-size: var(--font-size--small--2);
+ padding: .1em .2em;
+}
+
+/* Table cells should always top-align */
+
+table.docutils td {
+ vertical-align: top;
+}
diff --git a/_static/favicon.png b/_static/favicon.png
new file mode 100644
index 000000000..462cfedd1
Binary files /dev/null and b/_static/favicon.png differ
diff --git a/_static/og-image-200x200.png b/_static/og-image-200x200.png
new file mode 100644
index 000000000..0e80751e7
Binary files /dev/null and b/_static/og-image-200x200.png differ
diff --git a/_tools/generate_release_cycle.py b/_tools/generate_release_cycle.py
new file mode 100644
index 000000000..63d98cfce
--- /dev/null
+++ b/_tools/generate_release_cycle.py
@@ -0,0 +1,200 @@
+"""Read in a JSON and generate two CSVs and an SVG file."""
+
+from __future__ import annotations
+
+import argparse
+import csv
+import datetime as dt
+import json
+
+import jinja2
+
+
+def csv_date(date_str: str, now_str: str) -> str:
+ """Format a date for CSV."""
+ if date_str > now_str:
+ # Future, add italics
+ return f"*{date_str}*"
+ return date_str
+
+
+def parse_date(date_str: str) -> dt.date:
+ if len(date_str) == len("yyyy-mm"):
+ # We need a full yyyy-mm-dd, so let's approximate
+ return dt.date.fromisoformat(date_str + "-01")
+ return dt.date.fromisoformat(date_str)
+
+
+def parse_version(ver: str) -> list[int]:
+ return [int(i) for i in ver["key"].split(".")]
+
+
+class Versions:
+ """For converting JSON to CSV and SVG."""
+
+ def __init__(self, *, limit_to_active=False, special_py27=False) -> None:
+ with open("include/release-cycle.json", encoding="UTF-8") as in_file:
+ self.versions = json.load(in_file)
+
+ # Generate a few additional fields
+ for key, version in self.versions.items():
+ version["key"] = key
+ ver_info = parse_version(version)
+ if ver_info >= [3, 13]:
+ full_years = 2
+ else:
+ full_years = 1.5
+ version["first_release_date"] = r1 = parse_date(version["first_release"])
+ version["start_security_date"] = r1 + dt.timedelta(days=full_years * 365)
+ version["end_of_life_date"] = parse_date(version["end_of_life"])
+
+ self.cutoff = min(ver["first_release_date"] for ver in self.versions.values())
+
+ if limit_to_active:
+ self.cutoff = min(
+ version["first_release_date"]
+ for version in self.versions.values()
+ if version["status"] != "end-of-life"
+ )
+ self.versions = {
+ key: version
+ for key, version in self.versions.items()
+ if version["end_of_life_date"] >= self.cutoff
+ or (special_py27 and key == "2.7")
+ }
+ if special_py27:
+ self.cutoff = min(self.cutoff, dt.date(2019, 8, 1))
+ self.id_key = "active"
+ else:
+ self.id_key = "all"
+
+ self.sorted_versions = sorted(
+ self.versions.values(),
+ key=parse_version,
+ reverse=True,
+ )
+
+ # Set the row (Y coordinate) for the chart, to allow a gap between 2.7
+ # and the rest
+ y = len(self.sorted_versions) + (1 if special_py27 else 0)
+ for version in self.sorted_versions:
+ if special_py27 and version["key"] == "2.7":
+ y -= 1
+ version["y"] = y
+ y -= 1
+
+ def write_csv(self) -> None:
+ """Output CSV files."""
+ now_str = str(dt.datetime.now(dt.timezone.utc))
+
+ versions_by_category = {"branches": {}, "end-of-life": {}}
+ headers = None
+ for details in self.sorted_versions:
+ row = {
+ "Branch": details["branch"],
+ "Schedule": f":pep:`{details['pep']}`",
+ "Status": details["status"],
+ "First release": csv_date(details["first_release"], now_str),
+ "End of life": csv_date(details["end_of_life"], now_str),
+ "Release manager": details["release_manager"],
+ }
+ headers = row.keys()
+ cat = "end-of-life" if details["status"] == "end-of-life" else "branches"
+ versions_by_category[cat][details["key"]] = row
+
+ for cat, versions in versions_by_category.items():
+ with open(f"include/{cat}.csv", "w", encoding="UTF-8", newline="") as file:
+ csv_file = csv.DictWriter(file, fieldnames=headers, lineterminator="\n")
+ csv_file.writeheader()
+ csv_file.writerows(versions.values())
+
+ def write_svg(self, today: str, out_path: str) -> None:
+ """Output SVG file."""
+ env = jinja2.Environment(
+ loader=jinja2.FileSystemLoader("_tools/"),
+ autoescape=True,
+ lstrip_blocks=True,
+ trim_blocks=True,
+ undefined=jinja2.StrictUndefined,
+ )
+ template = env.get_template("release_cycle_template.svg.jinja")
+
+ # Scale. Should be roughly the pixel size of the font.
+ # All later sizes are multiplied by this, so you can think of all other
+ # numbers being multiples of the font size, like using `em` units in
+ # CSS.
+ # (Ideally we'd actually use `em` units, but SVG viewBox doesn't take
+ # those.)
+
+ # Uppercase sizes are un-scaled
+ SCALE = 18
+
+ # Width of the drawing and main parts
+ DIAGRAM_WIDTH = 46
+ LEGEND_WIDTH = 7
+ RIGHT_MARGIN = 0.5
+
+ # Height of one line. If you change this you'll need to tweak
+ # some positioning numbers in the template as well.
+ LINE_HEIGHT = 1.5
+
+ first_date = self.cutoff
+ last_date = max(ver["end_of_life_date"] for ver in self.sorted_versions)
+
+ def date_to_x(date: dt.date) -> float:
+ """Convert datetime.date to an SVG X coordinate"""
+ num_days = (date - first_date).days
+ total_days = (last_date - first_date).days
+ ratio = num_days / total_days
+ x = ratio * (DIAGRAM_WIDTH - LEGEND_WIDTH - RIGHT_MARGIN)
+ return (x + LEGEND_WIDTH) * SCALE
+
+ def year_to_x(year: int) -> float:
+ """Convert year number to an SVG X coordinate of 1st January"""
+ return date_to_x(dt.date(year, 1, 1))
+
+ def format_year(year: int) -> str:
+ """Format year number for display"""
+ return f"'{year % 100:02}"
+
+ with open(out_path, "w", encoding="UTF-8", newline="\n") as f:
+ template.stream(
+ SCALE=SCALE,
+ diagram_width=DIAGRAM_WIDTH * SCALE,
+ diagram_height=(self.sorted_versions[0]["y"] + 2) * LINE_HEIGHT * SCALE,
+ years=range(first_date.year, last_date.year + 1),
+ line_height=LINE_HEIGHT * SCALE,
+ legend_width=LEGEND_WIDTH * SCALE,
+ right_margin=RIGHT_MARGIN * SCALE,
+ versions=list(reversed(self.sorted_versions)),
+ today=dt.datetime.strptime(today, "%Y-%m-%d").date(),
+ year_to_x=year_to_x,
+ date_to_x=date_to_x,
+ format_year=format_year,
+ id_key=self.id_key,
+ ).dump(f)
+
+
+def main() -> None:
+ parser = argparse.ArgumentParser(
+ description=__doc__, formatter_class=argparse.ArgumentDefaultsHelpFormatter
+ )
+ parser.add_argument(
+ "--today",
+ default=str(dt.date.today()),
+ metavar=" YYYY-MM-DD",
+ help="Override today for testing",
+ )
+ args = parser.parse_args()
+
+ versions = Versions()
+ assert len(versions.versions) > 10
+ versions.write_csv()
+ versions.write_svg(args.today, "include/release-cycle-all.svg")
+
+ versions = Versions(limit_to_active=True, special_py27=True)
+ versions.write_svg(args.today, "include/release-cycle.svg")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/_tools/release_cycle_template.svg.jinja b/_tools/release_cycle_template.svg.jinja
new file mode 100644
index 000000000..d3d5866a0
--- /dev/null
+++ b/_tools/release_cycle_template.svg.jinja
@@ -0,0 +1,197 @@
+
+
diff --git a/advanced-tools/coverity.rst b/advanced-tools/coverity.rst
deleted file mode 100644
index 7c165a312..000000000
--- a/advanced-tools/coverity.rst
+++ /dev/null
@@ -1,141 +0,0 @@
-.. _coverity:
-
-=============
-Coverity Scan
-=============
-
-Coverity Scan is a free service for static code analysis of Open Source
-projects. It is based on Coverity's commercial product and is able to analyze
-C, C++ and Java code.
-
-Coverity's static code analysis doesn't run the code. Instead of that it uses
-abstract interpretation to gain information about the code's control flow and
-data flow. It's able to follow all possible code paths that a program may
-take. For example the analyzer understands that ``malloc()`` returns a memory
-that must be freed with ``free()`` later. It follows all branches and function
-calls to see if all possible combinations free the memory. The analyzer is
-able to detect all sorts of issues like resource leaks (memory, file
-descriptors), NULL dereferencing, use after free, unchecked return values,
-dead code, buffer overflows, integer overflows, uninitialized variables, and
-many more.
-
-
-Access to analysis reports
-==========================
-
-The results are available on the `Coverity Scan`_ website. In order to
-access the results you have to create an account yourself. Then go to
-*Projects using Scan* and add yourself to the Python project. New members must
-be approved by an admin (see `Contact`_).
-
-Access is restricted to Python core developers only. Other individuals may be
-given access at our own discretion, too. Every now and then Coverity detects a
-critical issue in Python's code -- new analyzers may even find new bugs in
-mature code. We don't want to disclose issues prematurely.
-
-
-Building and uploading analysis
-===============================
-
-The process is automated. A script checks out the code, runs
-``cov-build`` and uploads the latest analysis to Coverity. Since Coverity has
-limited the maximum number of builds per week Python is analyzed every second
-day. The build runs on a dedicated virtual machine on PSF's infrastructure at
-OSU Open Source Labs. The process is maintained by Christian Heimes (see
-`Contact`_). At present only the tip is analyzed with the 64bit Linux tools.
-
-
-Known limitations
-=================
-
-Some aspects of Python's C code are not yet understood by Coverity.
-
-False positives
----------------
-
-``Py_BuildValue("N", PyObject*)``
- Coverity doesn't understand that ``N`` format char passes the object along
- without touching its reference count. On this ground the analyzer detects
- a resource leak. CID 719685
-
-``PyLong_FromLong()`` for negative values
- Coverity claims that ``PyLong_FromLong()`` and other ``PyLong_From*()``
- functions cannot handle a negative value because the value might be used as
- an array index in ``get_small_int()``. CID 486783
-
-``PyLong_FromLong()`` for n in [-5 ... +255]
- For integers in the range of Python's small int cache the ``PyLong_From*()``
- function can never fail and never returns NULL. CID 1058291
-
-``PyArg_ParseTupleAndKeywords(args, kwargs, "s#", &data, &length)``
- Some functions use the format char combination such as ``s#``, ``u#`` or
- ``z#`` to get data and length of a character array. Coverity doesn't
- recognize the relation between data and length. Sometimes it detects a buffer
- overflow if data is written to a fixed size buffer although
- ``length <= sizeof(buffer)``. CID 486613
-
-``path_converter()`` dereferencing after null check
- The ``path_converter()`` function in ``posixmodule.c`` makes sure that
- either ``path_t.narrow`` or ``path_t.wide`` is filled unless
- ``path_t.nullable`` is explicitly enabled. CID 719648
-
-
-Modeling
-========
-
-Modeling is explained in the *Coverity Help Center* which is available in
-the help menu of `Coverity Connect`_. `coverity_model.c`_ contains a copy of
-Python's modeling file for Coverity. Please keep the copy in sync with the
-model file in *Analysis Settings* of `Coverity Scan`_.
-
-
-Workflow
-========
-
-False positive and intentional issues
--------------------------------------
-
-If the problem is listed under `Known limitations`_ then please set the
-classification to either "False positive" or "Intentional", the action to
-"Ignore", owner to your own account and add a comment why the issue
-is considered false positive or intentional.
-
-If you think it's a new false positive or intentional then please contact an
-admin. The first step should be an updated to Python's `Modeling`_ file.
-
-
-Positive issues
----------------
-
-You should always create an issue unless it's really a trivial case. Please
-add the full url to the ticket under *Ext. Reference* and add the CID
-(Coverity ID) to both the ticket and the checkin message. It makes it much
-easier to understand the relation between tickets, fixes and Coverity issues.
-
-
-Contact
-=======
-
-Please include both Brett and Christian in any mail regarding Coverity. Mails
-to Coverity should go through Brett or Christian, too.
-
-Christian Heimes
- admin, maintainer of build machine, intermediary between Python and Coverity
-
-Brett Cannon
- co-admin
-
-Dakshesh Vyas
- Technical Manager - Coverity Scan
-
-
-.. seealso::
-
- `Coverity Scan FAQ `_
-
-
-.. _Coverity Scan: https://scan.coverity.com/
-
-.. _Coverity Connect: https://scan.coverity.com/projects/python
-
-.. _coverity_model.c: https://github.com/python/cpython/blob/main/Misc/coverity_model.c
diff --git a/advanced-tools/gdb.rst b/advanced-tools/gdb.rst
deleted file mode 100644
index 1ce4049f4..000000000
--- a/advanced-tools/gdb.rst
+++ /dev/null
@@ -1,372 +0,0 @@
-.. _gdb:
-
-===========
-GDB support
-===========
-
-.. highlight:: none
-
-If you experience low-level problems such as crashes or deadlocks
-(e.g. when tinkering with parts of CPython which are written in C),
-it can be convenient to use a low-level debugger such as gdb in
-order to diagnose and fix the issue. By default, however, gdb (or any
-of its front-ends) doesn't know about high-level information specific to the
-CPython interpreter, such as which Python function is currently executing,
-or what type or value has a given Python object represented by a standard
-``PyObject *`` pointer. We hereafter present two ways to overcome this
-limitation.
-
-
-GDB 7 and later
-===============
-
-In gdb 7, support for `extending gdb with Python
-`_ was
-added. When CPython is built you will notice a ``python-gdb.py`` file in the
-root directory of your checkout. Read the module docstring for details on how
-to use the file to enhance gdb for easier debugging of a CPython process.
-
-To activate support, you must add the directory containing ``python-gdb.py``
-to GDB's "auto-load-safe-path". Put this in your ``~/.gdbinit`` file::
-
- add-auto-load-safe-path /path/to/checkout
-
-You can also add multiple paths, separated by ``:``.
-
-This is what a backtrace looks like (truncated) when this extension is
-enabled::
-
- #0 0x000000000041a6b1 in PyObject_Malloc (nbytes=Cannot access memory at address 0x7fffff7fefe8
- ) at Objects/obmalloc.c:748
- #1 0x000000000041b7c0 in _PyObject_DebugMallocApi (id=111 'o', nbytes=24) at Objects/obmalloc.c:1445
- #2 0x000000000041b717 in _PyObject_DebugMalloc (nbytes=24) at Objects/obmalloc.c:1412
- #3 0x000000000044060a in _PyUnicode_New (length=11) at Objects/unicodeobject.c:346
- #4 0x00000000004466aa in PyUnicodeUCS2_DecodeUTF8Stateful (s=0x5c2b8d "__lltrace__", size=11, errors=0x0, consumed=
- 0x0) at Objects/unicodeobject.c:2531
- #5 0x0000000000446647 in PyUnicodeUCS2_DecodeUTF8 (s=0x5c2b8d "__lltrace__", size=11, errors=0x0)
- at Objects/unicodeobject.c:2495
- #6 0x0000000000440d1b in PyUnicodeUCS2_FromStringAndSize (u=0x5c2b8d "__lltrace__", size=11)
- at Objects/unicodeobject.c:551
- #7 0x0000000000440d94 in PyUnicodeUCS2_FromString (u=0x5c2b8d "__lltrace__") at Objects/unicodeobject.c:569
- #8 0x0000000000584abd in PyDict_GetItemString (v=
- {'Yuck': , '__builtins__': , '__file__': 'Lib/test/crashers/nasty_eq_vs_dict.py', '__package__': None, 'y': , 'dict': {0: 0, 1: 1, 2: 2, 3: 3}, '__cached__': None, '__name__': '__main__', 'z': , '__doc__': None}, key=
- 0x5c2b8d "__lltrace__") at Objects/dictobject.c:2171
-
-(Notice how the dictionary argument to ``PyDict_GetItemString`` is displayed
-as its ``repr()``, rather than an opaque ``PyObject *`` pointer.)
-
-The extension works by supplying a custom printing routine for values of type
-``PyObject *``. If you need to access lower-level details of an object, then
-cast the value to a pointer of the appropriate type. For example::
-
- (gdb) p globals
- $1 = {'__builtins__': , '__name__':
- '__main__', 'ctypes': , '__doc__': None,
- '__package__': None}
-
- (gdb) p *(PyDictObject*)globals
- $2 = {ob_refcnt = 3, ob_type = 0x3dbdf85820, ma_fill = 5, ma_used = 5,
- ma_mask = 7, ma_table = 0x63d0f8, ma_lookup = 0x3dbdc7ea70
- , ma_smalltable = {{me_hash = 7065186196740147912,
- me_key = '__builtins__', me_value = },
- {me_hash = -368181376027291943, me_key = '__name__',
- me_value ='__main__'}, {me_hash = 0, me_key = 0x0, me_value = 0x0},
- {me_hash = 0, me_key = 0x0, me_value = 0x0},
- {me_hash = -9177857982131165996, me_key = 'ctypes',
- me_value = },
- {me_hash = -8518757509529533123, me_key = '__doc__', me_value = None},
- {me_hash = 0, me_key = 0x0, me_value = 0x0}, {
- me_hash = 6614918939584953775, me_key = '__package__', me_value = None}}}
-
-The pretty-printers try to closely match the ``repr()`` implementation of the
-underlying implementation of Python, and thus vary somewhat between Python 2
-and Python 3.
-
-An area that can be confusing is that the custom printer for some types look a
-lot like gdb's built-in printer for standard types. For example, the
-pretty-printer for a Python 3 ``int`` gives a ``repr()`` that is not
-distinguishable from a printing of a regular machine-level integer::
-
- (gdb) p some_machine_integer
- $3 = 42
-
- (gdb) p some_python_integer
- $4 = 42
-
- (gdb) p *(PyLongObject*)some_python_integer
- $5 = {ob_base = {ob_base = {ob_refcnt = 8, ob_type = 0x3dad39f5e0}, ob_size = 1},
- ob_digit = {42}}
-
-A similar confusion can arise with the ``str`` type, where the output looks a
-lot like gdb's built-in printer for ``char *``::
-
- (gdb) p ptr_to_python_str
- $6 = '__builtins__'
-
-The pretty-printer for ``str`` instances defaults to using single-quotes (as
-does Python's ``repr`` for strings) whereas the standard printer for ``char *``
-values uses double-quotes and contains a hexadecimal address::
-
- (gdb) p ptr_to_char_star
- $7 = 0x6d72c0 "hello world"
-
-Here's how to see the implementation details of a ``str`` instance (for Python
-3, where a ``str`` is a ``PyUnicodeObject *``)::
-
- (gdb) p *(PyUnicodeObject*)$6
- $8 = {ob_base = {ob_refcnt = 33, ob_type = 0x3dad3a95a0}, length = 12,
- str = 0x7ffff2128500, hash = 7065186196740147912, state = 1, defenc = 0x0}
-
-As well as adding pretty-printing support for ``PyObject *``,
-the extension adds a number of commands to gdb:
-
-``py-list``
- List the Python source code (if any) for the current frame in the selected
- thread. The current line is marked with a ">"::
-
- (gdb) py-list
- 901 if options.profile:
- 902 options.profile = False
- 903 profile_me()
- 904 return
- 905
- >906 u = UI()
- 907 if not u.quit:
- 908 try:
- 909 gtk.main()
- 910 except KeyboardInterrupt:
- 911 # properly quit on a keyboard interrupt...
-
- Use ``py-list START`` to list at a different line number within the python
- source, and ``py-list START,END`` to list a specific range of lines within
- the python source.
-
-``py-up`` and ``py-down``
- The ``py-up`` and ``py-down`` commands are analogous to gdb's regular ``up``
- and ``down`` commands, but try to move at the level of CPython frames, rather
- than C frames.
-
- gdb is not always able to read the relevant frame information, depending on
- the optimization level with which CPython was compiled. Internally, the
- commands look for C frames that are executing ``PyEval_EvalFrameEx`` (which
- implements the core bytecode interpreter loop within CPython) and look up
- the value of the related ``PyFrameObject *``.
-
- They emit the frame number (at the C level) within the thread.
-
- For example::
-
- (gdb) py-up
- #37 Frame 0x9420b04, for file /usr/lib/python2.6/site-packages/
- gnome_sudoku/main.py, line 906, in start_game ()
- u = UI()
- (gdb) py-up
- #40 Frame 0x948e82c, for file /usr/lib/python2.6/site-packages/
- gnome_sudoku/gnome_sudoku.py, line 22, in start_game(main=)
- main.start_game()
- (gdb) py-up
- Unable to find an older python frame
-
- so we're at the top of the python stack. Going back down::
-
- (gdb) py-down
- #37 Frame 0x9420b04, for file /usr/lib/python2.6/site-packages/gnome_sudoku/main.py, line 906, in start_game ()
- u = UI()
- (gdb) py-down
- #34 (unable to read python frame information)
- (gdb) py-down
- #23 (unable to read python frame information)
- (gdb) py-down
- #19 (unable to read python frame information)
- (gdb) py-down
- #14 Frame 0x99262ac, for file /usr/lib/python2.6/site-packages/gnome_sudoku/game_selector.py, line 201, in run_swallowed_dialog (self=, puzzle=None, saved_games=[{'gsd.auto_fills': 0, 'tracking': {}, 'trackers': {}, 'notes': [], 'saved_at': 1270084485, 'game': '7 8 0 0 0 0 0 5 6 0 0 9 0 8 0 1 0 0 0 4 6 0 0 0 0 7 0 6 5 0 0 0 4 7 9 2 0 0 0 9 0 1 0 0 0 3 9 7 6 0 0 0 1 8 0 6 0 0 0 0 2 8 0 0 0 5 0 4 0 6 0 0 2 1 0 0 0 0 0 4 5\n7 8 0 0 0 0 0 5 6 0 0 9 0 8 0 1 0 0 0 4 6 0 0 0 0 7 0 6 5 1 8 3 4 7 9 2 0 0 0 9 0 1 0 0 0 3 9 7 6 0 0 0 1 8 0 6 0 0 0 0 2 8 0 0 0 5 0 4 0 6 0 0 2 1 0 0 0 0 0 4 5', 'gsd.impossible_hints': 0, 'timer.__absolute_start_time__': , 'gsd.hints': 0, 'timer.active_time': , 'timer.total_time': }], dialog=, saved_game_model=, sudoku_maker=, main_page=0) at remote 0x98fa6e4>, d=)
- gtk.main()
- (gdb) py-down
- #8 (unable to read python frame information)
- (gdb) py-down
- Unable to find a newer python frame
-
- and we're at the bottom of the python stack.
-
-``py-bt``
- The ``py-bt`` command attempts to display a Python-level backtrace of the
- current thread.
-
- For example::
-
- (gdb) py-bt
- #8 (unable to read python frame information)
- #11 Frame 0x9aead74, for file /usr/lib/python2.6/site-packages/gnome_sudoku/dialog_swallower.py, line 48, in run_dialog (self=, main_page=0) at remote 0x98fa6e4>, d=)
- gtk.main()
- #14 Frame 0x99262ac, for file /usr/lib/python2.6/site-packages/gnome_sudoku/game_selector.py, line 201, in run_swallowed_dialog (self=, puzzle=None, saved_games=[{'gsd.auto_fills': 0, 'tracking': {}, 'trackers': {}, 'notes': [], 'saved_at': 1270084485, 'game': '7 8 0 0 0 0 0 5 6 0 0 9 0 8 0 1 0 0 0 4 6 0 0 0 0 7 0 6 5 0 0 0 4 7 9 2 0 0 0 9 0 1 0 0 0 3 9 7 6 0 0 0 1 8 0 6 0 0 0 0 2 8 0 0 0 5 0 4 0 6 0 0 2 1 0 0 0 0 0 4 5\n7 8 0 0 0 0 0 5 6 0 0 9 0 8 0 1 0 0 0 4 6 0 0 0 0 7 0 6 5 1 8 3 4 7 9 2 0 0 0 9 0 1 0 0 0 3 9 7 6 0 0 0 1 8 0 6 0 0 0 0 2 8 0 0 0 5 0 4 0 6 0 0 2 1 0 0 0 0 0 4 5', 'gsd.impossible_hints': 0, 'timer.__absolute_start_time__': , 'gsd.hints': 0, 'timer.active_time': , 'timer.total_time': }], dialog=, saved_game_model=, sudoku_maker=)
- main.start_game()
-
- The frame numbers correspond to those displayed by gdb's standard
- ``backtrace`` command.
-
-``py-print``
- The ``py-print`` command looks up a Python name and tries to print it.
- It looks in locals within the current thread, then globals, then finally
- builtins::
-
- (gdb) py-print self
- local 'self' = ,
- main_page=0) at remote 0x98fa6e4>
- (gdb) py-print __name__
- global '__name__' = 'gnome_sudoku.dialog_swallower'
- (gdb) py-print len
- builtin 'len' =
- (gdb) py-print scarlet_pimpernel
- 'scarlet_pimpernel' not found
-
-``py-locals``
- The ``py-locals`` command looks up all Python locals within the current
- Python frame in the selected thread, and prints their representations::
-
- (gdb) py-locals
- self = ,
- main_page=0) at remote 0x98fa6e4>
- d =
-
-You can of course use other gdb commands. For example, the ``frame`` command
-takes you directly to a particular frame within the selected thread.
-We can use it to go a specific frame shown by ``py-bt`` like this::
-
- (gdb) py-bt
- (output snipped)
- #68 Frame 0xaa4560, for file Lib/test/regrtest.py, line 1548, in ()
- main()
- (gdb) frame 68
- #68 0x00000000004cd1e6 in PyEval_EvalFrameEx (f=Frame 0xaa4560, for file Lib/test/regrtest.py, line 1548, in (), throwflag=0) at Python/ceval.c:2665
- 2665 x = call_function(&sp, oparg);
- (gdb) py-list
- 1543 # Run the tests in a context manager that temporary changes the CWD to a
- 1544 # temporary and writable directory. If it's not possible to create or
- 1545 # change the CWD, the original CWD will be used. The original CWD is
- 1546 # available from test_support.SAVEDCWD.
- 1547 with test_support.temp_cwd(TESTCWD, quiet=True):
- >1548 main()
-
-The ``info threads`` command will give you a list of the threads within the
-process, and you can use the ``thread`` command to select a different one::
-
- (gdb) info threads
- 105 Thread 0x7fffefa18710 (LWP 10260) sem_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S:86
- 104 Thread 0x7fffdf5fe710 (LWP 10259) sem_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S:86
- * 1 Thread 0x7ffff7fe2700 (LWP 10145) 0x00000038e46d73e3 in select () at ../sysdeps/unix/syscall-template.S:82
-
-You can use ``thread apply all COMMAND`` or (``t a a COMMAND`` for short) to run
-a command on all threads. You can use this with ``py-bt`` to see what every
-thread is doing at the Python level::
-
- (gdb) t a a py-bt
-
- Thread 105 (Thread 0x7fffefa18710 (LWP 10260)):
- #5 Frame 0x7fffd00019d0, for file /home/david/coding/python-svn/Lib/threading.py, line 155, in _acquire_restore (self=<_RLock(_Verbose__verbose=False, _RLock__owner=140737354016512, _RLock__block=, _RLock__count=1) at remote 0xd7ff40>, count_owner=(1, 140737213728528), count=1, owner=140737213728528)
- self.__block.acquire()
- #8 Frame 0x7fffac001640, for file /home/david/coding/python-svn/Lib/threading.py, line 269, in wait (self=<_Condition(_Condition__lock=<_RLock(_Verbose__verbose=False, _RLock__owner=140737354016512, _RLock__block=, _RLock__count=1) at remote 0xd7ff40>, acquire=, _is_owned=, _release_save=, release=, _acquire_restore=, _Verbose__verbose=False, _Condition__waiters=[]) at remote 0xd7fd10>, timeout=None, waiter=, saved_state=(1, 140737213728528))
- self._acquire_restore(saved_state)
- #12 Frame 0x7fffb8001a10, for file /home/david/coding/python-svn/Lib/test/lock_tests.py, line 348, in f ()
- cond.wait()
- #16 Frame 0x7fffb8001c40, for file /home/david/coding/python-svn/Lib/test/lock_tests.py, line 37, in task (tid=140737213728528)
- f()
-
- Thread 104 (Thread 0x7fffdf5fe710 (LWP 10259)):
- #5 Frame 0x7fffe4001580, for file /home/david/coding/python-svn/Lib/threading.py, line 155, in _acquire_restore (self=<_RLock(_Verbose__verbose=False, _RLock__owner=140737354016512, _RLock__block=, _RLock__count=1) at remote 0xd7ff40>, count_owner=(1, 140736940992272), count=1, owner=140736940992272)
- self.__block.acquire()
- #8 Frame 0x7fffc8002090, for file /home/david/coding/python-svn/Lib/threading.py, line 269, in wait (self=<_Condition(_Condition__lock=<_RLock(_Verbose__verbose=False, _RLock__owner=140737354016512, _RLock__block=, _RLock__count=1) at remote 0xd7ff40>, acquire=, _is_owned=, _release_save=, release=, _acquire_restore=, _Verbose__verbose=False, _Condition__waiters=[]) at remote 0xd7fd10>, timeout=None, waiter=, saved_state=(1, 140736940992272))
- self._acquire_restore(saved_state)
- #12 Frame 0x7fffac001c90, for file /home/david/coding/python-svn/Lib/test/lock_tests.py, line 348, in f ()
- cond.wait()
- #16 Frame 0x7fffac0011c0, for file /home/david/coding/python-svn/Lib/test/lock_tests.py, line 37, in task (tid=140736940992272)
- f()
-
- Thread 1 (Thread 0x7ffff7fe2700 (LWP 10145)):
- #5 Frame 0xcb5380, for file /home/david/coding/python-svn/Lib/test/lock_tests.py, line 16, in _wait ()
- time.sleep(0.01)
- #8 Frame 0x7fffd00024a0, for file /home/david/coding/python-svn/Lib/test/lock_tests.py, line 378, in _check_notify (self=, skipped=[], _mirrorOutput=False, testsRun=39, buffer=False, _original_stderr=, _stdout_buffer=, _stderr_buffer=, _moduleSetUpFailed=False, expectedFailures=[], errors=[], _previousTestClass=, unexpectedSuccesses=[], failures=[], shouldStop=False, failfast=False) at remote 0xc185a0>, _threads=(0,), _cleanups=[], _type_equality_funcs={: , : , : , : , `_,
-you can break at C labels, such as those generated for computed gotos.
-If you are debugging an interpreter compiled with computed goto support
-(generally true, certainly when using GCC), each instruction will be
-prefaced with a label named ``TARGET_``, e.g.,
-``TARGET_LOAD_CONST``. You can then set a breakpoint with a command
-like::
-
- (gdb) break ceval.c:_PyEval_EvalFrameDefault:TARGET_LOAD_CONST
-
-Add commands, save to a file, then reload in future sessions without
-worrying that the starting line number of individual instructions
-change over time.
diff --git a/advanced-tools/index.rst b/advanced-tools/index.rst
deleted file mode 100644
index afa96741f..000000000
--- a/advanced-tools/index.rst
+++ /dev/null
@@ -1,10 +0,0 @@
-==============
-Advanced Tools
-==============
-
-.. toctree::
- :maxdepth: 5
-
- gdb
- clang
- coverity
diff --git a/conf.py b/conf.py
index c914ccc1e..5050f5c45 100644
--- a/conf.py
+++ b/conf.py
@@ -1,15 +1,13 @@
-import os
-import sys
-import time
-
-# Location of custom extensions.
-sys.path.insert(0, os.path.abspath(".") + "/_extensions")
+import json
extensions = [
- 'custom_roles',
+ 'notfound.extension',
+ 'sphinx.ext.extlinks',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx_copybutton',
+ 'sphinx_inline_tabs',
+ 'sphinxext.opengraph',
'sphinxext.rediraffe',
]
@@ -18,7 +16,7 @@
# General information about the project.
project = "Python Developer's Guide"
-copyright = f'2011-{time.strftime("%Y")}, Python Software Foundation'
+copyright = '2011 Python Software Foundation'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
@@ -30,17 +28,56 @@
'.github',
]
+nitpicky = True
+
+
html_theme = 'furo'
-html_theme_options = {}
+html_theme_options = {
+ "source_repository": "https://github.com/python/devguide",
+ "source_branch": "main",
+}
html_static_path = ['_static']
html_css_files = [
'devguide_overrides.css',
]
+html_js_files = [
+ "activate_tab.js",
+]
html_logo = "_static/python-logo.svg"
+html_favicon = "_static/favicon.png"
# Set to '' to prevent appending "documentation" to the site title
html_title = ""
+linkcheck_allowed_redirects = {
+ # Edit page
+ r"https://docs.google.com/document/d/.*/": r"https://docs.google.com/document/d/.*/edit", # noqa: E501
+ # Canonical
+ r"https://docs.python.org/": r"https://docs.python.org/3/",
+ # Translations with country codes
+ r"https://docs.python.org/[a-z-]+/": r"https://docs.python.org/[a-z-]+/3/",
+ # Personal /my/ links redirect to login page
+ r"https://discuss.python.org/my/.*": r"https://discuss.python.org/login-preferences", # noqa: E501
+ # Category number URL to full slug
+ r"https://discuss.python.org/c/\d+": r"https://discuss.python.org/c/.*",
+ # Login page
+ r"https://github.com/python/buildmaster-config/issues/new.*": r"https://github.com/login.*", # noqa: E501
+ r"https://github.com/python/core-workflow/issues/new.*": r"https://github.com/login.*", # noqa: E501
+ r"https://github.com/orgs/python/teams.*": r"https://github.com/login.*", # noqa: E501
+ # Archive redirect
+ r"https://github.com/python/cpython/archive/main.zip": r"https://codeload.github.com/python/cpython/zip/refs/heads/main", # noqa: E501
+ # Blob to tree
+ r"https://github.com/python/cpython/blob/.*": r"https://github.com/python/cpython/tree/.*", # noqa: E501
+ # HackMD shortcuts
+ r"https://hackmd.io/s/.*": r"https://hackmd.io/@.*",
+ # Read the Docs
+ r"https://python-docs-tr.readthedocs.io/": r"https://python-docs-tr.readthedocs.io/tr/.*", # noqa: E501
+ r"https://virtualenv.pypa.io/": r"https://virtualenv.pypa.io/en/latest/",
+ r"https://www.sphinx-doc.org/": r"https://www.sphinx-doc.org/en/master/",
+ # Cookie consent
+ r"https://www.youtube.com/playlist.*": r"https://consent.youtube.com/.*",
+}
+
# ignore linkcheck anchors for /#/$ANCHOR since it is used for
# dynamic pages such as http://buildbot.python.org/all/#/console
# http://www.sphinx-doc.org/en/stable/config.html?highlight=linkcheck#confval-linkcheck_anchors_ignore
@@ -48,15 +85,48 @@
# match any anchor that starts with a '/' since this is an invalid HTML anchor
r'\/.*',
]
+
+linkcheck_ignore = [
+ # Checks fail due to rate limits
+ r'https://github.com/.*',
+ r'https://www.gnu.org/software/autoconf/',
+ # The Discourse groups are private unless you are logged in
+ 'https://discuss.python.org/groups/staff',
+ 'https://discuss.python.org/groups/moderators',
+ 'https://discuss.python.org/groups/admins',
+ # "Anchor not found":
+ r'https://packaging.python.org/.*#',
+ # "-rate limited-", causing a timeout
+ r'https://stackoverflow.com/.*',
+ # Discord doesn't allow robot crawlers: "403 Client Error: Forbidden"
+ r'https://support.discord.com/hc/en-us/articles/219070107-Server-Nicknames',
+ # Patreon also gives 403 to the GHA linkcheck runner
+ r'https://www.patreon.com/.*',
+]
+
rediraffe_redirects = {
- "clang.rst": "advanced-tools/clang.rst",
- "coverity.rst": "advanced-tools/coverity.rst",
- "gdb.rst": "advanced-tools/gdb.rst",
- "coredev.rst": "core-developers/become-core-developer.rst",
- "committing.rst": "core-developers/committing.rst",
- "developers.rst": "core-developers/developer-log.rst",
- "experts.rst": "core-developers/experts.rst",
- "motivations.rst": "core-developers/motivations.rst",
+ # Development Tools
+ "clang.rst": "development-tools/clang.rst",
+ "gdb.rst": "development-tools/gdb.rst",
+ # Advanced Tools was renamed Development Tools in gh-1149
+ "advanced-tools/clang.rst": "development-tools/clang.rst",
+ "advanced-tools/gdb.rst": "development-tools/gdb.rst",
+ # Core team
+ "coredev.rst": "core-team/join-team.rst",
+ "committing.rst": "core-team/committing.rst",
+ "developers.rst": "core-team/team-log.rst",
+ "experts.rst": "core-team/experts.rst",
+ "motivations.rst": "core-team/motivations.rst",
+ # core-developers/ -> core-team/
+ "core-developers/become-core-developer.rst": "core-team/join-team.rst",
+ "core-developers/committing.rst": "core-team/committing.rst",
+ "core-developers/developer-log.rst": "core-team/team-log.rst",
+ "core-developers/experts.rst": "core-team/experts.rst",
+ "core-developers/index.rst": "core-team/index.rst",
+ "core-developers/memorialization.rst": "core-team/memorialization.rst",
+ "core-developers/motivations.rst": "core-team/motivations.rst",
+ "core-developers/responsibilities.rst": "core-team/responsibilities.rst",
+ # Developer Workflow
"c-api.rst": "developer-workflow/c-api.rst",
"communication.rst": "developer-workflow/communication-channels.rst",
"devcycle.rst": "developer-workflow/development-cycle.rst",
@@ -65,47 +135,104 @@
"langchanges.rst": "developer-workflow/lang-changes.rst",
"porting.rst": "developer-workflow/porting.rst",
"stdlibchanges.rst": "developer-workflow/stdlib.rst",
+ # Documentation
"docquality.rst": "documentation/help-documenting.rst",
"documenting.rst": "documentation/start-documenting.rst",
+ # Translating
+ "documentation/translating.rst": "documentation/translations/translating.rst",
+ "translating.rst": "documentation/translations/translating.rst",
+ "coordinating.rst": "documentation/translations/coordinating.rst",
+ # Getting Started
"fixingissues.rst": "getting-started/fixing-issues.rst",
"help.rst": "getting-started/getting-help.rst",
"gitbootcamp.rst": "getting-started/git-boot-camp.rst",
"pullrequest.rst": "getting-started/pull-request-lifecycle.rst",
"setup.rst": "getting-started/setup-building.rst",
+ # CPython Internals
"compiler.rst": "internals/compiler.rst",
"exploring.rst": "internals/exploring.rst",
"garbage_collector.rst": "internals/garbage-collector.rst",
"parser.rst": "internals/parser.rst",
+ # Testing and Buildbots
"buildbots.rst": "testing/buildbots.rst",
"coverage.rst": "testing/coverage.rst",
"buildworker.rst": "testing/new-buildbot-worker.rst",
"runtests.rst": "testing/run-write-tests.rst",
"silencewarnings.rst": "testing/silence-warnings.rst",
+ # Issues and Triaging
"gh-faq.rst": "triage/github-bpo-faq.rst",
"tracker.rst": "triage/issue-tracker.rst",
"gh-labels.rst": "triage/labels.rst",
"triaging.rst": "triage/triaging.rst",
}
-linkcheck_ignore = [
- # The voters repo is private and appears as a 404
- 'https://github.com/python/voters/',
- # The python-core team link is private, redirects to login
- 'https://github.com/orgs/python/teams/python-core',
- # The Discourse groups are private unless you are logged in
- 'https://discuss.python.org/groups/staff',
- 'https://discuss.python.org/groups/moderators',
- 'https://discuss.python.org/groups/admins',
-]
-
intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
+ 'diataxis': ('https://diataxis.fr/', None),
}
todo_include_todos = True
+# sphinx-notfound-page
+notfound_urls_prefix = "/"
+
+# Dynamically expose the Python version associated with the "main" branch.
+# Exactly one entry in ``release-cycle.json`` should have ``"branch": "main"``.
+with open("include/release-cycle.json", encoding="UTF-8") as _f:
+ _cycle = json.load(_f)
+
+_main_version = next(
+ version for version, data in _cycle.items() if data.get("branch") == "main"
+)
+
+# prolog and epilogs
+rst_prolog = f"""
+.. |draft| replace::
+ This is part of a **Draft** of the Python Contributor's Guide.
+ Text in square brackets are notes about content to fill in.
+ Currently, the devguide and this new Contributor's Guide co-exist in the
+ repo. We are using Sphinx include directives to demonstrate the re-organization.
+ The final Contributor's Guide will replace the devguide with content in only one
+ place.
+ We welcome help with this!
+
+.. |purpose| replace::
+ The :ref:`contrib-plan` page has more details about the current state of this draft
+ and **how you can help**. See more info about the Contributor Guide in the
+ discussion forum: `Refactoring the DevGuide`_.
+
+.. _Refactoring the DevGuide: https://discuss.python.org/t/refactoring-the-devguide-into-a-contribution-guide/63409
+
+.. |main_version| replace:: {_main_version}
+
+"""
+
+# sphinx.ext.extlinks
+# This config is a dictionary of external sites,
+# mapping unique short aliases to a base URL and a prefix.
+# https://www.sphinx-doc.org/en/master/usage/extensions/extlinks.html
+_repo = "https://github.com/python/cpython"
+extlinks = {
+ "cpy-file": (f"{_repo}/blob/main/%s", "%s"),
+ "gh-label": (f"{_repo}/labels/%s", "%s"),
+ "github": ("https://github.com/%s", "%s"),
+ "github-user": ("https://github.com/%s", "@%s"),
+ "pypi": ("https://pypi.org/project/%s/", "%s"),
+ "pypi-org": ("https://pypi.org/org/%s/", "%s"),
+}
+
+# sphinxext-opengraph config
+ogp_site_url = "https://devguide.python.org/"
+ogp_site_name = "Python Developer's Guide"
+ogp_image = "_static/og-image-200x200.png"
+ogp_custom_meta_tags = [
+ '',
+ '',
+ '',
+]
+
# Strip the dollar prompt when copying code
# https://sphinx-copybutton.readthedocs.io/en/latest/use.html#strip-and-configure-input-prompts-for-code-cells
-copybutton_prompt_text = "$"
+copybutton_prompt_text = "$ "
# https://sphinx-copybutton.readthedocs.io/en/latest/use.html#honor-line-continuation-characters-when-copying-multline-snippets
copybutton_line_continuation_character = "\\"
diff --git a/contrib/code/developer-workflow.rst b/contrib/code/developer-workflow.rst
new file mode 100644
index 000000000..416ca2c02
--- /dev/null
+++ b/contrib/code/developer-workflow.rst
@@ -0,0 +1,25 @@
+====================
+Development workflow
+====================
+
+.. important::
+
+ |draft|
+
+ |purpose|
+
+[This is the existing :ref:`dev-workflow` page from the devguide]
+
+.. toctree::
+ :maxdepth: 5
+
+ ../../developer-workflow/communication-channels
+ ../../developer-workflow/development-cycle
+ ../../developer-workflow/stdlib
+ ../../developer-workflow/extension-modules
+ ../../developer-workflow/c-api
+ ../../developer-workflow/lang-changes
+ ../../developer-workflow/grammar
+ ../../developer-workflow/porting
+ ../../developer-workflow/sbom
+ ../../developer-workflow/psrt
diff --git a/contrib/code/development-tools.rst b/contrib/code/development-tools.rst
new file mode 100644
index 000000000..769bba2b0
--- /dev/null
+++ b/contrib/code/development-tools.rst
@@ -0,0 +1,19 @@
+=================
+Development tools
+=================
+
+.. important::
+
+ |draft|
+
+ |purpose|
+
+[This is the existing :ref:`development-tools` page from the devguide.]
+
+.. toctree::
+ :maxdepth: 5
+
+ ../../development-tools/clinic/index
+ ../../development-tools/gdb
+ ../../development-tools/clang
+ ../../development-tools/warnings
diff --git a/contrib/code/git.rst b/contrib/code/git.rst
new file mode 100644
index 000000000..7c7aaa57b
--- /dev/null
+++ b/contrib/code/git.rst
@@ -0,0 +1,11 @@
+========
+Git tips
+========
+
+.. important::
+
+ |draft|
+
+ |purpose|
+
+[More git help for advanced things needed by code contributors.]
diff --git a/contrib/code/index.rst b/contrib/code/index.rst
new file mode 100644
index 000000000..768095066
--- /dev/null
+++ b/contrib/code/index.rst
@@ -0,0 +1,30 @@
+.. _c_code:
+
+==================
+Code contributions
+==================
+
+.. important::
+
+ |draft|
+
+ |purpose|
+
+[The main page for code contributors.]
+
+[We'll include code-focused content from the :ref:`main devguide page `: Quick
+reference, Quick links, Proposing changes, and so on.]
+
+[The existing :ref:`internals` section of the devguide will be fully
+migrated into the Python repo.]
+
+
+.. toctree::
+ :maxdepth: 5
+
+ setup
+ git
+ pull-request-lifecycle
+ developer-workflow
+ testing
+ development-tools
diff --git a/contrib/code/pull-request-lifecycle.rst b/contrib/code/pull-request-lifecycle.rst
new file mode 100644
index 000000000..30c0fd590
--- /dev/null
+++ b/contrib/code/pull-request-lifecycle.rst
@@ -0,0 +1,21 @@
+.. _code-pull-request-lifecycle:
+
+======================
+Pull request lifecycle
+======================
+
+.. important::
+
+ |draft|
+
+ |purpose|
+
+
+[Details of pull requests for code contributions. The existing
+:ref:`pull-request-lifecycle` page is long and includes many details.
+Some only apply to code contributions, but many are common to all
+contributions. Should we keep a common page, with extra steps here, or
+should this page have all of the details even if they are duplicated
+elsewhere?]
+
+[See :ref:`docs-pull-request-lifecycle` for the documentation half of this conundrum.]
diff --git a/contrib/code/setup.rst b/contrib/code/setup.rst
new file mode 100644
index 000000000..2d14bb0d9
--- /dev/null
+++ b/contrib/code/setup.rst
@@ -0,0 +1,12 @@
+==================
+Setup and building
+==================
+
+.. important::
+
+ |draft|
+
+ |purpose|
+
+[More setup and build instructions specifically for code contributors, building
+on the basics from the :ref:`Getting Started ` section.]
diff --git a/contrib/code/testing.rst b/contrib/code/testing.rst
new file mode 100644
index 000000000..575d1477a
--- /dev/null
+++ b/contrib/code/testing.rst
@@ -0,0 +1,20 @@
+=====================
+Testing and buildbots
+=====================
+
+.. important::
+
+ |draft|
+
+ |purpose|
+
+[This is the existing :ref:`testing` page from the devguide.]
+
+.. toctree::
+ :maxdepth: 5
+
+ ../../testing/run-write-tests
+ ../../testing/silence-warnings
+ ../../testing/coverage
+ ../../testing/buildbots
+ ../../testing/new-buildbot-worker
diff --git a/contrib/contrib-plan.rst b/contrib/contrib-plan.rst
new file mode 100644
index 000000000..65e386e2b
--- /dev/null
+++ b/contrib/contrib-plan.rst
@@ -0,0 +1,47 @@
+.. _contrib-plan:
+
+==================================
+[Plan for the Contributor's Guide]
+==================================
+
+.. important::
+
+ |draft|
+
+ |purpose|
+
+We are in the process of updating and refactoring the devguide to be a
+Contributor's Guide. It will highlight the different kinds of contribution
+possible, and how to succeed at each kind.
+
+Currently, the Contibutor's Guide is a draft in this new last section of the
+devguide. We welcome feedback, but please understand that some of the current
+content is moving or skeletal.
+
+Repo structure
+==============
+
+While the reorganization is happening, we are keeping the old devguide as it
+is. The new Contributor's Guide is represented in this last section, but will
+eventually be the only content in the guide. To avoid copying content, we're
+using Sphinx include directives to display existing devguide content in its new
+Contributor's Guide location. That is not how the eventual Guide will be
+built. Once we are ready to make the Contributor's Guide real, we will
+rearrange content into its new location.
+
+How to help
+===========
+
+To help, you can:
+
+- `Write an issue`_ detailing a change you'd like to see here.
+- `Make a pull request`_ in this repo to add content.
+- Join us in the `Python Docs Discord`_ to collaborate with other docs-minded
+ community members.
+- Get in touch with the `Docs Editorial Board`_ to discuss larger documentation
+ concerns.
+
+.. _Write an issue: https://github.com/python/devguide/issues
+.. _Make a pull request: https://github.com/python/devguide/pulls
+.. _Python Docs Discord: https://discord.gg/qcfPbnM2zH
+.. _Docs Editorial Board: https://python.github.io/editorial-board/
diff --git a/contrib/core-team/committing.rst b/contrib/core-team/committing.rst
new file mode 100644
index 000000000..5b639cd5a
--- /dev/null
+++ b/contrib/core-team/committing.rst
@@ -0,0 +1,11 @@
+.. important::
+
+ |draft|
+
+ |purpose|
+
+
+[This is the existing core developers :ref:`committing` page from the devguide. We'll
+adjust "core developer" to "core team" where appropriate.]
+
+.. include:: ../../core-team/committing.rst
diff --git a/contrib/core-team/experts.rst b/contrib/core-team/experts.rst
new file mode 100644
index 000000000..aa16f10bd
--- /dev/null
+++ b/contrib/core-team/experts.rst
@@ -0,0 +1,10 @@
+.. important::
+
+ |draft|
+
+ |purpose|
+
+
+[This is the existing core team :ref:`experts` page from the devguide.]
+
+.. include:: ../../core-team/experts.rst
diff --git a/contrib/core-team/index.rst b/contrib/core-team/index.rst
new file mode 100644
index 000000000..2ca21344b
--- /dev/null
+++ b/contrib/core-team/index.rst
@@ -0,0 +1,24 @@
+.. important::
+
+ |draft|
+
+ |purpose|
+
+
+.. _c_core-team:
+
+=========
+Core team
+=========
+
+[This is mostly re-organized from the :ref:`core-team` section of the devguide]
+
+.. toctree::
+ :maxdepth: 5
+
+ responsibilities
+ committing
+ experts
+ team-log
+ motivations
+ join-team
diff --git a/contrib/core-team/join-team.rst b/contrib/core-team/join-team.rst
new file mode 100644
index 000000000..932216f7c
--- /dev/null
+++ b/contrib/core-team/join-team.rst
@@ -0,0 +1,10 @@
+.. important::
+
+ |draft|
+
+ |purpose|
+
+
+[This is the existing core team :ref:`join-core-team` page from the devguide.]
+
+.. include:: ../../core-team/join-team.rst
diff --git a/contrib/core-team/motivations.rst b/contrib/core-team/motivations.rst
new file mode 100644
index 000000000..38ba31023
--- /dev/null
+++ b/contrib/core-team/motivations.rst
@@ -0,0 +1,10 @@
+.. important::
+
+ |draft|
+
+ |purpose|
+
+
+[This is the existing core team :ref:`motivations` page from the devguide.]
+
+.. include:: ../../core-team/motivations.rst
diff --git a/contrib/core-team/responsibilities.rst b/contrib/core-team/responsibilities.rst
new file mode 100644
index 000000000..d6902bd78
--- /dev/null
+++ b/contrib/core-team/responsibilities.rst
@@ -0,0 +1,10 @@
+.. important::
+
+ |draft|
+
+ |purpose|
+
+
+[This is the existing core team :ref:`responsibilities` page from the devguide.]
+
+.. include:: ../../core-team/responsibilities.rst
diff --git a/contrib/core-team/team-log.rst b/contrib/core-team/team-log.rst
new file mode 100644
index 000000000..ecfe856a4
--- /dev/null
+++ b/contrib/core-team/team-log.rst
@@ -0,0 +1,10 @@
+.. important::
+
+ |draft|
+
+ |purpose|
+
+
+[This is the existing core team :ref:`team-log` page from the devguide.]
+
+.. include:: ../../core-team/team-log.rst
diff --git a/contrib/doc/devguide.rst b/contrib/doc/devguide.rst
new file mode 100644
index 000000000..2c83e5200
--- /dev/null
+++ b/contrib/doc/devguide.rst
@@ -0,0 +1,12 @@
+==================================
+Helping with the Developer's Guide
+==================================
+
+.. important::
+
+ |draft|
+
+ |purpose|
+
+
+[This is the existing :ref:`devguide` page from the devguide.]
diff --git a/contrib/doc/help-documenting.rst b/contrib/doc/help-documenting.rst
new file mode 100644
index 000000000..befb4b246
--- /dev/null
+++ b/contrib/doc/help-documenting.rst
@@ -0,0 +1,12 @@
+==========================
+Helping with documentation
+==========================
+
+.. important::
+
+ |draft|
+
+ |purpose|
+
+
+[This is the existing :ref:`help-documenting` page from the devguide.]
diff --git a/contrib/doc/index.rst b/contrib/doc/index.rst
new file mode 100644
index 000000000..dc8ec9307
--- /dev/null
+++ b/contrib/doc/index.rst
@@ -0,0 +1,29 @@
+.. _c_docs:
+
+===========================
+Documentation contributions
+===========================
+
+.. important::
+
+ |draft|
+
+ |purpose|
+
+
+[The main page for documentation contributors.]
+
+[We'll include docs-focused content from the :ref:`main devguide page `: Quick
+reference, Quick links, and so on.]
+
+
+.. toctree::
+ :maxdepth: 5
+
+ start-documenting
+ help-documenting
+ style-guide
+ markup
+ pull-request-lifecycle
+ translating
+ devguide
diff --git a/contrib/doc/markup.rst b/contrib/doc/markup.rst
new file mode 100644
index 000000000..96b9faad5
--- /dev/null
+++ b/contrib/doc/markup.rst
@@ -0,0 +1,12 @@
+=======================
+reStructuredText markup
+=======================
+
+.. important::
+
+ |draft|
+
+ |purpose|
+
+
+[This is the existing :ref:`markup` page from the devguide.]
diff --git a/contrib/doc/pull-request-lifecycle.rst b/contrib/doc/pull-request-lifecycle.rst
new file mode 100644
index 000000000..a62e63728
--- /dev/null
+++ b/contrib/doc/pull-request-lifecycle.rst
@@ -0,0 +1,21 @@
+.. _docs-pull-request-lifecycle:
+
+======================
+Pull request lifecycle
+======================
+
+.. important::
+
+ |draft|
+
+ |purpose|
+
+
+[Details of pull requests for documentation contributions. The existing
+:ref:`pull-request-lifecycle` page is long and includes many details.
+Some only apply to code contributions, but many are common to all
+contributions. Should we keep a common page, with documentation tweaks here, or
+should this page have only the documentation details even if they are duplicated
+elsewhere?]
+
+[See :ref:`code-pull-request-lifecycle` for the code half of this conundrum.]
diff --git a/contrib/doc/start-documenting.rst b/contrib/doc/start-documenting.rst
new file mode 100644
index 000000000..c5cf96161
--- /dev/null
+++ b/contrib/doc/start-documenting.rst
@@ -0,0 +1,12 @@
+===============
+Getting started
+===============
+
+.. important::
+
+ |draft|
+
+ |purpose|
+
+
+[This is the existing documentation :ref:`start-documenting` page from the devguide.]
diff --git a/contrib/doc/style-guide.rst b/contrib/doc/style-guide.rst
new file mode 100644
index 000000000..87762f3e0
--- /dev/null
+++ b/contrib/doc/style-guide.rst
@@ -0,0 +1,12 @@
+===========
+Style guide
+===========
+
+.. important::
+
+ |draft|
+
+ |purpose|
+
+
+[This is the existing documentation :ref:`style-guide` page from the devguide.]
diff --git a/contrib/doc/translating.rst b/contrib/doc/translating.rst
new file mode 100644
index 000000000..baface2f0
--- /dev/null
+++ b/contrib/doc/translating.rst
@@ -0,0 +1,12 @@
+===========
+Translating
+===========
+
+.. important::
+
+ |draft|
+
+ |purpose|
+
+
+[This is the existing :ref:`translating` page from the devguide.]
diff --git a/contrib/index.rst b/contrib/index.rst
new file mode 100644
index 000000000..e519c7dab
--- /dev/null
+++ b/contrib/index.rst
@@ -0,0 +1,119 @@
+.. _c_root:
+
+==================================
+Python Contributor's Guide (draft)
+==================================
+
+.. raw:: html
+
+
+
+
+.. important::
+
+ |draft|
+
+ |purpose|
+
+
+[Open question: how to divide content between this Introduction and the
+:ref:`introduction `?]
+
+This guide is a comprehensive resource for :ref:`contributing `
+to Python_ -- for both new and experienced contributors. It is :ref:`maintained
+` by the same community that maintains Python. We welcome your
+contributions to Python!
+
+We encourage everyone to contribute to Python. This guide should have
+everything you need to get started and be productive. If you still have
+questions after reviewing the material in this guide, the `Core Python
+Mentorship`_ group is available to help you through the process.
+
+There are a number of ways to contribute including code, documentation, and
+triaging issues. We've organized this guide to provide specifics based on the
+type of activity you'll be engaged in.
+
+
+Using this guide
+================
+
+We recommend reading this guide as needed. You can stop where you feel
+comfortable and begin contributing immediately without reading and
+understanding everything. If you do choose to skip around this guide, be aware
+that it is written assuming preceding sections have been read so you may need
+to backtrack to fill in missing concepts and terminology.
+
+No matter what kind of contribution you'll be making, you should start with
+these common sections:
+
+* :ref:`c_intro`
+* :ref:`c_project`
+
+Then choose a path based on your type of activity:
+
+*[The original table on the devguide home had a fourth column for Core
+Developers. That made the table wider and more confusing. I don't think core
+team members need a quick intro path since they will have been through the
+devguide before.]*
+
+*[I haven't adjusted the links in the table yet other than to add a link to the
+major section at the top of each column.]*
+
+.. list-table::
+ :widths: 10 10 10
+ :header-rows: 1
+
+ * - :ref:`Documentation `
+ - :ref:`Code `
+ - :ref:`Triaging `
+ * -
+ * :ref:`docquality`
+ * :ref:`documenting`
+ * :ref:`style-guide`
+ * :ref:`rst-primer`
+ * :ref:`translating`
+ * :ref:`devguide`
+ -
+ * :ref:`setup`
+ * :ref:`help`
+ * :ref:`pullrequest`
+ * :ref:`runtests`
+ * :ref:`fixingissues`
+ * :ref:`communication`
+ * :ref:`gitbootcamp`
+ * :ref:`devcycle`
+ -
+ * :ref:`tracker`
+ * :ref:`triaging`
+ * :ref:`helptriage`
+ * :ref:`experts`
+ * :ref:`labels`
+ * :ref:`gh-faq`
+ * :ref:`triage-team`
+
+Core team members will find guidance in the :ref:`c_core-team` section.
+
+Contents
+========
+
+.. toctree::
+ :maxdepth: 3
+
+ contrib-plan
+ intro/index
+ project/index
+ triage/index
+ doc/index
+ code/index
+ core-team/index
+ user-success
+ security
+ workflows/index
+
+
+.. _Python: https://www.python.org/
+.. _Core Python Mentorship: https://www.python.org/dev/core-mentorship/
diff --git a/contrib/intro/index.rst b/contrib/intro/index.rst
new file mode 100644
index 000000000..c5ba303df
--- /dev/null
+++ b/contrib/intro/index.rst
@@ -0,0 +1,53 @@
+.. _c_intro:
+
+============
+Introduction
+============
+
+.. important::
+
+ |draft|
+
+ |purpose|
+
+
+
+[Open question: how to divide content between this Introduction and the
+:ref:`home page `?]
+
+Welcome!
+
+New to open source?
+===================
+
+Python is an open source project, with culture and techniques from the broader
+open source world. You might find it helpful to read about open source in
+general. A number of individuals from the Python community have contributed to
+a series of excellent guides at `Open Source Guides
+`_.
+
+Anyone will find the following guides useful:
+
+* `How to Contribute to Open Source `_
+* `Building Welcoming Communities `_
+
+
+Healthy collaboration
+=====================
+
+[Importance of healthy inclusive collaboration]
+
+[While code is a large part of the project's success, project management, documentation, governance, sprint outreach, etc. matter.]
+
+[We respect the individual skills people bring to the project and strive to create and maintain a culture of inclusion.]
+
+About this guide
+================
+
+Types of contribution
+=====================
+
+[Pathways for contributors]
+
+Helping with this guide
+=======================
diff --git a/contrib/project/channels.rst b/contrib/project/channels.rst
new file mode 100644
index 000000000..711dbe587
--- /dev/null
+++ b/contrib/project/channels.rst
@@ -0,0 +1,16 @@
+.. important::
+
+ |draft|
+
+ |purpose|
+
+
+======================
+Communication channels
+======================
+
+* Repos
+* Discourse
+* Discord
+* Mailing lists (deprioritize)
+* Where to get help
diff --git a/contrib/project/conduct.rst b/contrib/project/conduct.rst
new file mode 100644
index 000000000..37fe3bbfa
--- /dev/null
+++ b/contrib/project/conduct.rst
@@ -0,0 +1,16 @@
+===============
+Code of Conduct
+===============
+
+.. important::
+
+ |draft|
+
+ |purpose|
+
+
+[Brief summary of the code of conduct, with links to official source.]
+
+* Standard for communication
+* How to report
+* Enforcement details
diff --git a/contrib/project/directory-structure.rst b/contrib/project/directory-structure.rst
new file mode 100644
index 000000000..0cebb25f7
--- /dev/null
+++ b/contrib/project/directory-structure.rst
@@ -0,0 +1,17 @@
+.. important::
+
+ |draft|
+
+ |purpose|
+
+.. _c_directory_structure:
+
+===================
+Directory structure
+===================
+
+[This is the :ref:`build_directory_structure` section from the devguide.]
+
+.. include:: ../../getting-started/setup-building.rst
+ :start-after: c_directory_structure_start
+ :end-before: c_directory_structure_end
diff --git a/contrib/project/generative-ai.rst b/contrib/project/generative-ai.rst
new file mode 100644
index 000000000..6cb5b62ff
--- /dev/null
+++ b/contrib/project/generative-ai.rst
@@ -0,0 +1,10 @@
+.. important::
+
+ |draft|
+
+ |purpose|
+
+
+[This is the existing :ref:`generative-ai` page from the devguide.]
+
+.. include:: ../../getting-started/generative-ai.rst
diff --git a/contrib/project/github.rst b/contrib/project/github.rst
new file mode 100644
index 000000000..fe45c6b8b
--- /dev/null
+++ b/contrib/project/github.rst
@@ -0,0 +1,15 @@
+.. important::
+
+ |draft|
+
+ |purpose|
+
+======
+GitHub
+======
+
+[Where are the actual artifacts?]
+
+* Main CPython repos
+* Core workflow repos
+* Infrastructure repos
diff --git a/contrib/project/governance.rst b/contrib/project/governance.rst
new file mode 100644
index 000000000..a4bc66ff1
--- /dev/null
+++ b/contrib/project/governance.rst
@@ -0,0 +1,25 @@
+.. important::
+
+ |draft|
+
+ |purpose|
+
+
+==========
+Governance
+==========
+
+[How decisions are made, who is involved, how to participate.]
+
+Steering Council
+================
+
+Documentation Editorial Board
+=============================
+
+Typing Council
+==============
+
+
+Others?
+=======
diff --git a/contrib/project/index.rst b/contrib/project/index.rst
new file mode 100644
index 000000000..9d3c89b9a
--- /dev/null
+++ b/contrib/project/index.rst
@@ -0,0 +1,29 @@
+.. _c_project:
+
+===================
+The CPython project
+===================
+
+.. important::
+
+ |draft|
+
+ |purpose|
+
+
+[Give the reader an understanding of the project as a whole. What are the
+moving parts, who is involved, how do they interact?]
+
+* Structure
+
+.. toctree::
+ :maxdepth: 5
+
+ conduct
+ roles
+ governance
+ generative-ai.rst
+ github
+ directory-structure.rst
+ channels
+ outreach
diff --git a/contrib/project/outreach.rst b/contrib/project/outreach.rst
new file mode 100644
index 000000000..d43aa8e9d
--- /dev/null
+++ b/contrib/project/outreach.rst
@@ -0,0 +1,12 @@
+========
+Outreach
+========
+
+.. important::
+
+ |draft|
+
+ |purpose|
+
+
+* Sprints
diff --git a/contrib/project/roles.rst b/contrib/project/roles.rst
new file mode 100644
index 000000000..8336fe465
--- /dev/null
+++ b/contrib/project/roles.rst
@@ -0,0 +1,17 @@
+=====
+Roles
+=====
+
+.. important::
+
+ |draft|
+
+ |purpose|
+
+
+[Quick overview of the roles people play. Core team has its own section.]
+
+* Core team
+* Triager
+* Contributors
+ * types of contributions
diff --git a/contrib/security.rst b/contrib/security.rst
new file mode 100644
index 000000000..db40b4a16
--- /dev/null
+++ b/contrib/security.rst
@@ -0,0 +1,13 @@
+=========================================
+Security and infrastructure contributions
+=========================================
+
+.. important::
+
+ |draft|
+
+ |purpose|
+
+* Security
+* Infrastructure
+* Core workflow
diff --git a/contrib/triage/index.rst b/contrib/triage/index.rst
new file mode 100644
index 000000000..0a547d9d7
--- /dev/null
+++ b/contrib/triage/index.rst
@@ -0,0 +1,14 @@
+.. _c_triage:
+
+===================
+Issues and triaging
+===================
+
+.. toctree::
+ :maxdepth: 5
+
+ issue-tracker
+ triaging
+ labels
+ reviewing
+ triage-team
diff --git a/contrib/triage/issue-tracker.rst b/contrib/triage/issue-tracker.rst
new file mode 100644
index 000000000..a5777bc81
--- /dev/null
+++ b/contrib/triage/issue-tracker.rst
@@ -0,0 +1,9 @@
+.. important::
+
+ |draft|
+
+ |purpose|
+
+[This is the existing :ref:`issue-tracker` page from the devguide]
+
+.. include:: ../../triage/issue-tracker.rst
diff --git a/contrib/triage/labels.rst b/contrib/triage/labels.rst
new file mode 100644
index 000000000..c36481733
--- /dev/null
+++ b/contrib/triage/labels.rst
@@ -0,0 +1,9 @@
+.. important::
+
+ |draft|
+
+ |purpose|
+
+[This is the existing :ref:`labels` page from the devguide]
+
+.. include:: ../../triage/labels.rst
diff --git a/contrib/triage/reviewing.rst b/contrib/triage/reviewing.rst
new file mode 100644
index 000000000..060f6b78d
--- /dev/null
+++ b/contrib/triage/reviewing.rst
@@ -0,0 +1,13 @@
+.. important::
+
+ |draft|
+
+ |purpose|
+
+
+=========
+Reviewing
+=========
+
+* How? Etiquette?
+* How to request a review?
diff --git a/contrib/triage/triage-team.rst b/contrib/triage/triage-team.rst
new file mode 100644
index 000000000..a9b59056a
--- /dev/null
+++ b/contrib/triage/triage-team.rst
@@ -0,0 +1,9 @@
+.. important::
+
+ |draft|
+
+ |purpose|
+
+[This is the existing :ref:`triage-team` page from the devguide]
+
+.. include:: ../../triage/triage-team.rst
diff --git a/contrib/triage/triaging.rst b/contrib/triage/triaging.rst
new file mode 100644
index 000000000..22e1ccc65
--- /dev/null
+++ b/contrib/triage/triaging.rst
@@ -0,0 +1,9 @@
+.. important::
+
+ |draft|
+
+ |purpose|
+
+[This is the existing :ref:`triaging` page from the devguide]
+
+.. include:: ../../triage/triaging.rst
diff --git a/contrib/user-success.rst b/contrib/user-success.rst
new file mode 100644
index 000000000..2a9ef5d4e
--- /dev/null
+++ b/contrib/user-success.rst
@@ -0,0 +1,14 @@
+=======================================
+Accessibility, design, and user success
+=======================================
+
+.. important::
+
+ |draft|
+
+ |purpose|
+
+
+* Accessibility
+* Design
+* User success
diff --git a/contrib/workflows/codespaces.rst b/contrib/workflows/codespaces.rst
new file mode 100644
index 000000000..eb97ef7c2
--- /dev/null
+++ b/contrib/workflows/codespaces.rst
@@ -0,0 +1,17 @@
+.. important::
+
+ |draft|
+
+ |purpose|
+
+.. _c_using_codespaces:
+
+=======================
+Using GitHub Codespaces
+=======================
+
+[This is the :ref:`using-codespaces` section from the devguide.]
+
+.. include:: ../../getting-started/setup-building.rst
+ :start-after: c_codespaces_start
+ :end-before: c_codespaces_end
diff --git a/contrib/workflows/compile.rst b/contrib/workflows/compile.rst
new file mode 100644
index 000000000..18157b717
--- /dev/null
+++ b/contrib/workflows/compile.rst
@@ -0,0 +1,22 @@
+.. important::
+
+ |draft|
+
+ |purpose|
+
+.. _c_compiling:
+
+=================
+Compile and build
+=================
+
+.. note::
+ [This is the :ref:`compiling` section from the devguide. I think this page
+ is too long and could be split by build target, but we can leave that for a
+ later time.]
+
+.. include:: ../../getting-started/setup-building.rst
+ :start-after: c_compile_and_build_start
+ :end-before: c_compile_and_build_end
+
+.. include:: ../../links.rst
diff --git a/contrib/workflows/get-source.rst b/contrib/workflows/get-source.rst
new file mode 100644
index 000000000..ed56fe4e1
--- /dev/null
+++ b/contrib/workflows/get-source.rst
@@ -0,0 +1,19 @@
+.. important::
+
+ |draft|
+
+ |purpose|
+
+.. _c_checkout:
+
+===================
+Get the source code
+===================
+
+.. note::
+ [This is the :ref:`checkout` section from the devguide. We might need to edit
+ it to clarify that some steps are only needed for code contribution.]
+
+.. include:: ../../getting-started/setup-building.rst
+ :start-after: c_get_source_code_start
+ :end-before: c_get_source_code_end
diff --git a/contrib/workflows/index.rst b/contrib/workflows/index.rst
new file mode 100644
index 000000000..2c6ccf2bc
--- /dev/null
+++ b/contrib/workflows/index.rst
@@ -0,0 +1,25 @@
+.. _c_workflows:
+
+=========
+Workflows
+=========
+
+.. important::
+
+ |draft|
+
+ |purpose|
+
+
+This section contains details of workflows needed for all kinds of
+contribution.
+
+.. toctree::
+
+ install-git.rst
+ get-source.rst
+ install-dependencies.rst
+ compile.rst
+ regenerate.rst
+ troubleshooting.rst
+ codespaces.rst
diff --git a/contrib/workflows/install-dependencies.rst b/contrib/workflows/install-dependencies.rst
new file mode 100644
index 000000000..9a511c6da
--- /dev/null
+++ b/contrib/workflows/install-dependencies.rst
@@ -0,0 +1,17 @@
+.. important::
+
+ |draft|
+
+ |purpose|
+
+.. _c_build-dependencies:
+
+====================
+Install Dependencies
+====================
+
+[This is the :ref:`build-dependencies` section from the devguide.]
+
+.. include:: ../../getting-started/setup-building.rst
+ :start-after: c_install_dependencies_start
+ :end-before: c_install_dependencies_end
diff --git a/contrib/workflows/install-git.rst b/contrib/workflows/install-git.rst
new file mode 100644
index 000000000..e3d738b2a
--- /dev/null
+++ b/contrib/workflows/install-git.rst
@@ -0,0 +1,17 @@
+.. important::
+
+ |draft|
+
+ |purpose|
+
+.. _c_vcsetup:
+
+===========
+Install Git
+===========
+
+[This is the :ref:`vcsetup` section from the devguide.]
+
+.. include:: ../../getting-started/setup-building.rst
+ :start-after: c_install_git_start
+ :end-before: c_install_git_end
diff --git a/contrib/workflows/regenerate.rst b/contrib/workflows/regenerate.rst
new file mode 100644
index 000000000..b5bca7dca
--- /dev/null
+++ b/contrib/workflows/regenerate.rst
@@ -0,0 +1,28 @@
+.. important::
+
+ |draft|
+
+ |purpose|
+
+.. _c_regenerating:
+
+===============================
+Regenerating auto-created files
+===============================
+
+.. note::
+ [These are two similar sections from the is the :ref:`setup-building` section from the devguide.]
+
+Regenerate ``configure``
+========================
+
+.. include:: ../../getting-started/setup-building.rst
+ :start-after: c_regenerate_configure_start
+ :end-before: c_regenerate_configure_end
+
+Regenerate the ABI dump
+=======================
+
+.. include:: ../../getting-started/setup-building.rst
+ :start-after: c_regenerate_abi_start
+ :end-before: c_regenerate_abi_end
diff --git a/contrib/workflows/troubleshooting.rst b/contrib/workflows/troubleshooting.rst
new file mode 100644
index 000000000..68aa80158
--- /dev/null
+++ b/contrib/workflows/troubleshooting.rst
@@ -0,0 +1,17 @@
+.. important::
+
+ |draft|
+
+ |purpose|
+
+.. _c_build_troubleshooting:
+
+===========
+Install Git
+===========
+
+[This is the :ref:`build_troubleshooting` section from the devguide.]
+
+.. include:: ../../getting-started/setup-building.rst
+ :start-after: c_build_troubleshooting_start
+ :end-before: c_build_troubleshooting_end
diff --git a/core-developers/become-core-developer.rst b/core-developers/become-core-developer.rst
deleted file mode 100644
index 1c8ef74e7..000000000
--- a/core-developers/become-core-developer.rst
+++ /dev/null
@@ -1,63 +0,0 @@
-.. _become-core-developer:
-.. _coredev:
-
-==============================
-How to Become a Core Developer
-==============================
-
-What it Takes
-=============
-
-When you have consistently contributed patches which meet quality standards
-without requiring extensive rewrites prior to being committed,
-you may qualify for commit privileges and become a core developer of Python.
-You must also work well with other core developers (and people in general)
-as you become an ambassador for the Python project.
-
-Typically a core developer will offer you the chance to gain commit privilege.
-The person making the offer will become your mentor and watch your commits for
-a while to make sure you understand the development process. If other core
-developers agree that you should gain commit privileges you are then extended
-an official offer. How core developers come to that agreement are outlined in
-:pep:`13`.
-
-
-Gaining Commit Privileges
-=========================
-
-The steps to gaining commit privileges are:
-
-1. A core developer starts a poll in the
- `Committers category`_ on the `Python Discourse`_ (``discuss.python.org``)
-
- - Open for 7 days
- - Results shown upon close
-
-2. The poll is announced on the `python-committers mailing list`_
-3. Wait for the poll to close and see if the results confirm your membership
- as per the voting results required by :pep:`13`
-4. The person who nominated you emails the steering council with your email
- address and a request that the council either accept or reject the proposed
- membership
-5. Assuming the steering council does not object, a member of the council will
- email you asking for:
-
- - Account details as required by
- 🔒 https://github.com/python/voters/
- - Your preferred email address to
- subscribe to the python-committers mailing list with
- - A reminder about the `Code of Conduct`_ and to report issues to the PSF
- Conduct WG
-
-6. Once you have provided the pertinent details, your various new privileges
- will be turned on
-7. Your details will be added to 🔒 https://github.com/python/voters/
-8. They will update the devguide to publicly list your team membership at
- :ref:`developers`
-9. An announcement email by the steering council member handling your new
- membership will be sent to the Committers Discourse category
-
-.. _Code of Conduct: https://www.python.org/psf/conduct/
-.. _Committers category: https://discuss.python.org/c/committers/5
-.. _Python Discourse: https://discuss.python.org
-.. _python-committers mailing list: https://mail.python.org/mailman3/lists/python-committers.python.org/
diff --git a/core-developers/index.rst b/core-developers/index.rst
deleted file mode 100644
index cf743c405..000000000
--- a/core-developers/index.rst
+++ /dev/null
@@ -1,13 +0,0 @@
-===============
-Core Developers
-===============
-
-.. toctree::
- :maxdepth: 5
-
- responsibilities
- committing
- experts
- developer-log
- motivations
- become-core-developer
diff --git a/core-developers/committing.rst b/core-team/committing.rst
similarity index 70%
rename from core-developers/committing.rst
rename to core-team/committing.rst
index be223ba83..41cf67254 100644
--- a/core-developers/committing.rst
+++ b/core-team/committing.rst
@@ -1,11 +1,11 @@
.. _committing:
-Accepting Pull Requests
+Accepting pull requests
=======================
.. highlight:: none
-This page is a step-by-step guide for core developers who need to assess,
+This page is a step-by-step guide for the core team to assess,
merge, and possibly backport a pull request on the main repository.
Assessing a pull request
@@ -31,11 +31,11 @@ to enter the public source tree. Ask yourself the following questions:
* **Do the checks on the pull request show that the test suite passes?**
Make sure that all of the status checks are passing.
-* **Is the patch in a good state?**
- Check :ref:`patch` and :ref:`helptriage` to review what is expected of
- a patch.
+* **Is the pull request in a good state?**
+ Check :ref:`pull-request-lifecycle` and :ref:`helptriage` to review what
+ is expected of a pull request.
-* **Does the patch break backwards-compatibility without a strong reason?**
+* **Does the change break backwards-compatibility without a strong reason?**
:ref:`Run the entire test suite ` to make sure that everything
still passes. If there is a change to the semantics, then there needs to
be a strong reason, because it will cause some peoples' code to break.
@@ -44,7 +44,7 @@ to enter the public source tree. Ask yourself the following questions:
`__.
* **Does documentation need to be updated?**
- If the pull request introduces backwards-incompatible changes (e.g.
+ If the pull request introduces backwards-incompatible changes (for example,
deprecating or removing a feature), then make sure that those changes
are reflected in the documentation before you merge the pull request.
@@ -54,101 +54,124 @@ to enter the public source tree. Ask yourself the following questions:
developer can apply the label ``needs backport to X.Y`` to the pull
request. Once the backport pull request has been created, remove the
``needs backport to X.Y`` label from the original pull request. (Only
- core developers and members of the :ref:`Python Triage Team `
+ the core team and members of the :ref:`Python Triage Team `
can apply labels to GitHub pull requests).
* **Does the pull request pass a check indicating that the submitter has signed the CLA?**
Make sure that the contributor has signed a `Contributor
Licensing Agreement `_
(CLA), unless their change has no possible intellectual property
- associated with it (e.g. fixing a spelling mistake in documentation).
- The `CPython CLA Bot `_
+ associated with it (for example, fixing a spelling mistake in documentation).
+ The `Python Software Foundation Contributor License Agreement Management Bot
+ `_
checks whether the author has signed the CLA, and replies in the PR
if they haven't. For further questions about the CLA
process, write to contributors@python.org.
* **Were** ``What's New in Python`` **and** ``Misc/NEWS.d/next`` **updated?**
- If the change is particularly interesting for end users (e.g. new features,
+ If the change is particularly interesting for end users (for example, new features,
significant improvements, or backwards-incompatible changes), then an
entry in the ``What's New in Python`` document (in ``Doc/whatsnew/``) should
be added as well. Changes that affect only documentation generally do not
require a ``NEWS`` entry. (See the following section for more information.)
-
.. _news-entry:
+.. _what-s-new-and-news-entries:
Updating NEWS and What's New in Python
--------------------------------------
-Almost all changes made to the code base deserve an entry in ``Misc/NEWS.d``.
-If the change is particularly interesting for end users (e.g. new features,
-significant improvements, or backwards-incompatible changes), then an entry in
-the ``What's New in Python`` document (in ``Doc/whatsnew/``) should be added
-as well. Changes that affect documentation only generally do not require
-a ``NEWS`` entry.
+Changes that require NEWS entries
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-There are two notable exceptions to this general principle, and they
-both relate to changes that:
+Most changes made to the codebase deserve an entry in :cpy-file:`Misc/NEWS.d`,
+except for the following:
-* Already have a ``NEWS`` entry
-* Have not yet been included in any formal release (including alpha
- and beta releases)
+* documentation changes
+* test changes
+* strictly internal changes with no user-visible effects
+* changes that already have a ``NEWS`` entry
+* reverts that have not yet been included in any formal release
+ (including alpha and beta releases)
-These are the two exceptions:
+For the last two, note the following:
#. **If a change is reverted prior to release**, then the corresponding
entry is simply removed. Otherwise, a new entry must be added noting
- that the change has been reverted (e.g. when a feature is released in
+ that the change has been reverted (for example, when a feature is released in
an alpha and then cut prior to the first beta).
#. **If a change is a fix (or other adjustment) to an earlier unreleased
change and the original** ``NEWS`` **entry remains valid**, then no additional
entry is needed.
-If a change needs an entry in ``What's New in Python``, then it is very
-likely not suitable for including in a maintenance release.
+Changes that require "What's New in Python" entries
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+If a change is particularly interesting for end users (for example, new features,
+significant improvements, or backwards-incompatible changes), add an entry in
+the "What's New in Python" document (in :cpy-file:`Doc/whatsnew/`)
+in addition to the ``NEWS`` entry.
+
+In most cases, it is sufficient to reuse the wording from the ``NEWS`` entry
+in the "What's New in Python" entry.
+
+.. note::
+
+ A change that needs an entry in "What's New in Python",
+ is very likely not suitable for inclusion in a maintenance release.
+
+How to add a NEWS entry
+^^^^^^^^^^^^^^^^^^^^^^^
``NEWS`` entries go into the ``Misc/NEWS.d`` directory as individual files. The
``NEWS`` entry can be created by using `blurb-it `_,
-or the `blurb `_ tool and its ``blurb add``
-command.
+or the :pypi:`blurb` tool and its ``blurb add`` command.
If you are unable to use the tool, then you can create the ``NEWS`` entry file
manually. The ``Misc/NEWS.d`` directory contains a sub-directory named
``next``, which contains various sub-directories representing classifications
-for what was affected (e.g. ``Misc/NEWS.d/next/Library`` for changes relating
+for what was affected (for example, ``Misc/NEWS.d/next/Library`` for changes relating
to the standard library). The file name itself should be in the format
``.gh-issue-..rst``:
-* ```` is today's date joined with a hyphen (``-``) to the current
- time, in the ``YYYY-MM-DD-hh-mm-ss`` format (e.g. ``2017-05-27-16-46-23``).
-* ```` is the issue number the change is for (e.g. ``12345``
+* ```` is today's date joined with a hyphen (``-``) to your current
+ local time, in the ``YYYY-MM-DD-hh-mm-ss`` format (for example, ``2017-05-27-16-46-23``).
+* ```` is the issue number the change is for (for example, ``12345``
for ``gh-issue-12345``).
* ```` is a unique string to guarantee that the file name is
- unique across branches (e.g. ``Yl4gI2``). It is typically six characters
+ unique across branches (for example, ``Yl4gI2``). It is typically six characters
long, but it can be any length of letters and numbers. Its uniqueness
can be satisfied by typing random characters on your keyboard.
As a result, a file name can look something like
``Misc/NEWS.d/next/Library/2017-05-27-16-46-23.gh-issue-12345.Yl4gI2.rst``.
+How to write a NEWS entry
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+All ``NEWS`` entries end up being part of the changelog.
+The changelog contains *a lot* of entries,
+and its intended audience is mainly users, not the core team and contributors.
+Take this into consideration when wording your ``NEWS`` entry.
+Describe the user-visible effects of your change succinctly and accurately;
+avoid long technical elaborations, digressions, and do not expect or require
+the reader to have read the actual diff for the change.
+
The contents of a ``NEWS`` file should be valid reStructuredText. An 80 character
column width should be used. There is no indentation or leading marker in the
-file (e.g. ``-``). There is also no need to start the entry with the issue
+file (for example, ``-``). There is also no need to start the entry with the issue
number since it is part of the file name. You can use
:ref:`inline markups ` too. Here is an example of a ``NEWS``
entry::
Fix warning message when :func:`os.chdir` fails inside
- :func:`test.support.temp_cwd`. Patch by Chris Jerdonek.
+ :func:`test.support.temp_cwd`. Contributed by Chris Jerdonek.
The inline Sphinx roles like ``:func:`` can be used help readers
find more information. You can build HTML and verify that the
link target is appropriate by using :ref:`make html `.
-While Sphinx roles can be beneficial to readers, they are not required.
-Inline ````code blocks```` can be used instead.
-
Working with Git_
-----------------
@@ -156,11 +179,11 @@ Working with Git_
.. seealso::
:ref:`gitbootcamp`
-As a core developer, you have the ability to push changes to the official
+As a core team member, you have the ability to push changes to the official
Python repositories, so you need to be careful with your workflow:
* **You should not push new branches to the main repository.** You can
- still use them in the fork that you use for the development of patches.
+ still use them in the fork that you use for your own development.
You can also push these branches to a separate public repository
for maintenance work before it is integrated into the main repository.
@@ -186,26 +209,27 @@ clone.
.. _committing-active-branches:
Seeing active branches
-''''''''''''''''''''''
+^^^^^^^^^^^^^^^^^^^^^^
If you use ``git branch``, then you will see a :ref:`list of branches
`. The only branch that receives new features is
``main``, the in-development branch. The other branches receive only
-bug fixes or security fixes.
+bug fixes or security fixes. In almost all cases the fixes should first
+originate on ``main`` and then be ported back to older branches.
.. _branch-merge:
Backporting changes to an older version
-'''''''''''''''''''''''''''''''''''''''
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If it is determined that a pull request needs to be backported into one or
-more of the maintenance branches, then a core developer can apply the label
+more of the maintenance branches, then a core team member can apply the label
``needs backport to X.Y`` to the pull request.
After the pull request has been merged, miss-islington (bot) will first try to
do the backport automatically. If miss-islington is unable to do it,
-then the pull request author or the core developer who merged it should look into
+then the pull request author or the core team member who merged it should look into
backporting it themselves, using the backport generated by cherry_picker.py_
as a starting point.
@@ -228,16 +252,16 @@ Note that cherry_picker.py_ adds the branch prefix automatically.
Once the backport pull request has been created, remove the
``needs backport to X.Y`` label from the original pull request. (Only
-core developers and members of the :ref:`Python Triage Team `
+members of the core team and :ref:`Python Triage Team `
can apply labels to GitHub pull requests).
.. _cherry_picker.py: https://github.com/python/cherry-picker
Reverting a merged pull request
-'''''''''''''''''''''''''''''''
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-To revert a merged pull request, press the ``Revert`` button at the
+To revert a merged pull request, press the :guilabel:`Revert` button at the
bottom of the pull request. That will bring up the page to create a
new pull request where the commit can be reverted. It will also create
a new branch on the main CPython repository. Delete the branch once
diff --git a/core-developers/developers.csv b/core-team/core-team.csv
similarity index 80%
rename from core-developers/developers.csv
rename to core-team/core-team.csv
index 6916c89bd..8c4625493 100644
--- a/core-developers/developers.csv
+++ b/core-team/core-team.csv
@@ -1,3 +1,25 @@
+Emma Smith,emmatyping,2025-07-31,,
+Tomas Roun,tomasr8,2025-06-16,,
+Peter Bierma,ZeroIntensity,2025-06-16,,
+Diego Russo,diegorusso,2025-05-13,,
+Bénédikt Tran,picnixz,2025-01-10,,
+Savannah Ostrowski,savannahostrowski,2024-11-13,,
+Matt Page,mpage,2024-10-10,,
+Kirill Podoprigora,Eclips4,2024-09-20,,
+Ned Batchelder,nedbat,2024-07-16,,
+Tian Gao,gaogaotiantian,2024-06-06,,
+Michael Droettboom,mdboom,2024-06-06,,
+Russell Keith-Magee,freakboy3742,2024-05-30,,
+Sam Gross,colesbury,2024-02-06,,
+Nikita Sobolev,sobolevn,2024-02-06,,
+Adam Turner,AA-Turner,2023-10-10,,
+C.A.M. Gerlach,CAM-Gerlach,2023-04-19,,
+Barney Gale,barneygale,2023-03-21,,
+Carl Meyer,carljm,2023-02-28,,
+Pradyun Gedam,pradyunsg,2023-01-30,,
+Shantanu Jain,hauntsaninja,2022-12-19,,
+Kumar Aditya,kumaraditya303,2022-11-21,,
+Hugo van Kemenade,hugovk,2022-11-21,,
Alex Waygood,AlexWaygood,2022-10-18,,
Filipe Laíns,FFY00,2022-10-17,,
Erlend Egeberg Aasland,erlend-aasland,2022-05-05,,
@@ -10,10 +32,10 @@ Batuhan Taskaya,isidentical,2020-11-08,,
Brandt Bucher,brandtbucher,2020-09-14,,
Lysandros Nikolaou,lysnikolaou,2020-06-29,,
Kyle Stanley,aeros,2020-04-14,,
-Dong-hee Na,corona10,2020-04-08,,
+Donghee Na,corona10,2020-04-08,,
Karthikeyan Singaravelan,tirkarthi,2019-12-31,,
Joannah Nanjekye,nanjekyejoannah,2019-09-23,,
-Abhilash Raj,maxking,2019-08-06,,
+Abhilash Raj,maxking,2019-08-06,2022-11-30,Privileges relinquished on 2022-11-30
Paul Ganssle,pganssle,2019-06-15,,
Stéphane Wirtel,matrixise,2019-04-08,,
Stefan Behnel,scoder,2019-04-08,,
@@ -34,7 +56,7 @@ Xavier de Gaye,xdegaye,2016-06-03,2018-01-25,Privileges relinquished on 2018-01-
Davin Potts,applio,2016-03-06,,
Martin Panter,vadmium,2015-08-10,2020-11-26,
Paul Moore,pfmoore,2015-03-15,,
-Robert Collins,rbtcollins,2014-10-16,,To work on unittest
+Robert Collins,rbtcollins,2014-10-16,2021-11-30,To work on unittest; privileges relinquished on 2021-11-30
Berker Peksağ,berkerpeksag,2014-06-26,,
Steve Dower,zooba,2014-05-10,,
Kushal Das,kushaldas,2014-04-14,,
@@ -51,15 +73,16 @@ Hynek Schlawack,hynek,2012-05-14,,
Richard Oudkerk,,2012-04-29,2017-02-10,For multiprocessing module; did not make GitHub transition
Andrew Svetlov,asvetlov,2012-03-13,,At PyCon sprint
Petri Lehtinen,akheron,2011-10-22,2020-11-12,
-Meador Inge,meadori,2011-09-19,2020-11-26,
+Meador Inge,meadori,2011-09-19,,
Jeremy Kloth,jkloth,2011-09-12,,
Sandro Tosi,sandrotosi,2011-08-01,,
Alex Gaynor,alex,2011-07-18,,For PyPy compatibility (since expanded scope)
Charles-François Natali,,2011-05-19,2017-02-10,Did not make GitHub transition
Nadeem Vawda,,2011-04-10,2017-02-10,Did not make GitHub transition
+CF Bolz-Tereick,cfbolz,2011-03-21,,for stdlib compatibility work for PyPy
Jason R. Coombs,jaraco,2011-03-14,,For sprinting on distutils2
Ross Lagerwall,,2011-03-13,2017-02-10,Did not make GitHub transition
-Eli Bendersky,eliben,2011-01-11,2020-11-26,
+Eli Bendersky,eliben,2011-01-11,2020-11-26,Relinquished privileges on 2020-11-26
Ned Deily,ned-deily,2011-01-09,,
David Malcolm,davidmalcolm,2010-10-27,2020-11-12,relinquished privileges on 2020-11-12
Tal Einat,taleinat,2010-10-04,,Initially for IDLE
@@ -81,12 +104,12 @@ Doug Hellmann,dhellmann,2009-09-20,2020-11-11,For documentation; relinquished pr
Frank Wierzbicki,,2009-08-02,2017-02-10,For Jython compatibility; did not make GitHub transition
Ezio Melotti,ezio-melotti,2009-06-07,,For documentation
Philip Jenvey,pjenvey,2009-05-07,2020-11-26,For Jython compatibility
-Michael Foord,voidspace,2009-04-01,,For IronPython compatibility
+Michael Foord,voidspace,2009-04-01,2025-01-24,For IronPython compatibility; deceased
R\. David Murray,bitdancer,2009-03-30,,
Chris Withers,cjw296,2009-03-08,,
Tarek Ziadé,tarekziade,2008-12-21,2017-02-10,For distutils module
Hirokazu Yamamoto,,2008-08-12,2017-02-10,For Windows build; did not make GitHub transition
-Armin Ronacher,mitsuhiko,2008-07-23,2020-11-26,For documentation toolset and ast module
+Armin Ronacher,mitsuhiko,2008-07-23,,For documentation toolset and ast module
Antoine Pitrou,pitrou,2008-07-16,,
Senthil Kumaran,orsenthil,2008-06-16,,
Jesse Noller,,2008-06-16,2017-02-10,For multiprocessing module; did not make GitHub transition
@@ -95,9 +118,9 @@ Guilherme Polo,,2008-04-24,2017-02-10,Did not make GitHub transition
Jeroen Ruigrok van der Werven,,2008-04-12,2017-02-10,For documentation; did not make GitHub transition
Benjamin Peterson,benjaminp,2008-03-25,,For bug triage
David Wolever,wolever,2008-03-17,2020-11-21,For 2to3 module
-Trent Nelson,tpn,2008-03-17,2020-11-26,
-Mark Dickinson,mdickinson,2008-01-06,,For maths-related work
-Amaury Forgeot d'Arc,amauryfa,2007-11-09,2020-11-26,
+Trent Nelson,tpn,2008-03-17,,
+Mark Dickinson,mdickinson,2008-01-06,2024-08-13,For maths-related work
+Amaury Forgeot d'Arc,amauryfa,2007-11-09,2020-11-26,Relinquished privileges on 2020-11-26
Christian Heimes,tiran,2007-10-31,,
Bill Janssen,,2007-08-28,2017-02-10,For ssl module; did not make GitHub transition
Jeffrey Yasskin,,2007-08-09,2017-02-10,Did not make GitHub transition
@@ -114,7 +137,7 @@ Steven Bethard,,2006-04-27,2017-02-10,For PEP access and SourceForge maintenance
Gerhard Häring,,2006-04-23,2017-02-10,Did not make the GitHub transition
George Yoshida,,2006-04-17,2017-02-10,For tracker administration; did not make GitHub transition
Ronald Oussoren,ronaldoussoren,2006-03-03,,For Mac-related work
-Nick Coghlan,ncoghlan,2005-10-16,,
+Alyssa Coghlan,ncoghlan,2005-10-16,,Also contributed as Nick Coghlan (prior to 2023-08-04)
Georg Brandl,birkenfeld,2005-05-28,,
Terry Jan Reedy,terryjreedy,2005-04-07,,
Bob Ippolito,etrepum,2005-03-02,2017-02-10,For Mac-related work
@@ -123,9 +146,9 @@ Facundo Batista,facundobatista,2004-10-16,,
Sean Reifschneider,,2004-09-17,2017-02-10,Did not make GitHub transition
Johannes Gijsbers,,2004-08-14,2005-07-27,Privileges relinquished on 2005-07-27
Matthias Klose,doko42,2004-08-04,,
-PJ Eby,pjeby,2004-03-24,2020-11-26,
+PJ Eby,pjeby,2004-03-24,2020-11-26,Relinquished privileges on 2020-11-26
Vinay Sajip,vsajip,2004-02-20,,
-Hye-Shik Chang,hyeshik,2003-12-10,,
+Hye-Shik Chang,hyeshik,2003-12-10,2025-02-28,Privileges relinquished on 2025-02-28
Armin Rigo,,2003-10-24,2012-06-01,Privileges relinquished in 2012
Andrew McNamara,,2003-06-09,2017-02-10,Did not make GitHub transition
Samuele Pedroni,,2003-05-16,2017-02-10,Did not make GitHub transition
@@ -134,11 +157,11 @@ Brett Cannon,brettcannon,2003-04-18,,
David Goodger,,2003-01-02,2017-02-10,Did not make GitHub transition
Gustavo Niemeyer,,2002-11-05,2017-02-10,Did not make GitHub transition
Tony Lownds,,2002-09-22,2017-02-10,Did not make GitHub transition
-Steve Holden,holdenweb,2002-06-14,2017-02-10,"Relinquished privileges on 2005-04-07,
+Steve Holden,holdenweb,2002-06-14,2017-02-10,"Relinquished privileges on 2005-04-07,
but granted again for Need for Speed sprint; did not make GitHub transition"
Christian Tismer,ctismer,2002-05-17,,For Need for Speed sprint
Jason Tishler,,2002-05-15,2017-02-10,Did not make GitHub transition
-Walter Dörwald,doerwalter,2002-03-21,,
+Walter Dörwald,doerwalter,2002-03-21,2021-11-16,Relinquished privileges on 2021-11-16
Andrew MacIntyre,,2002-02-17,2016-01-02,Privileges relinquished 2016-01-02
Gregory P. Smith,gpshead,2002-01-08,,
Anthony Baxter,,2001-12-21,2017-02-10,Did not make GitHub transition
@@ -171,9 +194,9 @@ Eric S. Raymond,,2000-06-02,2017-02-10,Did not make GitHub transition
Greg Stein,,1999-11-07,2017-02-10,Did not make GitHub transition
Just van Rossum,,1999-01-22,2017-02-10,Did not make GitHub transition
Greg Ward,,1998-12-18,2017-02-10,Did not make GitHub transition
-Andrew Kuchling,akuchling,1998-04-09,,
+Andrew Kuchling,akuchling,1998-04-09,2022-11-09,Privileges relinquished 2022-11-09
Ken Manheimer,,1998-03-03,2005-04-08,Privileges relinquished on 2005-04-08
-Jeremy Hylton,jeremyhylton,1997-08-13,2020-11-26,
+Jeremy Hylton,jeremyhylton,1997-08-13,,
Roger E. Masse,,1996-12-09,2017-02-10,Did not make GitHub transition
Fred Drake,freddrake,1996-07-23,,
Barry Warsaw,warsaw,1994-07-25,,
diff --git a/core-developers/experts.rst b/core-team/experts.rst
similarity index 61%
rename from core-developers/experts.rst
rename to core-team/experts.rst
index 0aa8104de..2fb37cb3f 100644
--- a/core-developers/experts.rst
+++ b/core-team/experts.rst
@@ -1,7 +1,7 @@
.. _experts:
=============
-Experts Index
+Experts index
=============
This document has tables that list Python Modules, Tools, Platforms and
@@ -17,7 +17,7 @@ while any other issues can and should be decided by any committer.
Developers can choose to follow labels, so if a label that they are
following is added to an issue or pull request, they will be notified
-automatically. The :file:`CODEOWNERS` file is also used to indicate
+automatically. The :cpy-file:`.github/CODEOWNERS` file is also used to indicate
maintainers that will be automatically added as reviewers to pull requests.
Unless a name is followed by a '*', you should never assign an issue to
@@ -55,29 +55,20 @@ Module Maintainers
__future__
__main__ gvanrossum, ncoghlan
_thread
-_testbuffer
abc
-aifc bitdancer
-argparse
+annotationlib JelleZijlstra*
+argparse savannahostrowski*, serhiy-storchaka*
array
-ast benjaminp, pablogsal, isidentical
-asynchat josiahcarlson, giampaolo*, stutzbach^
-asyncio 1st1, asvetlov, gvanrossum, graingert, kumaraditya303
-asyncore josiahcarlson, giampaolo*, stutzbach^
+ast benjaminp, pablogsal, isidentical, JelleZijlstra, eclips4
+asyncio 1st1, asvetlov, gvanrossum, graingert, kumaraditya303, willingc
atexit
-audioop serhiy-storchaka
base64
bdb
binascii
-binhex
bisect rhettinger*
builtins
-bz2
calendar
-cgi ethanfurman*
-cgitb ethanfurman*
-chunk
-cmath mdickinson
+cmath
cmd
code
codecs malemburg, doerwalter
@@ -85,95 +76,88 @@ codeop
collections rhettinger*
collections.abc rhettinger*, stutzbach^
colorsys
-compileall
+compileall carljm
+compression.bz2
+compression.gzip
+compression.lzma
+compression.zlib Yhg1s, gpshead*, emmatyping
+compression.zstd emmatyping*
concurrent.futures pitrou, brianquinlan, gpshead*
configparser ambv*
contextlib ncoghlan, 1st1
contextvars
-copy avassalotti
-copyreg avassalotti
+copy avassalotti, serhiy-storchaka*
+copyreg avassalotti, serhiy-storchaka*
cProfile
-crypt jafo^*
-csv smontanaro (inactive)
+csv smontanaro (inactive), serhiy-storchaka*
ctypes theller (inactive), abalkin, amauryfa, meadori
curses Yhg1s
-dataclasses ericvsmith*
+dataclasses ericvsmith*, carljm
datetime abalkin, pganssle
dbm
-decimal facundobatista, rhettinger, mdickinson
+decimal facundobatista, rhettinger
difflib tim-one (inactive)
dis 1st1
-distutils merwok, dstufft
doctest tim-one (inactive)
email warsaw, bitdancer*, maxking
encodings malemburg
-ensurepip ncoghlan, dstufft, pradyunsg
+ensurepip ncoghlan, dstufft, pradyunsg, pfmoore
enum eliben*, warsaw, ethanfurman*
errno Yhg1s
-faulthandler vstinner, gpshead
+faulthandler vstinner, gpshead, ZeroIntensity*
fcntl Yhg1s
filecmp
fileinput
-fnmatch
-formatter
-fractions mdickinson
+fnmatch serhiy-storchaka*
+fractions
ftplib giampaolo*
functools rhettinger*
-gc pitrou, pablogsal
-getopt
+gc pitrou, pablogsal, nascheme
+getopt serhiy-storchaka*
+getpath FFY00
getpass
-gettext
-glob
+gettext tomasr8
+glob serhiy-storchaka*
grp
-gzip
-hashlib tiran, gpshead*
+hashlib tiran, gpshead*, picnixz
heapq rhettinger*, stutzbach^
-hmac tiran, gpshead*
+hmac tiran, gpshead*, picnixz
html ezio-melotti*
http
idlelib kbkaiser (inactive), terryjreedy*, serwy (inactive),
taleinat
imaplib
-imghdr
-imp
importlib brettcannon
inspect 1st1
io benjaminp, stutzbach^
ipaddress pmoody^
itertools rhettinger*
-json etrepum (inactive), ezio-melotti, rhettinger
+json etrepum (inactive), ezio-melotti, rhettinger,
+ serhiy-storchaka*
keyword
-lib2to3 benjaminp
libmpdec
linecache
locale malemburg
logging vsajip
-lzma
mailbox
-mailcap
marshal
-math mdickinson, rhettinger, stutzbach^
+math rhettinger, stutzbach^
mimetypes
mmap Yhg1s
modulefinder theller (inactive), jvr^
-msilib
msvcrt
multiprocessing applio*, pitrou, jnoller^ (inactive), sbt^ (inactive), gpshead*
netrc
-nis
-nntplib
numbers
operator
-optparse mitsuhiko
+optparse mitsuhiko, serhiy-storchaka*
os
-os.path serhiy-storchaka
-ossaudiodev
-parser benjaminp, pablogsal
-pathlib
-pdb
-pickle avassalotti
-pickletools avassalotti
-pipes
+os.path serhiy-storchaka*
+parser pablogsal
+pathlib barneygale*
+pdb gaogaotiantian
+pickle avassalotti, serhiy-storchaka*
+pickletools avassalotti, serhiy-storchaka*
pkgutil
platform malemburg
plistlib
@@ -184,13 +168,13 @@ profile
pstats
pty Yhg1s*
pwd
-py_compile
+py_compile carljm
pyclbr isidentical
-pydoc
+pydoc AA-Turner, serhiy-storchaka*
queue rhettinger*
quopri
-random rhettinger, mdickinson
-re ezio-melotti, serhiy-storchaka
+random rhettinger
+re ezio-melotti, serhiy-storchaka*
readline Yhg1s
reprlib
resource Yhg1s
@@ -205,61 +189,55 @@ shlex
shutil tarekziade, giampaolo
signal gpshead
site
-smtpd giampaolo
smtplib
-sndhdr
socket gpshead
socketserver
-spwd
sqlite3 ghaering^, erlend-aasland*
ssl jackjansen, tiran, dstufft, alex
stat tiran
statistics stevendaprano, rhettinger
string
stringprep
-struct mdickinson, meadori
+struct meadori
subprocess astrand^ (inactive), giampaolo, gpshead*
-sunau
-symbol
symtable benjaminp
sys
sysconfig FFY00
syslog jafo^*
tabnanny tim-one (inactive)
tarfile gustaebel
-telnetlib
-tempfile
+tempfile serhiy-storchaka*
termios Yhg1s
-test ezio-melotti
+test ezio-melotti, serhiy-storchaka*
textwrap
threading pitrou, gpshead
time abalkin, pganssle
timeit
-tkinter gpolo^, serhiy-storchaka
+tkinter gpolo^, serhiy-storchaka*
token
tokenize meadori
+tomllib hauntsaninja*
trace abalkin
traceback iritkatriel
tracemalloc vstinner
tty Yhg1s*
turtle gregorlingl^, willingc
+turtledemo terryjreedy*
types 1st1
-typing gvanrossum, Fidget-Spinner, JelleZijlstra*, AlexWaygood*
+typing gvanrossum, JelleZijlstra*, AlexWaygood*, carljm, sobolevn*
unicodedata malemburg, ezio-melotti
-unittest voidspace*, ezio-melotti, rbtcollins, gpshead
-unittest.mock voidspace*
+unittest ezio-melotti, rbtcollins, gpshead, serhiy-storchaka*
+unittest.mock
urllib orsenthil
-uu
uuid
-venv vsajip
+venv vsajip, FFY00
warnings
wave
-weakref freddrake
+weakref freddrake, nascheme
webbrowser
winreg stutzbach^
winsound
wsgiref pjenvey
-xdrlib
xml.dom
xml.dom.minidom
xml.dom.pulldom
@@ -273,7 +251,7 @@ xmlrpc
zipapp pfmoore
zipfile alanmcintyre^, serhiy-storchaka, Yhg1s, gpshead
zipimport Yhg1s*
-zlib Yhg1s, gpshead*
+zoneinfo pganssle
==================== =============================================
@@ -283,28 +261,41 @@ Tools
================== ===========
Tool Maintainers
================== ===========
-Argument Clinic larryhastings
+Argument Clinic larryhastings, AlexWaygood*, erlend-aasland,
+ serhiy-storchaka*
+Deepfreeze gvanrossum, kumaraditya303
PEG Generator gvanrossum, pablogsal, lysnikolaou
================== ===========
+.. _platform-experts:
+
Platforms
=========
+For official contacts for supported platforms, see :pep:`11`.
+
+Platforms listed here are not necessarily supported by CPython.
+Some of the experts listed here maintain and distribute Python
+for “their” platform as a third-party project.
+
=================== ===========
Platform Maintainers
=================== ===========
-AIX David.Edelsohn^
+AIX edelsohn, ayappanec
+Android mhsmith
Cygwin jlt63^, stutzbach^
+Emscripten hoodmane, pmp-p, rdb, rth, ryanking13
FreeBSD
HP-UX
+iOS freakboy3742, ned-deily
+JVM/Java frank.wierzbicki^
Linux
-Mac OS X ronaldoussoren, ned-deily
+macOS ronaldoussoren, ned-deily, freakboy3742
NetBSD1
OS2/EMX aimacintyre^
-Solaris/OpenIndiana jcea
-Windows tjguk, zware, zooba, pfmoore
-JVM/Java frank.wierzbicki^
+Solaris/OpenIndiana jcea, kulikjak
+Windows tjguk, zooba, pfmoore
=================== ===========
@@ -314,56 +305,66 @@ Miscellaneous
================== ==========================================================
Interest Area Maintainers
================== ==========================================================
-algorithms rhettinger*
-argument clinic larryhastings
-ast/compiler benjaminp, brettcannon, 1st1, pablogsal, markshannon, isidentical, brandtbucher
-autoconf/makefiles Yhg1s*
-bsd
+algorithms rhettinger*, serhiy-storchaka
+argument clinic larryhastings, AlexWaygood*, erlend-aasland,
+ serhiy-storchaka*
+AST/compiler benjaminp, 1st1, pablogsal, markshannon, isidentical, brandtbucher, carljm, iritkatriel
+autoconf/makefiles Yhg1s*, emmatyping
issue tracker ezio-melotti
buildbots zware, pablogsal
-bytecode benjaminp, 1st1, markshannon, brandtbucher
+bytecode benjaminp, 1st1, markshannon, brandtbucher, carljm, iritkatriel
context managers ncoghlan
-core workflow Mariatta, ezio-melotti
-coverity scan tiran, brettcannon, Yhg1s
-cryptography gpshead, dstufft
-data formats mdickinson
+core workflow Mariatta, ezio-melotti, hugovk, AA-Turner
+cryptography gpshead, dstufft, picnixz
+data formats
database malemburg
-devguide merwok, ezio-melotti, willingc, Mariatta
-documentation ezio-melotti, merwok, JulienPalard, willingc
+devguide merwok, ezio-melotti, willingc, Mariatta, hugovk,
+ AA-Turner
+documentation ezio-melotti, merwok, JulienPalard, willingc, hugovk,
+ AA-Turner, AlexWaygood*
emoji Mariatta
extension modules encukou, ncoghlan
filesystem giampaolo
+frozen modules ericsnowcurrently, gvanrossum, kumaraditya303
f-strings ericvsmith*
GUI
-i18n malemburg, merwok
-import machinery brettcannon, ncoghlan, ericsnowcurrently
+i18n malemburg, merwok, tomasr8
+import machinery brettcannon, ncoghlan, ericsnowcurrently, FFY00
+initialization FFY00
io benjaminp, stutzbach^, gpshead
+JIT brandtbucher*, savannahostrowski*
locale malemburg
-mathematics mdickinson, malemburg, stutzbach^, rhettinger
-memory management tim-one, malemburg, Yhg1s
+mathematics malemburg, stutzbach^, rhettinger, serhiy-storchaka
+memory management tim-one, malemburg, Yhg1s, nascheme
memoryview
networking giampaolo, gpshead
object model benjaminp, Yhg1s
-packaging tarekziade, malemburg, alexis^, merwok, dstufft, pfmoore
+packaging tarekziade, malemburg, alexis^, merwok, dstufft, pfmoore, emmatyping
pattern matching brandtbucher*
-peg parser gvanrossum, pablogsal, lysnikolaou
-performance brettcannon, vstinner, serhiy-storchaka, 1st1, rhettinger, markshannon, brandtbucher
+PEG parser gvanrossum, pablogsal, lysnikolaou
+performance vstinner, serhiy-storchaka*, 1st1, rhettinger, markshannon,
+ brandtbucher, carljm, Fidget-Spinner, AlexWaygood*, nascheme
pip ncoghlan, dstufft, pfmoore, Marcus.Smith^, pradyunsg
-py3 transition benjaminp
release management tarekziade, malemburg, benjaminp, warsaw,
gvanrossum, anthonybaxter^, merwok, ned-deily,
- birkenfeld, JulienPalard
+ birkenfeld, JulienPalard, hugovk
+runtime lifecycle ericsnowcurrently, kumaraditya303, zooba, ZeroIntensity, nascheme
str.format ericvsmith*
-testing voidspace, ezio-melotti
+subinterpreters ericsnowcurrently, kumaraditya303, ZeroIntensity*
+symbol table JelleZijlstra, carljm
+testing ezio-melotti
test coverage
threads gpshead
time and dates malemburg, abalkin, pganssle
-unicode malemburg, ezio-melotti, benjaminp
+Unicode malemburg, ezio-melotti, benjaminp
version control merwok, ezio-melotti
================== ==========================================================
-Documentation Translations
+Documentation translations
==========================
-For a list of translators, see :ref:`this table about translations `.
+Translations are within the charter of
+`Editorial Board `_.
+For a list of translations and their coordinators, see
+:ref:`this table of translations `.
diff --git a/core-team/index.rst b/core-team/index.rst
new file mode 100644
index 000000000..f8dafe05e
--- /dev/null
+++ b/core-team/index.rst
@@ -0,0 +1,17 @@
+.. _core-dev:
+.. _core-team:
+
+=========
+Core team
+=========
+
+.. toctree::
+ :maxdepth: 5
+
+ responsibilities
+ committing
+ experts
+ team-log
+ motivations
+ join-team
+ memorialization
diff --git a/core-team/join-team.rst b/core-team/join-team.rst
new file mode 100644
index 000000000..d7996cd42
--- /dev/null
+++ b/core-team/join-team.rst
@@ -0,0 +1,116 @@
+.. _become-core-developer:
+.. _coredev:
+.. _join-core-team:
+
+=========================
+How to join the core team
+=========================
+
+What it takes
+=============
+
+When you have consistently made contributions which meet quality standards
+without requiring extensive rewrites prior to being committed,
+you may qualify for commit privileges and join the core team of Python.
+You must also work well with other core team members (and people in general)
+as you become an ambassador for the Python project.
+
+Typically a core team member will offer you the chance to gain commit privilege.
+The person making the offer will become your mentor and watch your commits for
+a while to make sure you understand the development process. If other core
+developers agree that you should gain commit privileges you are then extended
+an official offer. How core team members come to that agreement are outlined in
+:pep:`13`.
+
+
+Gaining commit privileges
+=========================
+
+After a candidate has demonstrated consistent contributions, commit privileges
+are granted through these steps:
+
+#. A core team member (submitter, usually the mentor) starts a poll
+ (see the :ref:`template ` below) in
+ the `Committers category`_ on the `Python Discourse`_.
+
+ - open for 7 days
+ - results shown only upon closing
+
+#. If the candidate receives at least two-thirds positive votes when the poll closes
+ (as per :pep:`13`), the submitter `emails the steering council
+ `_ with the candidate's email address
+ requesting that the council either accept or reject the proposed membership. Technically, the
+ council may only `veto a positive vote `_.
+
+#. Assuming the steering council does not veto the positive vote, a member of the council or its
+ delegate (approver, usually in practice a :ref:`Developer-in-Residence `) will
+ email the candidate:
+
+ - A request for account details as required by
+ `🔒 python/voters `_.
+ - A reminder about the `Code of Conduct`_ and guidance on reporting issues
+ to the PSF Conduct WG.
+
+#. Once the candidate has provided the pertinent details, the approver will:
+
+ - Enable the various new privileges.
+ - Remove the new committer from the triage team, if applicable.
+ - Add their details to `🔒 python/voters `_.
+ - Once the python/voters update is merged, regenerate the public team membership
+ list at :ref:`developers`.
+ See "Public list of members" in the ``voters`` README.
+ - Post an announcement in the `Committers Discourse category
+ `_. The past few announcements
+ were in the form of a separate post on the already open topic with
+ the poll.
+
+Getting a python.org email address
+----------------------------------
+
+Members of the core team can get an email address on the python.org domain.
+For more details refer to the `python.org email policy
+`_.
+
+
+Poll template
+=============
+
+.. _coredev-template:
+
+While Discourse uses Markdown for formatting, the poll functionality is
+custom and somewhat resembles BBcode. There's a creator for polls in the
+UI (click the cog icon in the edit box toolbar and choose "Build Poll").
+Here's what it outputs, you can copy and paste it for your poll:
+
+.. code-block:: bbcode
+
+ [poll type=regular results=on_close public=false chartType=bar groups=committers close=2024-07-15T21:15:00.000Z]
+ * Promote Basil Fawlty
+ * Do not promote
+ [/poll]
+
+The important options in the poll builder set to get this result:
+
+- Show who voted: **disabled** (``public=false``)
+- Limit voting to these groups: **committers** (``groups=committers``)
+- Automatically close poll: **in 7 days** (``close=...``)
+- Show results: **When poll is closed** (``results=on_close``)
+
+.. raw:: html
+
+
+
+.. _Code of Conduct: https://policies.python.org/python.org/code-of-conduct/
+.. _Committers category: https://discuss.python.org/c/committers/5
+.. _Python Discourse: https://discuss.python.org
diff --git a/core-team/memorialization.rst b/core-team/memorialization.rst
new file mode 100644
index 000000000..7ab0fab02
--- /dev/null
+++ b/core-team/memorialization.rst
@@ -0,0 +1,159 @@
+.. _memorialize-core-developer:
+.. _memorialize-core-team-member:
+
+===============
+Memorialization
+===============
+
+Rationale
+=========
+
+When a core team member passes away, memorializing accounts helps create
+a space for remembering the contributor and protects against attempted
+logins and fraudulent activity.
+
+The process
+===========
+
+The memorialization process is performed by a member of the PSF staff
+with administrative access to current and historical systems where
+the core team has access.
+
+After the status of the core team member in question is confirmed,
+access to the systems listed below is revoked and some changes are
+made to how the user displays to others.
+
+To respect the choices that someone made while alive, we aim to preserve
+content of their accounts without changes after they've passed away.
+To support the bereaved, in some instances, we may remove or change
+certain content when the legacy contact or family members request it.
+
+GitHub
+------
+
+* The user is removed from the `python/ `_
+ organization on GitHub;
+* The user is removed from the `psf/ `_
+ organization on GitHub;
+* The user is removed from the `pypa/ `_
+ organization on GitHub.
+
+The PSF staff does not follow up with GitHub with regards to GitHub account
+cancellation as this action is reserved for next-of-kin or designated by
+the deceased GitHub user to act as an account successor.
+
+The general policy regarding deceased users on GitHub is described on their
+`Deceased User Policy `_
+page.
+
+Repositories in the organization
+--------------------------------
+
+* The user's GitHub handle is removed from ``/.github/CODEOWNERS``.
+ To see all that need action, perform
+ `this query `_.
+* The user is marked as deceased in the private
+ `voters/python-core.toml `_
+ file with the ``left=`` field set to the day of passing, if known.
+
+discuss.python.org
+------------------
+
+* The user's "custom status" is set to 🕊 ``in memoriam``;
+* The user's "about me" is amended with ``$firstname passed away on $date. [In memoriam.]($in_memoriam_post_url)``;
+* In the user's security "recently used devices" the staff member
+ chooses "Log out all";
+* In the user's permissions the staff member chooses "Deactivate account";
+* The user's trust level is reset to ``1: basic user`` (trust level 0
+ doesn't allow links in "About Me");
+* The user's "associated accounts" (like GitHub) that provide an
+ alternative login method, are all disconnected;
+* The user's API keys are revoked;
+* The user's admin or moderator right is revoked;
+* The user's primary email address is reset to
+ ``USERNAME@in-memoriam.invalid`` and secondary email addresses are
+ removed (this step requires the administrator to contact Discourse.org
+ staff via ``team@discourse.org``).
+
+The "in memoriam" Discourse topic mentioned above is best created by
+a community member close to the deceased.
+
+The general best practice for deceased community members on
+Discourse-powered forums is described on their
+`Best practices for deceased community members `_
+page.
+
+python.org email account
+------------------------
+
+The PSF staff member emails ``postmaster@python.org`` to ask the email
+administrator to:
+
+* remove SMTP access from ``USERNAME@python.org``;
+* reset the password to POP3/IMAP for ``USERNAME@python.org``;
+* disable email forwarding, if set up, for ``USERNAME@python.org`` and
+ leave a record permanently as "in memoriam" to avoid future account
+ name reuse;
+* remove this email from all mailing lists under ``@python.org``;
+* remove any known alternate emails for the same user from all mailing
+ lists under ``@python.org``.
+
+In case the email shutdown causes issues for the estate executors, the
+PSF will reasonably try to help if contacted directly.
+
+python.org admin
+----------------
+
+* The user's account (``/admin/users/user``) is deactivated (NOT deleted)
+ and their staff and superuser status is unchecked;
+* The user's password is reset to a long random string;
+* The user's primary email address is set to
+ ``USERNAME@in-memoriam.invalid`` and set as unverified;
+* The user's secondary email addresses are deleted;
+* The user's API keys (both on the account and ``tastypie``) are deleted;
+* The user's "I would like to be a PSF Voting Member" field is cleared.
+
+devguide.python.org
+-------------------
+
+* The user is marked as deceased in `core-team.csv `_;
+* The user is removed from the `experts index `_.
+
+bugs.python.org
+---------------
+
+While the issue tracker was migrated to GitHub, the Roundup instance
+is still up for historical purposes.
+
+* the PSF staff member logs into ``bugs.nyc1.psf.io``;
+* the PSF staff member runs ``roundup-admin`` to set the user's email
+ address to ``USERNAME@in-memoriam.invalid``;
+* the user's alternate emails are removed;
+* the user's password is reset to a long random string;
+* the PSF staff member removes any active login sessions from Postgres.
+
+Other PSF-related infrastructure
+--------------------------------
+
+* The PSF staff member notifies administrators of the Python Core Devs
+ Discord server to remove the user from the server. The PSF staff
+ does not follow up with Discord with regards to Discord account
+ cancellation. The general policy regarding deceased users on Discord
+ is available on their `Deceased or Incapacitated Users `_
+ page.
+
+* The user is removed from Salt configuration for the PSF infrastructure
+ in `/pillar/base/users `_
+ that allows SSH access to PSF-controlled servers.
+
+* The user might have ran a buildbot worker. The PSF staff member will
+ look for that in the
+ `buildmaster-config `_
+ repository.
+
+PyPI
+----
+
+* The PSF staff member notifies PyPI admins by emailing them at
+ ``admin@pypi.org`` to mark the user as inactive, remove their email
+ addresses, prohibit their password resets, and revoke all API keys.
diff --git a/core-developers/motivations.rst b/core-team/motivations.rst
similarity index 75%
rename from core-developers/motivations.rst
rename to core-team/motivations.rst
index 1c813730d..d5a87e22c 100644
--- a/core-developers/motivations.rst
+++ b/core-team/motivations.rst
@@ -1,25 +1,25 @@
.. _motivations:
============================
-Motivations and Affiliations
+Motivations and affiliations
============================
-CPython core developers participate in the core development process for a
-variety of reasons. Being accepted as a core developer indicates that
+CPython core team members participate in the core development process for a
+variety of reasons. Being accepted as a core team member indicates that
an individual is interested in acquiring those responsibilities, has the
-ability to collaborate effectively with existing core developers, and has had
+ability to collaborate effectively with existing core team members, and has had
the time available to demonstrate both that interest and that ability.
-This page allows core developers that choose to do so to provide more
+This page allows core team members that choose to do so to provide more
information to the rest of the Python community regarding their personal
situation (such as their general location and professional affiliations), as
well as any personal motivations that they consider particularly relevant.
-Core developers that wish to provide this additional information add a new
+Core team members that wish to provide this additional information add a new
entry to the :ref:`published-motivations` section below. Guidelines relating
to content and layout are included as comments in the source code for this page.
-Core developers that are available for training, consulting, contract, or
+Core team members who are available for training, consulting, contract, or
full-time work, or are seeking crowdfunding support for their community
contributions, may also choose to provide that information here (including
linking out to commercial sites with the relevant details).
@@ -32,7 +32,7 @@ For more information on the origins and purpose of this page, see
Published entries
=================
-The following core developers have chosen to provide additional details
+The following core team members have chosen to provide additional details
regarding their professional affiliations and (optionally) other reasons for
participating in the CPython core development process:
@@ -43,7 +43,7 @@ participating in the CPython core development process:
Topic headings should be in the form of "Name (Country)" or
"Name (Continent)" to help give some indication as to the geographic
- distribution of core developers.
+ distribution of core team members.
NOTE: The rest of these guidelines are highly provisional - we can evolve
them as people add entries, and we decide on the style we like. The
@@ -80,7 +80,7 @@ participating in the CPython core development process:
country of residence.
Include a "Crowdfunding" bullet point with a link if you'd like to highlight
- crowdfunding services (e.g. Patreon) that folks can use to support your core
+ crowdfunding services (for example, Patreon) that folks can use to support your core
development work.
Include additional bullet points (without links) for any other affiliations
@@ -89,9 +89,9 @@ participating in the CPython core development process:
If there's a kind of link you'd like to include in your entry that isn't
already covered by the categories mentioned above, please start a discussion
about that on the Committers category on the Python Discourse
- (discuss.python.org) or the python-committers mailing list.
+ (discuss.python.org).
- The Committers Discourse category or the python-committers mailing list
+ The Committers Discourse category
is also the appropriate point of contact for any other
questions or suggestions relating to this page.
@@ -101,21 +101,25 @@ participating in the CPython core development process:
* Microsoft (Software Developer)
* Python Software Foundation (Fellow)
-.. topic:: Nick Coghlan (Australia)
+.. topic:: Alyssa Coghlan (Australia)
* Personal site: `Curious Efficiency `_
* `Extended bio `__
- * `Tritium `__ (Software Developer)
* Python Software Foundation (Fellow, Packaging Working Group)
+ * Element Labs/LM Studio (Python deployment engineer)
- Nick began using Python as a testing and prototyping language while working
- for Boeing Defence Australia, and continues to use it for that purpose today.
+ Alyssa began using Python as a testing and prototyping language while working
+ for Boeing Defence Australia. She now primarily uses it as the lead project
+ maintainer for the open source ``venvstacks`` Python deployment utility.
- As a core developer, he is primarily interested in helping to ensure Python's
+ As a core team member, she is primarily interested in helping to ensure Python's
continued suitability for educational, testing and data analysis use cases,
as well as in encouraging good architectural practices when assembling Python
applications and test harnesses from open source components.
+ Note: prior to August 2023, Alyssa used her birth name (Nick Coghlan). Some records
+ (for example, mailing list archives, version control history) will still reference that name.
+
.. topic:: Steve Dower (United States/Australia)
* Microsoft (Software Developer)
@@ -128,7 +132,7 @@ participating in the CPython core development process:
devices, and now works for Microsoft on anything that makes Python more
accessible to developers on any platform.
- As a core developer, his focus is on maintaining the already excellent
+ As a core team member, his focus is on maintaining the already excellent
Windows support and improving Python's ability to be embedded in other
applications.
@@ -143,7 +147,7 @@ participating in the CPython core development process:
* Works as a `Software Engineer `_
in Vancouver, helps organize `Vancouver PyLadies
`_ meetup on the side, and
- sometimes `speaks `_
+ sometimes `speaks `_
at conferences.
* Email address: mariatta@python.org
* `Sponsor Mariatta on GitHub `_
@@ -155,7 +159,7 @@ participating in the CPython core development process:
.. topic:: R. David Murray (United States)
- * Personal site: `bitdance.com `_
+ * Personal site: `bitdance.com `_
* Available for `Python and Internet Services Consulting
and Python contract programming `_
@@ -166,7 +170,7 @@ participating in the CPython core development process:
business started declining) to being a full time independent consultant,
David started contributing directly to CPython development. He became a
committer in 2009. He subsequently took over primary maintenance of the
- email package from Barry Warsaw, and contributed the unicode oriented API.
+ email package from Barry Warsaw, and contributed the Unicode oriented API.
David is also active in mentoring new contributors and, when time is
available, working on the infrastructure that supports CPython development,
specifically the Roundup-based bug tracker and the buildbot system.
@@ -175,7 +179,7 @@ participating in the CPython core development process:
primarily in Python, through the company in which he is a partner, `Murray &
Walker, Inc `_. He has done contract work
focused specifically on CPython development both through the PSF (the
- kickstart of the email unicode API development) and directly funded by
+ kickstart of the email Unicode API development) and directly funded by
interested corporations (additional development work on email funded by
QNX, and work on CPython ICC support funded by Intel). He would like to
spend more of his (and his company's) time on open source work, and so is
@@ -184,23 +188,23 @@ participating in the CPython core development process:
.. topic:: Antoine Pitrou (France)
* LinkedIn: ``_ (Senior Software Engineer)
- * Voltron Data
+ * QuantStack
* Python Software Foundation (Fellow)
* Email address: antoine@python.org
Antoine started working with Python in 2005 in order to implement a
decentralized virtual world protocol. He started contributing to CPython
- in 2007 and became a core developer in 2008. His motivations have been
+ in 2007 and became a core team member in 2008. His motivations have been
driven both by the abstract desire to make Python better for the whole
world, and by the concrete roadblocks he was hitting in professional
settings. Topics of choice have included interpreter optimizations,
garbage collection, network programming, system programming and
- concurrent programming (such as maintaining ``multiprocessing``).
+ concurrent programming.
As a professional, Antoine has been first specializing in network
programming, and more lately in open source data science infrastructure.
- He is currently working full time on Apache Arrow as a technical leader
- for Voltron Data.
+ He has made numerous contributions to Numba, Dask and is currently working
+ full time on Apache Arrow as a technical leader at QuantStack.
.. topic:: Victor Stinner (France)
@@ -219,25 +223,23 @@ participating in the CPython core development process:
.. topic:: Barry Warsaw (United States)
- * `LinkedIn: `_ (Senior Staff
- Software Engineer - Python Foundation team)
+ * NVIDIA, Principal System Software Engineer, Open Source Python Ecosystem
* Personal site: `barry.warsaw.us `_
* Blog: `We Fear Change `_
+ * `LinkedIn `_
+ * `Bluesky `_
* Email address: barry@python.org
* Python Software Foundation (Fellow)
Barry has been working in, with, and on Python since 1994. He attended the
- first Python workshop at NBS (now `NIST `_) in
- Gaithersburg, MD in 1994, where he met Guido and several other early Python
- adopters. Barry subsequently worked with Guido for 8 years while at `CNRI
- `_. From 2007 until 2017, Barry worked for
- `Canonical `_, corporate sponsor of `Ubuntu
- `_ Linux, primarily on the Python ecosystem, and
- is both an Ubuntu and a `Debian `_ uploading
- developer. Barry has served as Python's postmaster, webmaster, release
- manager, Language Summit co-chair, `Jython `_
- project leader, `GNU Mailman `_ project leader, and
- probably lots of other things he shouldn't admit to.
+ first Python workshop at `NIST `_ in Gaithersburg,
+ MD in 1994, where he met Guido and several other early Python adopters.
+ Barry subsequently worked with Guido for 8 years while at `CNRI
+ `_. Barry has served as Python's postmaster,
+ webmaster, release manager, Language Summit co-chair, `Jython
+ `_ project leader, `GNU Mailman
+ `_ project leader, and Python Steering Council
+ member in 2019, 2020, 2021, 2024, and 2025.
.. topic:: Eric Snow (United States)
@@ -259,15 +261,15 @@ participating in the CPython core development process:
.. topic:: Carol Willing (United States)
- * Noteable: ``__ (Technical Evangelist)
+ * Noteable (VP Engineering)
* Personal site: `Willing Consulting `_
* `Extended bio `__
- * Project Jupyter (Steering Council, Core Team for JupyterHub/Binder)
+ * Project Jupyter (Software Council, Core Team for JupyterHub/Binder)
* Python Software Foundation (Fellow)
Carol is focused on Python's usage in education and scientific research.
- She is interested in organizational development, operational workflows,
- and sustainability of open source projects.
+ She is interested in distributed computing, organizational development,
+ operational workflows, and sustainability of open source projects.
.. _goals-of-the-motivations-page:
@@ -277,12 +279,12 @@ Goals of this page
The `issue metrics`_ automatically collected by the CPython issue tracker
strongly suggest that the current core development process is bottlenecked on
-core developer time - this is most clearly indicated in the first metrics graph,
-which shows both the number of open issues and the number of patches awaiting
+core team time. This is most clearly indicated in the first metrics graph,
+which shows both the number of open issues and the number of pull requests awaiting
review growing steadily over time, despite CPython being one of the most
active open source projects in the world. This bottleneck then impacts not only
-resolving open issues and applying submitted patches, but also the process of
-identifying, nominating and mentoring new core developers.
+resolving open issues and accepting submitted pull requests, but also the process of
+identifying, nominating and mentoring new core team members.
The core commit statistics monitored by sites like `OpenHub`_ provide a good
record as to *who* is currently handling the bulk of the review and maintenance
@@ -291,13 +293,13 @@ people's ability to spend time on reviewing proposed changes, or mentoring new
contributors.
This page aims to provide at least some of that missing data by encouraging
-core developers to highlight professional affiliations in the following two
+core team members to highlight professional affiliations in the following two
cases (even if not currently paid for time spent participating in the core
development process):
-* developers working for vendors that distribute a commercially supported
+* members working for vendors that distribute a commercially supported
Python runtime
-* developers working for Sponsor Members of the Python Software Foundation
+* members working for Sponsor Members of the Python Software Foundation
These are cases where documenting our affiliations helps to improve the
overall transparency of the core development process, as well as making it
@@ -305,27 +307,27 @@ easier for staff at these organisations to locate colleagues that can help
them to participate in and contribute effectively to supporting the core
development process.
-Core developers working for organisations with a vested interest in the
+Core team members working for organisations with a vested interest in the
sustainability of the CPython core development process are also encouraged to
seek opportunities to spend work time on mentoring potential new core
developers, whether through the general `core mentorship program`_, through
mentoring colleagues, or through more targeted efforts like Outreachy's paid
`internships`_ and Google's `Summer of Code`_.
-Core developers that are available for consulting or contract work on behalf of
+Core team members who are available for consulting or contract work on behalf of
the Python Software Foundation or other organisations are also encouraged
to provide that information here, as this will help the PSF to better
facilitate funding of core development work by organisations that don't
-directly employ any core developers themselves.
+directly employ any core team members themselves.
-Finally, some core developers seeking to increase the time they have available
+Finally, some core team members seeking to increase the time they have available
to contribute to CPython may wish to pursue crowdfunding efforts that allow
their contributions to be funded directly by the community, rather than relying
on institutional sponsors allowing them to spend some or all of their work
time contributing to CPython development.
.. _issue metrics: https://bugs.python.org/issue?@template=stats
-.. _OpenHub: https://www.openhub.net/p/python/contributors
+.. _OpenHub: https://openhub.net/p/python/contributors
.. _core mentorship program: https://www.python.org/dev/core-mentorship/
.. _internships: https://www.outreachy.org/
.. _Summer of Code: https://wiki.python.org/moin/SummerOfCode/2016
@@ -334,15 +336,15 @@ time contributing to CPython development.
Limitations on scope
====================
-* Specific technical areas of interest for core developers should be captured in
+* Specific technical areas of interest for core team members should be captured in
the :ref:`Experts Index `.
-* This specific listing is limited to CPython core developers (since it's
- focused on the specific constraint that is core developer time), but it
+* This specific listing is limited to CPython core team members (since it's
+ focused on the specific constraint that is core team member time), but it
would be possible to create a more expansive listing on the Python wiki that
- also covers issue triagers, and folks seeking to become core developers.
+ also covers issue triagers, and folks seeking to join the core team.
-* Changes to the software and documentation maintained by core developers,
+* Changes to the software and documentation maintained by the core team,
together with related design discussions, all take place in public venues, and
hence are inherently subject to full public review. Accordingly, core
developers are NOT required to publish their motivations and affiliations if
diff --git a/core-developers/responsibilities.rst b/core-team/responsibilities.rst
similarity index 79%
rename from core-developers/responsibilities.rst
rename to core-team/responsibilities.rst
index aec4b98cc..3b2137d6b 100644
--- a/core-developers/responsibilities.rst
+++ b/core-team/responsibilities.rst
@@ -5,25 +5,25 @@ Responsibilities
================
As contributors to the CPython project, our shared responsibility is to
-collaborate constructively with other contributors, including core developers.
+collaborate constructively with other contributors, including core team members.
This responsibility covers all forms of contribution, whether that's submitting
-patches to the implementation or documentation, reviewing other peoples'
-patches, triaging issues on the issue tracker, or discussing design and
+pull requests to the implementation or documentation, reviewing other peoples'
+pull requests, triaging issues on the issue tracker, or discussing design and
development ideas on the core
:ref:`communication channels `.
-Core developers accept key additional responsibilities around the ongoing
+Core team members accept key additional responsibilities around the ongoing
management of the project:
-* core developers bear the additional responsibility of handling the
+* core team members bear the additional responsibility of handling the
consequences of accepting a change into the code base or documentation.
That includes reverting or fixing it if it causes problems in the
Buildbot fleet or someone spots a problem in post-commit review, as well
as helping out the release manager in resolving any problems found during
the pre-release testing cycle. While all contributors are free to help out
with this part of the process, and it is most welcome when they do, the
- actual responsibility rests with the core developer that merged the change
-* core developers also bear the primary responsibility for deciding when
+ actual responsibility rests with the core team member that merged the change
+* core team members also bear the primary responsibility for deciding when
changes proposed on the issue tracker should be escalated to
the appropriate :ref:`Discourse ` category
for wider discussion, as well as suggesting the use of the
@@ -31,20 +31,20 @@ management of the project:
of complex changes, or changes with a potentially significant impact on
end users
-As a result of the additional responsibilities they accept, core developers
+As a result of the additional responsibilities they accept, core team members
gain the privilege of being able to approve proposed changes, as well as being
-able to reject them as inappropriate. Core developers are also able to request
+able to reject them as inappropriate. Core team members are also able to request
that even already merged changes be escalated to
:ref:`Discourse ` for further discussion,
and potentially even reverted prior to release.
-Becoming a core developer isn't a binary "all-or-nothing" status - CPython
-is a large project, and different core developers accept responsibility for
+Joining the core team isn't a binary "all-or-nothing" status - CPython
+is a large project, and different core team members accept responsibility for
making design and development decisions in different areas (as documented
in the :ref:`experts` and :ref:`developers`).
-Communication Channels and Bug Notifications
+Communication channels and bug notifications
============================================
Mailing lists have generally been replaced by the
@@ -59,7 +59,7 @@ follow the link and click on the :guilabel:`Watch` button to set your notificati
.. _contributor_agreement:
-Sign a Contributor Agreement
+Sign a contributor agreement
============================
Submitting a `contributor form for Python`_ licenses any code you contribute to
@@ -68,7 +68,7 @@ the ability to license your code means it can be put under the PSF license so
it can be legally distributed with Python.
This is a very important step! Hopefully you have already submitted a
-contributor agreement if you have been submitting patches. But if you have not
+contributor agreement if you have been submitting pull requests. But if you have not
done this yet, it is best to do this ASAP, probably before you even do your
first commit so as to not forget. Also do not forget to enter your GitHub
username into your details on the issue tracker.
@@ -77,12 +77,12 @@ username into your details on the issue tracker.
.. _contributor form for Python: https://www.python.org/psf/contrib/
-Pull Request merging
+Pull request merging
====================
Once you have your commit privileges on GitHub you will be able to accept
pull requests on GitHub. You should plan to continue to submit your own
-changes through pull requests as if you weren't a core developer to benefit
+changes through pull requests as if you weren't a core team member to benefit
from various things such as automatic integration testing, but you
can accept your own pull requests if you feel comfortable doing so.
@@ -90,13 +90,13 @@ can accept your own pull requests if you feel comfortable doing so.
Expectations
============
-As a core developer, there are certain things that are expected of you.
+As a core team member, there are certain things that are expected of you.
First and foremost, be a good person. This might sound melodramatic, but you
are now a member of the Python project and thus represent the project and your
-fellow core developers whenever you discuss Python with anyone. We have a
+fellow core team members whenever you discuss Python with anyone. We have a
reputation for being a very nice group of people and we would like to keep it
-that way. Core developers responsibilities include following the `PSF Code of
+that way. Core team responsibilities include following the `PSF Code of
Conduct`_.
Second, please be prompt in responding to questions. Many contributors to Python
@@ -118,7 +118,7 @@ remove yourself from the list.
Fourth, please consider whether or not you wish to add your name to the
:ref:`motivations` list. Core contributor participation in the list helps the
wider Python community to better appreciate the perspectives currently
-represented amongst the core development team, the Python Software Foundation
+represented amongst the core team, the Python Software Foundation
to better assess the sustainability of current contributions to CPython core
development, and also serves as a referral list for organisations seeking
commercial Python support from the core development community.
@@ -127,4 +127,4 @@ And finally, enjoy yourself! Contributing to open source software should be fun
(overall). If you find yourself no longer enjoying the work then either take a
break or figure out what you need to do to make it enjoyable again.
-.. _PSF Code of Conduct: https://www.python.org/psf/conduct/
+.. _PSF Code of Conduct: https://policies.python.org/python.org/code-of-conduct/
diff --git a/core-developers/developer-log.rst b/core-team/team-log.rst
similarity index 81%
rename from core-developers/developer-log.rst
rename to core-team/team-log.rst
index 5a7ff01dd..77639ebf1 100644
--- a/core-developers/developer-log.rst
+++ b/core-team/team-log.rst
@@ -1,19 +1,20 @@
.. _developer-log:
.. _developers:
+.. _team-log:
-Developer Log
-=============
+Team log
+========
-This page lists the historical members of the Python development team. (The
+This page lists the historical members of the Python core team. (The
master list is kept in a private repository due to containing sensitive contact
information.)
.. csv-table::
:header: "Name", "GitHub username", "Joined", "Left", "Notes"
- :file: developers.csv
+ :file: core-team.csv
:encoding: "utf-8"
-Procedure for Granting or Dropping Access
+Procedure for granting or dropping access
-----------------------------------------
To be granted the ability to manage who is a committer, you must be a
diff --git a/developer-workflow/c-api.rst b/developer-workflow/c-api.rst
index 5564bdc9c..90c1d12e4 100644
--- a/developer-workflow/c-api.rst
+++ b/developer-workflow/c-api.rst
@@ -4,21 +4,28 @@
Changing Python's C API
=======================
-The C API is divided into three sections:
+The C API is divided into these tiers:
1. The internal, private API, available with ``Py_BUILD_CORE`` defined.
Ideally declared in ``Include/internal/``. Any API named with a leading
underscore is also considered private.
-2. The public C API, available when ``Python.h`` is included normally.
+2. The Unstable C API, identified by the ``PyUnstable_`` name prefix.
+ Ideally declared in :cpy-file:`Include/cpython/` along with the general public API.
+3. The “general” public C API, available when :cpy-file:`Include/Python.h` is included normally.
Ideally declared in ``Include/cpython/``.
-3. The Limited API, available with ``Py_LIMITED_API`` defined.
+4. The Limited C API, available with :c:macro:`Py_LIMITED_API` defined.
Ideally declared directly under ``Include/``.
-Each section has higher stability & maintenance requirements, and you will
-need to think about more issues when you add or change definitions in it.
+Each tier has different stability and maintenance requirements to consider
+when you add or change definitions in it.
-The compatibility guarantees for public C API are explained in the
-user documentation, ``Doc/c-api/stable.rst`` (:ref:`python:stable`).
+The public backwards compatibility guarantees for public C API are explained
+in the user documentation, ``Doc/c-api/stable.rst`` (:ref:`python:stable`).
+C language compatibility guarantees are in ``Doc/c-api/intro.rst``
+(:ref:`python:api-intro`).
+
+As core developers, we need to be more careful about compatibility than what
+we promise publicly. See :ref:`public-capi` for details.
The internal API
@@ -29,6 +36,11 @@ for building CPython itself, as indicated by a macro like ``Py_BUILD_CORE``.
While internal API can be changed at any time, it's still good to keep it
stable: other API or other CPython developers may depend on it.
+For users, internal API is sometimes the best workaround for a thorny problem
+--- though those use cases should be discussed on the
+`C API Discourse category `_
+or an issue so we can try to find a supported way to serve them.
+
With PyAPI_FUNC or PyAPI_DATA
-----------------------------
@@ -36,6 +48,7 @@ With PyAPI_FUNC or PyAPI_DATA
Functions or structures in ``Include/internal/`` defined with
``PyAPI_FUNC`` or ``PyAPI_DATA`` are internal functions which are
exposed only for specific use cases like debuggers and profilers.
+Ideally, these should be migrated to the :ref:`unstable-capi`.
With the extern keyword
@@ -50,19 +63,23 @@ When in doubt, new internal C functions should be defined in
``Include/internal`` using the ``extern`` keyword.
Private names
---------------
+-------------
Any API named with a leading underscore is also considered internal.
-There are two main use cases for using such names rather than putting the
-definition in ``Include/internal/`` (or directly in a ``.c`` file):
+There is currently only one main use case for using such names rather than
+putting the definition in :cpy-file:`Include/internal/` (or directly in a ``.c`` file):
+
+* Internal helpers for other public APIs, which users should not call directly.
+
+Note that historically, underscores were used for APIs that are better served by
+the :ref:`unstable-capi`:
+
+* “provisional” APIs, included in a Python release to test real-world
+ usage of new APIs;
+* APIs for very specialized uses like JIT compilers.
-* Internal helpers for other public API; users should not use these directly;
-* “Provisional” API, included in a Python release to test real-world usage
- of new API. Such names should be renamed when stabilized; preferably with
- a macro aliasing the old name to the new one.
- See :pep:`"Finalizing the API" in PEP 590 <590#finalizing-the-api>` for an example.
-Internal API Tests
+Internal API tests
------------------
C tests for the internal C API live in ``Modules/_testinternalcapi.c``.
@@ -81,7 +98,21 @@ CPython's public C API is available when ``Python.h`` is included normally
It should be defined in ``Include/cpython/`` (unless part of the Limited API,
see below).
-Guidelines for expanding/changing the public API:
+Before adding new public API, please ask in the `decisions repo`_ of
+the :pep:`C API workgroup <731>`.
+This helps us ensure *newly added* API is consistent and maintainable.
+
+Also check with the C API WG before requiring a C feature not present in C99.
+While the *public* docs only promise compatibility with C11, in practice
+we only intruduce C11 features individually as needed.
+
+.. _decisions repo: https://github.com/capi-workgroup/decisions/issues
+
+
+.. _public-api-guidelines:
+
+Guidelines for expanding/changing the public API
+------------------------------------------------
- Make sure the new API follows reference counting conventions.
(Following them makes the API easier to reason about, and easier use
@@ -94,19 +125,37 @@ Guidelines for expanding/changing the public API:
- Make sure the ownership rules and lifetimes of all applicable struct
fields, arguments and return values are well defined.
+- Functions returning ``PyObject *`` must return a valid pointer on success,
+ and ``NULL`` with an exception raised on error.
+ Most other API must return ``-1`` with an exception raised on error,
+ and ``0`` on success.
-C API Tests
+- APIs with lesser and greater results must return ``0`` for the lesser result,
+ and ``1`` for the greater result.
+ Consider a lookup function with a three-way return:
+
+ - ``return -1``: internal error or API misuse; exception raised
+ - ``return 0``: lookup succeeded; no item was found
+ - ``return 1``: lookup succeeded; item was found
+
+Please start a public discussion if these guidelines won't work for your API.
+
+.. note::
+
+ By *return value*, we mean the value returned by the *C return statement*.
+
+C API tests
-----------
Tests for the public C API live in the ``_testcapi`` module.
Functions named ``test_*`` are used as tests directly.
Tests that need Python code (or are just easier to partially write in Python)
-live in ``Lib/test``, mainly in :file:`Lib/test/test_capi.py`.
+live in ``Lib/test``, mainly in :cpy-file:`Lib/test/test_capi`.
Due to its size, the ``_testcapi`` module is defined in several source
files.
To add a new set of tests (or extract a set out of the monolithic
-:file:`Modules/_testcapimodule.c`):
+:cpy-file:`Modules/_testcapimodule.c`):
- Create a C file named ``Modules/_testcapi/yourfeature.c``
@@ -122,6 +171,11 @@ To add a new set of tests (or extract a set out of the monolithic
- Call the ``_PyTestCapi_Init_*`` from ``PyInit__testcapi`` in
``Modules/_testcapimodule.c``.
+- Add the new C file to :cpy-file:`Modules/Setup.stdlib.in`,
+ :cpy-file:`PCbuild/_testcapi.vcxproj` and
+ :cpy-file:`PCbuild/_testcapi.vcxproj.filters`,
+ alongside the other ``_testcapi/*.c`` entries.
+
Note that all ``Modules/_testcapi/*.c`` sources initialize the same module,
so be careful about name collisions.
@@ -129,6 +183,105 @@ When moving existing tests, feel free to replace ``TestError`` with
``PyExc_AssertionError`` unless actually testing custom exceptions.
+.. _unstable-capi:
+
+Unstable C API
+==============
+
+The unstable C API tier is meant for extensions that need tight integration
+with the interpreter, like debuggers and JIT compilers.
+Users of this tier may need to change their code with every feature release.
+
+In many ways, this tier is like the general C API:
+
+- it's available when ``Python.h`` is included normally,
+- it should be defined in :cpy-file:`Include/cpython/`,
+- it requires tests, so we don't break it unintentionally
+- it requires docs, so both we and the users,
+ can agree on the expected behavior,
+- it is tested and documented in the same way.
+
+The differences are:
+
+- Names of functions structs, macros, etc. start with the ``PyUnstable_``
+ prefix. This defines what's in the unstable tier.
+- The unstable API can change in feature releases, without any deprecation
+ period.
+- A stability note appears in the docs.
+ This happens automatically, based on the name
+ (via :cpy-file:`Doc/tools/extensions/c_annotations.py`).
+
+Despite being “unstable”, there are rules to make sure third-party code can
+use this API reliably:
+
+* Changes and removals can be done in feature releases
+ (:samp:`3.{x}.0`, including Alphas and Betas for :samp:`3.{x}.0`).
+* Adding a new unstable API *for an existing feature* is allowed even after
+ Beta feature freeze, up until the first Release Candidate.
+ Consensus on the `Core Development Discourse `_
+ is needed in the Beta period.
+* Backwards-incompatible changes should make existing C callers fail to compile.
+ For example, arguments should be added/removed, or a function should be
+ renamed.
+* When moving an API into or out of the Unstable tier, the old name
+ should continue to be available (but deprecated) until an incompatible
+ change is made. In other words, while we're allowed to break calling code,
+ we shouldn't break it *unnecessarily*.
+
+
+Moving an API from the public tier to Unstable
+----------------------------------------------
+
+* Expose the API under its new name, with the ``PyUnstable_`` prefix.
+ The ``PyUnstable_`` prefix must be used for all symbols (functions, macros,
+ variables, etc.).
+* Make the old name an alias (for example, a ``static inline`` function calling the
+ new function).
+* Deprecate the old name, typically using :c:macro:`Py_DEPRECATED`.
+* Announce the change in the "What's New".
+
+The old name should continue to be available until an incompatible change is
+made. Per Python’s backwards compatibility policy (:pep:`387`),
+this deprecation needs to last at least two releases
+(modulo Steering Council exceptions).
+
+The rules are relaxed for APIs that were introduced in Python versions
+before 3.12, when the official Unstable tier was added.
+You can make an incompatible change (and remove the old name)
+as if the function was already part of the Unstable tier
+for APIs introduced before Python 3.12 that are either:
+
+* Documented to be less stable than default.
+* Named with a leading underscore.
+
+Moving an API from the private tier to unstable
+-----------------------------------------------
+
+* Expose the API under its new name, with the ``PyUnstable_`` prefix.
+* If the old name is documented, or widely used externally,
+ make it an alias and deprecate it (typically with :c:macro:`Py_DEPRECATED`).
+ It should continue to be available until an incompatible change is made,
+ as if it was previously public.
+
+ This applies even to underscored names. Python wasn't always strict with
+ the leading underscore.
+* Announce the change in What's New.
+
+Moving an API from unstable to public
+-------------------------------------
+
+* Expose the API under its new name, without the ``PyUnstable_`` prefix.
+* Make the old ``PyUnstable_*`` name be an alias (for example, a ``static inline``
+ function calling the new function).
+* Announce the change in What's New.
+
+The old name should remain available until the
+new public name is deprecated or removed.
+There's no need to deprecate the old name (it was unstable to begin with),
+but there's also no need to break working code just because some function
+is now ready for a wider audience.
+
+
Limited API
===========
@@ -178,10 +331,13 @@ It is possible to remove items marked as part of the Stable ABI, but only
if there was no way to use them in any past version of the Limited API.
+.. _limited-api-guidelines:
+
Guidelines for adding to the Limited API
----------------------------------------
- Guidelines for the general :ref:`public-capi` apply.
+ See :ref:`public-api-guidelines`.
- New Limited API should only be defined if ``Py_LIMITED_API`` is set
to the version the API was added in or higher.
@@ -253,7 +409,7 @@ Adding a new definition to the Limited API
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03yy0000
- with the ``yy`` corresponding to the target CPython version, e.g.
+ with the ``yy`` corresponding to the target CPython version, for example,
``0x030A0000`` for Python 3.10.
- Append an entry to the Stable ABI manifest, ``Misc/stable_abi.toml``
- Regenerate the autogenerated files using ``make regen-limited-abi``.
@@ -261,19 +417,19 @@ Adding a new definition to the Limited API
.. code-block:: shell
- ./python ./Tools/scripts/stable_abi.py --generate-all ./Misc/stable_abi.toml
+ ./python ./Tools/build/stable_abi.py --generate-all ./Misc/stable_abi.toml
- Build Python and check the using ``make check-limited-abi``.
On platforms without ``make``, run this command directly:
.. code-block:: shell
- ./python ./Tools/scripts/stable_abi.py --all ./Misc/stable_abi.toml
+ ./python ./Tools/build/stable_abi.py --all ./Misc/stable_abi.toml
- Add tests -- see below.
-Limited API Tests
+Limited API tests
-----------------
Since Limited API is a subset of the C API, there's no need to test the
@@ -286,7 +442,7 @@ To add a test file:
- Add a C file ``Modules/_testcapi/yourfeature_limited.c``. If that file
already exists but its ``Py_LIMITED_API`` version is too low, add a version
- postfix, e.g. ``yourfeature_limited_3_12.c`` for Python 3.12+.
+ postfix, for example, ``yourfeature_limited_3_12.c`` for Python 3.12+.
- ``#define Py_LIMITED_API`` to the minimum limited API version needed.
- ``#include "parts.h"`` after the ``Py_LIMITED_API`` definition
- Enclose the entire rest of the file in ``#ifdef LIMITED_API_AVAILABLE``,
diff --git a/developer-workflow/communication-channels.rst b/developer-workflow/communication-channels.rst
index 239855bb1..9b088b350 100644
--- a/developer-workflow/communication-channels.rst
+++ b/developer-workflow/communication-channels.rst
@@ -2,7 +2,7 @@
.. _communication:
==============================
-Following Python's Development
+Following Python's development
==============================
Python's development is communicated through a myriad of ways,
@@ -24,15 +24,16 @@ in return.
.. _mailinglists:
-Mailing Lists
+Mailing lists
=============
-.. note:: Some mailing lists have been supplanted by categories in the
- Python `Discourse`_. Specifically,
+.. note::
+
+ Mailing lists have generally been replaced by the `Discourse`_ forum.
+ Specifically,
* The python-dev list is superseded by the `Core Development`_
and `PEPs`_ categories on Discourse.
-
* The python-ideas list is superseded by posts in the `Ideas`_
category on Discourse.
@@ -42,17 +43,21 @@ Mailing Lists
- Ideas about new functionality should **not** start here, and instead
should be discussed in `Ideas`_.
- Technical support questions should also not be asked here, and instead
- should go to the python-list_ or python-help_ mailing lists, or the
- `Python Help`_ category on Discourse.
+ should go to the `Python Help`_ category on Discourse or the python-list_.
-Existing threads on the python-dev_, python-committers_, and python-ideas_ mailing lists
-can be accessed through the `online archive `__.
+ Previous threads on the python-dev_, python-committers_, and python-ideas_
+ mailing lists can be accessed through the `online archive
+ `__.
+
+ .. _python-committers: https://mail.python.org/mailman3/lists/python-committers.python.org/
+ .. _python-dev: https://mail.python.org/mailman3/lists/python-dev.python.org/
+ .. _python-ideas: https://mail.python.org/mailman3/lists/python-ideas.python.org
General Python questions should go to `python-list`_ or `tutor`_
-or similar resources, such as StackOverflow_ or the ``#python`` IRC channel
+or similar resources, such as `Stack Overflow`_ or the ``#python`` IRC channel
on Libera.Chat_.
-`The core-workflow `_
+The `core-workflow `__
issue tracker is the place to discuss and work on improvements to the CPython
core development workflow.
@@ -62,16 +67,10 @@ https://mail.python.org/mailman3/ (newer lists, using Mailman3). Some lists may
be mirrored at `GMANE `_ and can be read and posted to in various
ways, including via web browsers, NNTP newsreaders, and RSS feed readers.
-.. _issue tracker: https://github.com/python/cpython/issues
-.. _python-committers: https://mail.python.org/mailman3/lists/python-committers.python.org/
-.. _python-dev: https://mail.python.org/mailman3/lists/python-dev.python.org/
-.. _python-help: https://mail.python.org/mailman/listinfo/python-help
-.. _python-ideas: https://mail.python.org/mailman3/lists/python-ideas.python.org
.. _python-list: https://mail.python.org/mailman/listinfo/python-list
.. _tutor: https://mail.python.org/mailman/listinfo/tutor
-.. _StackOverflow: https://stackoverflow.com/
+.. _Stack Overflow: https://stackoverflow.com/
.. _Libera.Chat: https://libera.chat/
-.. _web gateway: https://mail.python.org/archives/
.. _communication-discourse:
@@ -79,28 +78,24 @@ ways, including via web browsers, NNTP newsreaders, and RSS feed readers.
Discourse (discuss.python.org web forum)
========================================
-We have our own `Discourse`_ forum for both developers and users. This forum
-complements the `python-dev`_, `python-ideas`_, `python-help`_, and
-`python-list`_ mailing lists.
-
-This forum has different categories and most core development discussions
+We have our own `Discourse`_ forum for both developers and users.
+It has different categories and most core development discussions
take place in the open forum categories for `PEPs`_ and `Core Development`_
(these are the Discourse equivalents to the python-dev mailing list).
All categories are open for users to read and post with the exception of
the `Committers`_ category, where posting is restricted to the `CPython
-`_ core developers.
+`_ core team.
The Committers category is often used for announcements and notifications.
-It is also the designated venue for the core developer promotion votes
-(as the Discourse equivalent of the `python-committers`_ mailing list).
+It is also the designated venue for the core team promotion votes.
Tutorials for new users
--------------------------
+-----------------------
To start a topic or participate in any discussions in the forum, sign up and
create an account using an email address or GitHub account. You can do so by
-clicking the "Sign Up" button on the top right hand corner of the `Discourse`_
-main page.
+clicking the :guilabel:`Sign Up` button on the top right hand corner of the
+`Discourse`_ main page.
The Python Discourse `Quick Start `_
compiled by `Carol Willing `_ gives you
@@ -111,15 +106,18 @@ These tutorials can be activated by replying to a welcome message from "discours
Greetings!" received under Notifications and Messages in your user account.
* Click on your personal account found on the top right hand corner of the page.
-* The dropdown menu will show four different icons: 🔔 (Notifications),
- 🔖 (Bookmarks), ✉️ (Messages), and 👤 (Preferences).
+* The dropdown menu will show four different icons:
+ :guilabel:`🔔` (Notifications),
+ :guilabel:`🔖` (Bookmarks),
+ :guilabel:`✉️` (Messages), and
+ :guilabel:`👤` (Preferences).
* Select either Notifications or Messages.
* Open the "Greetings!" message sent by Discobot to start the tutorial.
Ensure that you read through the `Python Code of Conduct `_.
We are to be open, considerate and respectful to all users in the community.
You can report messages that don't respect the CoC by clicking on the three
-dots under the message and then on the ⚐ icon. You can also mention the
+dots under the message and then on the :guilabel:`⚐` icon. You can also mention the
`@staff `_,
`@moderators `_, or
`@admins `_ groups in a message.
@@ -127,7 +125,8 @@ dots under the message and then on the ⚐ icon. You can also mention the
Reading topics
------------------
+--------------
+
Click a topic title and read down the list of replies in chronological order,
following links or previewing replies and quotes as you go. Use your mouse to
scroll the screen, or use the timeline scroll bar on the right which also shows
@@ -138,30 +137,31 @@ bottom progress bar to expand it.
Notifications
-------------
-Following categories (Category notifications)
-'''''''''''''''''''''''''''''''''''''''''''''
+Following categories (category notifications)
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Notifications can be set for individual categories and topics. To change any of these
defaults, you can either go to your user preferences, or visit the category
-page, and use the notification button 🔔 above the topic list,
-on the top right hand corner of the category page beside the "+ New Topic" button.
+page, and use the notification button :guilabel:`🔔` above the topic list,
+on the top right hand corner of the category page beside the
+:guilabel:`+ New Topic` button.
-Clicking on the Notification control 🔔 will show a drop-down panel with 5
+Clicking on the notification control :guilabel:`🔔` will show a drop-down panel with 5
different options: Watching, Tracking, Watching First Post, Normal, and Muted.
All categories are set by default in Normal mode where you will only be notified
if someone mentions your @name or replies to you.
-Following individual threads (Topic notifications)
-''''''''''''''''''''''''''''''''''''''''''''''''''
+Following individual threads (topic notifications)
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
To follow any individual topics or threads, you can adjust your notifications
-through the notification button 🔔 found on the right of the topic at the end
+through the notification button :guilabel:`🔔` found on the right of the topic at the end
of the timeline. You can also do so at the bottom of each topic.
Select "Watching" and you will be notified when there is any new updated reply
from that particular thread.
Customising notifications on user preference
-''''''''''''''''''''''''''''''''''''''''''''
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
To get a bird's eye view of all your customised notifications, you can
go to `Preferences of your account `_.
@@ -182,29 +182,29 @@ mailing list mode" and save changes.
.. _Core Development: https://discuss.python.org/c/core-dev/23
.. _Committers: https://discuss.python.org/c/committers/5
.. _Ideas: https://discuss.python.org/c/ideas/6
-.. _Python Help: https://discuss.python.org/c/users/7
+.. _Python Help: https://discuss.python.org/c/help/7
Discord (private chat server)
=============================
For more real-time discussions, the core development team have a private Discord
-server available. Core developers, Steering Council members, triagers, and
+server available. Core team members, Steering Council members, triagers, and
documentarians on the project are eligible to join the server. Joining the
Discord server is entirely optional, as all essential communications occur on
the mailing lists and Discourse forums.
-For core developers, a long lived multiple use invitation link for this server
-can be found in the private core developer only section of the Discourse forum.
+For core team members, a long-lived multiple-use invitation link for this server
+can be found in the private core team only section of the Discourse forum.
For triagers and documentarians joining the Discord server, a single use invitation
link should be generated and sent to them directly.
When first joining the server, new users will only have access to the ``#welcome``
and ``#rules-and-info`` channels. To link their Discord ID with their project
-role, core developers may update their Steering Council 🔒 `voter record`_ with
+role, core team members may update their Steering Council 🔒 `voter record`_ with
their Discord ID before posting in the ``#welcome`` channel to request access
-to the rest of the server channels. Triagers, documentarians, and core developers
+to the rest of the server channels. Triagers, documentarians, and core team members
that would prefer not to add their Discord ID to their Steering Council voter
record may instead be vouched for by an existing member of the Discord server.
@@ -225,7 +225,7 @@ set a specific `Server Nickname`_
IRC
===
-Some core developers still participate in the ``#python-dev`` IRC channel on
+Some core team members still participate in the ``#python-dev`` IRC channel on
``irc.libera.chat``. This is not a place to ask for help with Python, but to
discuss issues related to Python's own development. See also the
``#python-dev-notifs`` channel for bots notifications.
@@ -234,12 +234,12 @@ discuss issues related to Python's own development. See also the
Blogs
=====
-Several core developers are active bloggers and discuss Python's development
+Several core team members are active bloggers and discuss Python's development
that way. You can find their blogs (and various other developers who use Python)
-at https://planetpython.org/.
+at `Planet Python `__.
-Setting Expectations for Open Source Participation
+Setting expectations for open source participation
==================================================
Burn-out is common in open source due to a misunderstanding of what users, contributors,
@@ -247,16 +247,30 @@ and maintainers should expect from each other. Brett Cannon gave a `talk `)
+* `bedevere`_
+* `blurb`_ (:pypi:`PyPI `)
+* `blurb_it`_
+* `miss-islington`_
+* `clabot`_
+* `webhook-mailer`_
Python `Performance Benchmark`_ project is intended to be an authoritative
source of benchmarks for all Python implementations.
.. _Python Core Workflow: https://github.com/python/core-workflow
-.. _cherry_picker: https://pypi.org/project/cherry_picker/
-.. _blurb: https://pypi.org/project/blurb
+.. _cherry_picker: https://github.com/python/cherry-picker
+.. _bedevere: https://github.com/python/bedevere
+.. _blurb: https://github.com/python/blurb
+.. _blurb_it: https://github.com/python/blurb_it
+.. _miss-islington: https://github.com/python/miss-islington
+.. _clabot: https://github.com/psf/clabot
+.. _webhook-mailer: https://github.com/python/webhook-mailer
.. _Performance Benchmark: https://github.com/python/pyperformance
diff --git a/developer-workflow/development-cycle.rst b/developer-workflow/development-cycle.rst
index 593d61b95..c8b2d5ebf 100644
--- a/developer-workflow/development-cycle.rst
+++ b/developer-workflow/development-cycle.rst
@@ -1,10 +1,10 @@
.. _development-cycle:
.. _devcycle:
-Development Cycle
+Development cycle
=================
-The responsibilities of a core developer shift based on what kind of branch of
+The responsibilities of a core team member shift based on what kind of branch of
Python a developer is working on and what stage the branch is in.
To clarify terminology, Python uses a ``major.minor.micro`` nomenclature
@@ -34,16 +34,16 @@ and *null* for final releases), and ``N`` is the release serial number.
Some examples of release tags: ``v3.7.0a1``, ``v3.6.3``, ``v2.7.14rc1``.
Branches
-''''''''
+--------
-There is a branch for each *feature version*, whether released or not (e.g.
-3.7, 3.8).
+There is a branch for each *feature version*, whether released or not (for
+example, 3.12, 3.13).
.. _indevbranch:
In-development (main) branch
-----------------------------
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The ``main`` branch is the branch for the next feature release; it is
under active development for all kinds of changes: new features, semantic
@@ -51,13 +51,11 @@ changes, performance improvements, bug fixes.
At some point during the life-cycle of a release, a
new :ref:`maintenance branch ` is created to host all bug fixing
-activity for further micro versions in a feature version (3.8.1, 3.8.2, etc.).
+activity for further micro versions in a feature version (3.12.1, 3.12.2, and so
+on).
-For versions 3.4 and before, this was conventionally done when the final
-release was cut (for example, 3.4.0 final).
-
-Starting with the 3.5 release, we create the release maintenance branch
-(e.g. 3.5) at the time we enter beta (3.5.0 beta 1). This allows
+We create the release maintenance branch
+(``3.14``) at the time we enter beta (3.14.0 beta 1). This allows
feature development for the release 3.n+1 to occur within the main
branch alongside the beta and release candidate stabilization periods
for release 3.n.
@@ -65,7 +63,7 @@ for release 3.n.
.. _maintbranch:
Maintenance branches
---------------------
+^^^^^^^^^^^^^^^^^^^^
A branch for a previous feature release, currently being maintained for bug
fixes, or for the next feature release in its
@@ -77,13 +75,19 @@ releases; the terms are used interchangeably. These releases have a
**micro version** number greater than zero.
The only changes allowed to occur in a maintenance branch without debate are
-bug fixes. Also, a general rule for maintenance branches is that compatibility
-must not be broken at any point between sibling micro releases (3.5.1, 3.5.2,
+bug fixes, test improvements, and edits to the documentation.
+Also, a general rule for maintenance branches is that compatibility
+must not be broken at any point between sibling micro releases (3.12.1, 3.12.2,
etc.). For both rules, only rare exceptions are accepted and **must** be
discussed first.
+Backporting changes reduces the risk of future conflicts.
+For documentation, it increases the visibility of improvements,
+since most readers access the `stable documentation `__
+rather than the `development documentation `__.
+
A new maintenance branch is normally created when the next feature release
-cycle reaches feature freeze, i.e. at its first beta pre-release.
+cycle reaches feature freeze, that is, at its first beta pre-release.
From that point on, changes intended for remaining pre-releases, the final
release (3.x.0), and subsequent bugfix releases are merged to
that maintenance branch.
@@ -91,14 +95,14 @@ that maintenance branch.
Sometime following the final release (3.x.0), the maintenance branch for
the previous minor version will go into :ref:`security mode `,
usually after at least one more bugfix release at the discretion of the
-release manager. For example, the 3.4 maintenance branch was put into
-:ref:`security mode ` after the 3.4.4 bugfix release
-which followed the release of 3.5.1.
+release manager. For example, the 3.11 maintenance branch was put into
+:ref:`security mode ` after the 3.11.9 bugfix release
+which followed the release of 3.12.2.
.. _secbranch:
Security branches
------------------
+^^^^^^^^^^^^^^^^^
A branch less than 5 years old but no longer in bugfix mode is a security
branch.
@@ -114,18 +118,18 @@ Commits to security branches are to be coordinated with the release manager
for the corresponding feature version, as listed in the :ref:`branchstatus`.
Merging of pull requests to security branches is restricted to release managers.
Any release made from a security branch is source-only and done only when actual
-security patches have been applied to the branch. These releases have a
+security fixes have been applied to the branch. These releases have a
**micro version** number greater than the last **bugfix** release.
.. _eolbranch:
End-of-life branches
---------------------
+^^^^^^^^^^^^^^^^^^^^
The code base for a release cycle which has reached end-of-life status
is frozen and no longer has a branch in the repo. The final state of
the end-of-lifed branch is recorded as a tag with the same name as the
-former branch, e.g. ``3.3`` or ``2.6``.
+former branch, for example, ``3.8`` or ``2.7``.
The :ref:`versions` page contains list of active and end-of-life branches.
@@ -135,27 +139,27 @@ The latest release for each Python version can be found on the `download page
.. _stages:
Stages
-''''''
+------
Based on what stage the :ref:`in-development ` version of Python
-is in, the responsibilities of a core developer change in regards to commits
+is in, the responsibilities of a core team member change in regards to commits
to the :abbr:`VCS (version control system)`.
Pre-alpha
----------
+^^^^^^^^^
The branch is in this stage when no official release has been done since
the latest final release. There are no special restrictions placed on
-commits, although the usual advice applies (getting patches reviewed, avoiding
-breaking the buildbots).
+commits, although the usual advice applies (getting pull requests reviewed,
+avoiding breaking the buildbots).
.. _alpha:
Alpha
------
+^^^^^
-Alpha releases typically serve as a reminder to core developers that they
+Alpha releases typically serve as a reminder to the core team that they
need to start getting in changes that change semantics or add something to
Python as such things should not be added during a Beta_. Otherwise no new
restrictions are in place while in alpha.
@@ -163,29 +167,26 @@ restrictions are in place while in alpha.
.. _beta:
Beta
-----
+^^^^
After a first beta release is published, no new features are accepted. Only
bug fixes and improvements to documentation and tests can now be committed.
-This is when core developers should concentrate on the task of fixing
+This is when the core team should concentrate on the task of fixing
regressions and other new issues filed by users who have downloaded the alpha
and beta releases.
Being in beta can be viewed much like being in RC_ but without the extra
overhead of needing commit reviews.
-Please see the note in the `In-development (main) branch`_ section above for
-new information about the creation of the 3.5 maintenance branch during beta.
-
.. _rc:
Release Candidate (RC)
-----------------------
+^^^^^^^^^^^^^^^^^^^^^^
A branch preparing for an RC release can only have bugfixes applied that have
-been reviewed by other core developers. Generally, these issues must be
-severe enough (e.g. crashes) that they deserve fixing before the final release.
+been reviewed by other core team members. Generally, these issues must be
+severe enough (for example, crashes) that they deserve fixing before the final release.
All other issues should be deferred to the next development cycle, since
stability is the strongest concern at this point.
@@ -195,40 +196,67 @@ changes should be discussed first with the release manager.
You **cannot** skip the peer review during an RC, no matter how small! Even if
it is a simple copy-and-paste change, **everything** requires peer review from
-a core developer.
+a core team member.
.. _final:
Final
------
+^^^^^
When a final release is being cut, only the release manager (RM) can make
changes to the branch. After the final release is published, the full
:ref:`development cycle ` starts again for the next minor version.
-Repository Administration
-'''''''''''''''''''''''''
+Repository administration
+-------------------------
The source code is currently hosted on `GitHub
`_ in the `Python organization `_.
-Organization Repository Policy
-------------------------------
-
-Within the `Python organization `_, repositories are expected to fall within these general categories:
-
-1. The reference implementation of Python and related repositories (i.e. `CPython `_)
-2. Reference implementations of PEPs (e.g. `mypy `_)
-3. Tooling and support around CPython and the language (e.g. `python.org repository `_)
-4. PSF-related repositories (e.g. the `Code of Conduct `_)
-5. PSF Infrastructure repositories (e.g. the `PSF Infrastructure Salt configurations `_)
-
-For any repository which does not explicitly and clearly fall under one of these categories, permission should be sought
-from the `Python steering council `_.
-
-Organization Owner Policy
--------------------------
+Organization repository policy
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Within the `GitHub Python organization `_,
+repositories are expected to relate to the Python language, the CPython
+reference implementation, their documentation and their development workflow.
+This includes, for example:
+
+* The reference implementation of Python and related repositories: `CPython `_.
+* Tooling and support around CPython development: `pyperformance `_, `Bedevere `_.
+* Helpers and backports for Python/CPython features: `typing_extensions `_, `typeshed `_, `tzdata `_, `pythoncapi-compat `_.
+* Organization-related repositories: the `Code of Conduct `_, `.github `_.
+* Documentation and websites for all the above: `python.org repository `_, `PEPs `_, `Devguide `_, docs translations.
+* Infrastructure for all the above: `docsbuild-scripts `_, `buildmaster-config `_.
+* Discussions and notes around official development-related processes and events: `steering-council `_, `core-sprint `_.
+
+Before adding a new repository to the organization, open a discussion to seek consensus
+in the `Committers Discourse category `_.
+Once people are satisfied with that, ask the `Python steering council `_
+to grant permission.
+
+Note that several repositories remain in the organization for historic reasons,
+and would probably not be appropriate to add today.
+
+Generally, new repositories should start their life under personal GitHub
+accounts or other GitHub orgs. It is relatively easy to move a repository to
+the organization once it is mature. For example, this would now apply to
+experimental features like `asyncio `_,
+`exceptiongroups `_,
+and drafts of new guides and other documentation (for example, `redistributor-guide
+`_).
+
+General-use tools and libraries (for example, `mypy `_
+or `Black `_) should also be developed outside
+the ``python`` organization, unless core devs (as represented by the SC)
+specifically want to “bless” one implementation (as with
+`typeshed `_,
+`tzdata `_, or
+`pythoncapi-compat `_).
+
+
+Organization owner policy
+^^^^^^^^^^^^^^^^^^^^^^^^^
The GitHub Organization Owner role allows for full management of all aspects of
the Python organization. Allowing for visibility and management of all aspects
@@ -254,8 +282,8 @@ Owner of the Python Organization.
.. _current owners:
-Current Owners
---------------
+Current owners
+^^^^^^^^^^^^^^
+----------------------+--------------------------------+-----------------+
| Name | Role | GitHub Username |
@@ -268,7 +296,7 @@ Current Owners
+----------------------+--------------------------------+-----------------+
| Ee Durbin | PSF Director of Infrastructure | ewdurbin |
+----------------------+--------------------------------+-----------------+
-| Van Lindberg | PSF General Counsel | VanL |
+| Jacob Coffee | PSF Infrastructure Engineer | JacobCoffee |
+----------------------+--------------------------------+-----------------+
| Łukasz Langa | CPython Developer in Residence | ambv |
+----------------------+--------------------------------+-----------------+
@@ -280,20 +308,20 @@ mentioned to request assistance from an organization owner.
.. _be performed: https://docs.github.com/en/organizations/managing-peoples-access-to-your-organization-with-roles/roles-in-an-organization#permissions-for-organization-roles
-Repository Administrator Role Policy
-------------------------------------
+Repository administrator role policy
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The Administrator role on the repository allows for managing all aspects
including collaborators, access control, integrations, webhooks, and branch
protection. For full details of the permission levels see `GitHub's
documentation on repository permission levels
`_.
-Common reasons for this role are: maintenance of Core Developer
-Workflow tooling, Release Managers for all :ref:`in-development `,
+Common reasons for this role are: maintenance of core
+workflow tooling, Release Managers for all :ref:`in-development `,
:ref:`maintenance `, and :ref:`security mode `
-releases, and additional Python Core Developers as necessary for redundancy.
-Occasional temporary administrator access is acceptable as necessary for Core
-Developer workflow projects.
+releases, and additional Python core team members as necessary for redundancy.
+Occasional temporary administrator access is acceptable as necessary for core
+workflow projects.
Inactive or unreachable members may be removed with or without notice. Members
who no longer necessitate this level of access will be removed with notice.
@@ -301,23 +329,21 @@ who no longer necessitate this level of access will be removed with notice.
Multi-Factor Authentication must be enabled by the user in order to remain an
Administrator of the repository.
-Current Administrators
-----------------------
+Current administrators
+^^^^^^^^^^^^^^^^^^^^^^
+-------------------+----------------------------------------------------------+-----------------+
| Name | Role | GitHub Username |
+===================+==========================================================+=================+
-| Pablo Galindo | Python 3.10 and 3.11 Release Manager, | pablogsal |
-| | Maintainer of buildbot.python.org | |
-+-------------------+----------------------------------------------------------+-----------------+
-| Łukasz Langa | Python 3.8 and 3.9 Release Manager, | ambv |
-| | PSF CPython Developer in Residence 2021-2022 | |
+| Hugo van Kemenade | Python 3.14 and 3.15 Release Manager | hugovk |
+-------------------+----------------------------------------------------------+-----------------+
-| Ned Deily | Python 3.6 and 3.7 Release Manager | ned-deily |
+| Thomas Wouters | Python 3.12 and 3.13 Release Manager | Yhg1s |
+-------------------+----------------------------------------------------------+-----------------+
-| Larry Hastings | Retired Release Manager (for Python 3.4 and 3.5) | larryhastings |
+| Pablo Galindo | Python 3.10 and 3.11 Release Manager, | pablogsal |
+| | Maintainer of buildbot.python.org | |
+-------------------+----------------------------------------------------------+-----------------+
-| Berker Peksag | Maintainer of bpo-linkify and cpython-emailer-webhook | berkerpeksag |
+| Łukasz Langa | Python 3.9 Release Manager, | ambv |
+| | PSF CPython Developer in Residence 2021-present | |
+-------------------+----------------------------------------------------------+-----------------+
| Brett Cannon | | brettcannon |
+-------------------+----------------------------------------------------------+-----------------+
@@ -325,16 +351,74 @@ Current Administrators
+-------------------+----------------------------------------------------------+-----------------+
| Mariatta Wijaya | Maintainer of bedevere, blurb_it and miss-islington | Mariatta |
+-------------------+----------------------------------------------------------+-----------------+
+| Seth Larson | PSF Security Developer-in-Residence | sethmlarson |
++-------------------+----------------------------------------------------------+-----------------+
-Repository Release Manager Role Policy
---------------------------------------
+Repository release manager role policy
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Release Managers for :ref:`in-development `, :ref:`maintenance
`, and :ref:`security mode ` Python releases are
granted Administrator privileges on the repository. Once a release branch has
-entered :ref:`end-of-life `, the Release Manager for that branch is
-removed as an Administrator and granted sole privileges (out side of repository
-administrators) to merge changes to that branch.
+entered :ref:`end-of-life `, the Release Manager for that branch
+creates a final tag and deletes the branch. After this, they are
+removed as an Administrator.
Multi-Factor Authentication must be enabled by the user in order to retain
access as a Release Manager of the branch.
+
+PyPI organization policy
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+The Python core team owns the :pypi-org:`cpython` and :pypi-org:`python`
+organizations on PyPI for publishing packages.
+The main benefits of adding packages to these organizations:
+
+* Visibility: we can see our packages under a PyPI org page
+* Maintainability: we can share granular PyPI access to improve the bus factor
+
+The general policy on which organization to use:
+
+* :pypi-org:`cpython`:
+ for development tools that are tied fairly closely to CPython development.
+ For example, :pypi:`blurb` and :pypi:`cherry-picker`.
+ Users generally shouldn’t have to care except for developing CPython itself
+ (although that doesn’t mean the tools necessarily have to be unusable for
+ anyone else).
+* :pypi-org:`python`:
+ for general-audience projects that are maintained by the Python core team.
+ For example, :pypi:`pyperformance`, :pypi:`python-docs-theme` and
+ :pypi:`tzdata`.
+
+
+Governance
+----------
+
+The Python Steering Council has overall authority over Python and has delegated
+some of its responsibilities to other groups.
+
+This table lists the PEPs defining each group's responsibilities,
+and the repository where you can open an issue to ask for a decision.
+
+.. list-table::
+ :header-rows: 1
+
+ * - Name
+ - PEP
+ - Contact repo
+ * - Steering Council
+ - :pep:`13`
+ - :github:`python/steering-council`
+ * - C API Working Group
+ - :pep:`731`
+ - :github:`capi-workgroup/decisions`
+ * - Documentation Editorial Board
+ - :pep:`732`
+ - :github:`python/editorial-board`
+ * - Typing Council
+ - :pep:`729`
+ - :github:`python/typing-council`
+
+.. seealso::
+
+ All governance PEPs: https://peps.python.org/topic/governance/
diff --git a/developer-workflow/extension-modules.rst b/developer-workflow/extension-modules.rst
index 3a5a759a5..7131cfdf8 100644
--- a/developer-workflow/extension-modules.rst
+++ b/developer-workflow/extension-modules.rst
@@ -2,16 +2,668 @@
.. _extensions:
==================================
-Standard Library Extension Modules
+Standard library extension modules
==================================
-In this section, we could explain how to write a CPython extension with the C language, but the topic can take a complete book.
-
-For this reason, we prefer to give you some links where you can read a very good documentation.
-
-Read the following references:
+In this section, we explain how to configure and compile the CPython project
+with a C :term:`extension module`. We will not explain how to write a C
+extension module and prefer to give you some links where you can read good
+documentation:
* https://docs.python.org/dev/c-api/
* https://docs.python.org/dev/extending/
* :pep:`399`
* https://pythonextensionpatterns.readthedocs.io/en/latest/
+
+Some modules in the standard library, such as :mod:`datetime` or :mod:`pickle`,
+have identical implementations in C and Python; the C implementation, when
+available, is expected to improve performance (such extension modules are
+commonly referred to as *accelerator modules*).
+
+Other modules mainly implemented in Python may import a C helper extension
+providing implementation details (for instance, the :mod:`csv` module uses
+the internal :mod:`!_csv` module defined in :cpy-file:`Modules/_csv.c`).
+
+Classifying extension modules
+=============================
+
+Extension modules can be classified into two categories:
+
+* A *built-in* extension module is a module built and shipped with
+ the Python interpreter. A built-in module is *statically* linked
+ into the interpreter, thereby lacking a :attr:`!__file__` attribute.
+
+ .. seealso:: :data:`sys.builtin_module_names` --- names of built-in modules.
+
+ Built-in modules are built with the :c:macro:`!Py_BUILD_CORE_BUILTIN`
+ macro defined.
+
+* A *shared* (or *dynamic*) extension module is built as a shared library
+ (``.so`` or ``.dll`` file) and is *dynamically* linked into the interpreter.
+
+ In particular, the module's :attr:`!__file__` attribute contains the path
+ to the ``.so`` or ``.dll`` file.
+
+ Shared modules are built with the :c:macro:`!Py_BUILD_CORE_MODULE`
+ macro defined. Using the :c:macro:`!Py_BUILD_CORE_BUILTIN` macro
+ instead causes an :exc:`ImportError` when importing the module.
+
+.. note::
+
+ Informally, built-in extension modules can be regarded as *required*
+ while shared extension modules are *optional* in the sense that they
+ might be supplied, overridden or disabled externally.
+
+ Usually, accelerator modules are built as *shared* extension modules,
+ especially if they already have a pure Python implementation.
+
+According to :pep:`399`, *new* extension modules MUST provide a working and
+tested pure Python implementation, unless a special dispensation from
+the :github:`Steering Council ` is given.
+
+Adding an extension module to CPython
+=====================================
+
+Assume that the standard library contains a pure Python module :mod:`!foo`
+with the following :func:`!foo.greet` function:
+
+.. code-block:: python
+ :caption: Lib/foo.py
+
+ def greet():
+ return "Hello World!"
+
+Instead of using the Python implementation of :func:`!foo.greet`, we want to
+use its corresponding C extension implementation exposed in the :mod:`!_foo`
+module. Ideally, we want to modify ``Lib/foo.py`` as follows:
+
+.. code-block:: python
+ :caption: Lib/foo.py
+
+ try:
+ # use the C implementation if possible
+ from _foo import greet
+ except ImportError:
+ # fallback to the pure Python implementation
+ def greet():
+ return "Hello World!"
+
+.. note::
+
+ Accelerator modules should *never* be imported directly. The convention is
+ to mark them as private implementation details with the underscore prefix
+ (namely, :mod:`!_foo` in this example).
+
+In order to incorporate the accelerator module, we need to determine:
+
+- where to update the CPython project tree with the extension module source code,
+- which files to modify to configure and compile the CPython project, and
+- which ``Makefile`` rules to invoke at the end.
+
+Updating the CPython project tree
+---------------------------------
+
+Usually, accelerator modules are added in the :cpy-file:`Modules` directory of
+the CPython project. If more than one file is needed for the extension module,
+it is more convenient to create a sub-directory in :cpy-file:`Modules`.
+
+In the simplest example where the extension module consists of one file, it may
+be placed in :cpy-file:`Modules` as ``Modules/_foomodule.c``. For a non-trivial
+example of the extension module :mod:`!_foo`, we consider the following working
+tree:
+
+- :ref:`Modules/_foo/_foomodule.c` --- the extension module implementation.
+- :ref:`Modules/_foo/helper.h` --- the extension helpers declarations.
+- :ref:`Modules/_foo/helper.c` --- the extension helpers implementations.
+
+By convention, the source file containing the extension module implementation
+is called ``module.c``, where ```` is the name of the module that
+will be later imported (in our case :mod:`!_foo`). In addition, the directory
+containing the implementation should also be named similarly.
+
+.. code-block:: c
+ :caption: Modules/_foo/helper.h
+ :name: Modules/_foo/helper.h
+
+ #ifndef _FOO_HELPER_H
+ #define _FOO_HELPER_H
+
+ #include "Python.h"
+
+ typedef struct {
+ /* ... */
+ } foomodule_state;
+
+ static inline foomodule_state *
+ get_foomodule_state(PyObject *module)
+ {
+ void *state = PyModule_GetState(module);
+ assert(state != NULL);
+ return (foomodule_state *)state;
+ }
+
+ /* Helper used in Modules/_foo/_foomodule.c
+ * but implemented in Modules/_foo/helper.c.
+ */
+ extern PyObject *
+ _Py_greet_fast(void);
+
+ #endif // _FOO_HELPER_H
+
+.. tip::
+
+ Functions or data that do not need to be shared across different C source
+ files should be declared ``static`` to avoid exporting their symbols from
+ ``libpython``.
+
+ If symbols need to be exported, their names must start with ``Py`` or
+ ``_Py``. This can be verified by ``make smelly``. For more details,
+ please refer to the section on :ref:`Changing Python's C API `.
+
+.. code-block:: c
+ :caption: Modules/_foo/helper.c
+ :name: Modules/_foo/helper.c
+
+ #include "_foomodule.h"
+
+ PyObject *_Py_greet_fast(void) {
+ return PyUnicode_FromString("Hello World!");
+ }
+
+.. code-block:: c
+ :caption: Modules/_foo/_foomodule.c
+ :name: Modules/_foo/_foomodule.c
+
+ #include "helper.h"
+ #include "clinic/_foomodule.c.h"
+
+ /* Functions for the extension module's state */
+ static int
+ foomodule_exec(PyObject *module)
+ {
+ // imports, static attributes, exported classes, etc
+ return 0;
+ }
+
+ static int
+ foomodule_traverse(PyObject *m, visitproc visit, void *arg)
+ {
+ foomodule_state *st = get_foomodule_state(m);
+ // call Py_VISIT() on the state attributes
+ return 0;
+ }
+
+ static int
+ foomodule_clear(PyObject *m)
+ {
+ foomodule_state *st = get_foomodule_state(m);
+ // call Py_CLEAR() on the state attributes
+ return 0;
+ }
+
+ static void
+ foomodule_free(void *m) {
+ (void)foomodule_clear((PyObject *)m);
+ }
+
+ /* Implementation of publicly exported functions. */
+
+ /*[clinic input]
+ module foo
+ [clinic start generated code]*/
+ /*[clinic end generated code: output=... input=...]*/
+
+ /*[clinic input]
+ foo.greet -> object
+
+ [clinic start generated code]*/
+
+ static PyObject *
+ foo_greet_impl(PyObject *module)
+ /*[clinic end generated code: output=... input=...]*/
+ {
+ return _Py_greet_fast();
+ }
+
+ /* Exported module's data */
+
+ static PyMethodDef foomodule_methods[] = {
+ // macro in 'clinic/_foomodule.c.h' after running 'make clinic'
+ FOO_GREET_METHODDEF
+ {NULL, NULL}
+ };
+
+ static struct PyModuleDef_Slot foomodule_slots[] = {
+ // 'foomodule_exec' may be NULL if the state is trivial
+ {Py_mod_exec, foomodule_exec},
+ {Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
+ {Py_mod_gil, Py_MOD_GIL_NOT_USED},
+ {0, NULL},
+ };
+
+ static struct PyModuleDef foomodule = {
+ PyModuleDef_HEAD_INIT,
+ .m_name = "_foo",
+ .m_doc = "some doc", // or NULL if not needed
+ .m_size = sizeof(foomodule_state),
+ .m_methods = foomodule_methods,
+ .m_slots = foomodule_slots,
+ .m_traverse = foomodule_traverse, // or NULL if the state is trivial
+ .m_clear = foomodule_clear, // or NULL if the state is trivial
+ .m_free = foomodule_free, // or NULL if the state is trivial
+ };
+
+ PyMODINIT_FUNC
+ PyInit__foo(void)
+ {
+ return PyModuleDef_Init(&foomodule);
+ }
+
+.. tip::
+
+ Recall that the ``PyInit_`` function must be suffixed by the
+ module name ```` used in import statements (here ``_foo``),
+ and which usually coincides with :c:member:`PyModuleDef.m_name`.
+
+ Other identifiers such as those used in :ref:`Argument Clinic `
+ inputs do not have such naming requirements.
+
+Configuring the CPython project
+-------------------------------
+
+Now that we have added our extension module to the CPython source tree,
+we need to update some configuration files in order to compile the CPython
+project on different platforms.
+
+Updating ``Modules/Setup.{bootstrap,stdlib}.in``
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Depending on whether the extension module is required to get a functioning
+interpreter or not, we update :cpy-file:`Modules/Setup.bootstrap.in` or
+:cpy-file:`Modules/Setup.stdlib.in`. In the former case, the extension
+module is necessarily built as a built-in extension module.
+
+.. tip::
+
+ For accelerator modules, :cpy-file:`Modules/Setup.stdlib.in` should be
+ preferred over :cpy-file:`Modules/Setup.bootstrap.in`.
+
+For built-in extension modules, update :cpy-file:`Modules/Setup.bootstrap.in`
+by adding the following line after the ``*static*`` marker:
+
+.. code-block:: text
+ :caption: :cpy-file:`Modules/Setup.bootstrap.in`
+ :emphasize-lines: 3
+
+ *static*
+ ...
+ _foo _foo/_foomodule.c _foo/helper.c
+ ...
+
+The syntax is ```` where ```` is the name of the
+module used in :keyword:`import` statements and ```` is the list
+of space-separated source files.
+
+For other extension modules, update :cpy-file:`Modules/Setup.stdlib.in`
+by adding the following line after the ``*@MODULE_BUILDTYPE@*`` marker
+but before the ``*shared*`` marker:
+
+.. code-block:: text
+ :caption: :cpy-file:`Modules/Setup.stdlib.in`
+ :emphasize-lines: 3
+
+ *@MODULE_BUILDTYPE@*
+ ...
+ @MODULE__FOO_TRUE@_foo _foo/_foomodule.c _foo/helper.c
+ ...
+ *shared*
+
+The ``@MODULE__TRUE@`` marker expects ```` to
+be the upper-cased form of ````, where ```` has the same meaning
+as before (in our case, ```` and ```` are ``_FOO`` and
+``_foo`` respectively). The marker is followed by the list of source files.
+
+If the extension module must be built as a *shared* module, put the
+``@MODULE__FOO_TRUE@_foo`` line after the ``*shared*`` marker:
+
+.. code-block:: text
+ :caption: :cpy-file:`Modules/Setup.stdlib.in`
+ :emphasize-lines: 4
+
+ ...
+ *shared*
+ ...
+ @MODULE__FOO_TRUE@_foo _foo/_foomodule.c _foo/helper.c
+
+Updating :cpy-file:`configure.ac`
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. add section about configuration variable afterwards
+
+* Locate the ``SRCDIRS`` variable and add the following line:
+
+ .. code-block:: text
+ :caption: :cpy-file:`configure.ac`
+ :emphasize-lines: 4
+
+ AC_SUBST([SRCDIRS])
+ SRCDIRS="\
+ ...
+ Modules/_foo \
+ ..."
+
+ .. note::
+
+ This step is only needed when adding new source directories to
+ the CPython project.
+
+* Find the section containing ``PY_STDLIB_MOD`` and ``PY_STDLIB_MOD_SIMPLE``
+ usages and add the following line:
+
+ .. code-block:: text
+ :caption: :cpy-file:`configure.ac`
+ :emphasize-lines: 3
+
+ dnl always enabled extension modules
+ ...
+ PY_STDLIB_MOD_SIMPLE([_foo], [-I\$(srcdir)/Modules/_foo], [])
+ ...
+
+ The ``PY_STDLIB_MOD_SIMPLE`` macro takes as arguments:
+
+ * the module name ```` used in :keyword:`import` statements,
+ * the compiler flags (CFLAGS), and
+ * the linker flags (LDFLAGS).
+
+ If the extension module may not be enabled or supported depending on the
+ host configuration, use the ``PY_STDLIB_MOD`` macro instead, which takes
+ as arguments:
+
+ * the module name ```` used in :keyword:`import` statements,
+ * a boolean indicating whether the extension is **enabled** or not,
+ * a boolean indicating whether the extension is **supported** or not,
+ * the compiler flags (CFLAGS), and
+ * the linker flags (LDFLAGS).
+
+ For instance, enabling the :mod:`!_foo` extension on Linux platforms, but
+ only providing support for 32-bit architecture, is achieved as follows:
+
+ .. code-block:: text
+ :caption: :cpy-file:`configure.ac`
+ :emphasize-lines: 2, 3
+
+ PY_STDLIB_MOD([_foo],
+ [test "$ac_sys_system" = "Linux"],
+ [test "$ARCH_RUN_32BIT" = "true"],
+ [-I\$(srcdir)/Modules/_foo], [])
+
+ More generally, the host's configuration status of the extension is
+ determined as follows:
+
+ +-----------+-----------------+----------+
+ | Enabled | Supported | Status |
+ +===========+=================+==========+
+ | true | true | yes |
+ +-----------+-----------------+----------+
+ | true | false | missing |
+ +-----------+-----------------+----------+
+ | false | true or false | disabled |
+ +-----------+-----------------+----------+
+
+ The extension status is ``n/a`` if the extension is marked unavailable
+ by the ``PY_STDLIB_MOD_SET_NA`` macro. To mark an extension as unavailable,
+ find the usages of ``PY_STDLIB_MOD_SET_NA`` in :cpy-file:`configure.ac` and
+ add the following line:
+
+ .. code-block:: text
+ :caption: :cpy-file:`configure.ac`
+ :emphasize-lines: 4
+
+ dnl Modules that are not available on some platforms
+ AS_CASE([$ac_sys_system],
+ ...
+ [PLATFORM_NAME], [PY_STDLIB_MOD_SET_NA([_foo])],
+ ...
+ )
+
+.. tip::
+
+ Consider reading the comments and configurations for existing modules
+ in :cpy-file:`configure.ac` for guidance on adding new external build
+ dependencies for extension modules that need them.
+
+Updating :cpy-file:`Makefile.pre.in`
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+If needed, add the following line to the section for module dependencies:
+
+.. code-block:: text
+ :caption: :cpy-file:`Makefile.pre.in`
+ :emphasize-lines: 4
+
+ ##########################################################################
+ # Module dependencies and platform-specific files
+ ...
+ MODULE__FOO_DEPS=$(srcdir)/Modules/_foo/helper.h
+ ...
+
+The ``MODULE__DEPS`` variable follows the same naming
+requirements as the ``@MODULE__TRUE@`` marker.
+
+Updating MSVC project files
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+We describe the minimal steps for compiling on Windows using MSVC.
+
+* Update :cpy-file:`PC/config.c`:
+
+ .. code-block:: c
+ :caption: :cpy-file:`PC/config.c`
+ :emphasize-lines: 3, 8
+
+ ...
+ // add the entry point prototype
+ extern PyObject* PyInit__foo(void);
+ ...
+ // update the entry points table
+ struct _inittab _PyImport_Inittab[] = {
+ ...
+ {"_foo", PyInit__foo},
+ ...
+ {0, 0}
+ };
+ ...
+
+ Each item in ``_PyImport_Inittab`` consists of the module name to import,
+ here :mod:`!_foo`, with the corresponding ``PyInit_*`` function correctly
+ suffixed.
+
+* Update :cpy-file:`PCbuild/pythoncore.vcxproj`:
+
+ .. code-block:: xml
+ :caption: :cpy-file:`PCbuild/pythoncore.vcxproj`
+ :emphasize-lines: 4, 11-12
+
+
+
+ ...
+
+ ...
+
+
+
+
+ ...
+
+
+ ...
+
+
+* Update :cpy-file:`PCbuild/pythoncore.vcxproj.filters`:
+
+ .. code-block:: xml
+ :caption: :cpy-file:`PCbuild/pythoncore.vcxproj.filters`
+ :emphasize-lines: 4-6, 13-18
+
+
+
+ ...
+
+ Modules\_foo
+
+ ...
+
+
+
+
+ ...
+
+ Modules\_foo
+
+
+ Modules\_foo
+
+ ...
+
+
+.. tip::
+
+ Header files use ```` tags, whereas
+ source files use ```` tags.
+
+
+Compiling the CPython project
+-----------------------------
+
+Now that the configuration is in place, it remains to compile the project:
+
+.. code-block:: shell
+
+ make regen-configure
+ ./configure
+ make regen-all
+ make regen-stdlib-module-names
+ make
+
+.. tip::
+
+ Use ``make -jN`` to speed-up compilation by utilizing as many CPU cores
+ as possible, where *N* is as many CPU cores you want to spare (and have
+ memory for). Be careful using ``make -j`` with no argument, as this puts
+ no limit on the number of jobs, and compilation can sometimes use up a
+ lot of memory (like when building with LTO).
+
+* ``make regen-configure`` updates the :cpy-file:`configure` script.
+
+ The :cpy-file:`configure` script must be generated using a specific version
+ of ``autoconf``. To that end, the :cpy-file:`Tools/build/regen-configure.sh`
+ script which the ``regen-configure`` rule is based on either requires Docker
+ or Podman, the latter being assumed by default.
+
+ .. tip::
+
+ We recommend installing `Podman `_
+ instead of Docker since the former does not require a background service
+ and avoids creating files owned by the ``root`` user in some cases.
+
+* ``make regen-all`` is responsible for regenerating header files and
+ invoking other scripts, such as :ref:`Argument Clinic `.
+ Execute this rule if you do not know which files should be updated.
+
+* ``make regen-stdlib-module-names`` updates the standard module names, making
+ :mod:`!_foo` discoverable and importable via ``import _foo``.
+
+* The final ``make`` step is generally not needed since the previous ``make``
+ invokations may completely rebuild the project, but it could be needed in
+ some specific cases.
+
+Troubleshooting
+---------------
+
+This section addresses common issues that you may face when following
+this example of adding an extension module.
+
+No rule to make target ``regen-configure``
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+This usually happens after running ``make distclean`` (which removes
+the ``Makefile``). The solution is to regenerate the :cpy-file:`configure`
+script as follows:
+
+.. code-block:: shell
+
+ ./configure # for creating the 'Makefile' file
+ make regen-configure # for updating the 'configure' script
+ ./configure # for updating the 'Makefile' file
+
+If missing, the :cpy-file:`configure` script can be regenerated
+by executing :cpy-file:`Tools/build/regen-configure.sh`:
+
+.. code-block:: shell
+
+ ./Tools/build/regen-configure.sh # create an up-to-date 'configure'
+ ./configure # create an up-to-date 'Makefile'
+
+``make regen-configure`` and missing permissions with Docker
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+If Docker complains about missing permissions, this Stack Overflow post
+could be useful in solving the issue: `How to fix docker: permission denied
+`_. Alternatively, you may try
+using `Podman `_.
+
+Missing ``Py_BUILD_CORE`` define when using internal headers
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+By default, the CPython :ref:`Stable ABI ` is exposed via
+:code:`#include "Python.h"`. In some cases, this may be insufficient
+and internal headers from :cpy-file:`Include/internal` are needed;
+in particular, those headers require the :c:macro:`!Py_BUILD_CORE`
+macro to be defined.
+
+To that end, one should define the :c:macro:`!Py_BUILD_CORE_BUILTIN`
+or the :c:macro:`!Py_BUILD_CORE_MODULE` macro depending on whether the
+extension module is built-in or shared. Using either of the two macros
+implies :c:macro:`!Py_BUILD_CORE` and gives access to CPython internals:
+
+.. code-block:: c
+ :caption: Definition of :c:macro:`!Py_BUILD_CORE_BUILTIN`
+
+ #ifndef Py_BUILD_CORE_MODULE
+ # define Py_BUILD_CORE_BUILTIN 1
+ #endif
+
+.. code-block:: c
+ :caption: Definition of :c:macro:`!Py_BUILD_CORE_MODULE`
+
+ #ifndef Py_BUILD_CORE_BUILTIN
+ # define Py_BUILD_CORE_MODULE 1
+ #endif
+
+Tips
+----
+
+In this section, we give some tips for improving the quality of
+extension modules meant to be included in the standard library.
+
+Restricting to the Limited API
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+In order for non-CPython implementations to benefit from new extension modules,
+it is recommended to use the :ref:`Limited API `. Instead of
+exposing the entire Stable ABI, define the :c:macro:`Py_LIMITED_API` macro
+*before* the :code:`#include "Python.h"` directive:
+
+.. code-block:: c
+ :caption: Using the 3.13 Limited API.
+ :emphasize-lines: 3, 6
+
+ #include "pyconfig.h" // Py_GIL_DISABLED
+ #ifndef Py_GIL_DISABLED
+ # define Py_LIMITED_API 0x030d0000
+ #endif
+
+ #include "Python.h"
+
+This makes the extension module non-CPython implementation-friendly by
+removing the dependencies to CPython internals.
diff --git a/developer-workflow/grammar.rst b/developer-workflow/grammar.rst
index 7ff1ed12a..d574dfed7 100644
--- a/developer-workflow/grammar.rst
+++ b/developer-workflow/grammar.rst
@@ -1,66 +1,8 @@
.. _grammar:
==========================
-Changing CPython's Grammar
+Changing CPython's grammar
==========================
-Abstract
-========
-
-There's more to changing Python's grammar than editing
-:file:`Grammar/python.gram`. Here's a checklist.
-
-.. note::
- These instructions are for Python 3.9 and beyond. Earlier
- versions use a different parser technology. You probably shouldn't
- try to change the grammar of earlier Python versions, but if you
- really want to, use GitHub to track down the earlier version of this
- file in the devguide.
-
-For more information on how to use the new parser, check the
-:ref:`section on how to use CPython's parser `.
-
-Checklist
-=========
-
-Note: sometimes things mysteriously don't work. Before giving up, try ``make clean``.
-
-* :file:`Grammar/python.gram`: The grammar, with actions that build AST nodes. After changing
- it, run ``make regen-pegen`` (or ``build.bat --regen`` on Windows), to
- regenerate :file:`Parser/parser.c`.
- (This runs Python's parser generator, ``Tools/peg_generator``).
-
-* :file:`Grammar/Tokens` is a place for adding new token types. After
- changing it, run ``make regen-token`` to regenerate :file:`Include/token.h`,
- :file:`Parser/token.c`, :file:`Lib/token.py` and
- :file:`Doc/library/token-list.inc`. If you change both ``python.gram`` and ``Tokens``,
- run ``make regen-token`` before ``make regen-pegen``. On Windows,
- ``build.bat --regen`` will regenerate both at the same time.
-
-* :file:`Parser/Python.asdl` may need changes to match the grammar. Then run ``make
- regen-ast`` to regenerate :file:`Include/Python-ast.h` and :file:`Python/Python-ast.c`.
-
-* :file:`Parser/tokenizer.c` contains the tokenization code. This is where you would
- add a new type of comment or string literal, for example.
-
-* :file:`Python/ast.c` will need changes to validate AST objects involved with the
- grammar change.
-
-* :file:`Python/ast_unparse.c` will need changes to unparse AST objects involved with the
- grammar change ("unparsing" is used to turn annotations into strings per :pep:`563`).
-
-* The :ref:`compiler` has its own page.
-
-* ``_Unparser`` in the :file:`Lib/ast.py` file may need changes to accommodate
- any modifications in the AST nodes.
-
-* :file:`Doc/library/ast.rst` may need to be updated to reflect changes to AST nodes.
-
-* Add some usage of your new syntax to ``test_grammar.py``.
-
-* Certain changes may require tweaks to the library module :mod:`pyclbr`.
-
-* :file:`Lib/tokenize.py` needs changes to match changes to the tokenizer.
-
-* Documentation must be written! Specifically, one or more of the pages in
- :file:`Doc/reference/` will need to be updated.
+This document is now part of the
+`CPython Internals Docs `_.
diff --git a/developer-workflow/index.rst b/developer-workflow/index.rst
index bc90a832a..e73927f1d 100644
--- a/developer-workflow/index.rst
+++ b/developer-workflow/index.rst
@@ -1,5 +1,7 @@
+.. _dev-workflow:
+
====================
-Development Workflow
+Development workflow
====================
.. toctree::
@@ -13,3 +15,5 @@ Development Workflow
lang-changes
grammar
porting
+ sbom
+ psrt
diff --git a/developer-workflow/lang-changes.rst b/developer-workflow/lang-changes.rst
index 7d663530c..52aabb15d 100644
--- a/developer-workflow/lang-changes.rst
+++ b/developer-workflow/lang-changes.rst
@@ -1,7 +1,7 @@
.. _lang-changes:
.. _langchanges:
-Changing the Python Language
+Changing the Python language
============================
On occasion people come up with an idea on how to change or improve Python as a
programming language. This document is meant to explain exactly what changes
@@ -9,7 +9,7 @@ have a reasonable chance of being considered and what the process is to propose
changes to the language.
-What Qualifies
+What qualifies
--------------
First and foremost, it must be understood that changes to the Python
programming language are difficult to make. When the language changes,
@@ -45,7 +45,7 @@ The `Ideas Discourse category`_
is specifically intended for discussion of new features and language changes.
Please don't be disappointed if your idea isn't met with universal approval:
as the :pep:`long list of Withdrawn and Rejected PEPs
-<0#abandoned-withdrawn-and-rejected-peps>`
+<0#rejected-superseded-and-withdrawn-peps>`
in the :pep:`PEP Index <0>` attests,
and as befits a reasonably mature programming language,
getting significant changes into Python isn't a simple task.
@@ -66,7 +66,7 @@ see `Justifying Python Language Changes`_.
.. _lang-changes-pep-process:
-PEP Process
+PEP process
-----------
Once you are certain you have a language change proposal
@@ -86,4 +86,3 @@ to inform others who may propose a similar language change in the future.
.. _Ideas Discourse category: https://discuss.python.org/c/ideas/6
.. _Status Quo Wins a Stalemate: https://www.curiousefficiency.org/posts/2011/02/status-quo-wins-stalemate.html
.. _Justifying Python Language Changes: https://www.curiousefficiency.org/posts/2011/02/justifying-python-language-changes.html
-
diff --git a/developer-workflow/porting.rst b/developer-workflow/porting.rst
index fc0c91517..f308e6c14 100644
--- a/developer-workflow/porting.rst
+++ b/developer-workflow/porting.rst
@@ -1,7 +1,7 @@
.. _porting:
=========================
-Porting to a New Platform
+Porting to a new platform
=========================
The first step is to familiarize yourself with the development toolchain on
@@ -13,11 +13,11 @@ which it has already been ported; preferably Unix, but Windows will
do, too. The build process for Python, in particular the ``Makefile`` in the
source distribution, will give you a hint on which files to compile
for Python. Not all source files are relevant: some are platform-specific,
-and others are only used in emergencies (e.g. ``getopt.c``).
+and others are only used in emergencies (for example, ``getopt.c``).
It is not recommended to start porting Python without at least a medium-level
-understanding of your target platform; i.e. how it is generally used, how to
-write platform-specific apps, etc. Also, some Python knowledge is required, or
+understanding of your target platform; how it is generally used, how to
+write platform-specific apps, and so on. Also, some Python knowledge is required, or
you will be unable to verify that your port is working correctly.
You will need a ``pyconfig.h`` file tailored for your platform. You can
diff --git a/developer-workflow/psrt.rst b/developer-workflow/psrt.rst
new file mode 100644
index 000000000..cf5acd2b7
--- /dev/null
+++ b/developer-workflow/psrt.rst
@@ -0,0 +1,194 @@
+Python Security Response Team (PSRT)
+====================================
+
+The Python Security Response Team (PSRT) is responsible for handling
+vulnerability reports for CPython and pip.
+
+Vulnerability report triage
+---------------------------
+
+Vulnerability reports are sent to one of two locations,
+the long-standing ``security@python.org`` mailing list
+or using the private vulnerability reporting feature
+of GitHub Security Advisories (GHSA).
+
+For reports sent to ``security@python.org``, a PSRT admin
+will triage the report and if the report seems plausible
+(that is, not spam and for the correct project) will reply with
+instructions on how to report the vulnerability on GitHub.
+
+If the reporter doesn't want to use GitHub's Security Advisories feature
+then the PSRT admins can create a draft report on behalf of the reporter.
+
+Coordinating a vulnerability report
+-----------------------------------
+
+Each report will have a member of the PSRT assigned as the "coordinator".
+The coordinator will be responsible for following the below process and
+will be publicly credited on vulnerability records post-publication.
+
+If a coordinator can't complete the process for any reason (time obligation,
+vacation, etc.) they must find a replacement coordinator in the PSRT
+and reassign the vulnerability report appropriately.
+
+Coordinators are expected to collaborate with other PSRT and core team members
+when needed for guidance on whether the report is an actual vulnerability,
+severity, advisory text, and fixes.
+
+**The vulnerability coordination process is:**
+
+* Coordinator will determine whether the report constitutes a vulnerability. If the report isn't a vulnerability,
+ the reporter should be notified appropriately. Close the GHSA report, the report can be reopened if
+ sufficient evidence is later obtained that the report is a vulnerability.
+
+* After a vulnerability report is accepted, a Common Vulnerabilities and Exposures (CVE) ID must be assigned. If this is not done
+ automatically, then a CVE ID can be obtained by the coordinator sending an email to ``cna@python.org``.
+ No details about the vulnerability report need to be shared with the PSF CVE Numbering Authority (CNA) for a CVE ID to be reserved.
+
+* If the report is a vulnerability, the coordinator will determine the severity of the vulnerability. Severity is one of:
+ **Low**, **Medium**, **High**, and **Critical**. Coordinators can use their knowledge of the code, how the code is likely used,
+ or another mechanism like Common Vulnerability Scoring System (CVSS) for determining a severity. Add this information to the GitHub Security Advisory.
+
+* Once a CVE ID is assigned, the coordinator will share the acceptance and CVE ID with the reporter.
+ Use this CVE ID for referencing the vulnerability. The coordinator will ask the reporter
+ if the reporter would like to be credited publicly for the report and if so, how they would like to be credited.
+ Add this information to the GitHub Security Advisory.
+
+* The coordinator authors the vulnerability advisory text. The advisory must include the following information:
+
+ * Title should be a brief description of the vulnerability and affected component
+ (for example, "Buffer over-read in SSLContext.set_npn_protocols()")
+
+ * Short description of the vulnerability, impact, and the conditions where the affected component is vulnerable, if applicable.
+
+ * Affected versions. This could be "all versions", but if the vulnerability exists in a new feature
+ or removed feature then this could be different. Include versions that are end-of-life in this calculation
+ (for example, "Python 3.9 and earlier", "Python 3.10 and later", "all versions of Python").
+
+ * Affected components and APIs. The module, function, class, or method must be specified so users can
+ search their codebase for usage. For issues affecting the entire project, this can be omitted.
+
+ * Mitigations for the vulnerability beyond upgrading to a fixed version, if applicable.
+
+ This can all be done within the GitHub Security Advisory UI for easier collaboration between reporter and coordinator.
+
+* The coordinator determines the fix approach and who will provide a fix.
+ Some reporters are willing to provide or collaborate to create a fix,
+ otherwise relevant core team members can be invited to collaborate by
+ the coordinator.
+
+ * For **Low** and **Medium** severity vulnerabilities it is acceptable
+ to develop a fix in public.
+ The pull request must be marked with the ``security`` and ``release-blocker``
+ labels so that a release is not created without including the fix.
+
+ * For **High** and **Critical** severity vulnerabilities the fix must be
+ developed privately using GitHub Security Advisories' "Private Forks" feature.
+ Core team members can be added to the GitHub Security Advisory via "collaborators"
+ to work on the fix together. Once a fix is approved privately and tested,
+ a public issue and pull request can be created with
+ the ``security`` and ``release-blocker`` labels.
+
+* Once the pull request is merged the advisory can be published. The coordinator will send the advisory by email
+ to ``security-announce@python.org`` using the below template. Backport labels must be added as appropriate.
+ After the advisory is published a CVE record can be created.
+
+Handling code signing certificate reports
+-----------------------------------------
+
+Python signs binaries using Azure Trusted Signing and Apple Developer ID
+certificates. If a code signing certificate is reported as "compromised" or
+"malware signed with certificate", the Python Security Response Team must
+request the following information from the reporter:
+
+* Checksum(s) of binaries signed by certificate.
+* Signature(s) of binaries signed by certificate.
+
+To avoid unnecessary user confusion and churn around revoking code signing
+certificates, any reports **must be verifiable independently by the PSRT before
+taking destructive actions**, such as revoking certificates. With this
+information the PSRT can take investigative steps to verify the report, such as:
+
+* Downloading and checking artifacts from the associated Azure Pipelines
+ executions against the reported list of checksums.
+* Verifying the validity of the signatures. `Past reports
+ `__ have contained signatures that
+ purported to be from Python code signing certificates, but were not valid.
+* Checking the Azure Pipelines and Azure Trusted Signing audit logs for signs of
+ compromise.
+
+If any signs of compromise or incorrectly signed binaries are discovered by the
+PSRT, only then will certificates be revoked and an advisory published.
+If compromise is reported, the following non-destructive actions can be taken by
+the PSRT without verifying the reported information as a precaution, if
+relevant:
+
+* Rotating secrets associated with code signing (``TrustedSigningSecret`` for
+ Azure Trusted Publishing).
+* Resetting passwords for accounts with access to signing certificates.
+
+Template responses
+------------------
+
+These template responses should be used as guidance for messaging
+in various points in the process above. They are not required to be sent as-is,
+please feel free to adapt them as needed for the current context.
+
+**Directing to GitHub Security Advisories:**
+
+.. highlight:: none
+
+::
+
+ Thanks for submitting this report.
+ We use GitHub Security Advisories for triaging vulnerability reports,
+ are you able to submit your report directly to GitHub?
+
+ https://github.com/python/cpython/security/advisories/new
+
+ If you're unable to submit a report to GitHub (due to not having a GitHub
+ account or something else) let me know and I will create a GitHub Security
+ Advisory on your behalf, although you won't be able to participate directly
+ in discussions.
+
+**Rejecting a vulnerability report:**
+
+::
+
+ Thanks for your report. We've determined that the report doesn't constitute
+ a vulnerability. Let us know if you disagree with this determination.
+ If you are interested in working on this further, you can optionally open a
+ public issue on GitHub.
+
+**Accepting a vulnerability report:**
+
+::
+
+ Thanks for your report. We've determined that the report
+ is a vulnerability. We've assigned {CVE-YYYY-XXXX} and determined
+ a severity of {Low,Medium,High,Critical}. Let us know if you disagree
+ with the determined severity.
+
+ If you would like to be publicly credited for this vulnerability as the
+ reporter, please indicate that, along with how you would like to be
+ credited (name or organization).
+
+ Please keep this vulnerability report private until we've published
+ an advisory to ``security-announce@python.org``.
+
+**Advisory email:**
+
+::
+
+ Title: [{CVE-YYYY-XXXX}] {title}
+
+ There is a {LOW, MEDIUM, HIGH, CRITICAL} severity vulnerability
+ affecting {project}.
+
+ {description}
+
+ Please see the linked CVE ID for the latest information on
+ affected versions:
+
+ * https://www.cve.org/CVERecord?id={CVE-YYYY-XXXX}
+ * {pull request URL}
diff --git a/developer-workflow/sbom.rst b/developer-workflow/sbom.rst
new file mode 100644
index 000000000..756c17570
--- /dev/null
+++ b/developer-workflow/sbom.rst
@@ -0,0 +1,109 @@
+Software Bill-of-Materials (SBOM)
+=================================
+
+Software Bill-of-Materials (abbreviated as "SBOM") is a document for sharing
+information about software and how it's been composed. This format is used
+most often in the security space for checking software and its dependencies
+for vulnerabilities using vulnerability databases like
+`CVE `_ and `OSV `_. The SBOM format
+that the CPython project uses is `SPDX `_
+which can be transformed into other formats if necessary by consumers.
+
+There are multiple sources of third-party dependencies for CPython.
+Some are vendored into the source code of CPython itself (like ``mpdecimal``
+vendored at :cpy-file:`Modules/_decimal/libmpdec`) or they could be optionally pulled
+in during builds like Windows using dependencies from the
+`python/cpython-source-deps `_
+repository.
+
+Whenever adding or updating a third-party dependency, an update will likely
+need to be done to the SBOM in order to track the version and software identifiers.
+
+Updating a dependency
+---------------------
+
+The SBOM for CPython's bundled dependencies is kept at
+:cpy-file:`Misc/sbom.spdx.json`. When updating a dependency to a new version
+you'll need to edit the version and other metadata about this dependency in
+the SBOM.
+
+The recommended workflow is:
+
+1. Download the new dependency as an archive. Take note of the new version, download
+ URL, and checksum of the downloaded archive.
+2. Update the vendored code in the CPython source tree.
+3. Edit :cpy-file:`Misc/sbom.spdx.json` to add the new ``versionInfo``,
+ ``downloadLocation``, ``checksums``, and ``externalReferences`` for the
+ corresponding ``package``. For most of these updates all that's needed is to
+ update the embedded version within URLs and project identifiers.
+ Don't update any information in ``files`` and ``relationships`` as this will
+ be generated automatically by the SBOM tool.
+4. Run ``make regen-sbom`` or ``python Tools/build/generate_sbom.py``.
+ Ensure that this doesn't fail with validation errors.
+5. Run ``git diff Misc/sbom.spdx.json`` and check the diff matches the
+ expected changes.
+6. Commit the changes to :cpy-file:`Misc/sbom.spdx.json` along with the
+ update to the dependency code.
+
+Adding a new dependency
+-----------------------
+
+When adding a dependency it's important to have the following information:
+
+* Name, version, and download URL of the project
+* License of the project as an `SPDX License Expression `_
+* Software identifiers that match values in vulnerability databases
+ (`CPE `_ and
+ `Package URLs `_
+ or "PURLs")
+* Paths to include and exclude in the CPython source tree corresponding to this dependency
+
+After gathering this information:
+
+1. Add the information into a new entry in ``packages`` in the file
+ :cpy-file:`Misc/sbom.spdx.json`. Don't worry about formatting, the tool will
+ auto-format your manually written JSON. The fields to fill out include:
+
+ * ``name`` for the project name.
+ * ``SPDXID`` which will be ``"SPDXRef-PACKAGE-{name}"``.
+ * ``licenseConcluded`` for the SPDX license identifier of the project license.
+ * ``versionInfo`` for the version of the project.
+ * ``downloadLocation`` should be an HTTPS URL for the project download as an archive.
+ * ``checksums[0].checksumValue`` and ``.algorithm`` will be the SHA-256
+ checksum of the downloaded archive.
+ * ``originator`` for the original author information, prefix with either an
+ ``Organization:`` or ``Person:`` depending on the author/maintenance situation.
+ * ``primaryPackagePurpose`` will likely be ``"SOURCE"``.
+ * ``externalReferences`` is a list of one or more project identifiers,
+ either CPE or Package URL. The value for ``referenceLocator`` must include
+ the value in ``versionInfo`` to ensure the identifier
+ corresponds to the correct release of the software. You can read more about
+ external references in the `SPDX SBOM specification`_.
+2. If a new license ID is to be used, add the license expression to
+ ``ALLOWED_LICENSE_EXPRESSIONS`` in the :cpy-file:`Tools/build/generate_sbom.py`.
+3. Add the paths to include and exclude into a ``PackageFiles`` instance
+ with a key corresponding to the SBOM ID for the package (``SPDXID`` without the
+ ``SPDXRef-PACKAGE-*`` prefix) in :cpy-file:`Tools/build/generate_sbom.py`.
+4. Run the tool with ``make regen-sbom`` or ``python Tools/build/generate_sbom.py``.
+ Ensure that the tool doesn't fail with any validation errors.
+5. Compare the changes to :cpy-file:`Misc/sbom.spdx.json` with ``git diff``, check
+ that all information appears correct.
+6. Commit the changes to :cpy-file:`Misc/sbom.spdx.json` and
+ :cpy-file:`Tools/build/generate_sbom.py`.
+
+.. _SPDX SBOM specification: https://spdx.github.io/spdx-spec/v2-draft/external-repository-identifiers/
+
+Removing a dependency
+---------------------
+
+When removing a dependency:
+
+1. Remove the entry from the :cpy-file:`Misc/sbom.spdx.json`
+ under the ``packages`` field.
+2. Remove the corresponding ``PackageFiles`` entry in :cpy-file:`Tools/build/generate_sbom.py`
+3. Run the tool with ``make regen-sbom`` or ``python Tools/build/generate_sbom.py``.
+ Ensure that the tool doesn't fail with any validation errors.
+4. Compare the changes to :cpy-file:`Misc/sbom.spdx.json` with ``git diff``, check
+ that correct package is removed from the SBOM.
+5. Commit the changes to :cpy-file:`Misc/sbom.spdx.json` and
+ :cpy-file:`Tools/build/generate_sbom.py`.
diff --git a/developer-workflow/stdlib.rst b/developer-workflow/stdlib.rst
index 176c72679..b683e55e9 100644
--- a/developer-workflow/stdlib.rst
+++ b/developer-workflow/stdlib.rst
@@ -1,7 +1,7 @@
.. _stdlib:
.. _stdlibchanges:
-Adding to the Stdlib
+Adding to the stdlib
====================
While the stdlib contains a great amount of useful code, sometimes you want
@@ -28,41 +28,39 @@ You have a several options for this:
* Search the `issue tracker`_ for discussion related to the proposed addition.
This may turn up an issue that explains why the suggestion wasn't accepted.
* Open a new thread in the `Ideas Discourse category`_
- to gather feedback directly from the Python core developers and community.
+ to gather feedback directly from the Python core team and community.
* Write a blog post about the code, which may also help gather useful feedback.
-* Post it to the `Python Cookbook`_.
- Based on feedback and reviews of the recipe,
- you can see if others find the functionality as useful as you do.
If you have found general acceptance and usefulness for your code from people,
you can open an issue on the `issue tracker`_ with the code attached as a
-:ref:`pull request `. If possible, also submit a
+:ref:`pull request `. If possible, also submit a
:ref:`contributor agreement `.
-If a core developer decides that your code would be useful to the general
+If a core team member decides that your code would be useful to the general
Python community, they will then commit your code. If your code is not picked
-up by a core developer and committed then please do not take this personally.
+up by a core team and committed then please do not take this personally.
Through your public sharing of your code in order to gauge community support
for it you at least can know that others will come across it who may find it
useful.
.. _Ideas Discourse category: https://discuss.python.org/c/ideas/6
-.. _Python Cookbook: https://code.activestate.com/recipes/langs/python/
Adding a new module
-------------------
+
It must be stated upfront that getting a new module into the stdlib is very
difficult. Adding any significant amount of code to the stdlib increases the
-burden placed upon core developers. It also means that the module somewhat
-becomes "sanctioned" by the core developers as a good way to do something,
+burden placed upon the core team. It also means that the module somewhat
+becomes "sanctioned" by the core team as a good way to do something,
typically leading to the rest of the Python community to using the new module
over other available solutions. All of this means that additions to the stdlib
are not taken lightly.
-Acceptable Types of Modules
-'''''''''''''''''''''''''''
+Acceptable types of modules
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
Typically two types of modules get added to the stdlib. One type is a module
which implements something that is difficult to get right. A good example of
this is the :py:mod:`multiprocessing` package. Working out the various OS
@@ -78,17 +76,18 @@ that the stdlib consists of.
While a new stdlib module does not need to appeal to all users of Python, it
should be something that a large portion of the community will find useful.
-This makes sure that the developer burden placed upon core developers is worth
+This makes sure that the developer burden placed upon the core team is worth
it.
Requirements
-''''''''''''
+^^^^^^^^^^^^
+
In order for a module to even be considered for inclusion into the stdlib, a
couple of requirements must be met.
The most basic is that the code must meet
-:ref:`standard patch requirements `. For code that has
+:ref:`standard pull request requirements `. For code that has
been developed outside the stdlib typically this means making sure the coding
style guides are followed and that the proper tests have been written.
@@ -105,23 +104,23 @@ year, a module needs to have established itself as (one of) the top choices by
the community for solving the problem the module is intended for.
The development of the module must move into Python's
-infrastructure (i.e., the module is no longer directly maintained outside of
+infrastructure (that is, the module is no longer directly maintained outside of
Python). This prevents a divergence between the code that is included in the
stdlib and that which is released outside the stdlib (typically done to provide
the module to older versions of Python). It also removes the burden of forcing
-core developers to have to redirect bug reports or patches to an external issue
+the core team to have to redirect bug reports or changes to an external issue
tracker and :abbr:`VCS (version control system)`.
Someone involved with the development of the
module must promise to help maintain the module in the stdlib for two years.
-This not only helps out other core developers by alleviating workload from bug
+This not only helps out other core team members by alleviating workload from bug
reports that arrive from the first Python release containing the module, but
also helps to make sure that the overall design of the module continues to be
uniform.
-Proposal Process
-''''''''''''''''
+Proposal process
+^^^^^^^^^^^^^^^^
If the module you want to propose adding to the stdlib meets the requirements,
you may propose its inclusion
@@ -135,3 +134,17 @@ once the authors of the module sign
:ref:`contributor agreements `.
.. _issue tracker: https://github.com/python/cpython/issues
+
+Adding a new environment variable
+---------------------------------
+
+Names of environment variables should be uppercase and, from Python 3.13
+onwards, use underscores for readability and accessibility.
+
+For example, use ``PYTHON_CPU_COUNT`` instead of ``PYTHONCPUCOUNT``.
+
+See also:
+
+* :ref:`python:using-on-envvars`
+* `"Change environment variable style" Discourse discussion
+ `__
diff --git a/advanced-tools/clang.rst b/development-tools/clang.rst
similarity index 51%
rename from advanced-tools/clang.rst
rename to development-tools/clang.rst
index d626c33ea..b353d82f0 100644
--- a/advanced-tools/clang.rst
+++ b/development-tools/clang.rst
@@ -1,15 +1,13 @@
.. _clang:
===========================
-Dynamic Analysis with Clang
+Dynamic analysis with Clang
===========================
.. highlight:: bash
This document describes how to use Clang to perform analysis on Python and its
-libraries. In addition to performing the analysis, the document will cover
-downloading, building and installing the latest Clang/LLVM combination (which
-is currently 3.4).
+libraries.
This document does not cover interpreting the findings. For a discussion of
interpreting results, see Marshall Clow's `Testing libc++ with
@@ -17,6 +15,13 @@ interpreting results, see Marshall Clow's `Testing libc++ with
blog posting is a detailed examinations of issues uncovered by Clang in
``libc++``.
+The document focuses on Clang, although most techniques should generally apply
+to GCC's sanitizers as well.
+
+The instructions were tested on Linux, but they should work on macOS as well.
+Instructions for Windows are incomplete.
+
+
What is Clang?
==============
@@ -25,7 +30,7 @@ front-end provides access to LLVM's optimizer and code generator. The
sanitizers - or checkers - are hooks into the code generation phase to
instrument compiled code so suspicious behavior is flagged.
-What are Sanitizers?
+What are sanitizers?
====================
Clang sanitizers are runtime checkers used to identify suspicious and undefined
@@ -49,177 +54,99 @@ A complete list of sanitizers can be found at `Controlling Code Generation
Clang and its sanitizers have strengths (and weaknesses). Its just one tool in
the war chest to uncovering bugs and improving code quality. Clang should be
-used to compliment other methods, including Code Reviews, Valgrind, Coverity,
+used to complement other methods, including Code Reviews, `Valgrind`_,
etc.
-Clang/LLVM Setup
+Clang/LLVM setup
================
-This portion of the document covers downloading, building and installing Clang
-and LLVM. There are three components to download and build. They are the LLVM
-compiler, the compiler front end and the compiler runtime library.
-
-In preparation you should create a scratch directory. Also ensure you are using
-Python 2 and not Python 3. Python 3 will cause the build to fail.
-
-Download, Build and Install
----------------------------
-
-Perform the following to download, build and install the Clang/LLVM 3.4. ::
-
- # Download
- wget https://llvm.org/releases/3.4/llvm-3.4.src.tar.gz
- wget https://llvm.org/releases/3.4/clang-3.4.src.tar.gz
- wget https://llvm.org/releases/3.4/compiler-rt-3.4.src.tar.gz
+Pre-built Clang builds are available for most platforms:
- # LLVM
- tar xvf llvm-3.4.src.tar.gz
- cd llvm-3.4/tools
+- On macOS, Clang is the default compiler.
+- For mainstream Linux distros, you can install a ``clang`` package.
+ In some cases, you also need to install ``llvm`` separately, otherwise
+ some tools are not available.
+- On Windows, the installer for Visual Studio (not Code)
+ includes the "C++ clang tools for windows" feature.
- # Clang Front End
- tar xvf ../../clang-3.4.src.tar.gz
- mv clang-3.4 clang
+You can also build ``clang`` from source; refer to
+`the clang documentation `_ for details.
- # Compiler RT
- cd ../projects
- tar xvf ../../compiler-rt-3.4.src.tar.gz
- mv compiler-rt-3.4/ compiler-rt
-
- # Build
- cd ..
- ./configure --enable-optimized --prefix=/usr/local
- make -j4
- sudo make install
-
-.. note::
-
- If you receive an error ``'LibraryDependencies.inc' file not found``, then
- ensure you are utilizing Python 2 and not Python 3. If you encounter the
- error after switching to Python 2, then delete everything and start over.
-
-After ``make install`` executes, the compilers will be installed in
-``/usr/local/bin`` and the various libraries will be installed in
-``/usr/local/lib/clang/3.4/lib/linux/``:
+The installer does not install all the components needed on occasion. For
+example, you might want to run a ``scan-build`` or examine the results with
+``scan-view``. If this is your case, you can build Clang from source and
+copy tools from ``tools/clang/tools`` to a directory on your ``PATH``.
-.. code-block:: console
+Another reason to build from source is to get the latest version of Clang/LLVM,
+if your platform's channels don't provide it yet.
+Newer versions of Clang/LLVM introduce new sanitizer checks.
- $ ls /usr/local/lib/clang/3.4/lib/linux/
- libclang_rt.asan-x86_64.a libclang_rt.profile-x86_64.a
- libclang_rt.dfsan-x86_64.a libclang_rt.san-x86_64.a
- libclang_rt.full-x86_64.a libclang_rt.tsan-x86_64.a
- libclang_rt.lsan-x86_64.a libclang_rt.ubsan_cxx-x86_64.a
- libclang_rt.msan-x86_64.a libclang_rt.ubsan-x86_64.a
-On Mac OS X, the libraries are installed in
-``/usr/local/lib/clang/3.3/lib/darwin/``:
+Python build setup
+==================
-.. code-block:: console
+This portion of the document covers invoking Clang and LLVM with the options
+required so the sanitizers analyze Python with under its test suite.
- $ ls /usr/local/lib/clang/3.3/lib/darwin/
- libclang_rt.10.4.a libclang_rt.ios.a
- libclang_rt.asan_osx.a libclang_rt.osx.a
- libclang_rt.asan_osx_dynamic.dylib libclang_rt.profile_ios.a
- libclang_rt.cc_kext.a libclang_rt.profile_osx.a
- libclang_rt.cc_kext_ios5.a libclang_rt.ubsan_osx.a
- libclang_rt.eprintf.a
+Set the compiler to Clang, in case it's not the default::
-.. note::
+ export CC="clang"
- You should never have to add the libraries to a project. Clang will handle
- it for you. If you find you cannot pass the ``-fsanitize=XXX`` flag through
- ``make``'s implicit variables (``CFLAGS``, ``CXXFLAGS``, ``CC``,
- ``CXXFLAGS``, ``LDFLAGS``) during ``configure``, then you should modify the
- makefile after configuring to ensure the flag is passed through the
- compiler.
+If you want to use additional sanitizer options (found in Clang documentation),
+add them to the ``CFLAGS`` variable.
+For example, you may want the checked process to exit after the first failure::
-The installer does not install all the components needed on occasion. For
-example, you might want to run a ``scan-build`` or examine the results with
-``scan-view``. You can copy the components by hand with: ::
+ export CFLAGS="-fno-sanitize-recover"
- sudo mkdir /usr/local/bin/scan-build
- sudo cp -r llvm-3.4/tools/clang/tools/scan-build /usr/local/bin
- sudo mkdir /usr/local/bin/scan-view
- sudo cp -r llvm-3.4/tools/clang/tools/scan-view /usr/local/bin
+Then, run ``./configure`` with the relevant flags:
-.. note::
+* ASan: ``--with-address-sanitizer --without-pymalloc``
+* UBsan: ``--with-undefined-behavior-sanitizer``
- Because the installer does not install all the components needed on
- occasion, you should not delete the scratch directory until you are sure
- things work as expected. If a library is missing, then you should search for
- it in the Clang/LLVM build directory.
+The ``--without-pymalloc`` option is not necessary (tests should pass without it),
+but disabling pymalloc helps ASan uncover more bugs (ASan does not track
+individual allocations done by pymalloc).
-Python Build Setup
-==================
+It is OK to specify both sanitizers.
-This portion of the document covers invoking Clang and LLVM with the options
-required so the sanitizers analyze Python with under its test suite. Two
-checkers are used - ASan and UBSan.
+After that, run ``make`` and ``make test`` as usual.
+Note that ``make`` itself may fail with a sanitizer failure,
+since the just-compiled Python runs during later stages of the build.
-Because the sanitizers are runtime checkers, its best to have as many positive
-and negative self tests as possible. You can never have enough self tests.
-The general idea is to compile and link with the sanitizer flags. At link time,
-Clang will include the needed runtime libraries. However, you can't use
-``CFLAGS`` and ``CXXFLAGS`` to pass the options through the compiler to the
-linker because the makefile rules for ``BUILDPYTHON``, ``_testembed`` and
-``_freeze_importlib`` don't use the implicit variables.
+Build setup for enabling sanitizers for all code
+------------------------------------------------
-As a workaround to the absence of flags to the linker, you can pass the
-sanitizer options by way of the compilers - ``CC`` and ``CXX``. Passing the
-flags though the compiler is used below, but passing them through ``LDFLAGS`` is
-also reported to work.
+Some parts of Python (for example, ``_testembed``, ``_freeze_importlib``,
+``test_cppext``) may not use the variables set by ``configure``,
+and with the above settings they'll be compiled without sanitization.
-Building Python
----------------
+As a workaround, you can pass the sanitizer options by way of the *compilers*,
+``CC`` (for C) and ``CXX`` (for C++). This is used below.
+Passing the options through ``LDFLAGS`` is also reported to work.
-To begin, export the variables of interest with the desired sanitizers. Its OK
-to specify both sanitizers: ::
+For ASan, use::
# ASan
- export CC="/usr/local/bin/clang -fsanitize=address"
- export CXX="/usr/local/bin/clang++ -fsanitize=address -fno-sanitize=vptr"
+ export CC="clang -fsanitize=address"
+ export CXX="clang++ -fsanitize=address -fno-sanitize=vptr"
-Or: ::
+And for UBSan::
# UBSan
- export CC="/usr/local/bin/clang -fsanitize=undefined"
- export CXX="/usr/local/bin/clang++ -fsanitize=undefined -fno-sanitize=vptr"
-
-The ``-fno-sanitize=vptr`` removes vtable checks that are part of UBSan from C++
-projects due to noise. Its not needed with Python, but you will likely need it
-for other C++ projects.
-
-After exporting ``CC`` and ``CXX``, ``configure`` as normal:
-
-.. code-block:: console
-
- $ ./configure
- checking build system type... x86_64-unknown-linux-gnu
- checking host system type... x86_64-unknown-linux-gnu
- checking for --enable-universalsdk... no
- checking for --with-universal-archs... 32-bit
- checking MACHDEP... linux
- checking for --without-gcc... no
- checking for gcc... /usr/local/bin/clang -fsanitize=undefined
- checking whether the C compiler works... yes
- ...
+ export CC="clang -fsanitize=undefined"
+ export CXX="clang++ -fsanitize=undefined -fno-sanitize=vptr"
-Next is a standard ``make`` (formatting added for clarity):
+It's OK to specify both sanitizers.
-.. code-block:: console
+After this, run ``./configure``, ``make`` and ``make test`` as usual.
- $ make
- /usr/local/bin/clang -fsanitize=undefined -c -Wno-unused-result
- -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I.
- -IInclude -I./Include -DPy_BUILD_CORE -o Modules/python.o
- ./Modules/python.c
- /usr/local/bin/clang -fsanitize=undefined -c -Wno-unused-result
- -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I.
- -IInclude -I./Include -DPy_BUILD_CORE -o Parser/acceler.o
- Parser/acceler.c
- ...
-Finally is ``make test`` (formatting added for clarity):
+Analyzing the output
+====================
+
+Sanitizer failures will make the process fail and output a diagnostic,
+for example:
.. code-block:: none
@@ -233,8 +160,12 @@ Finally is ``make test`` (formatting added for clarity):
^
...
-If you are using the address sanitizer, its important to pipe the output through
-``asan_symbolize.py`` to get a good trace. For example, from Issue 20953 during
+If you are using the address sanitizer, an additional tool is needed to
+get good traces. Usually, this happens automatically through the
+``llvm-symbolizer`` tool. If this tool is not installed on your ``PATH``,
+you can set ``ASAN_SYMBOLIZER_PATH`` to the location of the tool,
+or pipe test output through ``asan_symbolize.py`` script from the
+Clang distribution. For example, from Issue 20953 during
compile (formatting added for clarity):
.. code-block:: none
@@ -302,25 +233,25 @@ compile (formatting added for clarity):
.. note::
- ``asan_symbolize.py`` is supposed to be installed during ``make install``.
- If its not installed, then look in the Clang/LLVM build directory for it and
- copy it to ``/usr/local/bin``.
+ If ``asan_symbolize.py`` is not installed, build Clang from source, then
+ look in the Clang/LLVM build directory for it and use it directly or copy
+ it to a directory on ``PATH``.
-Blacklisting (Ignoring) Findings
---------------------------------
+Ignoring findings
+-----------------
.. highlight:: none
Clang allows you to alter the behavior of sanitizer tools for certain
-source-level by providing a special blacklist file at compile-time. The
-blacklist is needed because it reports every instance of an issue, even if the
+source-level by providing a special ignorelist file at compile-time. The
+ignorelist is needed because it reports every instance of an issue, even if the
issue is reported 10's of thousands of time in un-managed library code.
-You specify the blacklist with ``-fsanitize-blacklist=XXX``. For example::
+You specify the ignorelist with ``-fsanitize-ignorelist=XXX``. For example::
- -fsanitize-blacklist=my_blacklist.txt
+ -fsanitize-ignorelist=my_ignorelist.txt
-``my_blacklist.txt`` would then contain entries such as the following. The entry
+``my_ignorelist.txt`` would then contain entries such as the following. The entry
will ignore a bug in ``libc++``'s ``ios`` formatting functions::
fun:_Ios_Fmtflags
@@ -342,7 +273,7 @@ findings::
...
One of the function of interest is ``audioop_getsample_impl`` (flagged at line
-422), and the blacklist entry would include::
+422), and the ignorelist entry would include::
fun:audioop_getsample_imp
@@ -350,7 +281,9 @@ Or, you could ignore the entire file with::
src:Modules/audioop.c
-Unfortunately, you won't know what to blacklist until you run the sanitizer.
+Unfortunately, you won't know what to ignorelist until you run the sanitizer.
The documentation is available at `Sanitizer special case list
`_.
+
+.. _Valgrind: https://github.com/python/cpython/blob/main/Misc/README.valgrind
diff --git a/development-tools/clinic/howto.rst b/development-tools/clinic/howto.rst
new file mode 100644
index 000000000..364cf20be
--- /dev/null
+++ b/development-tools/clinic/howto.rst
@@ -0,0 +1,1572 @@
+.. _clinic-howtos:
+
+How-to guides
+=============
+
+
+How to rename C functions and variables generated by Argument Clinic
+--------------------------------------------------------------------
+
+Argument Clinic automatically names the functions it generates for you.
+Occasionally this may cause a problem, if the generated name collides with
+the name of an existing C function. There's an easy solution: override the names
+used for the C functions. Just add the keyword ``"as"``
+to your function declaration line, followed by the function name you wish to use.
+Argument Clinic will use that function name for the base (generated) function,
+then add ``"_impl"`` to the end and use that for the name of the impl function.
+
+For example, if we wanted to rename the C function names generated for
+:py:meth:`pickle.Pickler.dump`, it'd look like this::
+
+ /*[clinic input]
+ pickle.Pickler.dump as pickler_dumper
+
+ ...
+
+The base function would now be named :c:func:`!pickler_dumper`,
+and the impl function would now be named :c:func:`!pickler_dumper_impl`.
+
+
+Similarly, you may have a problem where you want to give a parameter
+a specific Python name, but that name may be inconvenient in C. Argument
+Clinic allows you to give a parameter different names in Python and in C,
+using the same ``"as"`` syntax::
+
+ /*[clinic input]
+ pickle.Pickler.dump
+
+ obj: object
+ file as file_obj: object
+ protocol: object = NULL
+ *
+ fix_imports: bool = True
+
+Here, the name used in Python (in the signature and the ``keywords``
+array) would be *file*, but the C variable would be named ``file_obj``.
+
+You can use this to rename the *self* parameter too!
+
+
+How to convert functions using ``PyArg_UnpackTuple``
+----------------------------------------------------
+
+To convert a function parsing its arguments with :c:func:`PyArg_UnpackTuple`,
+simply write out all the arguments, specifying each as an ``object``. You
+may specify the *type* argument to cast the type as appropriate. All
+arguments should be marked positional-only (add a ``/`` on a line by itself
+after the last argument).
+
+Currently the generated code will use :c:func:`PyArg_ParseTuple`, but this
+will change soon.
+
+
+How to use optional groups
+--------------------------
+
+Some legacy functions have a tricky approach to parsing their arguments:
+they count the number of positional arguments, then use a ``switch`` statement
+to call one of several different :c:func:`PyArg_ParseTuple` calls depending on
+how many positional arguments there are. (These functions cannot accept
+keyword-only arguments.) This approach was used to simulate optional
+arguments back before :c:func:`PyArg_ParseTupleAndKeywords` was created.
+
+While functions using this approach can often be converted to
+use :c:func:`!PyArg_ParseTupleAndKeywords`, optional arguments, and default values,
+it's not always possible. Some of these legacy functions have
+behaviors :c:func:`!PyArg_ParseTupleAndKeywords` doesn't directly support.
+The most obvious example is the builtin function :py:func:`!range`, which has
+an optional argument on the *left* side of its required argument!
+Another example is :py:meth:`curses.window.addch`, which has a group of two
+arguments that must always be specified together. (The arguments are
+called *x* and *y*; if you call the function passing in *x*,
+you must also pass in *y* — and if you don't pass in *x* you may not
+pass in *y* either.)
+
+In any case, the goal of Argument Clinic is to support argument parsing
+for all existing CPython builtins without changing their semantics.
+Therefore Argument Clinic supports
+this alternate approach to parsing, using what are called *optional groups*.
+Optional groups are groups of arguments that must all be passed in together.
+They can be to the left or the right of the required arguments. They
+can *only* be used with positional-only parameters.
+
+.. note:: Optional groups are *only* intended for use when converting
+ functions that make multiple calls to :c:func:`PyArg_ParseTuple`!
+ Functions that use *any* other approach for parsing arguments
+ should *almost never* be converted to Argument Clinic using
+ optional groups. Functions using optional groups currently
+ cannot have accurate signatures in Python, because Python just
+ doesn't understand the concept. Please avoid using optional
+ groups wherever possible.
+
+To specify an optional group, add a ``[`` on a line by itself before
+the parameters you wish to group together, and a ``]`` on a line by itself
+after these parameters. As an example, here's how :py:meth:`curses.window.addch`
+uses optional groups to make the first two parameters and the last
+parameter optional::
+
+ /*[clinic input]
+
+ curses.window.addch
+
+ [
+ x: int
+ X-coordinate.
+ y: int
+ Y-coordinate.
+ ]
+
+ ch: object
+ Character to add.
+
+ [
+ attr: long
+ Attributes for the character.
+ ]
+ /
+
+ ...
+
+
+Notes:
+
+* For every optional group, one additional parameter will be passed into the
+ impl function representing the group. The parameter will be an int named
+ ``group_{direction}_{number}``,
+ where ``{direction}`` is either ``right`` or ``left`` depending on whether the group
+ is before or after the required parameters, and ``{number}`` is a monotonically
+ increasing number (starting at 1) indicating how far away the group is from
+ the required parameters. When the impl is called, this parameter will be set
+ to zero if this group was unused, and set to non-zero if this group was used.
+ (By used or unused, I mean whether or not the parameters received arguments
+ in this invocation.)
+
+* If there are no required arguments, the optional groups will behave
+ as if they're to the right of the required arguments.
+
+* In the case of ambiguity, the argument parsing code
+ favors parameters on the left (before the required parameters).
+
+* Optional groups can only contain positional-only parameters.
+
+* Optional groups are *only* intended for legacy code. Please do not
+ use optional groups for new code.
+
+
+How to use real Argument Clinic converters, instead of "legacy converters"
+--------------------------------------------------------------------------
+
+To save time, and to minimize how much you need to learn
+to achieve your first port to Argument Clinic, the walkthrough above tells
+you to use "legacy converters". "Legacy converters" are a convenience,
+designed explicitly to make porting existing code to Argument Clinic
+easier.
+
+However, in the long term we probably want all our blocks to
+use Argument Clinic's real syntax for converters. Why? A couple
+reasons:
+
+* The proper converters are far easier to read and clearer in their intent.
+* There are some format units that are unsupported as "legacy converters",
+ because they require arguments, and the legacy converter syntax doesn't
+ support specifying arguments.
+* In the future we may have a new argument parsing library that isn't
+ restricted to what :c:func:`PyArg_ParseTuple` supports; this flexibility
+ won't be available to parameters using legacy converters.
+
+Therefore, if you don't mind a little extra effort, please use the normal
+converters instead of legacy converters.
+
+In a nutshell, the syntax for Argument Clinic (non-legacy) converters
+looks like a Python function call. However, if there are no explicit
+arguments to the function (all functions take their default values),
+you may omit the parentheses. Thus ``bool`` and ``bool()`` are exactly
+the same converters.
+
+All arguments to Argument Clinic converters are keyword-only.
+All Argument Clinic converters accept the following arguments:
+
+*c_default*
+ The default value for this parameter when defined in C.
+ Specifically, this will be the initializer for the variable declared
+ in the "parse function". See :ref:`the section on default values `
+ for how to use this.
+ Specified as a string.
+
+*annotation*
+ The annotation value for this parameter. Not currently supported,
+ because :pep:`8` mandates that the Python library may not use
+ annotations.
+
+*unused*
+ Wrap the argument with :c:macro:`Py_UNUSED` in the impl function signature.
+
+In addition, some converters accept additional arguments. Here is a list
+of these arguments, along with their meanings:
+
+*accept*
+ A set of Python types (and possibly pseudo-types);
+ this restricts the allowable Python argument to values of these types.
+ (This is not a general-purpose facility; as a rule it only supports
+ specific lists of types as shown in the legacy converter table.)
+
+ To accept ``None``, add ``NoneType`` to this set.
+
+*bitwise*
+ Only supported for unsigned integers. The native integer value of this
+ Python argument will be written to the parameter without any range checking,
+ even for negative values.
+
+*converter*
+ Only supported by the ``object`` converter. Specifies the name of a
+ :ref:`C "converter function" `
+ to use to convert this object to a native type.
+
+*encoding*
+ Only supported for strings. Specifies the encoding to use when converting
+ this string from a Python str (Unicode) value into a C ``char *`` value.
+
+
+*subclass_of*
+ Only supported for the ``object`` converter. Requires that the Python
+ value be a subclass of a Python type, as expressed in C.
+
+*type*
+ Only supported for the ``object`` and ``self`` converters. Specifies
+ the C type that will be used to declare the variable. Default value is
+ ``"PyObject *"``.
+
+*zeroes*
+ Only supported for strings. If true, embedded NUL bytes (``'\\0'``) are
+ permitted inside the value. The length of the string will be passed in
+ to the impl function, just after the string parameter, as a parameter named
+ ``_length``.
+
+Please note, not every possible combination of arguments will work.
+Usually these arguments are implemented by specific :c:func:`PyArg_ParseTuple`
+*format units*, with specific behavior. For example, currently you cannot
+call ``unsigned_short`` without also specifying ``bitwise=True``.
+Although it's perfectly reasonable to think this would work, these semantics don't
+map to any existing format unit. So Argument Clinic doesn't support it. (Or, at
+least, not yet.)
+
+Below is a table showing the mapping of legacy converters into real
+Argument Clinic converters. On the left is the legacy converter,
+on the right is the text you'd replace it with.
+
+========= =================================================================================
+``'B'`` ``unsigned_char(bitwise=True)``
+``'b'`` ``unsigned_char``
+``'c'`` ``char``
+``'C'`` ``int(accept={str})``
+``'d'`` ``double``
+``'D'`` ``Py_complex``
+``'es'`` ``str(encoding='name_of_encoding')``
+``'es#'`` ``str(encoding='name_of_encoding', zeroes=True)``
+``'et'`` ``str(encoding='name_of_encoding', accept={bytes, bytearray, str})``
+``'et#'`` ``str(encoding='name_of_encoding', accept={bytes, bytearray, str}, zeroes=True)``
+``'f'`` ``float``
+``'h'`` ``short``
+``'H'`` ``unsigned_short(bitwise=True)``
+``'i'`` ``int``
+``'I'`` ``unsigned_int(bitwise=True)``
+``'k'`` ``unsigned_long(bitwise=True)``
+``'K'`` ``unsigned_long_long(bitwise=True)``
+``'l'`` ``long``
+``'L'`` ``long long``
+``'n'`` ``Py_ssize_t``
+``'O'`` ``object``
+``'O!'`` ``object(subclass_of='&PySomething_Type')``
+``'O&'`` ``object(converter='name_of_c_function')``
+``'p'`` ``bool``
+``'S'`` ``PyBytesObject``
+``'s'`` ``str``
+``'s#'`` ``str(zeroes=True)``
+``'s*'`` ``Py_buffer(accept={buffer, str})``
+``'U'`` ``unicode``
+``'u'`` ``wchar_t``
+``'u#'`` ``wchar_t(zeroes=True)``
+``'w*'`` ``Py_buffer(accept={rwbuffer})``
+``'Y'`` ``PyByteArrayObject``
+``'y'`` ``str(accept={bytes})``
+``'y#'`` ``str(accept={robuffer}, zeroes=True)``
+``'y*'`` ``Py_buffer``
+``'Z'`` ``wchar_t(accept={str, NoneType})``
+``'Z#'`` ``wchar_t(accept={str, NoneType}, zeroes=True)``
+``'z'`` ``str(accept={str, NoneType})``
+``'z#'`` ``str(accept={str, NoneType}, zeroes=True)``
+``'z*'`` ``Py_buffer(accept={buffer, str, NoneType})``
+========= =================================================================================
+
+As an example, here's our sample ``pickle.Pickler.dump`` using the proper
+converter::
+
+ /*[clinic input]
+ pickle.Pickler.dump
+
+ obj: object
+ The object to be pickled.
+ /
+
+ Write a pickled representation of obj to the open file.
+ [clinic start generated code]*/
+
+One advantage of real converters is that they're more flexible than legacy
+converters. For example, the ``unsigned_int`` converter (and all the
+``unsigned_`` converters) can be specified without ``bitwise=True``. Their
+default behavior performs range checking on the value, and they won't accept
+negative numbers. You just can't do that with a legacy converter!
+
+Argument Clinic will show you all the converters it has
+available. For each converter it'll show you all the parameters
+it accepts, along with the default value for each parameter.
+Just run ``Tools/clinic/clinic.py --converters`` to see the full list.
+
+
+How to use the ``Py_buffer`` converter
+--------------------------------------
+
+When using the ``Py_buffer`` converter
+(or the ``'s*'``, ``'w*'``, ``'*y'``, or ``'z*'`` legacy converters),
+you *must* not call :c:func:`PyBuffer_Release` on the provided buffer.
+Argument Clinic generates code that does it for you (in the parsing function).
+
+
+.. _clinic-howto-advanced-converters:
+
+How to use advanced converters
+------------------------------
+
+Remember those format units you skipped for your first
+time because they were advanced? Here's how to handle those too.
+
+The trick is, all those format units take arguments—either
+conversion functions, or types, or strings specifying an encoding.
+(But "legacy converters" don't support arguments. That's why we
+skipped them for your first function.) The argument you specified
+to the format unit is now an argument to the converter; this
+argument is either *converter* (for ``O&``), *subclass_of* (for ``O!``),
+or *encoding* (for all the format units that start with ``e``).
+
+When using *subclass_of*, you may also want to use the other
+custom argument for ``object()``: *type*, which lets you set the type
+actually used for the parameter. For example, if you want to ensure
+that the object is a subclass of :c:var:`PyUnicode_Type`, you probably want
+to use the converter ``object(type='PyUnicodeObject *', subclass_of='&PyUnicode_Type')``.
+
+One possible problem with using Argument Clinic: it takes away some possible
+flexibility for the format units starting with ``e``. When writing a
+:c:func:`!PyArg_Parse*` call by hand, you could theoretically decide at runtime what
+encoding string to pass to that call. But now this string must
+be hard-coded at Argument-Clinic-preprocessing-time. This limitation is deliberate;
+it made supporting this format unit much easier, and may allow for future optimizations.
+This restriction doesn't seem unreasonable; CPython itself always passes in static
+hard-coded encoding strings for parameters whose format units start with ``e``.
+
+
+.. _clinic-howto-default-values:
+.. _default_values:
+
+How to assign default values to parameter
+-----------------------------------------
+
+Default values for parameters can be any of a number of values.
+At their simplest, they can be string, int, or float literals:
+
+.. code-block:: none
+
+ foo: str = "abc"
+ bar: int = 123
+ bat: float = 45.6
+
+They can also use any of Python's built-in constants:
+
+.. code-block:: none
+
+ yep: bool = True
+ nope: bool = False
+ nada: object = None
+
+There's also special support for a default value of ``NULL``, and
+for simple expressions, documented in the following sections.
+
+
+The ``NULL`` default value
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+For string and object parameters, you can set them to ``None`` to indicate
+that there's no default. However, that means the C variable will be
+initialized to ``Py_None``. For convenience's sakes, there's a special
+value called ``NULL`` for just this reason: from Python's perspective it
+behaves like a default value of ``None``, but the C variable is initialized
+with ``NULL``.
+
+
+Symbolic default values
+^^^^^^^^^^^^^^^^^^^^^^^
+
+The default value you provide for a parameter can't be any arbitrary
+expression. Currently the following are explicitly supported:
+
+* Numeric constants (integer and float)
+* String constants
+* ``True``, ``False``, and ``None``
+* Simple symbolic constants like :py:data:`sys.maxsize`, which must
+ start with the name of the module
+
+(In the future, this may need to get even more elaborate,
+to allow full expressions like ``CONSTANT - 1``.)
+
+
+Expressions as default values
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The default value for a parameter can be more than just a literal value.
+It can be an entire expression, using math operators and looking up attributes
+on objects. However, this support isn't exactly simple, because of some
+non-obvious semantics.
+
+Consider the following example:
+
+.. code-block:: none
+
+ foo: Py_ssize_t = sys.maxsize - 1
+
+:py:data:`sys.maxsize` can have different values on different platforms. Therefore
+Argument Clinic can't simply evaluate that expression locally and hard-code it
+in C. So it stores the default in such a way that it will get evaluated at
+runtime, when the user asks for the function's signature.
+
+What namespace is available when the expression is evaluated? It's evaluated
+in the context of the module the builtin came from. So, if your module has an
+attribute called :py:attr:`!max_widgets`, you may simply use it:
+
+.. code-block:: none
+
+ foo: Py_ssize_t = max_widgets
+
+If the symbol isn't found in the current module, it fails over to looking in
+:py:data:`sys.modules`. That's how it can find :py:data:`sys.maxsize` for example.
+(Since you don't know in advance what modules the user will load into their interpreter,
+it's best to restrict yourself to modules that are preloaded by Python itself.)
+
+Evaluating default values only at runtime means Argument Clinic can't compute
+the correct equivalent C default value. So you need to tell it explicitly.
+When you use an expression, you must also specify the equivalent expression
+in C, using the *c_default* parameter to the converter:
+
+.. code-block:: none
+
+ foo: Py_ssize_t(c_default="PY_SSIZE_T_MAX - 1") = sys.maxsize - 1
+
+Another complication: Argument Clinic can't know in advance whether or not the
+expression you supply is valid. It parses it to make sure it looks legal, but
+it can't *actually* know. You must be very careful when using expressions to
+specify values that are guaranteed to be valid at runtime!
+
+Finally, because expressions must be representable as static C values, there
+are many restrictions on legal expressions. Here's a list of Python features
+you're not permitted to use:
+
+* Function calls.
+* Inline if statements (``3 if foo else 5``).
+* Automatic sequence unpacking (``*[1, 2, 3]``).
+* List/set/dict comprehensions and generator expressions.
+* Tuple/list/set/dict literals.
+
+
+.. _clinic-howto-return-converters:
+
+How to use return converters
+----------------------------
+
+By default, the impl function Argument Clinic generates for you returns
+:c:type:`PyObject * `.
+But your C function often computes some C type,
+then converts it into the :c:type:`!PyObject *`
+at the last moment. Argument Clinic handles converting your inputs from Python types
+into native C types—why not have it convert your return value from a native C type
+into a Python type too?
+
+That's what a "return converter" does. It changes your impl function to return
+some C type, then adds code to the generated (non-impl) function to handle converting
+that value into the appropriate :c:type:`!PyObject *`.
+
+The syntax for return converters is similar to that of parameter converters.
+You specify the return converter like it was a return annotation on the
+function itself, using ``->`` notation.
+
+For example:
+
+.. code-block:: c
+
+ /*[clinic input]
+ add -> int
+
+ a: int
+ b: int
+ /
+
+ [clinic start generated code]*/
+
+Return converters behave much the same as parameter converters;
+they take arguments, the arguments are all keyword-only, and if you're not changing
+any of the default arguments you can omit the parentheses.
+
+(If you use both ``"as"`` *and* a return converter for your function,
+the ``"as"`` should come before the return converter.)
+
+There's one additional complication when using return converters: how do you
+indicate an error has occurred? Normally, a function returns a valid (non-``NULL``)
+pointer for success, and ``NULL`` for failure. But if you use an integer return converter,
+all integers are valid. How can Argument Clinic detect an error? Its solution: each return
+converter implicitly looks for a special value that indicates an error. If you return
+that value, and an error has been set (c:func:`PyErr_Occurred` returns a true
+value), then the generated code will propagate the error. Otherwise it will
+encode the value you return like normal.
+
+Currently Argument Clinic supports only a few return converters:
+
+.. code-block:: none
+
+ bool
+ double
+ float
+ int
+ long
+ Py_ssize_t
+ size_t
+ unsigned int
+ unsigned long
+
+None of these take parameters.
+For all of these, return ``-1`` to indicate error.
+
+To see all the return converters Argument Clinic supports, along with
+their parameters (if any),
+just run ``Tools/clinic/clinic.py --converters`` for the full list.
+
+
+How to clone existing functions
+-------------------------------
+
+If you have a number of functions that look similar, you may be able to
+use Clinic's "clone" feature. When you clone an existing function,
+you reuse:
+
+* its parameters, including
+
+ * their names,
+
+ * their converters, with all parameters,
+
+ * their default values,
+
+ * their per-parameter docstrings,
+
+ * their *kind* (whether they're positional only,
+ positional or keyword, or keyword only), and
+
+* its return converter.
+
+The only thing not copied from the original function is its docstring;
+the syntax allows you to specify a new docstring.
+
+Here's the syntax for cloning a function::
+
+ /*[clinic input]
+ module.class.new_function [as c_basename] = module.class.existing_function
+
+ Docstring for new_function goes here.
+ [clinic start generated code]*/
+
+(The functions can be in different modules or classes. I wrote
+``module.class`` in the sample just to illustrate that you must
+use the full path to *both* functions.)
+
+Sorry, there's no syntax for partially cloning a function, or cloning a function
+then modifying it. Cloning is an all-or nothing proposition.
+
+Also, the function you are cloning from must have been previously defined
+in the current file.
+
+
+How to call Python code
+-----------------------
+
+The rest of the advanced topics require you to write Python code
+which lives inside your C file and modifies Argument Clinic's
+runtime state. This is simple: you simply define a Python block.
+
+A Python block uses different delimiter lines than an Argument
+Clinic function block. It looks like this::
+
+ /*[python input]
+ # python code goes here
+ [python start generated code]*/
+
+All the code inside the Python block is executed at the
+time it's parsed. All text written to stdout inside the block
+is redirected into the "output" after the block.
+
+As an example, here's a Python block that adds a static integer
+variable to the C code::
+
+ /*[python input]
+ print('static int __ignored_unused_variable__ = 0;')
+ [python start generated code]*/
+ static int __ignored_unused_variable__ = 0;
+ /*[python checksum:...]*/
+
+
+.. _clinic-howto-self-converter:
+
+How to use the "self converter"
+-------------------------------
+
+Argument Clinic automatically adds a "self" parameter for you
+using a default converter. It automatically sets the ``type``
+of this parameter to the "pointer to an instance" you specified
+when you declared the type. However, you can override
+Argument Clinic's converter and specify one yourself.
+Just add your own *self* parameter as the first parameter in a
+block, and ensure that its converter is an instance of
+:class:`!self_converter` or a subclass thereof.
+
+What's the point? This lets you override the type of ``self``,
+or give it a different default name.
+
+How do you specify the custom type you want to cast ``self`` to?
+If you only have one or two functions with the same type for ``self``,
+you can directly use Argument Clinic's existing ``self`` converter,
+passing in the type you want to use as the *type* parameter::
+
+ /*[clinic input]
+
+ _pickle.Pickler.dump
+
+ self: self(type="PicklerObject *")
+ obj: object
+ /
+
+ Write a pickled representation of the given object to the open file.
+ [clinic start generated code]*/
+
+On the other hand, if you have a lot of functions that will use the same
+type for ``self``, it's best to create your own converter, subclassing
+:class:`!self_converter` but overwriting the :py:attr:`!type` member::
+
+ /*[python input]
+ class PicklerObject_converter(self_converter):
+ type = "PicklerObject *"
+ [python start generated code]*/
+
+ /*[clinic input]
+
+ _pickle.Pickler.dump
+
+ self: PicklerObject
+ obj: object
+ /
+
+ Write a pickled representation of the given object to the open file.
+ [clinic start generated code]*/
+
+
+How to use the "defining class" converter
+-----------------------------------------
+
+Argument Clinic facilitates gaining access to the defining class of a method.
+This is useful for :ref:`heap type ` methods that need to fetch
+module level state. Use :c:func:`PyType_FromModuleAndSpec` to associate a new
+heap type with a module. You can now use :c:func:`PyType_GetModuleState` on
+the defining class to fetch the module state, for example from a module method.
+
+Example from :cpy-file:`Modules/zlibmodule.c`.
+First, ``defining_class`` is added to the clinic input::
+
+ /*[clinic input]
+ zlib.Compress.compress
+
+ cls: defining_class
+ data: Py_buffer
+ Binary data to be compressed.
+ /
+
+
+After running the Argument Clinic tool, the following function signature is
+generated::
+
+ /*[clinic start generated code]*/
+ static PyObject *
+ zlib_Compress_compress_impl(compobject *self, PyTypeObject *cls,
+ Py_buffer *data)
+ /*[clinic end generated code: output=6731b3f0ff357ca6 input=04d00f65ab01d260]*/
+
+
+The following code can now use ``PyType_GetModuleState(cls)`` to fetch the
+module state::
+
+ zlibstate *state = PyType_GetModuleState(cls);
+
+
+Each method may only have one argument using this converter, and it must appear
+after ``self``, or, if ``self`` is not used, as the first argument. The argument
+will be of type ``PyTypeObject *``. The argument will not appear in the
+:py:attr:`!__text_signature__`.
+
+The ``defining_class`` converter is not compatible with :py:meth:`!__init__`
+and :py:meth:`!__new__` methods, which cannot use the :c:macro:`METH_METHOD`
+convention.
+
+It is not possible to use ``defining_class`` with slot methods. In order to
+fetch the module state from such methods, use :c:func:`PyType_GetModuleByDef`
+to look up the module and then :c:func:`PyModule_GetState` to fetch the module
+state. Example from the ``setattro`` slot method in
+:cpy-file:`Modules/_threadmodule.c`::
+
+ static int
+ local_setattro(localobject *self, PyObject *name, PyObject *v)
+ {
+ PyObject *module = PyType_GetModuleByDef(Py_TYPE(self), &thread_module);
+ thread_module_state *state = get_thread_state(module);
+ ...
+ }
+
+
+See also :pep:`573`.
+
+
+.. _clinic-howto-custom-converter:
+
+How to write a custom converter
+-------------------------------
+
+A converter is a Python class that inherits from :py:class:`CConverter`.
+The main purpose of a custom converter, is for parameters parsed with
+the ``O&`` format unit --- parsing such a parameter means calling
+a :c:func:`PyArg_ParseTuple` "converter function".
+
+Your converter class should be named :samp:`{ConverterName}_converter`.
+By following this convention, your converter class will be automatically
+registered with Argument Clinic, with its *converter name* being the name of
+your converter class with the ``_converter`` suffix stripped off.
+
+Instead of subclassing :py:meth:`!CConverter.__init__`,
+write a :py:meth:`!converter_init` method.
+:py:meth:`!converter_init` always accepts a *self* parameter.
+After *self*, all additional parameters **must** be keyword-only.
+Any arguments passed to the converter in Argument Clinic
+will be passed along to your :py:meth:`!converter_init` method.
+See :py:class:`CConverter` for a list of members you may wish to specify in
+your subclass.
+
+Here's the simplest example of a custom converter, from :cpy-file:`Modules/zlibmodule.c`::
+
+ /*[python input]
+
+ class ssize_t_converter(CConverter):
+ type = 'Py_ssize_t'
+ converter = 'ssize_t_converter'
+
+ [python start generated code]*/
+ /*[python end generated code: output=da39a3ee5e6b4b0d input=35521e4e733823c7]*/
+
+This block adds a converter named ``ssize_t`` to Argument Clinic.
+Parameters declared as ``ssize_t`` will be declared with type :c:type:`Py_ssize_t`,
+and will be parsed by the ``'O&'`` format unit,
+which will call the :c:func:`!ssize_t_converter` converter C function.
+``ssize_t`` variables automatically support default values.
+
+More sophisticated custom converters can insert custom C code to
+handle initialization and cleanup.
+You can see more examples of custom converters in the CPython
+source tree; grep the C files for the string ``CConverter``.
+
+
+How to write a custom return converter
+--------------------------------------
+
+Writing a custom return converter is much like writing
+a custom converter. Except it's somewhat simpler, because return
+converters are themselves much simpler.
+
+Return converters must subclass :py:class:`!CReturnConverter`.
+There are no examples yet of custom return converters,
+because they are not widely used yet. If you wish to
+write your own return converter, please read :cpy-file:`Tools/clinic/clinic.py`,
+specifically the implementation of :py:class:`!CReturnConverter` and
+all its subclasses.
+
+
+How to convert ``METH_O`` and ``METH_NOARGS`` functions
+-------------------------------------------------------
+
+To convert a function using :c:macro:`METH_O`, make sure the function's
+single argument is using the ``object`` converter, and mark the
+arguments as positional-only::
+
+ /*[clinic input]
+ meth_o_sample
+
+ argument: object
+ /
+ [clinic start generated code]*/
+
+
+To convert a function using :c:macro:`METH_NOARGS`, just don't specify
+any arguments.
+
+You can still use a self converter, a return converter, and specify
+a *type* argument to the object converter for :c:macro:`METH_O`.
+
+
+How to convert ``*args`` parameters (starargs / var-positional)
+---------------------------------------------------------------
+
+There are two converters suitable for ``*args``: *array* and *tuple*.
+
+Using the *array* converter will provide the implementation function with
+a C array *args* of type of :c:type:`PyObject * ` and the number
+of items in the array as :c:type:`Py_ssize_t` *args_length*.
+For example::
+
+ /*[clinic input]
+ var_positional_sample
+
+ spam: int
+ *args: array
+ [clinic start generated code]*/
+
+Using the *tuple* converter will provide the implementation function with
+a standard :c:type:`PyTupleObject`.
+For example::
+
+ /*[clinic input]
+ var_positional_sample
+
+ spam: int
+ *args: tuple
+ [clinic start generated code]*/
+
+.. versionadded:: 3.11
+
+
+How to convert ``tp_new`` and ``tp_init`` functions
+---------------------------------------------------
+
+You can convert :c:member:`~PyTypeObject.tp_new` and
+:c:member:`~PyTypeObject.tp_init` functions.
+Just name them ``__new__`` or ``__init__`` as appropriate. Notes:
+
+* The function name generated for ``__new__`` doesn't end in ``__new__``
+ like it would by default. It's just the name of the class, converted
+ into a valid C identifier.
+
+* No :c:type:`PyMethodDef` ``#define`` is generated for these functions.
+
+* ``__init__`` functions return ``int``, not ``PyObject *``.
+
+* Use the docstring as the class docstring.
+
+* Although ``__new__`` and ``__init__`` functions must always
+ accept both the ``args`` and ``kwargs`` objects, when converting
+ you may specify any signature for these functions that you like.
+ (If your function doesn't support keywords, the parsing function
+ generated will throw an exception if it receives any.)
+
+
+How to change and redirect Clinic's output
+------------------------------------------
+
+It can be inconvenient to have Clinic's output interspersed with
+your conventional hand-edited C code. Luckily, Clinic is configurable:
+you can buffer up its output for printing later (or earlier!), or write
+its output to a separate file. You can also add a prefix or suffix to
+every line of Clinic's generated output.
+
+While changing Clinic's output in this manner can be a boon to readability,
+it may result in Clinic code using types before they are defined, or
+your code attempting to use Clinic-generated code before it is defined.
+These problems can be easily solved by rearranging the declarations in your file,
+or moving where Clinic's generated code goes. (This is why the default behavior
+of Clinic is to output everything into the current block; while many people
+consider this hampers readability, it will never require rearranging your
+code to fix definition-before-use problems.)
+
+Let's start with defining some terminology:
+
+*field*
+ A field, in this context, is a subsection of Clinic's output.
+ For example, the ``#define`` for the :c:type:`PyMethodDef` structure
+ is a field, called ``methoddef_define``. Clinic has seven
+ different fields it can output per function definition:
+
+ .. code-block:: none
+
+ docstring_prototype
+ docstring_definition
+ methoddef_define
+ impl_prototype
+ parser_prototype
+ parser_definition
+ impl_definition
+
+ All the names are of the form ``"_"``,
+ where ``""`` is the semantic object represented (the parsing function,
+ the impl function, the docstring, or the methoddef structure) and ``""``
+ represents what kind of statement the field is. Field names that end in
+ ``"_prototype"``
+ represent forward declarations of that thing, without the actual body/data
+ of the thing; field names that end in ``"_definition"`` represent the actual
+ definition of the thing, with the body/data of the thing. (``"methoddef"``
+ is special, it's the only one that ends with ``"_define"``, representing that
+ it's a preprocessor #define.)
+
+*destination*
+ A destination is a place Clinic can write output to. There are
+ five built-in destinations:
+
+ ``block``
+ The default destination: printed in the output section of
+ the current Clinic block.
+
+ ``buffer``
+ A text buffer where you can save text for later. Text sent
+ here is appended to the end of any existing text. It's an
+ error to have any text left in the buffer when Clinic finishes
+ processing a file.
+
+ ``file``
+ A separate "clinic file" that will be created automatically by Clinic.
+ The filename chosen for the file is ``{basename}.clinic{extension}``,
+ where ``basename`` and ``extension`` were assigned the output
+ from ``os.path.splitext()`` run on the current file. (Example:
+ the ``file`` destination for :file:`_pickle.c` would be written to
+ :file:`_pickle.clinic.c`.)
+
+ **Important: When using a** ``file`` **destination, you**
+ *must check in* **the generated file!**
+
+ ``two-pass``
+ A buffer like ``buffer``. However, a two-pass buffer can only
+ be dumped once, and it prints out all text sent to it during
+ all processing, even from Clinic blocks *after* the dumping point.
+
+ ``suppress``
+ The text is suppressed—thrown away.
+
+
+Clinic defines five new directives that let you reconfigure its output.
+
+The first new directive is ``dump``:
+
+.. code-block:: none
+
+ dump
+
+This dumps the current contents of the named destination into the output of
+the current block, and empties it. This only works with ``buffer`` and
+``two-pass`` destinations.
+
+The second new directive is ``output``. The most basic form of ``output``
+is like this:
+
+.. code-block:: none
+
+ output
+
+This tells Clinic to output *field* to *destination*. ``output`` also
+supports a special meta-destination, called ``everything``, which tells
+Clinic to output *all* fields to that *destination*.
+
+``output`` has a number of other functions:
+
+.. code-block:: none
+
+ output push
+ output pop
+ output preset
+
+
+``output push`` and ``output pop`` allow you to push and pop
+configurations on an internal configuration stack, so that you
+can temporarily modify the output configuration, then easily restore
+the previous configuration. Simply push before your change to save
+the current configuration, then pop when you wish to restore the
+previous configuration.
+
+``output preset`` sets Clinic's output to one of several built-in
+preset configurations, as follows:
+
+``block``
+ Clinic's original starting configuration. Writes everything
+ immediately after the input block.
+
+ Suppress the ``parser_prototype``
+ and ``docstring_prototype``, write everything else to ``block``.
+
+``file``
+ Designed to write everything to the "clinic file" that it can.
+ You then ``#include`` this file near the top of your file.
+ You may need to rearrange your file to make this work, though
+ usually this just means creating forward declarations for various
+ ``typedef`` and ``PyTypeObject`` definitions.
+
+ Suppress the ``parser_prototype``
+ and ``docstring_prototype``, write the ``impl_definition`` to
+ ``block``, and write everything else to ``file``.
+
+ The default filename is ``"{dirname}/clinic/{basename}.h"``.
+
+``buffer``
+ Save up most of the output from Clinic, to be written into
+ your file near the end. For Python files implementing modules
+ or builtin types, it's recommended that you dump the buffer
+ just above the static structures for your module or
+ builtin type; these are normally very near the end. Using
+ ``buffer`` may require even more editing than ``file``, if
+ your file has static ``PyMethodDef`` arrays defined in the
+ middle of the file.
+
+ Suppress the ``parser_prototype``, ``impl_prototype``,
+ and ``docstring_prototype``, write the ``impl_definition`` to
+ ``block``, and write everything else to ``file``.
+
+``two-pass``
+ Similar to the ``buffer`` preset, but writes forward declarations to
+ the ``two-pass`` buffer, and definitions to the ``buffer``.
+ This is similar to the ``buffer`` preset, but may require
+ less editing than ``buffer``. Dump the ``two-pass`` buffer
+ near the top of your file, and dump the ``buffer`` near
+ the end just like you would when using the ``buffer`` preset.
+
+ Suppresses the ``impl_prototype``, write the ``impl_definition``
+ to ``block``, write ``docstring_prototype``, ``methoddef_define``,
+ and ``parser_prototype`` to ``two-pass``, write everything else
+ to ``buffer``.
+
+``partial-buffer``
+ Similar to the ``buffer`` preset, but writes more things to ``block``,
+ only writing the really big chunks of generated code to ``buffer``.
+ This avoids the definition-before-use problem of ``buffer`` completely,
+ at the small cost of having slightly more stuff in the block's output.
+ Dump the ``buffer`` near the end, just like you would when using
+ the ``buffer`` preset.
+
+ Suppresses the ``impl_prototype``, write the ``docstring_definition``
+ and ``parser_definition`` to ``buffer``, write everything else to ``block``.
+
+The third new directive is ``destination``:
+
+.. code-block:: none
+
+ destination