Commit graph

125357 commits

Author SHA1 Message Date
Neil Schemenauer
cdcacec79f
gh-129201: Use prefetch in GC mark alive phase. (gh-129203)
For the free-threaded version of the cyclic GC, restructure the "mark alive" phase to use software prefetch instructions.  This gives a speedup in most cases when the number of objects is large enough.  The prefetching is enabled conditionally based on the number of long-lived objects the GC finds.
2025-02-05 11:38:30 -08:00
Cody Maloney
5fb019fc29
gh-129559: Add bytearray.resize() (GH-129560)
Add bytearray.resize() which wraps PyByteArray_Resize.

Make negative size passed to resize exception/error rather than crash in optimized builds.
2025-02-05 11:33:17 -08:00
Adam Turner
7d9a22f509
Convert change detection to a Python script (#129627)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
2025-02-05 16:39:42 +00:00
Petr Viktorin
58a4357e29
gh-127833: Docs: Add a grammar-snippet directive & replace productionlist (GH-127835)
As a first step toward aligning the grammar documentation with Python's actual
grammar, this overrides the ReST `productionlist` directive to:
- use `:` instead of the `::=` symbol
- add syntax highlighting for strings (using a Pygments highlighting class)

All links and link targets should be preserved. (Unfortunately, this reaches
into some Sphinx internals; I don't see a better way to do exactly what
Sphinx does.)

This also adds a new directive, `grammar-snippet`, which formats the snippet
almost exactly like what's in the source, modulo syntax highlighting and
keeping the backtick character to mark links to other rules.
This will allow formatting the snippets as in the grammar file
(file:///home/encukou/dev/cpython/Doc/build/html/reference/grammar.html).

The new directive is applied to two simple rules in toplevel_components.rst

---------

Co-authored-by: Blaise Pabon <blaise@gmail.com>
Co-authored-by: William Ferreira <wqferr@gmail.com>
Co-authored-by: bswck <bartoszpiotrslawecki@gmail.com>
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
2025-02-05 16:12:23 +01:00
Victor Stinner
e5c3b7e349
gh-129354: Cleanup test_coroutines (#129684)
Remove unused variables.
2025-02-05 11:43:46 +00:00
Victor Stinner
a25042e6d2
gh-129354: Use PyErr_FormatUnraisable() function (#129523)
Replace PyErr_WriteUnraisable() with PyErr_FormatUnraisable().

Update tests:

* test_coroutines
* test_exceptions
* test_generators
* test_struct
2025-02-05 10:31:59 +00:00
Victor Stinner
dc804ffb2f
gh-128911: Use PyImport_ImportModuleAttr() function (#129657)
* Replace PyImport_ImportModule() + PyObject_GetAttr() with
  PyImport_ImportModuleAttr().
* Replace PyImport_ImportModule() + PyObject_GetAttrString() with
  PyImport_ImportModuleAttrString().
2025-02-05 11:03:58 +01:00
Kumar Aditya
fb5d1c9236
gh-129643: fix thread safety of PyList_SetItem (#129644) 2025-02-05 13:08:02 +05:30
Tomas R.
e41ec8e18b
gh-104400: pygettext: Prepare to replace TokenEater with a NodeVisitor (#129672)
* Update the module docstring
* Move ``key_for`` inside the class
* Move ``write_pot_file`` outside the class
2025-02-04 22:59:23 +00:00
Sam Gross
e5f10a7414
gh-127933: Add option to run regression tests in parallel (gh-128003)
This adds a new command line argument, `--parallel-threads` to the
regression test runner to allow it to run individual tests in multiple
threads in parallel in order to find multithreading bugs.

Some tests pass when run with `--parallel-threads`, but there's still
more work before the entire suite passes.
2025-02-04 17:44:59 -05:00
neonene
285c1c4e95
gh-129660: Do not use test_embed in PGO profile builds (#129661) 2025-02-04 20:33:07 +01:00
Serhiy Storchaka
f61afca262
gh-129646: Update the locale alias mapping (#129647)
* gh-129646: Update the locale alias mapping

* Add a NEWS file.
2025-02-04 16:22:05 +01:00
Victor Stinner
14489c1bb4
gh-129354: Use PyErr_FormatUnraisable() function (#129656)
Replace PyErr_WriteUnraisable() with PyErr_FormatUnraisable().
2025-02-04 16:21:10 +01:00
Serhiy Storchaka
979d766209
gh-128772: Fix pydoc for methods with __module__ is None (GH-129177) 2025-02-04 16:25:49 +02:00
Serhiy Storchaka
8b5c8508c7
gh-129350: Make tests for glob with trailing slash more strict (GH-129376)
Test that the trailing pathname separator is preserved.

Multiple trailing pathname separators are only preserved if the pattern
does not contain metacharacters, otherwise only one trailing pathname
separator is preserved. This is rather an implementation detail.
2025-02-04 16:24:22 +02:00
Serhiy Storchaka
078ab828b9
Use roles :data: and :const: for referencing module variables (GH-129507) 2025-02-04 16:16:41 +02:00
Mark Shannon
96ff4c2486
GH-128682: Mark two more macros as escaping. (GH-129645)
Expand out SETLOCAL so that code generator can see the decref. Mark Py_CLEAR as escaping
2025-02-04 14:00:51 +00:00
Mark Shannon
2effea4dab
GH-128682: Spill the stack pointer in labels, as well as instructions (GH-129618) 2025-02-04 12:18:31 +00:00
Yan Yanchii
d3c54f3788
gh-126835: Fix reference leak in Python/flowgrapc.::optimize_if_const_subscr (#129634) 2025-02-04 10:38:06 +00:00
Yan Yanchii
0664c1af9b
gh-126835: Move constant subscript folding to CFG (#129568)
Move folding of constant subscription from AST optimizer to CFG.

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2025-02-04 10:10:55 +02:00
donBarbos
bb5c6875d6
gh-111637: Clarify MIME type recognition behavior in mimetypes documentation (GH-129546) 2025-02-03 16:42:12 +00:00
Mark Shannon
75b628adeb
GH-128563: Generate opcode = ... in instructions that need opcode (GH-129608)
* Remove support for GO_TO_INSTRUCTION
2025-02-03 15:09:21 +00:00
Mark Shannon
808071b994
GH-128682: Make PyStackRef_CLOSE escaping. (GH-129404) 2025-02-03 12:41:32 +00:00
Victor Stinner
218f205f20
gh-129354: Use PyErr_FormatUnraisable() function (#129524)
Replace PyErr_WriteUnraisable() with PyErr_FormatUnraisable().

Update test_sqlite3 tests.

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2025-02-03 12:10:18 +00:00
Victor Stinner
04264a286e
gh-101944: Clarify PyModule_AddObjectRef() documentation (#129433) 2025-02-03 12:55:22 +01:00
Peter Bierma
39b754a359
gh-129407: Clarify that a SystemError isn't always CPython's fault (#129410) 2025-02-03 12:46:13 +01:00
Victor Stinner
632ca56821
gh-129342: Explain how to replace Py_GetProgramName() in C (#129361) 2025-02-03 12:36:41 +01:00
Illia Volochii
a33dcb9e43
gh-81340: Use copy_file_range in shutil.copyfile copy functions (GH-93152)
This allows the underlying file system an opportunity to optimise or avoid the actual copy.
2025-02-03 10:23:27 +00:00
Diego Russo
a29a9c0f38
GH-129231: Group executable JIT code in memory (GH-129232) 2025-02-02 15:19:55 -08:00
Diego Russo
567394517a
GH-128842: Collect JIT memory stats (GH-128941) 2025-02-02 15:17:53 -08:00
Yan Yanchii
e6c76b947b
GH-128872: Remove unused argument from _PyCode_Quicken (GH-128873)
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
2025-02-02 15:09:30 -08:00
Erlend E. Aasland
ecd2f84555
gh-105875: amend sqlite3 docstring wrt. SQLite requirement (#129599) 2025-02-02 23:03:54 +00:00
Victor Stinner
2ad069d906
gh-91417: Remove PySequence_Fast() from the limited C API (#129398)
The function never worked with the limited C API. It was added by
mistake.
2025-02-02 23:17:30 +01:00
Adam Turner
ae4788809d
GH-121970: Extract `misc_news` into a new extension (#129577) 2025-02-02 16:17:02 +00:00
Adam Turner
0612a89ffc
gh-126609: Allow translating the `availability` directive (#129549) 2025-02-02 16:12:01 +00:00
Vojtěch Boček
4e38eeafe2
gh-115514: Fix incomplete writes after close while using ssl in asyncio(#128037)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-02-02 15:11:25 +00:00
Cody Maloney
853a6b7de2
Revert "gh-129005: Align FileIO.readall() allocation (#129458)" (#129572)
This reverts commit f927204f64.
2025-02-02 15:59:15 +01:00
Adam Turner
237f186da4
gh-104400: Remove `fintl.gettext` from pygettext (#129580)
The ``fintl`` module is never installed or tested, meaning that the
fallback identity function is unconditionally used for ``_()``.
This means we can simplify, converting the docstring to a real
docstring, and converting some other strings to f-strings.

We also convert the module to UTF-8, sort imports,
and remove the history comment, which was last updated in 2002.
Consult the git history for a more accurate summary of changes.
2025-02-02 14:30:34 +00:00
Victor Stinner
df4a2f5bd7
gh-129539: Reorganize posixmodule.c header (#129558)
Add sections: Python includes, system includes, etc.

Add a comment explaining why an include is needed.
2025-02-02 09:16:48 +00:00
Gregory P. Smith
e1006ce1de
gh-119461: Restore the testSocket VSOCK skipUnless removed by PR #119465 (#129561)
Restore the skipUnless removed by #119465.

This test can only pass on virtual machines, not actual machines.

actual machines see:

```
    self.cli.connect((cid, VSOCKPORT))
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
OSError: [Errno 19] No such device
```

Reproduced on (Linux) Ubuntu 24.04.1 running 6.8.0-52-generic.
2025-02-01 20:46:56 -08:00
Stan Ulbrych
cf4c4ecc26
gh-126022: Replace TeX quotation marks with `"` in Doc/license.rst (#129535) 2025-02-01 18:49:45 +02:00
Victor Stinner
71ae93374d
gh-93649: Move _testcapi tests to specific files (#129544)
Move many functions from _testcapimodule.c into more specific files
in Modules/_testcapi/.

In moved code:

* Replace get_testerror() with PyExc_AssertionError.
* Replace raiseTestError() with
  PyErr_Format(PyExc_AssertionError, ...).
2025-02-01 13:39:16 +01:00
Kirill Podoprigora
7d0521d5fc
gh-126835: Move optimization of constant sequence creation from codegen to CFG (#129426)
Codegen phase has an optimization that transforms
```
LOAD_CONST x
LOAD_CONST y
LOAD_CONXT z
BUILD_LIST/BUILD_SET (3)
```
->
```
BUILD_LIST/BUILD_SET (0)
LOAD_CONST (x, y, z)
LIST_EXTEND/SET_UPDATE 1
```
This optimization has now been moved to CFG phase to make #128802 work.


Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Co-authored-by: Yan Yanchii <yyanchiy@gmail.com>
2025-02-01 11:39:44 +00:00
Seth Michael Larson
d89a5f6a6e
gh-105704: Disallow square brackets ([ and ]) in domain names for parsed URLs (#129418)
* gh-105704: Disallow square brackets ( and ) in domain names for parsed URLs

* Use Sphinx references

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* Add mismatched bracket test cases, fix news format

* Add more test coverage for ports

---------

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-01-31 09:41:34 -08:00
Mark Shannon
54f74b80ae
GH-128563: Move some labels, to simplify implementing tailcalling interpreter. (GH-129525) 2025-01-31 17:13:20 +00:00
Peter Bierma
9ba281d871
gh-128509: Add sys._is_immortal for identifying immortal objects (#128510)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-01-31 15:27:08 +00:00
Victor Stinner
60a85415ae
gh-93649: Add Modules/_testcapi/function.c file (#129521)
* Move PyFunction C API tests to a new file.
* Add Lib/test/test_capi/test_function.py.
* Move tests from test_capi.test_misc to test_capi.test_function.
2025-01-31 16:02:50 +01:00
Valery Fedorenko
fad36bf382
gh-126108: Fix potential null pointer dereference in PySys_AddWarnOptionUnicode (#126118) 2025-01-31 20:06:30 +05:30
Pablo Galindo Salgado
7eaef74561
gh-129430: Make walking vm regions more efficient in MacOS (#129494) 2025-01-31 14:08:48 +00:00
Victor Stinner
79f85a0bc1
gh-129354: Use PyErr_FormatUnraisable() function (#129518)
Replace PyErr_WriteUnraisable() with PyErr_FormatUnraisable().
2025-01-31 15:06:14 +01:00