Prepare the docs for using the notation used in the `python.gram`
file. If we want to sync the two, the meta-syntax should be the same.
Link the Full Grammar docs here; keep only a few extras.
Also, remove the distinction between lexical and syntactic rules,
except for whitespace handling.
With f- and t-strings, the line between the two is blurry.
(cherry picked from commit 28d91d06f13ceda3df0cefacec497c370eff4802)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Blaise Pabon <blaise@gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
Co-authored-by: Colin Marquardt <cmarqu42@gmail.com>
bpo-45210: Document that error indicator may be set in tp_dealloc (GH-28358)
(cherry picked from commit 8441b263af964f353bf02d56c32a4fc547cdc330)
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Co-authored-by: Edward Z. Yang <ezyang@mit.edu>
Co-authored-by: Victor Stinner <vstinner@python.org>
gh-133968: Add PyUnicodeWriter_WriteASCII() function (#133973)
Replace most PyUnicodeWriter_WriteUTF8() calls with
PyUnicodeWriter_WriteASCII().
(cherry picked from commit f49a07b531543dd8a42d90f5b1c89c0312fbf806)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
GH-135287: clang-cl PGO builds on Windows fail with `could not open '/GENPROFILE'` (GH-135289)
(cherry picked from commit 0045100ccbc3919e8990fa59bc413fe38d21b075)
Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
Use f-strings in csv docs example (GH-135245)
(cherry picked from commit 2677dd017a033eaaad3b8e1e0eb5664a44e7e231)
Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
* gh-135276: Refresh `zipfile.Path` from zipp 3.23 (GH-135277)
Apply changes from zipp 3.23
(cherry picked from commit 8d6eb0c26276c4013346622580072908d46d2341)
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
* Removed features slated for Python 3.15 only.
---------
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
gh-134976: document the exception type that can be raised by `s[i]` (GH-134977)
(cherry picked from commit 158e5162bfaa8a49178ce2c3f2455c3e03b60157)
Co-authored-by: Yongzi Li <204532581+Yzi-Li@users.noreply.github.com>
gh-135244: generate UUID random Node ID with a CSPRNG as per RFC 9562, §6.10.3 (GH-135226)
This aligns with the recommendations of RFC 9562, Section 6.10, paragraph 3 [1].
[1]: https://www.rfc-editor.org/rfc/rfc9562.html#section-6.10-3.
---------
(cherry picked from commit 1cb716387255a7bdab5b580bcf8ac1b6fa32cc41)
Co-authored-by: LamentXU <108666168+LamentXU123@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
gh-134876: Add fallback for when process_vm_readv fails with ENOSYS (GH-134878)
(cherry picked from commit ac9c3431cc5916a795c42b3e2b965233ceffe6f0)
Co-authored-by: Daniel Golding <goldingd89@gmail.com>
gh-134155: fix AttributeError in email._header_value_parser.get_address (GH-134194)
Append the defect to defects instead of to the parse tree.
(cherry picked from commit d9cad074d52fe31327429fd81e4d2eeea3dbe35b)
Co-authored-by: Sergey Miryanov <sergey.miryanov@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
gh-134160: Use PyModuleDef.m_free in the example module xxlimited (GH-135174)
(cherry picked from commit 1adca08d658ee2d520f3193960eaf3ae2ead1cef)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
feat(docs): type fix - apply pep8 by using docstring instead of comment in the doc. (GH-135181)
Giving the right example incitates the tutorial readers to do the same in the future.
(cherry picked from commit 343182853f19a42c0ba8980d3104076a8c7bcfe7)
Co-authored-by: Jean-Louis GUENEGO <jlguenego@gmail.com>
gh-134993: Add os.lstat() to os.supports_dir_fd (GH-135188)
(cherry picked from commit e004cf8fd5c006a7a1c60807a03066f4c43452e5)
Co-authored-by: Victor Stinner <vstinner@python.org>
gh-135155: Added dependencies required for compiling the _zstd module (GH-135156)
(cherry picked from commit a7d41e8aab5211f4ed7f636c41d63adcab0affba)
Co-authored-by: Weipeng Hong <hongweichen8888@sina.com>
We were incorrectly handling a few opcodes that leave their operands on the stack. Treat all of these conservatively; assume that they always leave operands on the stack.
(cherry picked from commit 6b77af257c25d31f1f137e477cb23e63692ddf29)
gh-135166: Fix exception type expected by test.test_zstd (GH-135167)
(cherry picked from commit 1b55e12766d007aea9fcd0966e29ce220b67d28e)
Co-authored-by: Weipeng Hong <hongweichen8888@sina.com>
gh-134989: Fix Py_RETURN_NONE in the limited C API (GH-135165)
Fix Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE macros in the
limited C API 3.11 and older:
Don't treat Py_None, Py_True and Py_False as immortal.
(cherry picked from commit 9258f3da9175134d03f2c8c7c7eed223802ad945)
Co-authored-by: Victor Stinner <vstinner@python.org>
gh-135124: Change stdout errors in regrtest worker process (GH-135138)
Set sys.stdout encoder error handler to backslashreplace in regrtest
workers to avoid UnicodeEncodeError when printing a traceback
or any other non-encodable character.
Move the code from the Regrtest class to setup_process().
Call setup_process() earlier, before displaying regrtest headers.
(cherry picked from commit 3d396ab7591d544ac8bc1fb49615b4e867ca1c83)
Co-authored-by: Victor Stinner <vstinner@python.org>
Modifies the environment handling and execution arguments of the Android management
script to support the compilation of third-party binaries, and the use of the testbed to
invoke third-party test code.
(cherry picked from commit 2e1544fd2b0cd46ba93fc51e3cdd47f4781d7499)
Co-authored-by: Malcolm Smith <smith@chaquo.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
gh-129876: Update IDLE News3.txt to May 2025 (GH-135139)
(cherry picked from commit 0df15d0d4d55dcf7b7a7f4b2985bf84fd092d257)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
gh-134989: Implement PyObject_DelAttr() as a macro in the limited C API (GH-135021)
(cherry picked from commit c21113072cd1f0da83729f99d3576647db85d816)
Co-authored-by: Victor Stinner <vstinner@python.org>
The `test_ssl_in_multiple_threads` test failed because `test_check_hostname_idn()`
modified the global warnings filters via `warnings_helper.check_no_resource_warning()`.
Only check for warnings when the context aware warnings feature is enabled, which makes
the warnings filter context-local and thread-safe.
(cherry picked from commit 40c8be0008ecadb5d0dc9a017434b1133a3a6e06)
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
On Windows, the `_PyOS_SigintEvent()` event handle is used to interrupt
the main thread when Ctrl-C is pressed. Previously, we also waited on
the event from other threads, but ignored the result. However, this can
race with interpreter shutdown because the main thread closes the handle
in `_PySignal_Fini` and threads may still be running and using mutexes
during interpreter shtudown.
Only use `_PyOS_SigintEvent()` in the main thread in parking_lot.c, like
we do in other places in the CPython codebase.
(cherry picked from commit cc581f32bf5f15e9f2f89b830ec64ea25684d0cd)
Co-authored-by: Sam Gross <colesbury@gmail.com>
Use a more clear example for the PEP 758 what's new section (GH-135118)
(cherry picked from commit 1f515104441898111c20aca5a7bbda1d11b15d36)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
On a fresh Xcode install (including some CI provider configurations), there is
no pre-existing testing set that can be used to identify simulator models. Use
the default device set to detect available models instead. Live testing
simulators are still created in the testing set.
(cherry picked from commit dba9de731b231ca0c079205f496d1e3d178b4fd3)
Co-authored-by: Joe Rickerby <joerick@mac.com>
The `getlogin` function is not thread-safe: replace with `getlogin_r` where
available.
(cherry picked from commit 1ffe913c2017b44804aca18befd45689df06c069)
Co-authored-by: Duane Griffin <duaneg@dghda.com>
gh-134248 test_getallocatedblocks pre-check to ignore immortalized strings (GH-134871)
When sanity checking against gettotalrefcount(), we exclude the blocks for
immortalized strings since their references are not tracked/reported. This
now matches refleak.py's book-keeping using the same functions.
(cherry picked from commit 54ca55978e305ebb099d1b49633211597625bd52)
Co-authored-by: tpburns <trevorpburns@gmail.com>
Apply Intel Control-flow Technology for x86-64 on asm_trampoline.S.
Required for mitigation against return-oriented programming (ROP)
and Call or Jump Oriented Programming (COP/JOP) attacks.
Manual application is required for the assembly files.
See also: https://sourceware.org/annobin/annobin.html/Test-cf-protection.html
gh-134875: Fix mimallc build error for the old compilers (gh-134994)
(cherry picked from commit b525e31b7fc50e7a498f8b9b16437cb7b9656f6f)
Co-authored-by: Donghee Na <donghee.na@python.org>
Make them similar to PyArg_Parse error messages, mention None as
a possible value, show a wrong type and the string length.
(cherry picked from commit df98a47a61a274eb7427c6201ddabec9ffd30b0a)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
50 producer and 50 consumer threads need more than 5GB of memory.
(cherry picked from commit 7a79f52d83c22f5a9787e590f267325c1175d389)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
The `textiowrapper_iternext` function called `_textiowrapper_writeflush`, but did not
use a critical section, making it racy in free-threaded builds.
(cherry picked from commit 44fb7c361cb24dcf9989a7a1cfee4f6aad5c81aa)
Co-authored-by: Duane Griffin <duaneg@dghda.com>