Skip to content

Commit f24102e

Browse files
committed
Merge remote-tracking branch 'upstream/main' into gh-116146-initfunc-docs-tests
2 parents 27b9d61 + 7dbc797 commit f24102e

130 files changed

Lines changed: 1910 additions & 590 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/build.yml‎

Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -491,53 +491,6 @@ jobs:
491491
if: fromJSON(needs.build-context.outputs.run-tests)
492492
uses: ./.github/workflows/reusable-test-lazy-imports-all.yml
493493

494-
build-asan:
495-
name: 'Address sanitizer'
496-
runs-on: ${{ matrix.os }}
497-
timeout-minutes: 60
498-
needs: build-context
499-
if: needs.build-context.outputs.run-ubuntu == 'true'
500-
strategy:
501-
fail-fast: false
502-
matrix:
503-
os: [ubuntu-26.04]
504-
env:
505-
OPENSSL_VER: 3.5.9
506-
PYTHONSTRICTEXTENSIONBUILD: 1
507-
ASAN_OPTIONS: detect_leaks=0:allocator_may_return_null=1:handle_segv=0
508-
steps:
509-
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
510-
with:
511-
persist-credentials: false
512-
- name: Runner image version
513-
run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV"
514-
- name: Register gcc problem matcher
515-
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
516-
- name: Install dependencies
517-
run: sudo ./.github/workflows/posix-deps-apt.sh
518-
- name: Configure OpenSSL env vars
519-
run: |
520-
echo "MULTISSL_DIR=${GITHUB_WORKSPACE}/multissl" >> "$GITHUB_ENV"
521-
echo "OPENSSL_DIR=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}" >> "$GITHUB_ENV"
522-
echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> "$GITHUB_ENV"
523-
- name: 'Restore OpenSSL build'
524-
id: cache-openssl
525-
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
526-
with:
527-
path: ./multissl/openssl/${{ env.OPENSSL_VER }}
528-
key: ${{ matrix.os }}-multissl-openssl-${{ env.OPENSSL_VER }}
529-
- name: Install OpenSSL
530-
if: steps.cache-openssl.outputs.cache-hit != 'true'
531-
run: python3 Tools/ssl/multissltests.py --steps=library --base-directory "$MULTISSL_DIR" --openssl "$OPENSSL_VER" --system Linux
532-
- name: Configure CPython
533-
run: ./configure --config-cache --with-address-sanitizer --without-pymalloc --with-openssl="$OPENSSL_DIR"
534-
- name: Build CPython
535-
run: make -j4
536-
- name: Display build info
537-
run: make pythoninfo
538-
- name: Tests
539-
run: xvfb-run make ci
540-
541494
build-san:
542495
# ${{ '' } is a hack to nest jobs under the same sidebar category.
543496
name: Sanitizers${{ '' }} # zizmor: ignore[obfuscation]
@@ -554,6 +507,9 @@ jobs:
554507
sanitizer:
555508
- TSan
556509
include:
510+
- check-name: Address
511+
sanitizer: ASan
512+
free-threading: false
557513
- check-name: Undefined behavior
558514
sanitizer: UBSan
559515
free-threading: false
@@ -667,7 +623,6 @@ jobs:
667623
- build-wasi
668624
- test-hypothesis
669625
- test-lazy-imports-all
670-
- build-asan
671626
- build-san
672627
- cross-build-linux
673628
- cifuzz
@@ -714,7 +669,6 @@ jobs:
714669
build-ubuntu-installed,
715670
build-ubuntu-ssltests,
716671
test-hypothesis,
717-
build-asan,
718672
build-san,
719673
cross-build-linux,
720674
'

‎.github/workflows/reusable-san.yml‎

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ jobs:
4343
# please update the versions in `Tools/pixi-packages/variants.yaml` too.
4444
echo "CC=clang" >> "$GITHUB_ENV"
4545
echo "CXX=clang++" >> "$GITHUB_ENV"
46+
- name: ASan option setup
47+
if: inputs.sanitizer == 'ASan'
48+
run: |
49+
echo "MULTISSL_DIR=${GITHUB_WORKSPACE}/multissl" >> "$GITHUB_ENV"
50+
echo "OPENSSL_DIR=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}" >> "$GITHUB_ENV"
51+
echo "ASAN_OPTIONS=${SAN_LOG_OPTION} detect_leaks=0 allocator_may_return_null=1 handle_segv=0" >> "$GITHUB_ENV"
52+
echo "PYTHONSTRICTEXTENSIONBUILD=1" >> "$GITHUB_ENV"
53+
env:
54+
SAN_LOG_OPTION: log_path=${{ github.workspace }}/san_log
4655
- name: TSan option setup
4756
if: inputs.sanitizer == 'TSan'
4857
run: |
@@ -88,24 +97,27 @@ jobs:
8897
- name: Add ccache to PATH
8998
run: |
9099
echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
91-
- name: 'Restore OpenSSL build (TSan)'
100+
- name: 'Restore OpenSSL build'
92101
id: cache-openssl
93-
if: inputs.sanitizer == 'TSan'
102+
if: inputs.sanitizer == 'TSan' || inputs.sanitizer == 'ASan'
94103
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
95104
with:
96105
path: ./multissl/openssl/${{ env.OPENSSL_VER }}
97-
key: ${{ env.IMAGE_OS_VERSION }}-multissl-openssl-tsan-${{ env.OPENSSL_VER }}
98-
- name: Install OpenSSL (TSan)
106+
key: >-
107+
${{ env.IMAGE_OS_VERSION }}-multissl-openssl-${{
108+
inputs.sanitizer == 'TSan' && 'tsan-' || ''
109+
}}${{ env.OPENSSL_VER }}
110+
- name: Install OpenSSL
99111
if: >-
100-
inputs.sanitizer == 'TSan'
112+
(inputs.sanitizer == 'TSan' || inputs.sanitizer == 'ASan')
101113
&& steps.cache-openssl.outputs.cache-hit != 'true'
102114
run: >-
103115
python3 Tools/ssl/multissltests.py
104116
--steps=library
105117
--base-directory="${MULTISSL_DIR}"
106118
--openssl="${OPENSSL_VER}"
107119
--system=Linux
108-
--tsan
120+
${{ inputs.sanitizer == 'TSan' && '--tsan' || '' }}
109121
# gh-157958: -O2 instead of the pydebug default -Og to avoid a clang 21
110122
# compile-time blowup on some interpreter files.
111123
# (https://github.com/llvm/llvm-project/issues/179695)
@@ -117,14 +129,20 @@ jobs:
117129
--config-cache
118130
OPT="-O2 -g"
119131
${{
120-
inputs.sanitizer == 'TSan'
132+
inputs.sanitizer == 'ASan'
133+
&& '--with-address-sanitizer --without-pymalloc'
134+
|| inputs.sanitizer == 'TSan'
121135
&& '--with-thread-sanitizer'
122136
|| inputs.sanitizer == 'MSan'
123137
&& '--with-memory-sanitizer'
124138
|| '--with-undefined-behavior-sanitizer --with-strict-overflow'
125139
}}
126140
${{ inputs.sanitizer == 'MSan' && '--with-assertions' || '--with-pydebug' }}
127-
${{ inputs.sanitizer == 'TSan' && '--with-openssl="$OPENSSL_DIR" --with-openssl-rpath=auto' || '' }}
141+
${{
142+
(inputs.sanitizer == 'TSan' || inputs.sanitizer == 'ASan')
143+
&& '--with-openssl="$OPENSSL_DIR" --with-openssl-rpath=auto'
144+
|| ''
145+
}}
128146
${{ inputs.free-threading && '--disable-gil' || '' }}
129147
- name: Build CPython
130148
run: make -j4

‎Doc/c-api/function.rst‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ There are a few functions specific to Python functions.
1414
1515
The C structure used for functions.
1616

17+
In the free-threaded build, direct access to mutable fields requires
18+
synchronization if another thread may modify the function. See
19+
:ref:`freethreading-extensions-howto`.
20+
1721

1822
.. c:var:: PyTypeObject PyFunction_Type
1923
@@ -71,6 +75,11 @@ There are a few functions specific to Python functions.
7175
This is normally a :class:`string <str>` containing the module name,
7276
but can be set to any other object by Python code.
7377
78+
In the free-threaded build, if the attribute may be modified concurrently,
79+
convert the borrowed reference to a strong reference with :c:func:`Py_XNewRef`
80+
immediately, before calling any other Python API. The same applies to
81+
:c:func:`PyFunction_GET_MODULE`.
82+
7483
7584
.. c:function:: PyObject* PyFunction_GetDefaults(PyObject *op)
7685

‎Doc/c-api/init_config.rst‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,6 +1439,10 @@ PyConfig
14391439
14401440
See also the :c:member:`~PyConfig.filesystem_errors` member.
14411441
1442+
See also :c:func:`PyUnicode_EncodeFSDefault` and
1443+
:ref:`related functions <capi-filesystem-encoding>`
1444+
for encoding paths at runtime.
1445+
14421446
.. c:member:: wchar_t* filesystem_errors
14431447
14441448
:term:`Filesystem error handler <filesystem encoding and error handler>`:

‎Doc/c-api/interp-lifecycle.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ Process-wide parameters
514514
Return the version of this Python interpreter. This is a string that looks
515515
something like ::
516516
517-
"3.15.0rc2 (3.15.0~rc2-1.fc44.x86_64, Sep 3 2026, 00:00:00) [GCC 16.2.1 20260819 (Red Hat 16.2.1-2)]"
517+
"3.0a5+ (py3k:63103M, May 12 2008, 00:53:55) \n[GCC 4.2.3]"
518518
519519
.. index:: single: version (in module sys)
520520

‎Doc/c-api/reflection.rst‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ Reflection
9696
Return the name of *func* if it is a function, class or instance object, else the
9797
name of *func*\s type.
9898
99+
For a Python function or method, the returned pointer refers to the
100+
function's name and must not be retained across operations that may change
101+
that name. In the free-threaded build, copy the string before detaching
102+
the thread state or executing Python code if the name may be modified
103+
concurrently.
104+
99105
100106
.. c:function:: const char* PyEval_GetFuncDesc(PyObject *func)
101107

‎Doc/c-api/unicode.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,8 @@ system.
812812
used for ``strict``.
813813
814814
815+
.. _capi-filesystem-encoding:
816+
815817
File System Encoding
816818
""""""""""""""""""""
817819

‎Doc/howto/remote_debugging.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ To disable remote debugging support, use any of the following:
1616

1717
* Set the :envvar:`PYTHON_DISABLE_REMOTE_DEBUG` environment variable to ``1`` before
1818
starting the interpreter.
19-
* Use the :option:`-X disable_remote_debug` command-line option.
19+
* Use the :option:`-X disable-remote-debug` command-line option.
2020
* Compile Python with the :option:`--without-remote-debug` build flag.
2121

2222
.. _permission-requirements:
@@ -717,7 +717,7 @@ When to use ``PYTHON_DISABLE_REMOTE_DEBUG``
717717
-------------------------------------------
718718

719719
The environment variable :envvar:`PYTHON_DISABLE_REMOTE_DEBUG` (and the
720-
equivalent :option:`-X disable_remote_debug` flag) allows operators to disable
720+
equivalent :option:`-X disable-remote-debug` flag) allows operators to disable
721721
the in-process side of the protocol as a **defence-in-depth** measure. This
722722
may be useful in hardened or sandboxed deployment environments where no
723723
debugging or profiling of the process is expected and reducing attack surface

‎Doc/library/calendar.rst‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is
169169
the specified width, representing an empty day. The *weekday* parameter
170170
is unused.
171171

172-
.. method:: formatweek(theweek, w=0)
172+
.. method:: formatweek(theweek, width)
173173

174-
Return a single week in a string with no newline. If *w* is provided, it
175-
specifies the width of the date columns, which are centered. Depends
174+
Return a single week in a string with no newline. *width* specifies
175+
the width of the date columns, which are centered. Depends
176176
on the first weekday as specified in the constructor or set by the
177177
:meth:`setfirstweekday` method.
178178

@@ -200,7 +200,7 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is
200200
:meth:`setfirstweekday` method.
201201

202202

203-
.. method:: formatmonthname(theyear, themonth, width=0, withyear=True)
203+
.. method:: formatmonthname(theyear, themonth, width, withyear=True)
204204

205205
Return a string representing the month's name centered within the
206206
specified *width*. If *withyear* is ``True``, include the year in the

‎Doc/library/dbm.rst‎

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ The :meth:`!setdefault` method requires two arguments.
100100

101101
Key and values are always stored as :class:`bytes`. This means that when
102102
strings are used they are implicitly converted to the default encoding before
103-
being stored.
103+
being stored. For detailed information about accepted types, see
104+
:ref:`dbm-key-value-types`.
104105

105106
These objects also support being used in a :keyword:`with` statement, which
106107
will automatically close them when done.
@@ -121,6 +122,47 @@ will automatically close them when done.
121122
:meth:`!clear` methods are now available for all :mod:`!dbm` backends.
122123

123124

125+
.. _dbm-key-value-types:
126+
127+
Key and value types
128+
-------------------
129+
130+
The accepted types for keys and values vary by backend. Keys and values are
131+
handled the same way, except where noted below:
132+
133+
* **Traditional backends:**
134+
135+
* :mod:`dbm.gnu` and :mod:`dbm.ndbm`: Accept :class:`str` and :class:`bytes`
136+
objects.
137+
* :mod:`dbm.dumb`: Accepts :class:`str` and :class:`bytes` objects;
138+
:class:`bytearray` is acceptable as a value, but not as a key.
139+
140+
* **SQLite backend** (:mod:`dbm.sqlite3`): Accepts :class:`str`, :class:`bytes`,
141+
:class:`int`, :class:`float`, :class:`bool`, :class:`bytearray`,
142+
:class:`memoryview`, and :class:`array.array` objects.
143+
144+
**Storage format:**
145+
146+
All keys and values are stored as :class:`bytes` objects in the database.
147+
When retrieving, you'll always get bytes back, regardless of the original
148+
type stored.
149+
150+
**Type conversion examples:**
151+
152+
* ``db['key'] = 'string'`` stored as ``b'string'``
153+
* ``db['key'] = bytearray(b'data')`` stored as ``b'data'``
154+
(:mod:`dbm.dumb` and :mod:`dbm.sqlite3` only)
155+
* ``db['key'] = 42`` stored as ``b'42'`` (:mod:`dbm.sqlite3` only)
156+
* ``db['key'] = 3.14`` stored as ``b'3.14'`` (:mod:`dbm.sqlite3` only)
157+
* ``db['key'] = True`` stored as ``b'1'`` (:mod:`dbm.sqlite3` only)
158+
* ``db['key'] = False`` stored as ``b'0'`` (:mod:`dbm.sqlite3` only)
159+
* ``db['key'] = memoryview(b'data')`` stored as ``b'data'``
160+
(:mod:`dbm.sqlite3` only)
161+
* ``db['key'] = array.array('i', [1, 2, 3])`` stored as bytes (for example, on
162+
little-endian: ``b'\x01\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00'``)
163+
(:mod:`dbm.sqlite3` only)
164+
165+
124166
The following example records some hostnames and a corresponding title, and
125167
then prints out the contents of the database::
126168

@@ -142,8 +184,9 @@ then prints out the contents of the database::
142184
# Often-used methods of the dict interface work too.
143185
print(db.get('python.org', b'not present'))
144186

145-
# Storing a non-string key or value will raise an exception (most
146-
# likely a TypeError).
187+
# Storing a non-string key or value behavior depends on the backend:
188+
# - Traditional backends (ndbm, gnu, dumb) will raise a TypeError
189+
# - The sqlite3 backend accepts it and converts to bytes
147190
db['www.yahoo.com'] = 4
148191

149192
# db is automatically closed when leaving the with statement.

0 commit comments

Comments
 (0)