Commit Graph

118950 Commits

Author SHA1 Message Date
Eric Snow fd7e08a6f3
gh-76785: Use Pending Calls When Releasing Cross-Interpreter Data (gh-109556)
This fixes some crashes in the _xxinterpchannels module, due to a race between interpreters.
2023-09-19 15:01:34 -06:00
Victor Stinner 754519a9f8
gh-109580: Skip test_perf_profiler on ASAN build (#109584)
Skip test_perf_profiler if Python is built with ASAN, MSAN or UBSAN
sanitizer. Python does crash randomly in this test on such build.
2023-09-19 19:42:51 +02:00
Sam Gross 9df6712c12
gh-108724: Fix _PySemaphore compile error on WASM (gh-109583)
Some WASM platforms have POSIX semaphores, but not sem_timedwait.
2023-09-19 17:35:11 +00:00
Sam Gross 0c89056fe5
gh-108724: Add PyMutex and _PyParkingLot APIs (gh-109344)
PyMutex is a one byte lock with fast, inlineable lock and unlock functions for the common uncontended case.  The design is based on WebKit's WTF::Lock.

PyMutex is built using the _PyParkingLot APIs, which provides a cross-platform futex-like API (based on WebKit's WTF::ParkingLot).  This internal API will be used for building other synchronization primitives used to implement PEP 703, such as one-time initialization and events.

This also includes tests and a mini benchmark in Tools/lockbench/lockbench.py to compare with the existing PyThread_type_lock.

Uncontended acquisition + release:
* Linux (x86-64): PyMutex: 11 ns, PyThread_type_lock: 44 ns
* macOS (arm64): PyMutex: 13 ns, PyThread_type_lock: 18 ns
* Windows (x86-64): PyMutex: 13 ns, PyThread_type_lock: 38 ns

PR Overview:

The primary purpose of this PR is to implement PyMutex, but there are a number of support pieces (described below).

* PyMutex:  A 1-byte lock that doesn't require memory allocation to initialize and is generally faster than the existing PyThread_type_lock.  The API is internal only for now.
* _PyParking_Lot:  A futex-like API based on the API of the same name in WebKit.  Used to implement PyMutex.
* _PyRawMutex:  A word sized lock used to implement _PyParking_Lot.
* PyEvent:  A one time event.  This was used a bunch in the "nogil" fork and is useful for testing the PyMutex implementation, so I've included it as part of the PR.
* pycore_llist.h:  Defines common operations on doubly-linked list.  Not strictly necessary (could do the list operations manually), but they come up frequently in the "nogil" fork. ( Similar to https://man.freebsd.org/cgi/man.cgi?queue)

---------

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2023-09-19 09:54:29 -06:00
Victor Stinner 0a31ff0050
gh-109496: Skip test_capi.test_decref_freed_object() on ASAN (#109573)
Skip test_decref_freed_object() of test_capi.test_misc if Python is
built with ASAN, MSAN or UBSAN sanitizers.
2023-09-19 14:42:08 +00:00
Victor Stinner 67d9363372
gh-109566: Run GHA and buildbot tests with --fail-rerun (#109567) 2023-09-19 15:50:27 +02:00
Raymond Hettinger f2636d2c45
Misc itertool recipe improvements, mostly docstrings and comments (gh-109555) 2023-09-19 07:39:44 -05:00
Nikita Sobolev 94c95d42a3
gh-109485: Further improve `test_future_stmt` tests (#109486)
Add assertSyntaxError() which run tests with an additional docstring
and without docstring, and checks for the error message.
2023-09-19 14:01:59 +02:00
Victor Stinner 59f32a785f
gh-109435: Add Doc/library/cmdline.rst (#109436)
Document modules providing a command-line interface (CLI).
2023-09-19 13:57:28 +02:00
Jenner afa7b0d743
no-issue: Fix typo TestContentTyopeHeader to TestContentTypeHeader (gh-109069) 2023-09-19 18:50:35 +09:00
Nikita Sobolev f65497fd25
gh-109125: Run mypy on `Tools/wasm` (#109126) 2023-09-18 23:49:26 -06:00
Serhiy Storchaka ed582a2ed9
gh-109469: Silence compiler warnings on string comparisons in _testcapi (GH-109533) 2023-09-19 08:12:29 +03:00
Serhiy Storchaka beb5ec5817
gh-109546: Add more tests for formatting floats and fractions (GH-109548) 2023-09-19 08:09:11 +03:00
Serhiy Storchaka c829975428
Fix error handling in _PySys_UpdateConfig() (GH-109524) 2023-09-18 20:09:59 +03:00
Xuehai Pan 74f315edd0
gh-102757: fix function signature mismatch for `functools.reduce` between code and documentation (#102759) 2023-09-18 10:42:58 -06:00
Victor Stinner 0bb0d88e2d
gh-109496: Detect Py_DECREF() after dealloc in debug mode (#109539)
On a Python built in debug mode, Py_DECREF() now calls
_Py_NegativeRefcount() if the object is a dangling pointer to
deallocated memory: memory filled with 0xDD "dead byte" by the debug
hook on memory allocators. The fix is to check the reference count
*before* checking for _Py_IsImmortal().

Add test_decref_freed_object() to test_capi.test_misc.
2023-09-18 14:59:09 +00:00
Victor Stinner ef659b9616
gh-109508: Fix libregrtest formatting of getcwd() (#109537) 2023-09-18 16:45:48 +02:00
Tian Gao 412f5e85d6
gh-109371: Fix monitoring with instruction events set (gh-109385) 2023-09-18 23:30:08 +09:00
Shantanu 23f9f6f464
gh-108843: fix ast.unparse for f-string with many quotes (#108981) 2023-09-18 14:56:19 +01:00
Nikita Sobolev 4dd47c63a9
gh-108303: Fix and move `badsyntax_pep3120.py` (#109513)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-09-18 14:04:17 +01:00
Hugo van Kemenade dd5d2141ab
gh-109408: Azure Pipelines: test 3.12 branch (#109453) 2023-09-18 15:37:23 +03:00
Hugo van Kemenade 2209d814ca
Docs: getopt is deprecated in Python 3.13 (#109438) 2023-09-18 13:45:59 +03:00
DongWoo Son df8b3a46a7
Fix a typo in c-analyzer (#109213)
Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
Co-authored-by: Dale Collison <92315623+dcollison@users.noreply.github.com>
2023-09-18 00:27:54 -07:00
Anthony Sottile ce5b3e19e6
Fix extraneous backslashes in hashlib docs (#109468) 2023-09-18 00:25:33 -07:00
Alex Waygood 54fbfa8d5e
gh-109413: Improve mypy config for libregrtest (#109518)
Improve the mypy config file for libregrtest
2023-09-17 17:35:51 -07:00
Hugo van Kemenade a75daed7e0
gh-109408: Remove Ubuntu unit tests from Azure Pipelines (#109452) 2023-09-17 11:46:15 -06:00
Serhiy Storchaka add16f1a5e
gh-108511: Add C API functions which do not silently ignore errors (GH-109025)
Add the following functions:

* PyObject_HasAttrWithError()
* PyObject_HasAttrStringWithError()
* PyMapping_HasKeyWithError()
* PyMapping_HasKeyStringWithError()
2023-09-17 14:23:31 +03:00
Nikita Sobolev e57ecf6bbc
gh-108303: Move all certificates to `Lib/test/certdata/` (#109489) 2023-09-16 18:47:18 +02:00
AlberLC 929cc4e4a0
gh-109451: Fix wrong format specifier in logging documentation (GH-109465) 2023-09-16 10:06:04 +01:00
Vinay Sajip a6846d45ff
gh-109414: Add some basic information about venvs in the introduction. (GH-109440)
Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-16 09:49:02 +01:00
partev 0b38ce440b
gh-109474: Update two Unix packaging URLs (#109307)
update packaging URLs

fix a broken URL for fedora RPM packaging guide and fix a URL redirect for Slackware packaging guide.
2023-09-16 10:46:09 +03:00
Brett Cannon e218e5022e
GH-83417: Allow `venv` to add a `.gitignore` file to environments via a new `scm_ignore_file` parameter (GH-108125)
This feature is off by default via code but on by default via the CLI. The `.gitignore` file contains `*` which causes the entire directory to be ignored.

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-09-15 22:38:08 +00:00
Hood Chatham 6b179adb8c
gh-106213: Make Emscripten trampolines work with JSPI (GH-106219)
There is a WIP proposal to enable webassembly stack switching which have been
implemented in v8:

https://github.com/WebAssembly/js-promise-integration

It is not possible to switch stacks that contain JS frames so the Emscripten JS
trampolines that allow calling functions with the wrong number of arguments
don't work in this case. However, the js-promise-integration proposal requires
the [type reflection for Wasm/JS API](https://github.com/WebAssembly/js-types)
proposal, which allows us to actually count the number of arguments a function
expects.

For better compatibility with stack switching, this PR checks if type reflection
is available, and if so we use a switch block to decide the appropriate
signature. If type reflection is unavailable, we should use the current EMJS
trampoline.

We cache the function argument counts since when I didn't cache them performance
was negatively affected.

Co-authored-by: T. Wouters <thomas@python.org>
Co-authored-by: Brett Cannon <brett@python.org>
2023-09-15 15:04:21 -07:00
Gregory P. Smith 59073c9ab8
gh-109096: Deprecate `http.server.CGIHTTPRequestHandler` (#109387)
Deprecate `http.server.CGIHTTPRequestHandler`.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-09-15 14:26:45 -07:00
Michael Droettboom 19f5effc27
GH-109373: Store metadata required for pystats comparison in the JSON (GH-109374) 2023-09-15 13:10:46 -07:00
Egil Martinsson 3d881453d3
gh-109350: Fix outdated captured output in unittest.mock documentation (#109353) 2023-09-15 19:25:16 +01:00
Alex Waygood 92ed7e4df1
gh-109413: Fix some trivial mypy nitpicks in libregrtest (#109454) 2023-09-15 17:01:28 +00:00
Victor Stinner 8ea4ad4d2d
gh-91960: Disable Cirrus CI for now (#109457)
Python is out of free credit and so all jobs are reported as failure.

Rename .cirrus.yml to .cirrus-DISABLED.yml to disable the job.
2023-09-15 16:41:25 +00:00
Guido van Rossum a7a079798d
gh-109287: Desugar inst(X) to op(X); macro(X) = X (#109294)
This makes the internal representation in the code generator simpler: there's a list of ops, and a list of macros, and there's no special-casing needed for ops that aren't macros. (There's now special-casing for ops that are also macros, but that's simpler.)
2023-09-15 08:39:05 -07:00
Nikita Sobolev 47af188593
Add missing `PyDoc_STR` calls (#109393)
In files:

* Modules/_ctypes/cfield.c
* Modules/_struct.c
* Objects/dictobject.c
* Objects/typevarobject.c
* Objects/unionobject.c
2023-09-15 15:10:48 +02:00
Christopher Yeh 5eec58a9e5
Fix date.__repr__() docstring (#109422) 2023-09-15 15:05:19 +02:00
Hugo van Kemenade b434dd7e36
Docs: Superseded modules: list only module names (#109439) 2023-09-15 15:56:23 +03:00
Nikita Sobolev 1ece084be3
gh-109395: Remove skipped macOS builds from Azure Pipelines (#109400) 2023-09-15 11:55:09 +03:00
Nikita Sobolev 82505dc351
gh-108303: Move `test_future` into its own test_future_stmt subdir (#109368) 2023-09-15 09:52:24 +02:00
Hugo van Kemenade fa493900fb
gh-109395: Remove skipped coverage job from Azure Pipelines (#109412) 2023-09-15 08:27:47 +03:00
Victor Stinner 74c72a2fc7
gh-109425: regrtest decodes worker stdout with backslashreplace (#109428)
libregrtest now decodes stdout of test worker processes with the
"backslashreplace" error handler to log corrupted stdout, instead of
failing with an error and not logging the stdout.
2023-09-14 23:37:37 +00:00
buermarc 68a6f21f47
gh-109375: Fix bug where pdb registers an alias without an associated command (#109376) 2023-09-14 22:31:30 +01:00
Victor Stinner e091b9f20f
gh-109396: Fix test_socket.test_hmac_sha1() in FIPS mode (#109423)
Use a longer key: FIPS mode requires at least of at least 112 bits.
The previous key was only 32 bits.
2023-09-14 21:24:11 +00:00
Nikita Sobolev d7dc3d9455
gh-109418: Fix hypothesis strategy for b2a_roundtrip test (#109419) 2023-09-14 14:38:31 -06:00
Alex Waygood 3b9d10b031
gh-109413: libregrtest: Add and improve type annotations (#109405) 2023-09-14 18:33:18 +00:00