Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions .github/workflows/jit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ jobs:
fail-fast: false
matrix:
target:
# To re-enable later when we support these.
# - i686-pc-windows-msvc/msvc
# - x86_64-pc-windows-msvc/msvc
# - aarch64-pc-windows-msvc/msvc
- i686-pc-windows-msvc/msvc
- x86_64-pc-windows-msvc/msvc
- aarch64-pc-windows-msvc/msvc
- x86_64-apple-darwin/clang
- aarch64-apple-darwin/clang
- x86_64-unknown-linux-gnu/gcc
Expand All @@ -71,16 +70,15 @@ jobs:
llvm:
- 21
include:
# To re-enable later when we support these.
# - target: i686-pc-windows-msvc/msvc
# architecture: Win32
# runner: windows-2022
# - target: x86_64-pc-windows-msvc/msvc
# architecture: x64
# runner: windows-2022
# - target: aarch64-pc-windows-msvc/msvc
# architecture: ARM64
# runner: windows-11-arm
- target: i686-pc-windows-msvc/msvc
architecture: Win32
runner: windows-2022
- target: x86_64-pc-windows-msvc/msvc
architecture: x64
runner: windows-2022
- target: aarch64-pc-windows-msvc/msvc
architecture: ARM64
runner: windows-11-arm
- target: x86_64-apple-darwin/clang
architecture: x86_64
runner: macos-15-intel
Expand Down
29 changes: 29 additions & 0 deletions Doc/c-api/object.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,35 @@ Object Protocol
instead of the :func:`repr`.


.. c:function:: void PyUnstable_Object_Dump(PyObject *op)

Dump an object *op* to ``stderr``. This should only be used for debugging.

The output is intended to try dumping objects even after memory corruption:

* Information is written starting with fields that are the least likely to
crash when accessed.
* This function can be called without an :term:`attached thread state`, but
it's not recommended to do so: it can cause deadlocks.
* An object that does not belong to the current interpreter may be dumped,
but this may also cause crashes or unintended behavior.
* Implement a heuristic to detect if the object memory has been freed. Don't
display the object contents in this case, only its memory address.
* The output format may change at any time.

Example of output:

.. code-block:: output

object address : 0x7f80124702c0
object refcount : 2
object type : 0x9902e0
object type name: str
object repr : 'abcdef'

.. versionadded:: next


.. c:function:: int PyObject_HasAttrWithError(PyObject *o, PyObject *attr_name)

Returns ``1`` if *o* has the attribute *attr_name*, and ``0`` otherwise.
Expand Down
8 changes: 3 additions & 5 deletions Doc/c-api/structures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -698,14 +698,12 @@ The following flags can be used with :c:member:`PyMemberDef.flags`:
entry indicates an offset from the subclass-specific data, rather than
from ``PyObject``.

Can only be used as part of :c:member:`Py_tp_members <PyTypeObject.tp_members>`
Can only be used as part of the :c:data:`Py_tp_members`
:c:type:`slot <PyType_Slot>` when creating a class using negative
:c:member:`~PyType_Spec.basicsize`.
It is mandatory in that case.

This flag is only used in :c:type:`PyType_Slot`.
When setting :c:member:`~PyTypeObject.tp_members` during
class creation, Python clears it and sets
When setting :c:member:`~PyTypeObject.tp_members` from the slot during
class creation, Python clears the flag and sets
:c:member:`PyMemberDef.offset` to the offset from the ``PyObject`` struct.

.. index::
Expand Down
16 changes: 8 additions & 8 deletions Doc/c-api/type.rst
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,8 @@ The following functions and structs are used to create

The *bases* argument can be used to specify base classes; it can either
be only one class or a tuple of classes.
If *bases* is ``NULL``, the *Py_tp_bases* slot is used instead.
If that also is ``NULL``, the *Py_tp_base* slot is used instead.
If *bases* is ``NULL``, the :c:data:`Py_tp_bases` slot is used instead.
If that also is ``NULL``, the :c:data:`Py_tp_base` slot is used instead.
If that also is ``NULL``, the new type derives from :class:`object`.

The *module* argument can be used to record the module in which the new
Expand Down Expand Up @@ -590,9 +590,9 @@ The following functions and structs are used to create
:c:type:`PyAsyncMethods` with an added ``Py_`` prefix.
For example, use:

* ``Py_tp_dealloc`` to set :c:member:`PyTypeObject.tp_dealloc`
* ``Py_nb_add`` to set :c:member:`PyNumberMethods.nb_add`
* ``Py_sq_length`` to set :c:member:`PySequenceMethods.sq_length`
* :c:data:`Py_tp_dealloc` to set :c:member:`PyTypeObject.tp_dealloc`
* :c:data:`Py_nb_add` to set :c:member:`PyNumberMethods.nb_add`
* :c:data:`Py_sq_length` to set :c:member:`PySequenceMethods.sq_length`

An additional slot is supported that does not correspond to a
:c:type:`!PyTypeObject` struct field:
Expand All @@ -611,7 +611,7 @@ The following functions and structs are used to create

If it is not possible to switch to a ``MANAGED`` flag (for example,
for vectorcall or to support Python older than 3.12), specify the
offset in :c:member:`Py_tp_members <PyTypeObject.tp_members>`.
offset in :c:data:`Py_tp_members`.
See :ref:`PyMemberDef documentation <pymemberdef-offsets>`
for details.

Expand Down Expand Up @@ -639,7 +639,7 @@ The following functions and structs are used to create

.. versionchanged:: 3.14
The field :c:member:`~PyTypeObject.tp_vectorcall` can now set
using ``Py_tp_vectorcall``. See the field's documentation
using :c:data:`Py_tp_vectorcall`. See the field's documentation
for details.

.. c:member:: void *pfunc
Expand All @@ -649,7 +649,7 @@ The following functions and structs are used to create

*pfunc* values may not be ``NULL``, except for the following slots:

* ``Py_tp_doc``
* :c:data:`Py_tp_doc`
* :c:data:`Py_tp_token` (for clarity, prefer :c:data:`Py_TP_USE_SPEC`
rather than ``NULL``)

Expand Down
2 changes: 1 addition & 1 deletion Doc/c-api/typeobj.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2273,7 +2273,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
This field should be set to ``NULL`` and treated as read-only.
Python will fill it in when the type is :c:func:`initialized <PyType_Ready>`.

For dynamically created classes, the ``Py_tp_bases``
For dynamically created classes, the :c:data:`Py_tp_bases`
:c:type:`slot <PyType_Slot>` can be used instead of the *bases* argument
of :c:func:`PyType_FromSpecWithBases`.
The argument form is preferred.
Expand Down
2 changes: 1 addition & 1 deletion Doc/deprecations/pending-removal-in-future.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ although there is currently no date scheduled for their removal.
* :mod:`mailbox`: Use of StringIO input and text mode is deprecated, use
BytesIO and binary mode instead.

* :mod:`os`: Calling :func:`os.register_at_fork` in multi-threaded process.
* :mod:`os`: Calling :func:`os.register_at_fork` in a multi-threaded process.

* :class:`!pydoc.ErrorDuringImport`: A tuple value for *exc_info* parameter is
deprecated, use an exception instance.
Expand Down
2 changes: 1 addition & 1 deletion Doc/howto/isolating-extensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ garbage collection protocol.
That is, heap types should:

- Have the :c:macro:`Py_TPFLAGS_HAVE_GC` flag.
- Define a traverse function using ``Py_tp_traverse``, which
- Define a traverse function using :c:data:`Py_tp_traverse`, which
visits the type (e.g. using ``Py_VISIT(Py_TYPE(self))``).

Please refer to the documentation of
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/decimal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ allows the settings to be changed. This approach meets the needs of most
applications.

For more advanced work, it may be useful to create alternate contexts using the
Context() constructor. To make an alternate active, use the :func:`setcontext`
:meth:`Context` constructor. To make an alternate active, use the :func:`setcontext`
function.

In accordance with the standard, the :mod:`decimal` module provides two ready to
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/os.rst
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ process and user.

.. function:: initgroups(username, gid, /)

Call the system initgroups() to initialize the group access list with all of
Call the system ``initgroups()`` to initialize the group access list with all of
the groups of which the specified username is a member, plus the specified
group id.

Expand Down
48 changes: 26 additions & 22 deletions Doc/whatsnew/3.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,7 @@ Other language changes
and compression. Common code patterns which can be optimized with
:func:`~bytearray.take_bytes` are listed below.

(Contributed by Cody Maloney in :gh:`139871`.)

.. list-table:: Suggested Optimizing Refactors
.. list-table:: Suggested optimizing refactors
:header-rows: 1

* - Description
Expand Down Expand Up @@ -387,10 +385,12 @@ Other language changes
buffer.resize(n)
data = buffer.take_bytes()

(Contributed by Cody Maloney in :gh:`139871`.)

* Many functions related to compiling or parsing Python code, such as
:func:`compile`, :func:`ast.parse`, :func:`symtable.symtable`,
and :func:`importlib.abc.InspectLoader.source_to_code`, now allow to pass
the module name. It is needed to unambiguous :ref:`filter <warning-filter>`
and :func:`importlib.abc.InspectLoader.source_to_code`, now allow the module
name to be passed. It is needed to unambiguously :ref:`filter <warning-filter>`
syntax warnings by module name.
(Contributed by Serhiy Storchaka in :gh:`135801`.)

Expand Down Expand Up @@ -776,6 +776,17 @@ unittest
(Contributed by Garry Cairns in :gh:`134567`.)


venv
----

* On POSIX platforms, platlib directories will be created if needed when
creating virtual environments, instead of using ``lib64 -> lib`` symlink.
This means purelib and platlib of virtual environments no longer share the
same ``lib`` directory on platforms where :data:`sys.platlibdir` is not
equal to ``lib``.
(Contributed by Rui Xi in :gh:`133951`.)


warnings
--------

Expand All @@ -788,17 +799,6 @@ warnings
(Contributed by Serhiy Storchaka in :gh:`135801`.)


venv
----

* On POSIX platforms, platlib directories will be created if needed when
creating virtual environments, instead of using ``lib64 -> lib`` symlink.
This means purelib and platlib of virtual environments no longer share the
same ``lib`` directory on platforms where :data:`sys.platlibdir` is not
equal to ``lib``.
(Contributed by Rui Xi in :gh:`133951`.)


xml.parsers.expat
-----------------

Expand Down Expand Up @@ -1084,19 +1084,23 @@ New features

(Contributed by Victor Stinner in :gh:`129813`.)

* Add a new :c:func:`PyImport_CreateModuleFromInitfunc` C-API for creating
a module from a *spec* and *initfunc*.
(Contributed by Itamar Oren in :gh:`116146`.)

* Add :c:func:`PyTuple_FromArray` to create a :class:`tuple` from an array.
(Contributed by Victor Stinner in :gh:`111489`.)

* Add :c:func:`PyUnstable_Object_Dump` to dump an object to ``stderr``.
It should only be used for debugging.
(Contributed by Victor Stinner in :gh:`141070`.)

* Add :c:func:`PyUnstable_ThreadState_SetStackProtection` and
:c:func:`PyUnstable_ThreadState_ResetStackProtection` functions to set
the stack protection base address and stack protection size of a Python
thread state.
(Contributed by Victor Stinner in :gh:`139653`.)

* Add a new :c:func:`PyImport_CreateModuleFromInitfunc` C-API for creating
a module from a *spec* and *initfunc*.
(Contributed by Itamar Oren in :gh:`116146`.)


Changed C APIs
--------------
Expand Down Expand Up @@ -1242,7 +1246,7 @@ Porting to Python 3.15
This section lists previously described changes and other bugfixes
that may require changes to your code.

* :class:`sqlite3.Connection` APIs has been cleaned up.
* :class:`sqlite3.Connection` APIs have been cleaned up.

* All parameters of :func:`sqlite3.connect` except *database* are now keyword-only.
* The first three parameters of methods :meth:`~sqlite3.Connection.create_function`
Expand All @@ -1262,7 +1266,7 @@ that may require changes to your code.
* :meth:`~mmap.mmap.resize` has been removed on platforms that don't support the
underlying syscall, instead of raising a :exc:`SystemError`.

* Resource warning is now emitted for unclosed
* A resource warning is now emitted for an unclosed
:func:`xml.etree.ElementTree.iterparse` iterator if it opened a file.
Use its :meth:`!close` method or the :func:`contextlib.closing` context
manager to close it.
Expand Down
14 changes: 9 additions & 5 deletions Include/cpython/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,10 @@ PyAPI_FUNC(PyObject *) PyType_GetDict(PyTypeObject *);

PyAPI_FUNC(int) PyObject_Print(PyObject *, FILE *, int);
PyAPI_FUNC(void) _Py_BreakPoint(void);
PyAPI_FUNC(void) _PyObject_Dump(PyObject *);
PyAPI_FUNC(void) PyUnstable_Object_Dump(PyObject *);

// Alias for backward compatibility
#define _PyObject_Dump PyUnstable_Object_Dump

PyAPI_FUNC(PyObject*) _PyObject_GetAttrId(PyObject *, _Py_Identifier *);

Expand Down Expand Up @@ -387,10 +390,11 @@ PyAPI_FUNC(PyObject *) _PyObject_FunctionStr(PyObject *);
process with a message on stderr if the given condition fails to hold,
but compile away to nothing if NDEBUG is defined.

However, before aborting, Python will also try to call _PyObject_Dump() on
the given object. This may be of use when investigating bugs in which a
particular object is corrupt (e.g. buggy a tp_visit method in an extension
module breaking the garbage collector), to help locate the broken objects.
However, before aborting, Python will also try to call
PyUnstable_Object_Dump() on the given object. This may be of use when
investigating bugs in which a particular object is corrupt (e.g. buggy a
tp_visit method in an extension module breaking the garbage collector), to
help locate the broken objects.

The WITH_MSG variant allows you to supply an additional message that Python
will attempt to print to stderr, after the object dump. */
Expand Down
2 changes: 1 addition & 1 deletion Include/internal/pycore_global_objects_fini_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Include/internal/pycore_magic_number.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ Known values:
Python 3.15a1 3653 (Fix handling of opcodes that may leave operands on the stack when optimizing LOAD_FAST)
Python 3.15a1 3654 (Fix missing exception handlers in logical expression)
Python 3.15a1 3655 (Fix miscompilation of some module-level annotations)
Python 3.15a1 3656 (Add TRACE_RECORD instruction, for platforms with switch based interpreter)


Python 3.16 will start with 3700
Expand All @@ -299,7 +300,7 @@ PC/launcher.c must also be updated.

*/

#define PYC_MAGIC_NUMBER 3655
#define PYC_MAGIC_NUMBER 3656
/* This is equivalent to converting PYC_MAGIC_NUMBER to 2 bytes
(little-endian) and then appending b'\r\n'. */
#define PYC_MAGIC_NUMBER_TOKEN \
Expand Down
Loading
Loading