Commit Graph

120165 Commits

Author SHA1 Message Date
Sam Gross 99854ce170
gh-113688: Split up gcmodule.c (gh-113715)
This splits part of Modules/gcmodule.c of into Python/gc.c, which
now contains the core garbage collection implementation. The Python
module remain in the Modules/gcmodule.c file.
2024-01-05 12:17:16 -08:00
Sam Gross 0b7476080b
gh-112532: Tag mimalloc heaps and pages (#113742)
* gh-112532: Tag mimalloc heaps and pages

Mimalloc pages are data structures that contain contiguous allocations
of the same block size. Note that they are distinct from operating
system pages. Mimalloc pages are contained in segments.

When a thread exits, it abandons any segments and contained pages that
have live allocations. These segments and pages may be later reclaimed
by another thread. To support GC and certain thread-safety guarantees in
free-threaded builds, we want pages to only be reclaimed by the
corresponding heap in the claimant thread. For example, we want pages
containing GC objects to only be claimed by GC heaps.

This allows heaps and pages to be tagged with an integer tag that is
used to ensure that abandoned pages are only claimed by heaps with the
same tag. Heaps can be initialized with a tag (0-15); any page allocated
by that heap copies the corresponding tag.

* Fix conversion warning
2024-01-05 12:08:50 -08:00
Hugo van Kemenade eb53750757
gh-101100: Fix Sphinx warnings in `library/pyclbr.rst` (#113739)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-01-05 19:15:07 +00:00
Zackery Spytz 5e1916ba1b
gh-80532: Do not set ipv6type when cross-compiling (#17956)
Co-authored-by: Xavier de Gaye <xdegaye@gmail.com>
2024-01-05 15:34:25 +00:00
Hugo van Kemenade e56c53334f
gh-101100: Fix Sphinx warnings for 2.6 deprecations and removals (#113725)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2024-01-05 13:31:28 +00:00
Pablo Galindo Salgado 3003fbbf00
gh-113703: Correctly identify incomplete f-strings in the codeop module (#113709) 2024-01-05 12:16:46 +00:00
Mark Shannon 0ae60b66de
GH-113486: Do not emit spurious PY_UNWIND events for optimized calls to classes. (GH-113680) 2024-01-05 09:45:22 +00:00
Alex Waygood ed6ea3ea79
gh-113320: Reduce the number of dangerous `getattr()` calls when constructing protocol classes (#113401)
- Only attempt to figure out whether protocol members are "method members" or not if the class is marked as a runtime protocol. This information is irrelevant for non-runtime protocols; we can safely skip the risky introspection for them.
- Only do the risky getattr() calls in one place (the runtime_checkable class decorator), rather than in three places (_ProtocolMeta.__init__, _ProtocolMeta.__instancecheck__ and _ProtocolMeta.__subclasscheck__). This reduces the number of locations in typing.py where the risky introspection could go wrong.
- For runtime protocols, if determining whether a protocol member is callable or not fails, give a better error message. I think it's reasonable for us to reject runtime protocols that have members which raise strange exceptions when you try to access them. PEP-544 clearly states that all protocol member must be callable for issubclass() calls against the protocol to be valid -- and if a member raises when we try to access it, there's no way for us to figure out whether it's a callable member or not!
2024-01-05 01:01:48 +00:00
Sam Gross fcb3c2a444
gh-112532: Isolate abandoned segments by interpreter (#113717)
* gh-112532: Isolate abandoned segments by interpreter

Mimalloc segments are data structures that contain memory allocations along
with metadata. Each segment is "owned" by a thread. When a thread exits,
it abandons its segments to a global pool to be later reclaimed by other
threads. This changes the pool to be per-interpreter instead of process-wide.

This will be important for when we use mimalloc to find GC objects in the
`--disable-gil` builds. We want heaps to only store Python objects from a
single interpreter. Absent this change, the abandoning and reclaiming process
could break this isolation.

* Add missing '&_mi_abandoned_default' to 'tld_empty'
2024-01-04 22:21:40 +00:00
Barney Gale c2e8298eba
GH-113225: Speed up `pathlib.Path.glob()` (#113226)
Use `os.DirEntry.path` as the string representation of child paths, unless
the parent path is empty, in which case we use the entry `name`.
2024-01-04 20:48:26 +00:00
Guido van Rossum 4681a5271a
gh-113538: Don't error in stream reader protocol callback when task is cancelled (#113690) 2024-01-04 12:20:21 -08:00
wookie184 1600d78e2d
gh-113569: Display calls in Mock.assert_has_calls failure when empty (GH-113573) 2024-01-04 21:11:34 +02:00
Jamie Phan 1ae7ceba29
gh-113696: Docs: Annotate PyObject_CallOneArg and PyObject_CallNoArgs as returning a strong reference (#113697) 2024-01-04 15:05:31 +01:00
Brandt Bucher 35ef8cb259
GH-113689: Fix broken handling of invalid executors (GH-113694) 2024-01-04 11:14:15 +00:00
Filip Łapkiewicz 4c4b08dd2b
gh-52161: Enhance Cmd support for docstrings (#110987)
In `cmd.Cmd.do_help` call `inspect.cleandoc()`,
to clean indentation and remove leading/trailing empty
lines from a dosctring before printing.
2024-01-03 19:37:34 +00:00
Alex Waygood f1f8392432
Document the `co_lines` method on code objects (#113682)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2024-01-03 19:29:24 +00:00
Itamar Oren 178919cf21
gh-113258: Write frozen modules to the build tree on Windows (GH-113303)
This ensures the source directory is not modified at build time, and different builds (e.g. different versions or GIL vs no-GIL) do not have conflicts.
2024-01-03 17:30:20 +00:00
Irit Katriel 7d01fb4808
gh-113603: Compiler no longer tries to maintain the no-empty-block invariant (#113636) 2024-01-03 16:57:48 +00:00
Donghee Na 0c3455a969
gh-111926: Set up basic sementics of weakref API for freethreading (gh-113621)
---------

Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-01-03 13:25:27 +00:00
Hugo van Kemenade fab7ad62ce
gh-101100: Fix Sphinx warnings for removed dead batteries (#113669)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-01-03 13:04:26 +00:00
Rodrigo Girão Serrão 4de468cce1
`functools.partial` docs: Use the more common spelling for "referenceable" (#113675) 2024-01-03 12:50:44 +00:00
Ege Akman ea978c645e
gh-113637: Let c_annotations.py to handle the spacing of Limited/Unstable API & Stable ABI translation strings (#113638) 2024-01-03 13:22:38 +02:00
Mark Shannon dc8df6e840
GH-113595: Don't enter invalid executor (GH-113596) 2024-01-03 11:01:13 +00:00
Itamar Oren 5dc79e3d7f
gh-113628: Fix test_site test with long stdlib paths (#113640) 2024-01-02 17:30:53 -07:00
Brandt Bucher b0fb074d59
GH-113657: Add back missing _SET_IP uops in tier two (GH-113662) 2024-01-02 14:09:57 -08:00
Skip Montanaro bab0758ea4
gh-110824 Temporarily skip test_sysconfig.test_library on macOS framework builds. (GH-113298)
Co-authored-by: Ned Deily <nad@python.org>
2024-01-02 16:29:08 -05:00
Serhiy Storchaka 50b093f5c7
gh-53502: Fix plistlib.dump() for naive datetime with aware_datetime option (GH-113645) 2024-01-02 21:45:36 +02:00
dependabot[bot] fff1e8a50b
build(deps): bump actions/upload-artifact from 3 to 4 (#113614)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-02 18:20:17 +02:00
dependabot[bot] ce7a8eef79
build(deps): bump actions/stale from 8 to 9 (#113611)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-02 18:19:01 +02:00
Christopher Chavez f637b44dd2
gh-111178: Avoid calling functions from incompatible pointer types in _tkinter.c (GH-112893)
Fix undefined behavior warnings (UBSan  -fsanitize=function).
2024-01-02 15:51:32 +01:00
Christopher Chavez a1eea1d032
gh-111178: Avoid calling functions from incompatible pointer types in dictobject.c (#112892)
Fix undefined behavior warnings (UBSan  -fsanitize=function).
2024-01-02 15:32:37 +01:00
Christopher Chavez acf4cf5ca5
gh-111178: Avoid calling functions from incompatible pointer types in descrobject.c (GH-112861)
Fix undefined behavior warnings (UBSan  -fsanitize=function), for example:

Python/generated_cases.c.h:3315:13: runtime error: call to function mappingproxy_dealloc through pointer to incorrect function type 'void (*)(struct _object *)'
descrobject.c:1160: note: mappingproxy_dealloc defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Python/generated_cases.c.h:3315:13 in
2024-01-02 15:03:39 +01:00
Christopher Chavez 5d36a95e64
gh-111178: Avoid calling functions from incompatible pointer types in listobject.c (GH-112820)
Fix undefined behavior warnings (UBSan  -fsanitize=function), for example:

Objects/object.c:674:11: runtime error: call to function list_repr through pointer to incorrect function type 'struct _object *(*)(struct _object *)'
listobject.c:382: note: list_repr defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/object.c:674:11 in
2024-01-02 14:41:32 +01:00
Pablo Galindo Salgado 9ed36d533a
gh-113602: Bail out when the parser tries to override existing errors (#113607)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
2024-01-02 13:00:52 +00:00
John D. McDonald 8ff44f8554
gh-81094: Refer to PEP 318 in compound_statements.rst (#113588)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2024-01-02 10:40:14 +02:00
Hugo van Kemenade 7595380347
gh-101100: Fix Sphinx warnings from removed `~!` references (#113629)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-01-02 00:37:37 -07:00
Donghee Na 3aadb95085
no-issue: Use the official term "free-threading" for GitHub Action (gh-113622) 2024-01-02 09:16:53 +09:00
Neil Schemenauer b2566d89ce
GH-113633: Use module state structure for _testcapi. (GH-113634)
Use module state structure for _testcapi.
2024-01-01 23:04:09 +00:00
Ronald Oussoren 8e4ff5c788
gh-53502: Fixes for tests in gh-113363 (#113627)
* gh-53502: Fixes for tests in gh-113363

* Use 32-bit compatible date in test_dump_naive_datetime_with_aware_datetime_option

* Saving non-aware datetimes will use the old behaviour regardless of the aware_datimetime setting
2024-01-01 21:31:43 +01:00
AN Long b4b2cc1012
gh-53502: add a new option aware_datetime in plistlib to loads or dumps aware datetime. (#113363)
* add options to loads and dumps aware datetime in plistlib
2024-01-01 19:51:24 +01:00
Ronald Oussoren d0b0e3d2ef
gh-113536: Expose `os.waitid` on macOS (#113542)
* gh-113536: Expose `os.waitid` on macOS

This API has been available on macOS for a long time, but was
explicitly excluded due to unspecified problems with the API
in ancient versions of macOS.

* Document that the API is available on macOS starting in Python 3.13
2024-01-01 19:38:29 +01:00
Jeffrey Kintscher 5f3cc90a12
gh-62260: Fix ctypes.Structure subclassing with multiple layers (GH-13374)
The length field of StgDictObject for Structure class contains now
the total number of items in ffi_type_pointer.elements (excluding
the trailing null).

The old behavior of using the number of elements in the parent class can
cause the array to be truncated when it is copied, especially when there
are multiple layers of subclassing.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-01-01 18:24:24 +02:00
dependabot[bot] 4036e48d59
build(deps): bump hypothesis from 6.91.0 to 6.92.2 in /Tools (#113615)
Bumps [hypothesis](https://github.com/HypothesisWorks/hypothesis) from 6.91.0 to 6.92.2.
- [Release notes](https://github.com/HypothesisWorks/hypothesis/releases)
- [Commits](https://github.com/HypothesisWorks/hypothesis/compare/hypothesis-python-6.91.0...hypothesis-python-6.92.2)

---
updated-dependencies:
- dependency-name: hypothesis
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-01 09:42:44 +00:00
dependabot[bot] 9132f4287b
build(deps): bump github/codeql-action from 2 to 3 (#113613)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2 to 3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-01 09:30:30 +00:00
dependabot[bot] 686d65aec1
build(deps): bump actions/setup-python from 4 to 5 (#113612)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-01 09:25:58 +00:00
Parth Doshi 9ce6c01e38
# gh-111700: Fix syntax highlighting for C code in the "What's New In Python 3.12" documentation (#113609)
Fix PEP 684 syntax highlighting in what's new Python 3.12
2024-01-01 10:08:05 +02:00
Irit Katriel 2849cbb53a
gh-101578: [doc] mention that PyErr_GetRaisedException returns NULL when the error indicator is not set (#113369) 2023-12-31 23:16:33 +00:00
Hugo van Kemenade 30a6d79fb8
gh-101100: Fix Sphinx warnings in `library/configparser.rst` (#113598)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-12-31 10:57:33 -07:00
Delgan 471aa75241
Update ConfigParser docs defining valid section name (#110506) 2023-12-30 16:18:06 -07:00
Ronald Oussoren f48a1bcb29
gh-89414: Document that SIGCLD is not available on macOS (#113580)
Document that SIGCLD is not available on macOS
2023-12-30 16:19:47 +01:00