Commit Graph

123967 Commits

Author SHA1 Message Date
Mark Shannon c9014374c5
GH-125174: Make immortal objects more robust, following design from PEP 683 (GH-125251) 2024-10-10 18:19:08 +01:00
Petr Viktorin 01fc3b34cc
gh-124570: ctypes: Run some Structure tests on Union as well (GH-124976)
- Move some Structure tests to test_structunion; use a common base
  test class + two subclasses to run them on Union too
- Remove test_union for now as it's redundant

Note: `test_simple_structs` & `test_simple_unions` are in the common
file because they share `formats`.
2024-10-10 16:27:52 +02:00
Victor Stinner c914212474
gh-125196: Use PyUnicodeWriter for JSON encoder (#125249)
Replace the private _PyUnicodeWriter with the public PyUnicodeWriter.
2024-10-10 15:33:00 +02:00
neonene 120b891e4d
gh-124153: Simplify PyType_GetBaseByToken (GH-124488) 2024-10-10 12:57:13 +00:00
Sergey B Kirpichev 87d7315ac5
gh-125118: don't copy arbitrary values to _Bool in the struct module (GH-125169)
memcopy'ing arbitrary values to _Bool variable triggers undefined
behaviour. Avoid this.
We assume that `false` is represented by all zero bytes.

Credits to Alex Gaynor.

Co-authored-by: Sam Gross <colesbury@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2024-10-10 14:42:03 +02:00
Donghee Na e4cab488d4
gh-124471: Set name for unnamed reusable workflow (#124475)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
2024-10-10 12:39:53 +00:00
Irit Katriel f9ae5d1cee
gh-71784: [doc] add usage examples for traceback.TracebackException (#125189)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-10-10 11:21:12 +01:00
Victor Stinner 82dfdc3287
gh-125196: Use PyUnicodeWriter for repr(tuple) (#125242) 2024-10-10 10:20:53 +00:00
Victor Stinner 1639d934b9
gh-125196: Add a free list to PyUnicodeWriter (#125227) 2024-10-10 12:11:06 +02:00
Adam Turner 7a10cdec35
Pin the doctest workflow to Ubuntu 22.04 (#125236) 2024-10-10 10:34:55 +01:00
Richard Hansen 99400930ac
gh-124872: Refine contextvars documentation (#124773)
* Add definitions for "context", "current context", and "context
    management protocol".
  * Update related definitions to be consistent with the new
    definitions.
  * Restructure the documentation for the `contextvars.Context` class
    to prepare for adding context manager support, and for consistency
    with the definitions.
  * Use `testcode` and `testoutput` to test the `Context.run` example.
  * Expand the documentation for the `Py_CONTEXT_EVENT_ENTER` and
    `Py_CONTEXT_EVENT_EXIT` events to clarify and to prepare for
    planned changes.
2024-10-09 16:44:03 -07:00
Victor Stinner 942916378a
gh-125196: Use PyUnicodeWriter for repr(contextvars.Token) (#125220)
Replace the private _PyUnicodeWriter with the public PyUnicodeWriter.
2024-10-09 23:37:14 +00:00
Victor Stinner 1b2a5485f9
gh-125196: PyUnicodeWriter_Discard(NULL) does nothing (#125222) 2024-10-09 23:32:02 +00:00
Serhiy Storchaka 9ad55e85d7
gh-124969: Skip the test for ALT_DIGITS also on iOS (#125177)
Skip the locale.ALT_DIGITS test on all Apple platforms, not just macOS.
2024-10-10 07:30:14 +08:00
Pablo Galindo Salgado c7d5d1d93b
gh-125140: Remove the current directory from sys.path when using pyrepl (GH-125212)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2024-10-09 22:30:56 +00:00
Victor Stinner 1877543d03
gh-125196: Use PyUnicodeWriter for repr(structseq) (#125219)
Replace the private _PyUnicodeWriter with the public PyUnicodeWriter.

* Avoid temporary PyUnicode_DecodeUTF8(): call
  PyUnicodeWriter_WriteUTF8() instead.
* Avoid temporary PyObject_Repr(): call PyUnicodeWriter_WriteRepr()
  instead.
2024-10-09 22:04:50 +00:00
Victor Stinner ee3167b978
gh-125196: Add fast-path for int in PyUnicodeWriter_WriteStr() (#125214)
PyUnicodeWriter_WriteStr() and PyUnicodeWriter_WriteRepr() now call
directly _PyLong_FormatWriter() if the argument is an int.
2024-10-10 00:01:02 +02:00
Savannah Ostrowski 0c5a48c1c9
GH-124693: Support parsing negative scientific and complex numbers argparse (GH-124823)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-10-09 21:56:50 +00:00
Victor Stinner 52f70da19c
gh-125196: Use PyUnicodeWriter for repr(list) (#125202)
Replace the private _PyUnicodeWriter with the public PyUnicodeWriter.

Replace PyObject_Repr() + _PyUnicodeWriter_WriteStr()
with PyUnicodeWriter_WriteRepr().
2024-10-09 23:56:30 +02:00
Serhiy Storchaka 7d2c39752f
gh-91818: Use default program name in the CLI of many modules (GH-124867)
As argparse now detects by default when the code was run as a module.

This leads to using the actual executable name instead of simply "python"
to display in the usage message ("usage: python -m ...").
2024-10-10 00:20:53 +03:00
Adam Turner cbfd392479
GH-121970: Extract ``availability`` into a new extension (#125082) 2024-10-09 21:50:03 +01:00
Eric Snow f2cb399470
gh-116510: Fix a Crash Due to Shared Immortal Interned Strings (gh-124865)
Fix a crash caused by immortal interned strings being shared between
sub-interpreters that use basic single-phase init. In that case, the string
can be used by an interpreter that outlives the interpreter that created and
interned it. For interpreters that share obmalloc state, also share the
interned dict with the main interpreter.

This is an un-revert of gh-124646 that then addresses the Py_TRACE_REFS
failures identified by gh-124785.
2024-10-09 11:32:16 -06:00
Irit Katriel d501153aed
gh-119786: Move parser doc from devguide to InternalDocs (#125119)
Co-authored-by: Jacob Coffee <jacob@z7x.org>
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
Co-Authored-By: Adam Turner <9087854+aa-turner@users.noreply.github.com>
Co-Authored-By: Carl Friedrich Bolz-Tereick <cfbolz@gmx.de>
Co-Authored-By: Carol Willing <carolcode@willingconsulting.com>
Co-Authored-By: Erlend E. Aasland <erlend@python.org>
Co-Authored-By: Ezio Melotti <ezio.melotti@gmail.com>
Co-Authored-By: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-Authored-By: Irit Katriel <iritkatriel@yahoo.com>
Co-Authored-By: Itamar Ostricher <itamarost@gmail.com>
Co-Authored-By: Julien Palard <julien@palard.fr>
Co-Authored-By: Mana <potpath@users.noreply.github.com>
Co-Authored-By: Muhammad Mahad <mahadpy@gmail.com>
Co-Authored-By: Ned Batchelder <ned@nedbatchelder.com>
Co-Authored-By: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-Authored-By: slateny <46876382+slateny@users.noreply.github.com>
Co-Authored-By: wookie184 <wookie1840@gmail.com>
2024-10-09 18:21:35 +01:00
Victor Stinner 9bda7750c2
gh-125196: Use PyUnicodeWriter in symtable.c (#125199) 2024-10-09 17:54:54 +02:00
mpage f978fb4f8d
gh-115999: Refactor `LOAD_GLOBAL` specializations to avoid reloading {globals, builtins} keys (gh-124953)
Each of the `LOAD_GLOBAL` specializations is implemented roughly as:

1. Load keys version.
2. Load cached keys version.
3. Deopt if (1) and (2) don't match.
4. Load keys.
5. Load cached index into keys.
6. Load object from (4) at offset from (5).

This is not thread-safe in free-threaded builds; the keys object may be replaced
in between steps (3) and (4).

This change refactors the specializations to avoid reloading the keys object and
instead pass the keys object from guards to be consumed by downstream uops.
2024-10-09 15:18:25 +00:00
Victor Stinner b9a8ca0a6a
gh-115754: Use Py_GetConstant(Py_CONSTANT_EMPTY_STR) (#125194)
Replace PyUnicode_New(0, 0), PyUnicode_FromString("")
and PyUnicode_FromStringAndSize("", 0)
with Py_GetConstant(Py_CONSTANT_EMPTY_STR).
2024-10-09 17:15:23 +02:00
Victor Stinner 6a39e96ab8
gh-115754: Use Py_GetConstant(Py_CONSTANT_EMPTY_BYTES) (#125195)
Replace PyBytes_FromString("") and PyBytes_FromStringAndSize("", 0)
with Py_GetConstant(Py_CONSTANT_EMPTY_BYTES).
2024-10-09 17:12:11 +02:00
Victor Stinner 3ee474f568
gh-111178: Fix function signatures in codeobject.c (#125180) 2024-10-09 15:02:24 +00:00
Mark Shannon eb18574cc3
GH-120024: Tidy up pycore_stackref.h, splitting into GIL and free-threading sections (GH-125095) 2024-10-09 15:43:09 +01:00
Victor Stinner 440632adb2
gh-111178: Fix function signatures in cellobject.c (#125182) 2024-10-09 16:13:55 +02:00
Hugo van Kemenade a5716a3091
gh-101100: Fix Sphinx warnings in `library/unittest.mock.rst` (#124106) 2024-10-09 17:02:18 +03:00
JamesMcCarthy21 e0835aff2e
gh-125168: Fix typo in `__future__.rst` (#125183)
* Update `__future__.rst`

Fixed typo in the sentence :pep:`649`: *Deferred evaluation of annotations using descriptors* - James McCarthy

* Update `__future__.rst`

Fixed sphinx formatting
2024-10-09 16:17:18 +03:00
Tomas R. 6b533a659b
gh-125039: Make `this_instr`/`prev_instr` const in cases generator (GH-125071) 2024-10-09 13:54:39 +01:00
Alex Waygood 3024b16d51
gh-101100: Consolidate documentation on `ModuleType` attributes (#124709)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Barry Warsaw <barry@python.org>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-10-09 10:53:57 +00:00
Alyssa Coghlan 7a303fc78a
Fix importlib.resources issue reference in 3.13 What's New (#125175)
Previous link was to the PR that removed the
mentioned importlib.resources APIs, rather than
the issue that added back their improved forms.
2024-10-09 20:40:50 +10:00
Petr Viktorin d20c43d8e2
gh-107562: Update test certificates to expire far in the future (GH-125104)
Generated with Lib/test/certdata/make_ssl_certs.py
using openssl-3.2.2-3.fc40.x86_64 (Fedora 40).
2024-10-09 11:17:02 +02:00
Alexander Kanavin 53930cbe47
gh-107562: make_ssl_certs.py: produce test certificates that expire far in the future by default (GH-107594)
This allows testing Y2038 with system time set to after that,
so that actual Y2038 issues can be exposed, and not masked
by expired certificate errors.

Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
2024-10-09 11:16:08 +02:00
Serhiy Storchaka 21c04e1a97
gh-124969: Fix locale.nl_langinfo(locale.ALT_DIGITS) (GH-124974)
Now it returns a tuple of up to 100 strings (an empty tuple on most locales).
Previously it returned the first item of that tuple or an empty string.
2024-10-09 11:42:08 +03:00
Furkan Onder 92760bd85b
gh-125150: Skip test_fma_zero_result on NetBSD due to IEE 754-2008 implementation issues (#125151)
Skip test_fma_zero_result on NetBSD due to IEE 754-2008 implementation issues
2024-10-09 10:40:06 +02:00
Victor Stinner e0c87c64b1
gh-124502: Remove _PyUnicode_EQ() function (#125114)
* Replace unicode_compare_eq() with unicode_eq().
* Use unicode_eq() in setobject.c.
* Replace _PyUnicode_EQ() with _PyUnicode_Equal().
* Remove unicode_compare_eq() and _PyUnicode_EQ().
2024-10-09 10:15:17 +02:00
musvaage 7f93dbf6fe
docs: in venv table use executable name (GH-124315)
Co-authored-by: musvaage <musvaage@users.noreply.github.com>
2024-10-09 09:04:35 +01:00
Jelle Zijlstra 78406382c9
gh-101552: Allow pydoc to display signatures in source format (#124669)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-10-09 05:03:53 +00:00
Donghee Na b502573f7f
gh-124612: Use ghcr.io/python/autoconf instead of public image (#124657)
* gh-124612: Use ghcr.io/python/autoconf instead of public image

* Update
2024-10-09 09:33:18 +09:00
Mariusz Felisiak 14b44c58e1
gh-123849: Fix test_sqlite3.test_table_dump when foreign keys are enabled by default (#123859) 2024-10-08 22:46:11 +00:00
Savannah Ostrowski 37228bd16e
GH-124478: Cleanup argparse documentation (#124877)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Tomas R <tomas.roun8@gmail.com>
2024-10-08 15:07:29 -07:00
Sergey B Kirpichev eafd14fbe0
gh-116110: remove extra processing for the __signature__ attribute (GH-116234)
This is an alternative to GH-100168.
2024-10-08 12:36:03 -07:00
Raymond Hettinger b2a7272408
Misc improvements to the itertools docs (gh-125147) 2024-10-08 14:02:58 -05:00
spacemanspiff2007 760b1e103a
gh-124832: Add a note to indicate that `datetime.now` may return the same instant (#124834)
* Update datetime.rst

* Update datetime.rst

replace warning with note

* Update Doc/library/datetime.rst

Co-authored-by: Victor Stinner <vstinner@python.org>

* Update Doc/library/datetime.rst

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

---------

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-10-08 11:17:53 -07:00
Michael Droettboom c6127af868
gh-125063: Emit slices as constants in the bytecode compiler (#125064)
* Make slices marshallable

* Emit slices as constants

* Update Python/marshal.c

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

* Refactor codegen_slice into two functions so it
always has the same net effect

* Fix for free-threaded builds

* Simplify marshal loading of slices

* Only return SUCCESS/ERROR from codegen_slice

---------

Co-authored-by: Mark Shannon <mark@hotpy.org>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2024-10-08 13:18:39 -04:00
Cody Maloney 7dca7322cc
gh-125084: Resolve paths in generator common code (GH-125085)
In out of tree builds, the paths can contain `../ which needs to be
resolved for the relative path calculation to work.
2024-10-08 12:16:02 -05:00