Skip to content

Commit

Permalink
Merge branch 'main' into pythongh-72904-fnmatch-seps
Browse files Browse the repository at this point in the history
  • Loading branch information
barneygale committed Oct 28, 2023
2 parents 5d4062c + 2655369 commit 1ad624d
Show file tree
Hide file tree
Showing 1,395 changed files with 35,715 additions and 20,298 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ indent_style = space
[*.{py,c,cpp,h}]
indent_size = 4

[*.rst]
indent_size = 3

[*.yml]
indent_size = 2
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ body:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- "CPython main branch"
validations:
required: true
Expand Down
77 changes: 70 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ on:
- '3.10'
- '3.9'
- '3.8'
- '3.7'
pull_request:
branches:
- 'main'
Expand All @@ -22,7 +21,6 @@ on:
- '3.10'
- '3.9'
- '3.8'
- '3.7'

permissions:
contents: read
Expand All @@ -40,6 +38,7 @@ jobs:
run-docs: ${{ steps.docs-changes.outputs.run-docs || false }}
run_tests: ${{ steps.check.outputs.run_tests }}
run_hypothesis: ${{ steps.check.outputs.run_hypothesis }}
run_cifuzz: ${{ steps.check.outputs.run_cifuzz }}
config_hash: ${{ steps.config_hash.outputs.hash }}
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -76,6 +75,21 @@ jobs:
echo "Run hypothesis tests"
echo "run_hypothesis=true" >> $GITHUB_OUTPUT
fi
# oss-fuzz maintains a configuration for fuzzing the main branch of
# CPython, so CIFuzz should be run only for code that is likely to be
# merged into the main branch; compatibility with older branches may
# be broken.
FUZZ_RELEVANT_FILES='(\.c$|\.h$|\.cpp$|^configure$|^\.github/workflows/build\.yml$|^Modules/_xxtestfuzz)'
if [ "$GITHUB_BASE_REF" = "main" ] && [ "$(git diff --name-only origin/$GITHUB_BASE_REF.. | grep -qE $FUZZ_RELEVANT_FILES; echo $?)" -eq 0 ]; then
# The tests are pretty slow so they are executed only for PRs
# changing relevant files.
echo "Run CIFuzz tests"
echo "run_cifuzz=true" >> $GITHUB_OUTPUT
else
echo "Branch too old for CIFuzz tests; or no C files were changed"
echo "run_cifuzz=false" >> $GITHUB_OUTPUT
fi
- name: Compute hash for config cache key
id: config_hash
run: |
Expand Down Expand Up @@ -112,14 +126,14 @@ jobs:
if: needs.check_source.outputs.run_tests == 'true'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Restore config.cache
uses: actions/cache@v3
with:
path: config.cache
key: ${{ github.job }}-${{ runner.os }}-${{ needs.check_source.outputs.config_hash }}
- uses: actions/setup-python@v4
with:
python-version: '3.x'
key: ${{ github.job }}-${{ runner.os }}-${{ needs.check_source.outputs.config_hash }}-${{ env.pythonLocation }}
- name: Install Dependencies
run: sudo ./.github/workflows/posix-deps-apt.sh
- name: Add ccache to PATH
Expand Down Expand Up @@ -264,7 +278,7 @@ jobs:
- uses: actions/checkout@v4
- name: Register gcc problem matcher
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
- name: Install Dependencies
- name: Install dependencies
run: sudo ./.github/workflows/posix-deps-apt.sh
- name: Configure OpenSSL env vars
run: |
Expand Down Expand Up @@ -534,6 +548,46 @@ jobs:
- name: Tests
run: xvfb-run make test

# CIFuzz job based on https://google.github.io/oss-fuzz/getting-started/continuous-integration/
cifuzz:
name: CIFuzz
runs-on: ubuntu-latest
timeout-minutes: 60
needs: check_source
if: needs.check_source.outputs.run_cifuzz == 'true'
permissions:
security-events: write
strategy:
fail-fast: false
matrix:
sanitizer: [address, undefined, memory]
steps:
- name: Build fuzzers (${{ matrix.sanitizer }})
id: build
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: cpython3
sanitizer: ${{ matrix.sanitizer }}
- name: Run fuzzers (${{ matrix.sanitizer }})
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
fuzz-seconds: 600
oss-fuzz-project-name: cpython3
output-sarif: true
sanitizer: ${{ matrix.sanitizer }}
- name: Upload crash
uses: actions/upload-artifact@v3
if: failure() && steps.build.outcome == 'success'
with:
name: ${{ matrix.sanitizer }}-artifacts
path: ./out/artifacts
- name: Upload SARIF
if: always() && steps.build.outcome == 'success'
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: cifuzz-sarif/results.sarif
checkout_path: cifuzz-sarif

all-required-green: # This job does nothing and is only used for the branch protection
name: All required checks pass
if: always()
Expand All @@ -550,6 +604,7 @@ jobs:
- build_ubuntu_ssltests
- test_hypothesis
- build_asan
- cifuzz

runs-on: ubuntu-latest

Expand All @@ -562,6 +617,7 @@ jobs:
build_ubuntu_ssltests,
build_win32,
build_win_arm64,
cifuzz,
test_hypothesis,
allowed-skips: >-
${{
Expand All @@ -585,6 +641,13 @@ jobs:
'
|| ''
}}
${{
!fromJSON(needs.check_source.outputs.run_cifuzz)
&& '
cifuzz,
'
|| ''
}}
${{
!fromJSON(needs.check_source.outputs.run_hypothesis)
&& '
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ permissions:

env:
FORCE_COLOR: 1
RUFF_FORMAT: github
RUFF_OUTPUT_FORMAT: github

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ gmon.out
.coverage
.mypy_cache/
.pytest_cache/
.ruff_cache/
.DS_Store

*.exe
Expand Down
18 changes: 13 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.288
rev: v0.1.2
hooks:
- id: ruff
name: Run Ruff on Lib/test/
args: [--exit-non-zero-on-fix]
files: ^Lib/test/
- id: ruff
name: Run Ruff on Argument Clinic
args: [--exit-non-zero-on-fix, --config=Tools/clinic/.ruff.toml]
files: ^Tools/clinic/|Lib/test/test_clinic.py

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-toml
exclude: ^Lib/test/test_tomllib/
Expand All @@ -17,12 +21,16 @@ repos:
types: [python]
exclude: Lib/test/tokenizedata/coding20731.py
- id: trailing-whitespace
types_or: [c, python, rst]
types_or: [c, inc, python, rst]

- repo: https://github.com/sphinx-contrib/sphinx-lint
rev: v0.6.8
rev: v0.8.1
hooks:
- id: sphinx-lint
args: [--enable=default-role]
files: ^Doc/|^Misc/NEWS.d/next/
types: [rst]

- repo: meta
hooks:
- id: check-hooks-apply
- id: check-useless-excludes
1 change: 0 additions & 1 deletion Doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
PYTHON = python3
VENVDIR = ./venv
SPHINXBUILD = PATH=$(VENVDIR)/bin:$$PATH sphinx-build
SPHINXLINT = PATH=$(VENVDIR)/bin:$$PATH sphinx-lint
BLURB = PATH=$(VENVDIR)/bin:$$PATH blurb
JOBS = auto
PAPER =
Expand Down
9 changes: 7 additions & 2 deletions Doc/c-api/arg.rst
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,10 @@ API Functions
.. c:function:: int PyArg_ParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, char *keywords[], ...)
Parse the parameters of a function that takes both positional and keyword
parameters into local variables. The *keywords* argument is a
``NULL``-terminated array of keyword parameter names. Empty names denote
parameters into local variables.
The *keywords* argument is a ``NULL``-terminated array of keyword parameter
names specified as null-terminated ASCII or UTF-8 encoded C strings.
Empty names denote
:ref:`positional-only parameters <positional-only_parameter>`.
Returns true on success; on failure, it returns false and raises the
appropriate exception.
Expand All @@ -426,6 +428,9 @@ API Functions
Added support for :ref:`positional-only parameters
<positional-only_parameter>`.
.. versionchanged:: 3.13
Added support for non-ASCII keyword parameter names.
.. c:function:: int PyArg_VaParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, char *keywords[], va_list vargs)
Expand Down
2 changes: 2 additions & 0 deletions Doc/c-api/call.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ This is a pointer to a function with the following signature:
Doing so will allow callables such as bound methods to make their onward
calls (which include a prepended *self* argument) very efficiently.

.. versionadded:: 3.8

To call an object that implements vectorcall, use a :ref:`call API <capi-call>`
function as with any other callable.
:c:func:`PyObject_Vectorcall` will usually be most efficient.
Expand Down
13 changes: 13 additions & 0 deletions Doc/c-api/init.rst
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,19 @@ code, or when embedding the Python interpreter:
When the current thread state is ``NULL``, this issues a fatal error (so that
the caller needn't check for ``NULL``).
See also :c:func:`PyThreadState_GetUnchecked`.
.. c:function:: PyThreadState* PyThreadState_GetUnchecked()
Similar to :c:func:`PyThreadState_Get`, but don't kill the process with a
fatal error if it is NULL. The caller is responsible to check if the result
is NULL.
.. versionadded:: 3.13
In Python 3.5 to 3.12, the function was private and known as
``_PyThreadState_UncheckedGet()``.
.. c:function:: PyThreadState* PyThreadState_Swap(PyThreadState *tstate)
Expand Down
34 changes: 31 additions & 3 deletions Doc/c-api/init_config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ PyConfig
Set to ``1`` by the :envvar:`PYTHONDUMPREFS` environment variable.
Need a special build of Python with the ``Py_TRACE_REFS`` macro defined:
Needs a special build of Python with the ``Py_TRACE_REFS`` macro defined:
see the :option:`configure --with-trace-refs option <--with-trace-refs>`.
Default: ``0``.
Expand Down Expand Up @@ -878,6 +878,19 @@ PyConfig
.. versionadded:: 3.12
.. c:member:: int cpu_count
If the value of :c:member:`~PyConfig.cpu_count` is not ``-1`` then it will
override the return values of :func:`os.cpu_count`,
:func:`os.process_cpu_count`, and :func:`multiprocessing.cpu_count`.
Configured by the :samp:`-X cpu_count={n|default}` command line
flag or the :envvar:`PYTHON_CPU_COUNT` environment variable.
Default: ``-1``.
.. versionadded:: 3.13
.. c:member:: int isolated
If greater than ``0``, enable isolated mode:
Expand Down Expand Up @@ -1035,7 +1048,7 @@ PyConfig
Incremented by the :option:`-d` command line option. Set to the
:envvar:`PYTHONDEBUG` environment variable value.
Need a :ref:`debug build of Python <debug-build>` (the ``Py_DEBUG`` macro
Needs a :ref:`debug build of Python <debug-build>` (the ``Py_DEBUG`` macro
must be defined).
Default: ``0``.
Expand Down Expand Up @@ -1087,6 +1100,7 @@ PyConfig
Set by the :option:`-X pycache_prefix=PATH <-X>` command line option and
the :envvar:`PYTHONPYCACHEPREFIX` environment variable.
The command-line option takes precedence.
If ``NULL``, :data:`sys.pycache_prefix` is set to ``None``.
Expand Down Expand Up @@ -1130,13 +1144,27 @@ PyConfig
Default: ``NULL``.
.. c:member:: wchar_t* run_presite
``package.module`` path to module that should be imported before
``site.py`` is run.
Set by the :option:`-X presite=package.module <-X>` command-line
option and the :envvar:`PYTHON_PRESITE` environment variable.
The command-line option takes precedence.
Needs a :ref:`debug build of Python <debug-build>` (the ``Py_DEBUG`` macro
must be defined).
Default: ``NULL``.
.. c:member:: int show_ref_count
Show total reference count at exit (excluding immortal objects)?
Set to ``1`` by :option:`-X showrefcount <-X>` command line option.
Need a :ref:`debug build of Python <debug-build>` (the ``Py_REF_DEBUG``
Needs a :ref:`debug build of Python <debug-build>` (the ``Py_REF_DEBUG``
macro must be defined).
Default: ``0``.
Expand Down
Loading

0 comments on commit 1ad624d

Please sign in to comment.