Skip to content

Commit

Permalink
Merge branch 'main' into pythongh-58058
Browse files Browse the repository at this point in the history
  • Loading branch information
savannahostrowski authored Sep 24, 2024
2 parents 7301095 + e256a75 commit 158fc56
Show file tree
Hide file tree
Showing 127 changed files with 1,958 additions and 930 deletions.
11 changes: 6 additions & 5 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ Python/compile.c @markshannon @iritkatriel
Python/assemble.c @markshannon @iritkatriel
Python/flowgraph.c @markshannon @iritkatriel
Python/instruction_sequence.c @iritkatriel
Python/ast_opt.c @isidentical
Python/bytecodes.c @markshannon
Python/optimizer*.c @markshannon
Python/optimizer_analysis.c @Fidget-Spinner
Expand Down Expand Up @@ -158,10 +157,12 @@ Include/internal/pycore_time.h @pganssle @abalkin
/Tools/cases_generator/ @markshannon

# AST
Python/ast.c @isidentical @JelleZijlstra
Parser/asdl.py @isidentical @JelleZijlstra
Parser/asdl_c.py @isidentical @JelleZijlstra
Lib/ast.py @isidentical @JelleZijlstra
Python/ast.c @isidentical @JelleZijlstra @eclips4
Python/ast_opt.c @isidentical @eclips4
Parser/asdl.py @isidentical @JelleZijlstra @eclips4
Parser/asdl_c.py @isidentical @JelleZijlstra @eclips4
Lib/ast.py @isidentical @JelleZijlstra @eclips4
Lib/test/test_ast/ @eclips4

# Mock
/Lib/unittest/mock.py @cjw296
Expand Down
11 changes: 10 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.10
rev: v0.6.7
hooks:
- id: ruff
name: Run Ruff (lint) on Doc/
Expand All @@ -10,6 +10,10 @@ repos:
name: Run Ruff (lint) on Lib/test/
args: [--exit-non-zero-on-fix]
files: ^Lib/test/
- id: ruff
name: Run Ruff (lint) on Tools/build/check_warnings.py
args: [--exit-non-zero-on-fix, --config=Tools/build/.ruff.toml]
files: ^Tools/build/check_warnings.py
- id: ruff
name: Run Ruff (lint) on Argument Clinic
args: [--exit-non-zero-on-fix, --config=Tools/clinic/.ruff.toml]
Expand All @@ -22,6 +26,11 @@ repos:
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.8.0
hooks:
- id: black
name: Run Black on Tools/build/check_warnings.py
files: ^Tools/build/check_warnings.py
language_version: python3.12
args: [--line-length=79]
- id: black
name: Run Black on Tools/jit/
files: ^Tools/jit/
Expand Down
23 changes: 12 additions & 11 deletions Android/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
# Python for Android

These instructions are only needed if you're planning to compile Python for
Android yourself. Most users should *not* need to do this. If you're looking to
use Python on Android, one of the following tools will provide a much more
approachable user experience:

* [Briefcase](https://briefcase.readthedocs.io), from the BeeWare project
* [Buildozer](https://buildozer.readthedocs.io), from the Kivy project
* [Chaquopy](https://chaquo.com/chaquopy/)
Android yourself. Most users should *not* need to do this. Instead, use one of
the tools listed in `Doc/using/android.rst`, which will provide a much easier
experience.


## Prerequisites
Expand Down Expand Up @@ -89,10 +85,10 @@ The test suite can be run on Linux, macOS, or Windows:
The test suite can usually be run on a device with 2 GB of RAM, but this is
borderline, so you may need to increase it to 4 GB. As of Android
Studio Koala, 2 GB is the default for all emulators, although the user interface
may indicate otherwise. The effective setting is `hw.ramSize` in
~/.android/avd/*.avd/hardware-qemu.ini, whereas Android Studio displays the
value from config.ini. Changing the value in Android Studio will update both of
these files.
may indicate otherwise. Locate the emulator's directory under `~/.android/avd`,
and find `hw.ramSize` in both config.ini and hardware-qemu.ini. Either set these
manually to the same value, or use the Android Studio Device Manager, which will
update both files.

Before running the test suite, follow the instructions in the previous section
to build the architecture you want to test. Then run the test script in one of
Expand Down Expand Up @@ -133,3 +129,8 @@ Every time you run `android.py test`, changes in pure-Python files in the
repository's `Lib` directory will be picked up immediately. Changes in C files,
and architecture-specific files such as sysconfigdata, will not take effect
until you re-run `android.py make-host` or `build`.


## Using in your own app

See `Doc/using/android.rst`.
32 changes: 31 additions & 1 deletion Doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,26 @@ venv:
echo "The venv has been created in the $(VENVDIR) directory"; \
fi

.PHONY: dist-no-html
dist-no-html: dist-text dist-pdf dist-epub dist-texinfo

.PHONY: dist
dist:
rm -rf dist
mkdir -p dist

$(MAKE) dist-html
$(MAKE) dist-text
$(MAKE) dist-pdf
$(MAKE) dist-epub
$(MAKE) dist-texinfo

.PHONY: dist-html
dist-html:
# archive the HTML
@echo "Building HTML..."
mkdir -p dist
rm -rf build/html
find dist -name 'python-$(DISTVERSION)-docs-html*' -exec rm -rf {} \;
$(MAKE) html
cp -pPR build/html dist/python-$(DISTVERSION)-docs-html
tar -C dist -cf dist/python-$(DISTVERSION)-docs-html.tar python-$(DISTVERSION)-docs-html
Expand All @@ -198,8 +211,13 @@ dist:
rm dist/python-$(DISTVERSION)-docs-html.tar
@echo "Build finished and archived!"

.PHONY: dist-text
dist-text:
# archive the text build
@echo "Building text..."
mkdir -p dist
rm -rf build/text
find dist -name 'python-$(DISTVERSION)-docs-text*' -exec rm -rf {} \;
$(MAKE) text
cp -pPR build/text dist/python-$(DISTVERSION)-docs-text
tar -C dist -cf dist/python-$(DISTVERSION)-docs-text.tar python-$(DISTVERSION)-docs-text
Expand All @@ -209,9 +227,13 @@ dist:
rm dist/python-$(DISTVERSION)-docs-text.tar
@echo "Build finished and archived!"

.PHONY: dist-pdf
dist-pdf:
# archive the A4 latex
@echo "Building LaTeX (A4 paper)..."
mkdir -p dist
rm -rf build/latex
find dist -name 'python-$(DISTVERSION)-docs-pdf*' -exec rm -rf {} \;
$(MAKE) latex PAPER=a4
# remove zip & bz2 dependency on all-pdf,
# as otherwise the full latexmk process is run twice.
Expand All @@ -222,16 +244,24 @@ dist:
cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-a4.tar.bz2
@echo "Build finished and archived!"

.PHONY: dist-epub
dist-epub:
# copy the epub build
@echo "Building EPUB..."
mkdir -p dist
rm -rf build/epub
rm -f dist/python-$(DISTVERSION)-docs.epub
$(MAKE) epub
cp -pPR build/epub/Python.epub dist/python-$(DISTVERSION)-docs.epub
@echo "Build finished and archived!"

.PHONY: dist-texinfo
dist-texinfo:
# archive the texinfo build
@echo "Building Texinfo..."
mkdir -p dist
rm -rf build/texinfo
find dist -name 'python-$(DISTVERSION)-docs-texinfo*' -exec rm -rf {} \;
$(MAKE) texinfo
$(MAKE) info --directory=build/texinfo
cp -pPR build/texinfo dist/python-$(DISTVERSION)-docs-texinfo
Expand Down
10 changes: 5 additions & 5 deletions Doc/c-api/monitoring.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. highlight:: c

.. _monitoring:
.. _c-api-monitoring:

Monitoring C API
================
Expand Down Expand Up @@ -141,18 +141,18 @@ would typically correspond to a python function.
to the base-2 logarithm of ``sys.monitoring.events.PY_START``.
``state_array`` is an array with a monitoring state entry for each event in
``event_types``, it is allocated by the user but populated by
``PyMonitoring_EnterScope`` with information about the activation state of
:c:func:`!PyMonitoring_EnterScope` with information about the activation state of
the event. The size of ``event_types`` (and hence also of ``state_array``)
is given in ``length``.
The ``version`` argument is a pointer to a value which should be allocated
by the user together with ``state_array`` and initialized to 0,
and then set only by ``PyMonitoring_EnterScope`` itelf. It allows this
and then set only by :c:func:`!PyMonitoring_EnterScope` itelf. It allows this
function to determine whether event states have changed since the previous call,
and to return quickly if they have not.
The scopes referred to here are lexical scopes: a function, class or method.
``PyMonitoring_EnterScope`` should be called whenever the lexical scope is
:c:func:`!PyMonitoring_EnterScope` should be called whenever the lexical scope is
entered. Scopes can be reentered, reusing the same *state_array* and *version*,
in situations like when emulating a recursive Python function. When a code-like's
execution is paused, such as when emulating a generator, the scope needs to
Expand Down Expand Up @@ -189,4 +189,4 @@ would typically correspond to a python function.
.. c:function:: int PyMonitoring_ExitScope(void)
Exit the last scope that was entered with ``PyMonitoring_EnterScope``.
Exit the last scope that was entered with :c:func:`!PyMonitoring_EnterScope`.
2 changes: 2 additions & 0 deletions Doc/c-api/time.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.. highlight:: c

.. _c-api-time:

PyTime C API
============

Expand Down
76 changes: 51 additions & 25 deletions Doc/deprecations/c-api-pending-removal-in-3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,64 @@ Pending Removal in Python 3.14

* Functions to configure Python's initialization, deprecated in Python 3.11:

* ``PySys_SetArgvEx()``: set :c:member:`PyConfig.argv` instead.
* ``PySys_SetArgv()``: set :c:member:`PyConfig.argv` instead.
* ``Py_SetProgramName()``: set :c:member:`PyConfig.program_name` instead.
* ``Py_SetPythonHome()``: set :c:member:`PyConfig.home` instead.
* :c:func:`!PySys_SetArgvEx()`:
Set :c:member:`PyConfig.argv` instead.
* :c:func:`!PySys_SetArgv()`:
Set :c:member:`PyConfig.argv` instead.
* :c:func:`!Py_SetProgramName()`:
Set :c:member:`PyConfig.program_name` instead.
* :c:func:`!Py_SetPythonHome()`:
Set :c:member:`PyConfig.home` instead.

The :c:func:`Py_InitializeFromConfig` API should be used with
:c:type:`PyConfig` instead.

* Global configuration variables:

* :c:var:`Py_DebugFlag`: use :c:member:`PyConfig.parser_debug` instead.
* :c:var:`Py_VerboseFlag`: use :c:member:`PyConfig.verbose` instead.
* :c:var:`Py_QuietFlag`: use :c:member:`PyConfig.quiet` instead.
* :c:var:`Py_InteractiveFlag`: use :c:member:`PyConfig.interactive` instead.
* :c:var:`Py_InspectFlag`: use :c:member:`PyConfig.inspect` instead.
* :c:var:`Py_OptimizeFlag`: use :c:member:`PyConfig.optimization_level` instead.
* :c:var:`Py_NoSiteFlag`: use :c:member:`PyConfig.site_import` instead.
* :c:var:`Py_BytesWarningFlag`: use :c:member:`PyConfig.bytes_warning` instead.
* :c:var:`Py_FrozenFlag`: use :c:member:`PyConfig.pathconfig_warnings` instead.
* :c:var:`Py_IgnoreEnvironmentFlag`: use :c:member:`PyConfig.use_environment` instead.
* :c:var:`Py_DontWriteBytecodeFlag`: use :c:member:`PyConfig.write_bytecode` instead.
* :c:var:`Py_NoUserSiteDirectory`: use :c:member:`PyConfig.user_site_directory` instead.
* :c:var:`Py_UnbufferedStdioFlag`: use :c:member:`PyConfig.buffered_stdio` instead.
* :c:var:`Py_HashRandomizationFlag`: use :c:member:`PyConfig.use_hash_seed`
* :c:var:`Py_DebugFlag`:
Use :c:member:`PyConfig.parser_debug` instead.
* :c:var:`Py_VerboseFlag`:
Use :c:member:`PyConfig.verbose` instead.
* :c:var:`Py_QuietFlag`:
Use :c:member:`PyConfig.quiet` instead.
* :c:var:`Py_InteractiveFlag`:
Use :c:member:`PyConfig.interactive` instead.
* :c:var:`Py_InspectFlag`:
Use :c:member:`PyConfig.inspect` instead.
* :c:var:`Py_OptimizeFlag`:
Use :c:member:`PyConfig.optimization_level` instead.
* :c:var:`Py_NoSiteFlag`:
Use :c:member:`PyConfig.site_import` instead.
* :c:var:`Py_BytesWarningFlag`:
Use :c:member:`PyConfig.bytes_warning` instead.
* :c:var:`Py_FrozenFlag`:
Use :c:member:`PyConfig.pathconfig_warnings` instead.
* :c:var:`Py_IgnoreEnvironmentFlag`:
Use :c:member:`PyConfig.use_environment` instead.
* :c:var:`Py_DontWriteBytecodeFlag`:
Use :c:member:`PyConfig.write_bytecode` instead.
* :c:var:`Py_NoUserSiteDirectory`:
Use :c:member:`PyConfig.user_site_directory` instead.
* :c:var:`Py_UnbufferedStdioFlag`:
Use :c:member:`PyConfig.buffered_stdio` instead.
* :c:var:`Py_HashRandomizationFlag`:
Use :c:member:`PyConfig.use_hash_seed`
and :c:member:`PyConfig.hash_seed` instead.
* :c:var:`Py_IsolatedFlag`: use :c:member:`PyConfig.isolated` instead.
* :c:var:`Py_LegacyWindowsFSEncodingFlag`: use :c:member:`PyPreConfig.legacy_windows_fs_encoding` instead.
* :c:var:`Py_LegacyWindowsStdioFlag`: use :c:member:`PyConfig.legacy_windows_stdio` instead.
* :c:var:`!Py_FileSystemDefaultEncoding`: use :c:member:`PyConfig.filesystem_encoding` instead.
* :c:var:`!Py_HasFileSystemDefaultEncoding`: use :c:member:`PyConfig.filesystem_encoding` instead.
* :c:var:`!Py_FileSystemDefaultEncodeErrors`: use :c:member:`PyConfig.filesystem_errors` instead.
* :c:var:`!Py_UTF8Mode`: use :c:member:`PyPreConfig.utf8_mode` instead. (see :c:func:`Py_PreInitialize`)
* :c:var:`Py_IsolatedFlag`:
Use :c:member:`PyConfig.isolated` instead.
* :c:var:`Py_LegacyWindowsFSEncodingFlag`:
Use :c:member:`PyPreConfig.legacy_windows_fs_encoding` instead.
* :c:var:`Py_LegacyWindowsStdioFlag`:
Use :c:member:`PyConfig.legacy_windows_stdio` instead.
* :c:var:`!Py_FileSystemDefaultEncoding`:
Use :c:member:`PyConfig.filesystem_encoding` instead.
* :c:var:`!Py_HasFileSystemDefaultEncoding`:
Use :c:member:`PyConfig.filesystem_encoding` instead.
* :c:var:`!Py_FileSystemDefaultEncodeErrors`:
Use :c:member:`PyConfig.filesystem_errors` instead.
* :c:var:`!Py_UTF8Mode`:
Use :c:member:`PyPreConfig.utf8_mode` instead.
(see :c:func:`Py_PreInitialize`)

The :c:func:`Py_InitializeFromConfig` API should be used with
:c:type:`PyConfig` instead.
35 changes: 21 additions & 14 deletions Doc/deprecations/c-api-pending-removal-in-3.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,26 @@ Pending Removal in Python 3.15
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

* The bundled copy of ``libmpdecimal``.
* :c:func:`PyImport_ImportModuleNoBlock`: use :c:func:`PyImport_ImportModule` instead.
* :c:func:`PyWeakref_GET_OBJECT`: use :c:func:`PyWeakref_GetRef` instead.
* :c:func:`PyWeakref_GetObject`: use :c:func:`PyWeakref_GetRef` instead.
* :c:type:`!Py_UNICODE_WIDE` type: use :c:type:`wchar_t` instead.
* :c:type:`Py_UNICODE` type: use :c:type:`wchar_t` instead.
* The :c:func:`PyImport_ImportModuleNoBlock`:
Use :c:func:`PyImport_ImportModule` instead.
* :c:func:`PyWeakref_GetObject` and :c:func:`PyWeakref_GET_OBJECT`:
Use :c:func:`PyWeakref_GetRef` instead.
* :c:type:`Py_UNICODE` type and the :c:macro:`!Py_UNICODE_WIDE` macro:
Use :c:type:`wchar_t` instead.
* Python initialization functions:

* :c:func:`PySys_ResetWarnOptions`: clear :data:`sys.warnoptions` and
:data:`!warnings.filters` instead.
* :c:func:`Py_GetExecPrefix`: get :data:`sys.exec_prefix` instead.
* :c:func:`Py_GetPath`: get :data:`sys.path` instead.
* :c:func:`Py_GetPrefix`: get :data:`sys.prefix` instead.
* :c:func:`Py_GetProgramFullPath`: get :data:`sys.executable` instead.
* :c:func:`Py_GetProgramName`: get :data:`sys.executable` instead.
* :c:func:`Py_GetPythonHome`: get :c:member:`PyConfig.home` or
the :envvar:`PYTHONHOME` environment variable instead.
* :c:func:`PySys_ResetWarnOptions`:
Clear :data:`sys.warnoptions` and :data:`!warnings.filters` instead.
* :c:func:`Py_GetExecPrefix`:
Get :data:`sys.exec_prefix` instead.
* :c:func:`Py_GetPath`:
Get :data:`sys.path` instead.
* :c:func:`Py_GetPrefix`:
Get :data:`sys.prefix` instead.
* :c:func:`Py_GetProgramFullPath`:
Get :data:`sys.executable` instead.
* :c:func:`Py_GetProgramName`:
Get :data:`sys.executable` instead.
* :c:func:`Py_GetPythonHome`:
Get :c:member:`PyConfig.home`
or the :envvar:`PYTHONHOME` environment variable instead.
Loading

0 comments on commit 158fc56

Please sign in to comment.