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
6 changes: 6 additions & 0 deletions Doc/library/csv.rst
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,12 @@ The :mod:`!csv` module defines the following classes:
in particular if it is a single column,
so there is no delimiter to find.

If several combinations fit the sample equally well ---
for example if both ``','`` and ``';'`` split every row consistently ---
the delimiters ``','``, ``'\t'``, ``';'``, ``' '`` and ``':'``
are preferred, in this order,
no matter how many times each of them occurs.

.. versionchanged:: next
The dialect is now deduced by trial parsing
and the results may differ from those of earlier Python versions.
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/warnings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ Available Functions
and calls to :func:`simplefilter`.


.. decorator:: deprecated(msg, *, category=DeprecationWarning, stacklevel=1)
.. decorator:: deprecated(message, /, *, category=DeprecationWarning, stacklevel=1)

Decorator to indicate that a class, function or overload is deprecated.

Expand Down
58 changes: 31 additions & 27 deletions Doc/using/mac.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Installation steps
For `current Python versions <https://www.python.org/downloads/>`_
(other than those in ``security`` status), the release team produces a
**Python for macOS** installer package for each new release.
A list of available installers
is available `here <https://www.python.org/downloads/macos/>`_.
A list of available installers is provided on the
`macOS downloads page <https://www.python.org/downloads/macos/>`__.
We recommend using the most recent supported Python version where possible.
Current installers provide a
`universal2 binary <https://en.wikipedia.org/wiki/Universal_binary>`_ build
Expand All @@ -39,14 +39,14 @@ supported by a wide range of macOS versions,
currently typically from at least **macOS 10.15 Catalina** on.

The downloaded file is a standard macOS installer package file (``.pkg``).
File integrity information (checksum, size, sigstore signature, etc) for each file is included
File integrity information (such as checksum, size, and Sigstore signature) for each file is included
on the release download page. Installer packages and their contents are signed and notarized
with ``Python Software Foundation`` Apple Developer ID certificates
to meet `macOS Gatekeeper requirements <https://support.apple.com/en-us/102445>`_.

For a default installation, double-click on the downloaded installer package file.
This should launch the standard macOS Installer app and display the first of several
installer windows steps.
installer steps.

.. image:: mac_installer_01_introduction.png

Expand All @@ -73,8 +73,8 @@ display. For most uses, the standard set of installation operations is appropria
By pressing the **Customize** button, you can choose to omit or select certain package
components of the installer. Click on each package name to see a description of
what it installs.
To also install support for the optional free-threaded feature,
see :ref:`install-freethreaded-macos`.
For details of the optional free-threaded feature, which is installed
by default, see :ref:`install-freethreaded-macos`.

.. image:: mac_installer_05_custom_install.png

Expand All @@ -98,7 +98,7 @@ for its use.

.. image:: mac_installer_08_install_certificates.png

If ``Successfully installed certifi`` and ``update complete`` appears
If ``Successfully installed certifi`` and ``update complete`` appear
in the terminal window, the installation is complete.
Close this terminal window and the installer window.

Expand Down Expand Up @@ -171,7 +171,7 @@ be certain of what you are about to run.

.. _alternative_bundles:

Alternative Distributions
Alternative distributions
=========================

Besides the standard ``python.org`` for macOS installer, there are third-party
Expand Down Expand Up @@ -199,7 +199,7 @@ other libraries, and are not maintained or supported by the core Python team.

.. _mac-package-manager:

Installing Additional Python Packages
Installing additional Python packages
=====================================

Refer to the `Python Packaging User Guide`_ for more information.
Expand All @@ -211,7 +211,7 @@ Refer to the `Python Packaging User Guide`_ for more information.

.. _gui-programming-on-the-mac:

GUI Programming
GUI programming
===============

There are several options for building GUI applications on the Mac with Python.
Expand Down Expand Up @@ -241,19 +241,22 @@ A number of alternative macOS GUI toolkits are available including:
supports desktop operating systems.


Advanced Topics
Advanced topics
===============

.. _install-freethreaded-macos:

Installing Free-threaded Binaries
Installing free-threaded binaries
---------------------------------

.. versionadded:: 3.13

.. versionchanged:: 3.15
Free-threading support is now installed by default.

The ``python.org`` :ref:`Python for macOS <getting-and-installing-macpython>`
installer package can optionally install an additional build of
Python |version| that supports :pep:`703`, the free-threading feature
installer package installs, by default, an additional build of
Python |version| that supports :term:`free threading`
(running with the :term:`global interpreter lock` disabled).
Check the release page on ``python.org`` for possible updated information.

Expand All @@ -262,14 +265,15 @@ there is some additional overhead in single-threaded workloads compared
to the regular build. Additionally, third-party packages, in particular ones
with an :term:`extension module`, may not be ready for use in a
free-threaded build, and will re-enable the :term:`GIL`.
Therefore, the support for free-threading
is not installed by default. It is packaged as a separate install option,
available by clicking the **Customize** button on the **Installation Type**
As of Python 3.15, free-threading support is installed by default.
It is packaged as a separate install option, which can be deselected
by clicking the **Customize** button on the **Installation Type**
step of the installer as described above.

.. image:: mac_installer_09_custom_install_free_threaded.png

If the box next to the **Free-threaded Python** package name is checked,
If the box next to the **Free-threaded Python** package name is checked
(as it is by default),
a separate :file:`PythonT.framework` will also be installed
alongside the normal :file:`Python.framework` in :file:`/Library/Frameworks`.
This configuration allows a free-threaded Python |version| build to co-exist
Expand All @@ -284,7 +288,7 @@ Known cautions and limitations:
the free-threaded interpreter, and |python_x_dot_y_t_literal_config|,
a configuration utility which may be useful for package builders.
Since :file:`/usr/local/bin` is typically included in your shell ``PATH``,
in most cases no changes to your ``PATH`` environment variables should
in most cases no changes to your ``PATH`` environment variable should
be needed to use |python_x_dot_y_t_literal|.

- For this release, the **Shell profile updater** package and the
Expand Down Expand Up @@ -367,8 +371,8 @@ the macOS command line :command:`installer` utility lets you select non-default
options, too. If you are not familiar with :command:`installer`, it can be
somewhat cryptic (see :command:`man installer` for more information).
As an example, the following shell snippet shows one way to do it,
using the |x_dot_y_b2_literal| release and selecting the free-threaded interpreter
option:
using the |x_dot_y_b2_literal| release and deselecting the free-threaded
interpreter option:

.. parsed-literal::

Expand All @@ -378,7 +382,7 @@ option:
curl -O \https://www.python.org/ftp/python/\ |version|\ .0/${RELEASE}

# create installer choicechanges to customize the install:
# enable the PythonTFramework-\ |version|\ package
# disable the PythonTFramework-\ |version|\ package
# while accepting the other defaults (install all other packages)
cat > ./choicechanges.plist <<EOF
<?xml version="1.0" encoding="UTF-8"?>
Expand All @@ -387,7 +391,7 @@ option:
<array>
<dict>
<key>attributeSetting</key>
<integer>1</integer>
<integer>0</integer>
<key>choiceAttribute</key>
<string>selected</string>
<key>choiceIdentifier</key>
Expand All @@ -400,7 +404,7 @@ option:
sudo installer -pkg ./${RELEASE} -applyChoiceChangesXML ./choicechanges.plist -target /


You can then test that both installer builds are now available with something like:
After a default install, you can test that both builds are available with something like:

.. parsed-literal::

Expand All @@ -425,7 +429,7 @@ You can then test that both installer builds are now available with something li

.. _distributing-python-applications-on-the-mac:

Distributing Python Applications
Distributing Python applications
--------------------------------

A range of tools exist for converting your Python code into a standalone
Expand All @@ -442,7 +446,7 @@ distributable application:
* `PyInstaller <https://pyinstaller.org/>`_: A cross-platform packaging tool that creates
a single file or folder as a distributable artifact.

App Store Compliance
App Store compliance
--------------------

Apps submitted for distribution through the macOS App Store must pass Apple's
Expand All @@ -464,7 +468,7 @@ This patch is not normally required to use CPython on a Mac; nor is it required
if you are distributing an app *outside* the macOS App Store. It is *only*
required if you are using the macOS App Store as a distribution channel.

Other Resources
Other resources
===============

The `python.org Help page <https://www.python.org/about/help/>`_ has links to many useful resources.
Expand Down
Binary file modified Doc/using/mac_installer_01_introduction.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Doc/using/mac_installer_02_readme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Doc/using/mac_installer_03_license.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Doc/using/mac_installer_04_installation_type.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Doc/using/mac_installer_05_custom_install.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Doc/using/mac_installer_06_summary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Doc/using/mac_installer_07_applications.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Doc/using/mac_installer_08_install_certificates.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions Include/internal/pycore_interp_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,7 @@ struct _is {
struct _obmalloc_state *obmalloc;

PyObject *audit_hooks;
PyMutex audit_hooks_mutex;
PyType_WatchCallback type_watchers[TYPE_MAX_WATCHERS];
PyCode_WatchCallback code_watchers[CODE_MAX_WATCHERS];
PyContext_WatchCallback context_watchers[CONTEXT_MAX_WATCHERS];
Expand Down
4 changes: 4 additions & 0 deletions Lib/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ def sniff(self, sample, delimiters=None):
beginning, then, after eliminating the combinations which are
clearly worse than the leader, a several times larger part,
and so on.
If several combinations fit the sample equally well, the
delimiters listed in the preferred attribute are preferred, in
that order, no matter how many times each of them occurs.
"""
import re
from collections import defaultdict
Expand Down
5 changes: 1 addition & 4 deletions Lib/stat.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
"""Constants/functions for interpreting results of os.stat() and os.lstat().
Suggested usage: from stat import *
"""
"""Constants/functions for interpreting results of os.stat() and os.lstat()."""

# Indices for stat struct members in the tuple returned by os.stat()

Expand Down
14 changes: 14 additions & 0 deletions Lib/test/test_free_threading/test_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ def worker(worker_id):
workers = [lambda: worker(i) for i in range(5)]
threading_helper.run_concurrently(workers)

def test_sys_audit_hooks(self):
def _hook(*args):
return None

def adder():
for _ in range(100):
sys.addaudithook(_hook)

def auditor():
for _ in range(2000):
sys.audit("fusil.tsan.test")

threading_helper.run_concurrently([adder, auditor])


if __name__ == "__main__":
unittest.main()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes a data race in free-threading build in :func:`sys.addaudithook`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix :func:`time.strftime` and :meth:`datetime.datetime.strftime` returning a
wrong ISO 8601 week number (``%V``) on OpenBSD.
7 changes: 7 additions & 0 deletions Modules/timemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,13 @@ Other codes may be available on your platform. See documentation for\n\
the C library strftime function.\n"

#ifdef HAVE_STRFTIME
// gh-154460: OpenBSD's wcsftime() computes %V incorrectly: it returns 53
// whenever the ISO 8601 week belongs to a different year than tm_year.
// strftime() is not affected.
#ifdef __OpenBSD__
# undef HAVE_WCSFTIME
#endif

#ifdef HAVE_WCSFTIME
#define time_char wchar_t
#define format_time wcsftime
Expand Down
1 change: 1 addition & 0 deletions Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ init_interpreter(PyInterpreterState *interp,
llist_init(&interp->mem_free_queue.head);
llist_init(&interp->asyncio_tasks_head);
interp->asyncio_tasks_lock = (PyMutex){0};
interp->audit_hooks_mutex = (PyMutex){0};
for (int i = 0; i < _PY_MONITORING_UNGROUPED_EVENTS; i++) {
interp->monitors.tools[i] = 0;
}
Expand Down
26 changes: 18 additions & 8 deletions Python/sysmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ should_audit(PyInterpreterState *interp)
return 0;
}
return (interp->runtime->audit_hooks.head
|| interp->audit_hooks
|| FT_ATOMIC_LOAD_PTR_ACQUIRE(interp->audit_hooks)
|| PyDTrace_AUDIT_ENABLED());
}

Expand Down Expand Up @@ -306,13 +306,14 @@ sys_audit_tstate(PyThreadState *ts, const char *event,
}

/* Call interpreter hooks */
if (is->audit_hooks) {
PyObject *audit_hooks = FT_ATOMIC_LOAD_PTR_ACQUIRE(is->audit_hooks);
if (audit_hooks) {
eventName = PyUnicode_FromString(event);
if (!eventName) {
goto exit;
}

hooks = PyObject_GetIter(is->audit_hooks);
hooks = PyObject_GetIter(audit_hooks);
if (!hooks) {
goto exit;
}
Expand Down Expand Up @@ -536,20 +537,29 @@ sys_addaudithook_impl(PyObject *module, PyObject *hook)
}

PyInterpreterState *interp = tstate->interp;
PyMutex mutex = interp->audit_hooks_mutex;
PyMutex_Lock(&mutex);

if (interp->audit_hooks == NULL) {
interp->audit_hooks = PyList_New(0);
if (interp->audit_hooks == NULL) {
return NULL;
PyObject *new_list = PyList_New(0);
if (new_list == NULL) {
goto error;
}
/* Avoid having our list of hooks show up in the GC module */
PyObject_GC_UnTrack(interp->audit_hooks);
PyObject_GC_UnTrack(new_list);
FT_ATOMIC_STORE_PTR_RELEASE(interp->audit_hooks, new_list);
}

if (PyList_Append(interp->audit_hooks, hook) < 0) {
return NULL;
goto error;
}

PyMutex_Unlock(&mutex);
Py_RETURN_NONE;

error:
PyMutex_Unlock(&mutex);
return NULL;
}

/*[clinic input]
Expand Down
Loading
Loading