Skip to content

Commit

Permalink
Merge branch 'main' into count-branches
Browse files Browse the repository at this point in the history
  • Loading branch information
gvanrossum committed Sep 11, 2023
2 parents cb2cf12 + baa6dc8 commit d74670c
Show file tree
Hide file tree
Showing 129 changed files with 4,676 additions and 3,748 deletions.
7 changes: 5 additions & 2 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ freebsd_task:
sysctl_script:
- sysctl net.inet.tcp.blackhole=0
- sysctl net.inet.udp.blackhole=0
build_script:
configure_script:
- mkdir build
- cd build
- ../configure --with-pydebug
build_script:
- cd build
- make -j$(sysctl -n hw.ncpu)
pythoninfo_script:
- cd build && make pythoninfo
- cd build
- make pythoninfo
test_script:
- cd build
# dtrace fails to build on FreeBSD - see gh-73263
Expand Down
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,6 @@ Doc/c-api/stable.rst @encukou
/Tools/clinic/** @erlend-aasland @AlexWaygood
/Lib/test/test_clinic.py @erlend-aasland @AlexWaygood
Doc/howto/clinic.rst @erlend-aasland

# WebAssembly
/Tools/wasm/ @brettcannon
11 changes: 7 additions & 4 deletions Doc/library/itertools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1030,13 +1030,16 @@ The following recipes have a more mathematical flavor:
def sieve(n):
"Primes less than n."
# sieve(30) --> 2 3 5 7 11 13 17 19 23 29
if n > 2:
yield 2
start = 3
data = bytearray((0, 1)) * (n // 2)
data[:3] = 0, 0, 0
limit = math.isqrt(n) + 1
for p in compress(range(limit), data):
for p in iter_index(data, 1, start, limit):
yield from iter_index(data, 1, start, p*p)
data[p*p : n : p+p] = bytes(len(range(p*p, n, p+p)))
data[2] = 1
return iter_index(data, 1) if n > 2 else iter([])
start = p*p
yield from iter_index(data, 1, start)

def factor(n):
"Prime factors of n."
Expand Down
2 changes: 2 additions & 0 deletions Doc/library/types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,8 @@ Additional Utility Classes and Functions
However, for a structured record type use :func:`~collections.namedtuple`
instead.

:class:`!SimpleNamespace` objects are supported by :func:`copy.replace`.

.. versionadded:: 3.3

.. versionchanged:: 3.9
Expand Down
161 changes: 108 additions & 53 deletions Doc/whatsnew/3.12.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1274,13 +1274,19 @@ although there is currently no date scheduled for their removal.
Removed
=======

* ``asynchat`` and ``asyncore``: These two modules have been removed
asynchat and asyncore
---------------------

* These two modules have been removed
according to the schedule in :pep:`594`,
having been deprecated in Python 3.6.
Use :mod:`asyncio` instead.
(Contributed by Nikita Sobolev in :gh:`96580`.)

* :mod:`configparser`: Several names deprecated in the :mod:`configparser` way back in 3.2 have
configparser
------------

* Several names deprecated in the :mod:`configparser` way back in 3.2 have
been removed per :gh:`89336`:

* :class:`configparser.ParsingError` no longer has a ``filename`` attribute
Expand All @@ -1290,13 +1296,19 @@ Removed
* :class:`configparser.ConfigParser` no longer has a ``readfp`` method.
Use :meth:`~configparser.ConfigParser.read_file` instead.

* ``distutils``: Remove the ``distutils`` package. It was deprecated in Python 3.10 by
distutils
---------

* Remove the :py:mod:`!distutils` package. It was deprecated in Python 3.10 by
:pep:`632` "Deprecate distutils module". For projects still using
``distutils`` and cannot be updated to something else, the ``setuptools``
project can be installed: it still provides ``distutils``.
(Contributed by Victor Stinner in :gh:`92584`.)

* :mod:`ensurepip`: Remove the bundled setuptools wheel from :mod:`ensurepip`,
ensurepip
---------

* Remove the bundled setuptools wheel from :mod:`ensurepip`,
and stop installing setuptools in environments created by :mod:`venv`.

``pip (>= 22.1)`` does not require setuptools to be installed in the
Expand All @@ -1314,27 +1326,42 @@ Removed

(Contributed by Pradyun Gedam in :gh:`95299`.)

* :mod:`enum`: Remove ``EnumMeta.__getattr__``, which is no longer needed for
enum
----

* Remove :mod:`enum`'s ``EnumMeta.__getattr__``, which is no longer needed for
enum attribute access.
(Contributed by Ethan Furman in :gh:`95083`.)

* :mod:`ftplib`: Remove the ``FTP_TLS.ssl_version`` class attribute: use the
ftplib
------

* Remove :mod:`ftplib`'s ``FTP_TLS.ssl_version`` class attribute: use the
*context* parameter instead.
(Contributed by Victor Stinner in :gh:`94172`.)

* :mod:`gzip`: Remove the ``filename`` attribute of :class:`gzip.GzipFile`,
gzip
----

* Remove the ``filename`` attribute of :mod:`gzip`'s :class:`gzip.GzipFile`,
deprecated since Python 2.6, use the :attr:`~gzip.GzipFile.name` attribute
instead. In write mode, the ``filename`` attribute added ``'.gz'`` file
extension if it was not present.
(Contributed by Victor Stinner in :gh:`94196`.)

* :mod:`hashlib`: Remove the pure Python implementation of
hashlib
-------

* Remove the pure Python implementation of :mod:`hashlib`'s
:func:`hashlib.pbkdf2_hmac()`, deprecated in Python 3.10. Python 3.10 and
newer requires OpenSSL 1.1.1 (:pep:`644`): this OpenSSL version provides
a C implementation of :func:`~hashlib.pbkdf2_hmac()` which is faster.
(Contributed by Victor Stinner in :gh:`94199`.)

* :mod:`importlib`: Many previously deprecated cleanups in :mod:`importlib` have now been
importlib
---------

* Many previously deprecated cleanups in :mod:`importlib` have now been
completed:

* References to, and support for :meth:`!module_repr()` has been removed.
Expand All @@ -1350,10 +1377,13 @@ Removed
* ``importlib.abc.Finder``, ``pkgutil.ImpImporter``, and ``pkgutil.ImpLoader``
have been removed. (Contributed by Barry Warsaw in :gh:`98040`.)

* The :mod:`!imp` module has been removed. (Contributed by Barry Warsaw in
:gh:`98040`.)
imp
---

* Replace removed :mod:`!imp` functions with :mod:`importlib` functions:
* The :mod:`!imp` module has been removed. (Contributed by Barry Warsaw in
:gh:`98040`.)

* Replace removed :mod:`!imp` functions with :mod:`importlib` functions:

================================= =======================================
imp importlib
Expand All @@ -1370,7 +1400,7 @@ Removed
``imp.source_from_cache()`` :func:`importlib.util.source_from_cache`
================================= =======================================

* Replace ``imp.load_source()`` with::
* Replace ``imp.load_source()`` with::

import importlib.util
import importlib.machinery
Expand All @@ -1385,28 +1415,34 @@ Removed
loader.exec_module(module)
return module

* Removed :mod:`!imp` functions and attributes with no replacements:
* Removed :mod:`!imp` functions and attributes with no replacements:

* undocumented functions:

* undocumented functions:
* ``imp.init_builtin()``
* ``imp.load_compiled()``
* ``imp.load_dynamic()``
* ``imp.load_package()``

* ``imp.init_builtin()``
* ``imp.load_compiled()``
* ``imp.load_dynamic()``
* ``imp.load_package()``
* ``imp.lock_held()``, ``imp.acquire_lock()``, ``imp.release_lock()``:
the locking scheme has changed in Python 3.3 to per-module locks.
* ``imp.find_module()`` constants: ``SEARCH_ERROR``, ``PY_SOURCE``,
``PY_COMPILED``, ``C_EXTENSION``, ``PY_RESOURCE``, ``PKG_DIRECTORY``,
``C_BUILTIN``, ``PY_FROZEN``, ``PY_CODERESOURCE``, ``IMP_HOOK``.

* ``imp.lock_held()``, ``imp.acquire_lock()``, ``imp.release_lock()``:
the locking scheme has changed in Python 3.3 to per-module locks.
* ``imp.find_module()`` constants: ``SEARCH_ERROR``, ``PY_SOURCE``,
``PY_COMPILED``, ``C_EXTENSION``, ``PY_RESOURCE``, ``PKG_DIRECTORY``,
``C_BUILTIN``, ``PY_FROZEN``, ``PY_CODERESOURCE``, ``IMP_HOOK``.
io
--

* :mod:`io`: Remove ``io.OpenWrapper`` and ``_pyio.OpenWrapper``, deprecated in Python
* Remove :mod:`io`'s ``io.OpenWrapper`` and ``_pyio.OpenWrapper``, deprecated in Python
3.10: just use :func:`open` instead. The :func:`open` (:func:`io.open`)
function is a built-in function. Since Python 3.10, :func:`!_pyio.open` is
also a static method.
(Contributed by Victor Stinner in :gh:`94169`.)

* :mod:`locale`: Remove the :func:`!locale.format` function, deprecated in Python 3.7:
locale
------

* Remove :mod:`locale`'s :func:`!locale.format` function, deprecated in Python 3.7:
use :func:`locale.format_string` instead.
(Contributed by Victor Stinner in :gh:`94226`.)

Expand All @@ -1418,7 +1454,10 @@ Removed

.. _aiosmtpd: https://pypi.org/project/aiosmtpd/

* :mod:`sqlite3`: The following undocumented :mod:`sqlite3` features, deprecated in Python
sqlite3
-------

* The following undocumented :mod:`sqlite3` features, deprecated in Python
3.10, are now removed:

* ``sqlite3.enable_shared_cache()``
Expand All @@ -1434,30 +1473,34 @@ Removed

(Contributed by Erlend E. Aasland in :gh:`92548`.)

* :mod:`ssl`:
ssl
---

* Remove the :func:`!ssl.RAND_pseudo_bytes` function, deprecated in Python 3.6:
use :func:`os.urandom` or :func:`ssl.RAND_bytes` instead.
(Contributed by Victor Stinner in :gh:`94199`.)
* Remove :mod:`ssl`'s :func:`!ssl.RAND_pseudo_bytes` function, deprecated in Python 3.6:
use :func:`os.urandom` or :func:`ssl.RAND_bytes` instead.
(Contributed by Victor Stinner in :gh:`94199`.)

* Remove the :func:`!ssl.match_hostname` function.
It was deprecated in Python 3.7. OpenSSL performs
hostname matching since Python 3.7, Python no longer uses the
:func:`!ssl.match_hostname` function.
(Contributed by Victor Stinner in :gh:`94199`.)

* Remove the :func:`!ssl.match_hostname` function.
It was deprecated in Python 3.7. OpenSSL performs
hostname matching since Python 3.7, Python no longer uses the
:func:`!ssl.match_hostname` function.
(Contributed by Victor Stinner in :gh:`94199`.)
* Remove the :func:`!ssl.wrap_socket` function, deprecated in Python 3.7:
instead, create a :class:`ssl.SSLContext` object and call its
:class:`ssl.SSLContext.wrap_socket` method. Any package that still uses
:func:`!ssl.wrap_socket` is broken and insecure. The function neither sends a
SNI TLS extension nor validates server hostname. Code is subject to `CWE-295
<https://cwe.mitre.org/data/definitions/295.html>`_: Improper Certificate
Validation.
(Contributed by Victor Stinner in :gh:`94199`.)

* Remove the :func:`!ssl.wrap_socket` function, deprecated in Python 3.7:
instead, create a :class:`ssl.SSLContext` object and call its
:class:`ssl.SSLContext.wrap_socket` method. Any package that still uses
:func:`!ssl.wrap_socket` is broken and insecure. The function neither sends a
SNI TLS extension nor validates server hostname. Code is subject to `CWE-295
<https://cwe.mitre.org/data/definitions/295.html>`_: Improper Certificate
Validation.
(Contributed by Victor Stinner in :gh:`94199`.)
unittest
--------

* :mod:`unittest`: Removed many old deprecated :mod:`unittest` features:
* Removed many old deprecated :mod:`unittest` features:

- A number of :class:`~unittest.TestCase` method aliases:
* A number of :class:`~unittest.TestCase` method aliases:

============================ =============================== ===============
Deprecated alias Method Name Deprecated in
Expand All @@ -1482,33 +1525,45 @@ Removed
You can use https://github.com/isidentical/teyit to automatically modernise
your unit tests.

- Undocumented and broken :class:`~unittest.TestCase` method
* Undocumented and broken :class:`~unittest.TestCase` method
``assertDictContainsSubset`` (deprecated in Python 3.2).

- Undocumented :meth:`TestLoader.loadTestsFromModule
* Undocumented :meth:`TestLoader.loadTestsFromModule
<unittest.TestLoader.loadTestsFromModule>` parameter *use_load_tests*
(deprecated and ignored since Python 3.2).

- An alias of the :class:`~unittest.TextTestResult` class:
* An alias of the :class:`~unittest.TextTestResult` class:
``_TextTestResult`` (deprecated in Python 3.2).

(Contributed by Serhiy Storchaka in :issue:`45162`.)

* :mod:`webbrowser`: Remove support for obsolete browsers from :mod:`webbrowser`.
webbrowser
----------

* Remove support for obsolete browsers from :mod:`webbrowser`.
Removed browsers include: Grail, Mosaic, Netscape, Galeon, Skipstone,
Iceape, Firebird, and Firefox versions 35 and below (:gh:`102871`).

* :mod:`xml.etree.ElementTree`: Remove the ``ElementTree.Element.copy()`` method of the
xml.etree.ElementTree
---------------------

* Remove the ``ElementTree.Element.copy()`` method of the
pure Python implementation, deprecated in Python 3.10, use the
:func:`copy.copy` function instead. The C implementation of :mod:`xml.etree.ElementTree`
has no ``copy()`` method, only a ``__copy__()`` method.
(Contributed by Victor Stinner in :gh:`94383`.)

* :mod:`zipimport`: Remove ``find_loader()`` and ``find_module()`` methods,
zipimport
---------

* Remove :mod:`zipimport`'s ``find_loader()`` and ``find_module()`` methods,
deprecated in Python 3.10: use the ``find_spec()`` method instead. See
:pep:`451` for the rationale.
(Contributed by Victor Stinner in :gh:`94379`.)

Others
------

* Removed the ``suspicious`` rule from the documentation Makefile, and
removed ``Doc/tools/rstlint.py``, both in favor of `sphinx-lint
<https://github.com/sphinx-contrib/sphinx-lint>`_.
Expand Down Expand Up @@ -1599,7 +1654,7 @@ Changes in the Python API
functions is now changed due to the changes introduced in :pep:`701`. This
means that ``STRING`` tokens are not emitted any more for f-strings and the
tokens described in :pep:`701` are now produced instead: ``FSTRING_START``,
``FSRING_MIDDLE`` and ``FSTRING_END`` are now emitted for f-string "string"
``FSTRING_MIDDLE`` and ``FSTRING_END`` are now emitted for f-string "string"
parts in addition to the appropriate tokens for the tokenization in the
expression components. For example for the f-string ``f"start {1+1} end"``
the old version of the tokenizer emitted::
Expand Down
2 changes: 1 addition & 1 deletion Grammar/python.gram
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,7 @@ invalid_expression:
_PyPegen_check_legacy_stmt(p, a) ? NULL : p->tokens[p->mark-1]->level == 0 ? NULL :
RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "invalid syntax. Perhaps you forgot a comma?") }
| a=disjunction 'if' b=disjunction !('else'|':') { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "expected 'else' after 'if' expression") }
| a='lambda' [lambda_params] b=':' &(FSTRING_MIDDLE | fstring_replacement_field) {
| a='lambda' [lambda_params] b=':' &FSTRING_MIDDLE {
RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "f-string: lambda expressions are not allowed without parentheses") }

invalid_named_expression(memo):
Expand Down
1 change: 0 additions & 1 deletion Include/cpython/import.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ struct _frozen {
const unsigned char *code;
int size;
int is_package;
PyObject *(*get_code)(void);
};

/* Embedding apps may change this pointer to point to their favorite
Expand Down
19 changes: 9 additions & 10 deletions Include/cpython/pystate.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,18 +194,17 @@ struct _ts {

};

/* WASI has limited call stack. Python's recursion limit depends on code
layout, optimization, and WASI runtime. Wasmtime can handle about 700
recursions, sometimes less. 500 is a more conservative limit. */
#ifndef C_RECURSION_LIMIT
# ifdef __wasi__
# define C_RECURSION_LIMIT 500
# else
// This value is duplicated in Lib/test/support/__init__.py
# define C_RECURSION_LIMIT 1500
# endif
#ifdef __wasi__
// WASI has limited call stack. Python's recursion limit depends on code
// layout, optimization, and WASI runtime. Wasmtime can handle about 700
// recursions, sometimes less. 500 is a more conservative limit.
# define Py_C_RECURSION_LIMIT 500
#else
// This value is duplicated in Lib/test/support/__init__.py
# define Py_C_RECURSION_LIMIT 1500
#endif


/* other API */

/* Similar to PyThreadState_Get(), but don't issue a fatal error
Expand Down
Loading

0 comments on commit d74670c

Please sign in to comment.