Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
9a8714d
bpo-36384: Leading zeros in IPv4 addresses are no longer tolerated (G…
miss-islington May 2, 2021
d015d59
[3.9] gh-97514: Don't use Linux abstract sockets for multiprocessing …
miss-islington Oct 28, 2022
f75758e
[3.9] gh-107845: Fix symlink handling for tarfile.data_filter (GH-107…
encukou Aug 22, 2023
d4efb30
[3.9] gh-101180: Fix a bug where iso2022_jp_3 and iso2022_jp_2004 cod…
ambv Nov 6, 2023
bed6f1e
[3.9] gh-91133: tempfile.TemporaryDirectory: fix symlink bug in clean…
serhiy-storchaka Jan 17, 2024
c35e547
[3.9] gh-109858: Protect zipfile from "quoted-overlap" zipbomb (GH-11…
miss-islington Jan 17, 2024
793ad24
[3.9] gh-113659: Skip hidden .pth files (GH-113660) (GH-114146)
serhiy-storchaka Jan 17, 2024
95b8788
[3.9] gh-118486: Support mkdir(mode=0o700) on Windows (GH-118488) (GH…
zooba May 24, 2024
39dab4f
[3.9] gh-122133: Authenticate socket connection for `socket.socketpai…
miss-islington Jul 30, 2024
542ae1b
[3.9] gh-122133: Rework pure Python socketpair tests to avoid use of …
miss-islington Aug 2, 2024
fb55ab7
[3.9] gh-121650: Encode newlines in headers, and verify headers are s…
ambv Sep 4, 2024
f82d701
[3.9] gh-103848: Adds checks to ensure that bracketed hosts found by …
vstinner Dec 2, 2024
ea96755
[3.9] gh-122792: Make IPv4-mapped IPv6 address properties consistent …
ambv Dec 3, 2024
5c2ea55
[3.9] gh-119511: Fix a potential denial of service in imaplib (GH-119…
hugovk Feb 19, 2025
e78171c
[3.9] gh-105704: Disallow square brackets (`[` and `]`) in domain nam…
miss-islington Feb 19, 2025
525a263
[3.9] gh-121284: Fix email address header folding with parsed encoded…
encukou Apr 3, 2025
856d6cf
[3.9] gh-80222: Fix email address header folding with long quoted-str…
brianschubert Jun 2, 2025
a10ddaa
[3.7] gh-133767: Fix use-after-free in the unicode-escape decoder wit…
serhiy-storchaka Oct 29, 2026
f36450d
3.7.17.x: update testPrivateNetworks for the CVE-2024-4032 fix
icanhasmath Oct 29, 2026
2354bae
[3.9] gh-128840: Limit the number of parts in IPv6 address parsing (G…
miss-islington Jun 3, 2025
fe7e9e6
[3.9] gh-128840: Fix parsing long IPv6 addresses with embedded IPv4 a…
miss-islington Jun 3, 2025
f0f9c5b
[3.7] gh-135034: Normalize link targets in tarfile, add `os.path.real…
Yhg1s Oct 29, 2026
de950ea
bpo-12800: tarfile: Restore fix from 011525ee9 (GH-21409)
miss-islington Nov 25, 2020
0c64d04
[3.9] gh-135462: Fix quadratic complexity in processing special input…
serhiy-storchaka Jul 3, 2025
1b77d81
[3.9] gh-102555: Fix comment parsing in HTMLParser according to the H…
miss-islington Jul 12, 2025
84f0d1d
[3.9] gh-135661: Fix parsing start and end tags in HTMLParser accordi…
miss-islington Jul 12, 2025
56eebfb
[3.9] gh-135661: Fix parsing attributes with whitespaces around the "…
miss-islington Jul 22, 2025
0e237d8
[3.9] gh-130577: tarfile now validates archives to ensure member offs…
vstinner Sep 13, 2025
3aa6279
[3.9] gh-118350: Fix support of elements "textarea" and "title" in HT…
serhiy-storchaka Sep 13, 2025
6f837c0
[3.9] gh-139400: Make sure that parent parsers outlive their subparse…
hartwork Oct 7, 2025
bc5dc09
[3.9] gh-115398: Expose Expat >=2.6.0 reparse deferral API (CVE-2023-…
hartwork Mar 6, 2024
d1c766f
[3.9] gh-117187: Fix XML tests for vanilla Expat <2.6.0 (GH-117203) (…
miss-islington Mar 27, 2024
22e0603
[3.9] gh-121227: Disallow setting an empty list for NPN (GH-137161)
StanFromIreland Oct 7, 2025
e7e7778
[3.9] gh-135661: Fix CDATA section parsing in HTMLParser (GH-135665) …
miss-islington Oct 7, 2025
b5d3f7c
[3.9] gh-139700: Check consistency of the zip64 end of central direct…
miss-islington Oct 7, 2025
221e4e6
[3.9] gh-136063: fix quadratic-complexity parsing in `email.message._…
miss-islington Oct 31, 2025
330e6c3
[3.9] gh-136065: Fix quadratic complexity in os.path.expandvars() (GH…
ambv Oct 31, 2025
752f27d
[3.10] gh-143916: Reject control characters in wsgiref.headers.Headers
gpshead Jan 20, 2026
a7400ea
[3.10] gh-143925: Reject control characters in data: URL mediatypes (…
sethmlarson Jan 25, 2026
add92c6
[3.10] gh-143919: Reject control characters in http cookies (#144094)
sethmlarson Jan 25, 2026
b759ad0
[3.10] gh-144125: email: verify headers are sound in BytesGenerator (…
miss-islington Jan 25, 2026
233f69f
[3.10] gh-119452: Fix a potential virtual memory allocation denial of…
miss-islington Jan 25, 2026
2b8012f
[3.10] gh-142145: Remove quadratic behavior in node ID cache clearing…
miss-islington Jan 25, 2026
567a59c
[3.10] gh-119451: Fix a potential denial of service in http.client (G…
miss-islington Jan 25, 2026
76668b2
[3.10] gh-119342: Fix a potential denial of service in plistlib (GH-1…
serhiy-storchaka Mar 2, 2026
84df321
[3.10] gh-144833: Fix use-after-free in SSL module when SSL_new() fai…
miss-islington Mar 2, 2026
a5342bc
[3.10] gh-143916: Allow HTAB in wsgiref header values (#145140)
miss-islington Mar 2, 2026
a124829
[3.10] gh-143935: Email preserve parens when folding comments (GH-143…
edgarrmondragon Mar 2, 2026
500cd3c
[3.10] gh-143930: Reject leading dashes in webbrowser URLs (GH-143931…
tomcruiseqi Mar 24, 2026
7396392
[3.10] gh-143930: Tweak the exception message and increase test cover…
miss-islington Apr 3, 2026
6f4e61a
[3.10] gh-137586: Open external osascript program with absolute path …
miss-islington Apr 7, 2026
e440d80
[3.10] gh-145986: Avoid unbound C recursion in `conv_content_model` i…
StanFromIreland Apr 8, 2026
45cb573
[3.10] gh-148169: Fix webbrowser `%action` substitution bypass of das…
StanFromIreland Apr 13, 2026
9616e26
[3.10] gh-148395: Fix a possible UAF in `{LZMA,BZ2}Decompressor` (GH-…
StanFromIreland Apr 13, 2026
82d7aac
[3.10] gh-141707: Skip TarInfo DIRTYPE normalization during GNU long …
miss-islington Apr 30, 2026
1f51b59
[3.10] gh-144370: Disallow usage of control characters in status in w…
vstinner May 17, 2026
27e0b7f
[3.10] gh-151981: Make tarfile._Stream.seek break at EOF (GH-151982) …
miss-islington Jun 27, 2026
e0a2872
[3.10] gh-87451: Apply CVE-2021-4189 PASV fix to ftplib.ftpcp() (GH-1…
miss-islington Jun 27, 2026
56dbc23
[3.10] gh-146211: Reject CR/LF in HTTP tunnel request headers (GH-146…
sethmlarson Jun 27, 2026
a279f93
[3.10] gh-145599, CVE 2026-3644: Reject control characters in `http.c…
vstinner Jun 27, 2026
7be289b
[3.10] gh-150743: Limit trailer lines and interim responses read by h…
miss-islington Jun 28, 2026
7e47422
[3.10] gh-150599: Prevent bz2 decompressor reuse after errors (#15060…
StanFromIreland Jul 4, 2026
2760765
[3.10] gh-149486: tarfile.data_filter: validate written link target (…
StanFromIreland Jul 6, 2026
61479c3
[3.10] gh-151987: Pass filter_function to TarFile._extract_one() duri…
miss-islington Jul 11, 2026
f221606
[3.10] gh-153438: Update NuGet download URL (GH-153482) (GH-153515) (…
miss-islington Aug 10, 2026
6f93747
[3.10] gh-146581: Fix vulnerability in shutil.unpack_archive() for ZI…
miss-islington Aug 10, 2026
369975e
[3.10] gh-100372: Use BIO_eof to detect EOF for SSL_FILETYPE_ASN1 (GH…
miss-islington Aug 10, 2026
32e7e3d
[3.10] gh-149079: Fix O(n^2) canonical ordering in unicodedata.normal…
miss-islington Aug 10, 2026
7d7ab94
[3.10] gh-109638: Fix exponential time in csv.Sniffer for doubled quo…
miss-islington Aug 10, 2026
b106739
[3.10] gh-152674: Avoid quadratic behavior in xml.etree.ElementPath i…
miss-islington Aug 10, 2026
97d3890
[3.10] gh-153030: Fix quadratic complexity in incremental parsing in …
serhiy-storchaka Aug 10, 2026
d732baf
[3.10] gh-151558: Fix symlink escape via `tarfile` hardlink-extractio…
StanFromIreland Aug 10, 2026
d050ade
[3.10] gh-146333: Fix quadratic regex backtracking in configparser op…
encukou Aug 10, 2026
effdee6
[3.10] gh-143927: Normalize all line endings (CR, CRLF, and LF) in co…
miss-islington Aug 10, 2026
2239271
[3.10] gh-98820: Fix quadratic time in csv.Sniffer for quoted fields …
serhiy-storchaka Aug 11, 2026
fc065e7
[3.10] gh-149018: Use `XML_SetHashSalt16Bytes` in `pyexpat`/`_element…
StanFromIreland Aug 13, 2026
5bc037f
[3.10] gh-157190: Fix tarfile `data`/`tar` filter bypass via hard lin…
freakboy3742 Sep 29, 2026
c02dd2c
[3.10] gh-155694: Scope HTTPPasswordMgr credentials by URL scheme (GH…
miss-islington Oct 1, 2026
3f62699
[3.10] gh-156293: Use-after-free for server-side SSLContext with sni_…
gpshead Oct 1, 2026
5a84184
[3.10] gh-158446: Reject float format precision near INT_MAX (GH-1584…
gpshead Oct 1, 2026
5089a20
[3.10] gh-155292: Don't consider Unicode codepoint attributes outside…
encukou Oct 1, 2026
46ef304
[3.10] gh-156353: Fix configparser space delimiter parsing (GH-156382…
miss-islington Oct 1, 2026
7d51e6e
[3.10] gh-157265: tarfile: Honor None result of filter for link fallb…
miss-islington Oct 1, 2026
0dcbc3c
[3.10] gh-156002: Bound zipfile decompression for bzip2/LZMA/Zstandar…
miss-islington Oct 1, 2026
6328f18
[3.10] gh-155999: `tarfile`: handle a member that leaves the destinat…
StanFromIreland Oct 1, 2026
045c5f0
[3.10] gh-156793: Validate SSLContext.wrap_bio() parameters like wrap…
Yhg1s Oct 1, 2026
8181aac
[3.11] gh-87720 Fix additional header refolding-quoting edge case (GH…
miss-islington Oct 25, 2026
2fc7606
[3.11] gh-159428: Don't read mimetypes.knownfiles by default on Windo…
cjames23 Oct 25, 2026
43f9a4e
[3.11] gh-160300: Reject cookies with a negative version in http.cook…
miss-islington Oct 25, 2026
3e69c96
[3.11] gh-160097: Reject links replacing the destination in `tarfile.…
miss-islington Oct 25, 2026
70c0a71
[3.11] gh-160040: Distrust compromised eMudhra intermediate CA keys (…
gpshead Oct 24, 2026
4099c75
3.9.25.x: catch socket.timeout in the gh-119452 CGI read loop
icanhasmath Oct 27, 2026
75a1897
[3.13] gh-143921: Reject NUL, CR and LF in IMAP commands (GH-143922, …
serhiy-storchaka Jul 7, 2026
0e6a15e
gh-143923: Reject control characters in POP3 commands
sethmlarson Jan 20, 2026
3948f7f
gh-150751: validate http.client Content-Length and chunk-size (GH-150…
metsw24-max Oct 8, 2026
1931dd4
gh-150751: Ignore optional whitespace around Content-Length in http.c…
danilablagorodniy37 Oct 14, 2026
003c98d
[3.11] bpo-43153: Don't mask `PermissionError` with `NotADirectoryErr…
miss-islington Dec 5, 2023
0ba42d4
[3.11] gh-79325: Fix recursion error in TemporaryDirectory cleanup on…
serhiy-storchaka Dec 7, 2023
1dfbe1a
[3.10] gh-157579: Fix race condition in the cleanup of tempfile.Tempo…
icanhasmath Oct 28, 2026
49a8e4c
[3.9] gh-131261: Update libexpat to 2.7.0 (CVE-2024-8176) (GH-131272)…
sethmlarson Apr 3, 2025
7f28c20
[3.9] gh-131809: Upgrade vendored expat to 2.7.1 (GH-132192) (#132242)
sethmlarson Apr 8, 2025
187ad54
[3.9] gh-138998: Upgrade vendored expat to 2.7.2 (GH-138999) (GH-139055)
StanFromIreland Oct 7, 2025
cc85809
[3.9] gh-139312: Update bundled libexpat to 2.7.3 (GH-139319) (GH-139…
miss-islington Oct 7, 2025
efa5c0c
[3.10] gh-144363: Update bundled libexpat to 2.7.4 (GH-144365) (#144515)
StanFromIreland Mar 2, 2026
33103ef
[3.10] gh-146083: Upgrade bundled Expat to 2.7.5 (GH-146085) (#146608)
StanFromIreland Apr 8, 2026
68fdda1
[3.10] gh-149017: Upgrade bundled Expat to 2.8.0 (#149020) (#149075)
StanFromIreland Aug 10, 2026
5e62684
[3.10] gh-149698: Update bundled expat to 2.8.1 (GH-149699) (#155551)
StanFromIreland Aug 11, 2026
112391d
[3.10] gh-152216: Update bundled expat to 2.8.2 (GH-152234) (#155577)
StanFromIreland Aug 11, 2026
782afe8
[3.10] gh-155558: Update bundled Expat to 2.8.3 (GH-155560) (#155618)
StanFromIreland Aug 13, 2026
bad967a
[3.10] gh-156723: Update bundled libexpat to version 2.8.4 (GH-156724…
StanFromIreland Sep 27, 2026
fd6b9d8
[3.10] gh-157953: Update bundled Expat to 2.8.5 (GH-157957) (#158327)
StanFromIreland Oct 1, 2026
e4a79e3
[3.11] gh-158876: Update bundled Expat to 2.9.0 (GH-158881) (#160261)
StanFromIreland Oct 25, 2026
2cd474f
bpo-42825: Enable /OPT:REF (GH-24098)
Austin-Lamb Feb 19, 2021
b2ea02b
Add parseaddr Unicode regression test (CVE-2023-27043 follow-up)
icanhasmath Apr 21, 2026
71908d7
Upgrade bundled setuptools to 68.0.0.2 (3.7.17.x)
icanhasmath Oct 29, 2026
927b5ce
Upgrade bundled pip to 24.0.post3 (3.7.17.x)
icanhasmath Oct 29, 2026
2639f59
3.7.17.x: link z.lib from Platform shared/zlib 1.3.2 on Windows
icanhasmath Oct 29, 2026
5809b6c
3.7.17.x: skip NoneInfoExtractTests where 3.7's Path.glob() fails
icanhasmath Oct 29, 2026
3c3d071
3.7.17.x: resolve symbolic links in ntpath.realpath (bpo-9949)
icanhasmath Oct 29, 2026
855e5c8
Update version to 3.7.17.8 and add release notes
icanhasmath Oct 29, 2026
ec96847
Bundle pip 24.0.post4 (3.7.17.x)
icanhasmath Oct 29, 2026
e1800cc
Bundle setuptools 68.0.0.post3 (3.7.17.x)
icanhasmath Oct 29, 2026
30c75a3
[3.9] gh-137836: Support more RAWTEXT and PLAINTEXT elements in HTMLP…
serhiy-storchaka Oct 31, 2025
ebd2dab
[3.9] gh-120384: gh-120298: Fix array-out-of-bounds & use after free …
miss-islington Oct 31, 2025
4dbfe1e
[3.9] gh-134062: Fix hash collisions in IPv4Network and IPv6Network (…
miss-islington Jun 2, 2025
43e3475
3.7.17.x: bpo-9949 test follow-ups for the resolving ntpath.realpath
icanhasmath Oct 29, 2026
69ab1c8
3.7.17.x: rename the newer Expat API symbols in pyexpatns.h
icanhasmath Oct 29, 2026
aa21066
3.7.17.x: docs: give backported changes 3.7.17.8 version notes
icanhasmath Oct 29, 2026
83ed748
3.7.17.x: release notes for the added fixes; gh-97514 does not apply
icanhasmath Oct 29, 2026
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
4 changes: 4 additions & 0 deletions Doc/library/asyncio-eventloop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,10 @@ Opening network connections
.. versionchanged:: 3.5

Added support for SSL/TLS in :class:`ProactorEventLoop`.
.. versionchanged:: 3.7.17.8
Raises a ``DeprecationWarning`` if ``ssl.check_hostname`` is ``True``
and ``server_hostname`` is not supplied. In Python 3.13 and
later a ``ValueError`` is raised instead.

.. seealso::

Expand Down
6 changes: 6 additions & 0 deletions Doc/library/email.errors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ The following exception classes are defined in the :mod:`email.errors` module:
:class:`~email.mime.image.MIMEImage`).


.. exception:: HeaderWriteError()

Raised when an error occurs when the :mod:`~email.generator` outputs
headers.


Here is the list of the defects that the :class:`~email.parser.FeedParser`
can find while parsing messages. Note that the defects are added to the message
where the problem was found, so for example, if a message nested inside a
Expand Down
18 changes: 18 additions & 0 deletions Doc/library/email.policy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,24 @@ added matters. To illustrate::

.. versionadded:: 3.6


.. attribute:: verify_generated_headers

If ``True`` (the default), the generator will raise
:exc:`~email.errors.HeaderWriteError` instead of writing a header
that is improperly folded or delimited, such that it would
be parsed as multiple headers or joined with adjacent data.
Such headers can be generated by custom header classes or bugs
in the ``email`` module.

As it's a security feature, this defaults to ``True`` even in the
:class:`~email.policy.Compat32` policy.
For backwards compatible, but unsafe, behavior, it must be set to
``False`` explicitly.

.. versionadded:: 3.7.17.8


The following :class:`Policy` method is intended to be called by code using
the email library to create policy instances with custom settings:

Expand Down
33 changes: 20 additions & 13 deletions Doc/library/html.parser.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@
This module defines a class :class:`HTMLParser` which serves as the basis for
parsing text files formatted in HTML (HyperText Mark-up Language) and XHTML.

.. class:: HTMLParser(*, convert_charrefs=True)
.. class:: HTMLParser(*, convert_charrefs=True, scripting=False)

Create a parser instance able to parse invalid markup.

If *convert_charrefs* is ``True`` (the default), all character
references (except the ones in ``script``/``style`` elements) are
If *convert_charrefs* is true (the default), all character
references (except the ones in elements like ``script`` and ``style``) are
automatically converted to the corresponding Unicode characters.

If *scripting* is false (the default), the content of the ``noscript``
element is parsed normally; if it's true, it's returned as is without
being parsed.

An :class:`.HTMLParser` instance is fed HTML data and calls handler methods
when start tags, end tags, text, comments, and other markup elements are
encountered. The user should subclass :class:`.HTMLParser` and override its
Expand All @@ -37,6 +41,9 @@ parsing text files formatted in HTML (HyperText Mark-up Language) and XHTML.
.. versionchanged:: 3.5
The default value for argument *convert_charrefs* is now ``True``.

.. versionchanged:: 3.7.17.8
Added the *scripting* parameter.


Example HTML Parser Application
-------------------------------
Expand Down Expand Up @@ -159,24 +166,24 @@ implementations do nothing (except for :meth:`~HTMLParser.handle_startendtag`):
.. method:: HTMLParser.handle_data(data)

This method is called to process arbitrary data (e.g. text nodes and the
content of ``<script>...</script>`` and ``<style>...</style>``).
content of elements like ``script`` and ``style``).


.. method:: HTMLParser.handle_entityref(name)

This method is called to process a named character reference of the form
``&name;`` (e.g. ``&gt;``), where *name* is a general entity reference
(e.g. ``'gt'``). This method is never called if *convert_charrefs* is
``True``.
(e.g. ``'gt'``).
This method is only called if *convert_charrefs* is false.


.. method:: HTMLParser.handle_charref(name)

This method is called to process decimal and hexadecimal numeric character
references of the form ``&#NNN;`` and ``&#xNNN;``. For example, the decimal
equivalent for ``&gt;`` is ``&#62;``, whereas the hexadecimal is ``&#x3E;``;
in this case the method will receive ``'62'`` or ``'x3E'``. This method
is never called if *convert_charrefs* is ``True``.
in this case the method will receive ``'62'`` or ``'x3E'``.
This method is only called if *convert_charrefs* is false.


.. method:: HTMLParser.handle_comment(data)
Expand Down Expand Up @@ -284,8 +291,8 @@ Parsing an element with a few attributes and a title::
Data : Python
End tag : h1

The content of ``script`` and ``style`` elements is returned as is, without
further parsing::
The content of elements like ``script`` and ``style`` is returned as is,
without further parsing::

>>> parser.feed('<style type="text/css">#python { color: green }</style>')
Start tag: style
Expand All @@ -294,10 +301,10 @@ further parsing::
End tag : style

>>> parser.feed('<script type="text/javascript">'
... 'alert("<strong>hello!</strong>");</script>')
... 'alert("<strong>hello! &#9786;</strong>");</script>')
Start tag: script
attr: ('type', 'text/javascript')
Data : alert("<strong>hello!</strong>");
Data : alert("<strong>hello! &#9786;</strong>");
End tag : script

Parsing comments::
Expand All @@ -317,7 +324,7 @@ correct char (note: these 3 references are all equivalent to ``'>'``)::

Feeding incomplete chunks to :meth:`~HTMLParser.feed` works, but
:meth:`~HTMLParser.handle_data` might be called more than once
(unless *convert_charrefs* is set to ``True``)::
if *convert_charrefs* is false::

>>> for chunk in ['<sp', 'an>buff', 'ered ', 'text</s', 'pan>']:
... parser.feed(chunk)
Expand Down
4 changes: 2 additions & 2 deletions Doc/library/http.cookies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ The following example demonstrates how to use the :mod:`http.cookies` module.
Set-Cookie: chips=ahoy
Set-Cookie: vienna=finger
>>> C = cookies.SimpleCookie()
>>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";')
>>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=;";')
>>> print(C)
Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;"
Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=;"
>>> C = cookies.SimpleCookie()
>>> C["oreo"] = "doublestuff"
>>> C["oreo"]["path"] = "/"
Expand Down
19 changes: 17 additions & 2 deletions Doc/library/ipaddress.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ write code that handles both IP versions correctly. Address objects are
1. A string in decimal-dot notation, consisting of four decimal integers in
the inclusive range 0--255, separated by dots (e.g. ``192.168.0.1``). Each
integer represents an octet (byte) in the address. Leading zeroes are
tolerated only for values less than 8 (as there is no ambiguity
between the decimal and octal interpretations of such strings).
not tolerated to prevent confusion with octal notation.
2. An integer that fits into 32 bits.
3. An integer packed into a :class:`bytes` object of length 4 (most
significant octet first).
Expand All @@ -117,6 +116,22 @@ write code that handles both IP versions correctly. Address objects are
>>> ipaddress.IPv4Address(b'\xC0\xA8\x00\x01')
IPv4Address('192.168.0.1')

.. versionchanged:: 3.8

Leading zeros are tolerated, even in ambiguous cases that look like
octal notation.

.. versionchanged:: 3.10

Leading zeros are no longer tolerated and are treated as an error.
IPv4 address strings are now parsed as strict as glibc
:func:`~socket.inet_pton`.

.. versionchanged:: 3.7.17.8

The above change is also included in ActiveState Python 3.7
starting with version 3.7.17.8.

.. attribute:: version

The appropriate version number: ``4`` for IPv4, ``6`` for IPv6.
Expand Down
7 changes: 7 additions & 0 deletions Doc/library/os.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1833,6 +1833,10 @@ features:
platform-dependent. On some platforms, they are ignored and you should call
:func:`chmod` explicitly to set them.

On Windows, a *mode* of ``0o700`` is specifically handled to apply access
control to the new directory such that only the current user and
administrators have access. Other values of *mode* are ignored.

This function can also support :ref:`paths relative to directory descriptors
<dir_fd>`.

Expand All @@ -1845,6 +1849,9 @@ features:
.. versionchanged:: 3.6
Accepts a :term:`path-like object`.

.. versionchanged:: 3.7.17.8
Windows now handles a *mode* of ``0o700``.


.. function:: makedirs(name, mode=0o777, exist_ok=False)

Expand Down
36 changes: 36 additions & 0 deletions Doc/library/pyexpat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,42 @@ XMLParser Objects
:exc:`ExpatError` to be raised with the :attr:`code` attribute set to
``errors.codes[errors.XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING]``.

.. method:: xmlparser.SetReparseDeferralEnabled(enabled)

.. warning::

Calling ``SetReparseDeferralEnabled(False)`` has security implications,
as detailed below; please make sure to understand these consequences
prior to using the ``SetReparseDeferralEnabled`` method.

Expat 2.6.0 introduced a security mechanism called "reparse deferral"
where instead of causing denial of service through quadratic runtime
from reparsing large tokens, reparsing of unfinished tokens is now delayed
by default until a sufficient amount of input is reached.
Due to this delay, registered handlers may — depending of the sizing of
input chunks pushed to Expat — no longer be called right after pushing new
input to the parser. Where immediate feedback and taking over responsiblity
of protecting against denial of service from large tokens are both wanted,
calling ``SetReparseDeferralEnabled(False)`` disables reparse deferral
for the current Expat parser instance, temporarily or altogether.
Calling ``SetReparseDeferralEnabled(True)`` allows re-enabling reparse
deferral.

Note that :meth:`SetReparseDeferralEnabled` has been backported to some
prior releases of CPython as a security fix. Check for availability of
:meth:`SetReparseDeferralEnabled` using :func:`hasattr` if used in code
running across a variety of Python versions.

.. versionadded:: 3.7.17.8

.. method:: xmlparser.GetReparseDeferralEnabled()

Returns whether reparse deferral is currently enabled for the given
Expat parser instance.

.. versionadded:: 3.7.17.8


:class:`xmlparser` objects have the following attributes:


Expand Down
24 changes: 23 additions & 1 deletion Doc/library/ssl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1699,6 +1699,12 @@ to speed up repeated connections from the same clients.
:class:`SSLContext` representing a certificate chain that matches the server
name.

If the callback assigns a new context to :attr:`SSLSocket.context`, any
further ClientHello message on the same connection (for example after a
TLS 1.3 HelloRetryRequest) is dispatched to the new context's
*sni_callback*, if it has one; the original callback is not called again
for that connection.

Due to the early negotiation phase of the TLS connection, only limited
methods and attributes are usable like
:meth:`SSLSocket.selected_alpn_protocol` and :attr:`SSLSocket.context`.
Expand All @@ -1722,6 +1728,11 @@ to speed up repeated connections from the same clients.

.. versionadded:: 3.7

.. versionchanged:: 3.7.17.8
After the callback assigns a new :attr:`SSLSocket.context`, later
ClientHello messages on the connection are dispatched to the new
context's *sni_callback*.

.. attribute:: SSLContext.set_servername_callback(server_name_callback)

This is a legacy API retained for backwards compatibility. When possible,
Expand Down Expand Up @@ -1839,7 +1850,11 @@ to speed up repeated connections from the same clients.
outgoing BIO.

The *server_side*, *server_hostname* and *session* parameters have the
same meaning as in :meth:`SSLContext.wrap_socket`.
same meaning as in :meth:`SSLContext.wrap_socket`, and are validated in
the same way: in particular a :exc:`DeprecationWarning` is raised when
:attr:`~SSLContext.check_hostname` is enabled but no *server_hostname* is
given, since there would be no name to match the peer's certificate
against. In Python 3.13 and later a ``ValueError`` is raised instead.

.. versionchanged:: 3.6
*session* argument was added.
Expand All @@ -1848,6 +1863,13 @@ to speed up repeated connections from the same clients.
The method returns on instance of :attr:`SSLContext.sslobject_class`
instead of hard-coded :class:`SSLObject`.

.. versionchanged:: 3.7.17.8
The *server_side*, *server_hostname* and *session* parameters are now
validated as :meth:`SSLContext.wrap_socket` validates them. Previously
a context with :attr:`~SSLContext.check_hostname` enabled and no
*server_hostname* was accepted, and verified the certificate chain but
never the peer's identity.

.. attribute:: SSLContext.sslobject_class

The return type of :meth:`SSLContext.wrap_bio`, defaults to
Expand Down
38 changes: 38 additions & 0 deletions Doc/library/tarfile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,15 @@ The :mod:`tarfile` module defines the following exceptions:
Raised to refuse extracting a symbolic link pointing outside the destination
directory.

.. exception:: LinkFallbackError

Raised to refuse emulating a link (hard or symbolic) by extracting another
archive member, when that member would be rejected by the filter location.
The exception that was raised to reject the replacement member is available
as :attr:`!BaseException.__context__`.

.. versionadded:: 3.7.17.8


The following constants are available at the module level:

Expand Down Expand Up @@ -713,6 +722,11 @@ A ``TarInfo`` object has the following public data attributes:
Name of the target file name, which is only present in :class:`TarInfo` objects
of type :const:`LNKTYPE` and :const:`SYMTYPE`.

For symbolic links (``SYMTYPE``), the *linkname* is relative to the directory
that contains the link.
For hard links (``LNKTYPE``), the *linkname* is relative to the root of
the archive.


.. attribute:: TarInfo.uid

Expand Down Expand Up @@ -912,19 +926,38 @@ reused in custom filters:
paths (in case the name is absolute
even after stripping slashes, e.g. ``C:/foo`` on Windows).
This raises :class:`~tarfile.AbsolutePathError`.
- Normalize filenames (:attr:`TarInfo.name`) that contain ``..`` components
using :func:`os.path.normpath`.
Note that this removes internal ``..`` components, which may change the
meaning of the name if it traverses symbolic links.
- :ref:`Refuse <tarfile-extraction-refuse>` to extract files whose absolute
path (after following symlinks) would end up outside the destination.
This raises :class:`~tarfile.OutsideDestinationError`.
- :ref:`Refuse <tarfile-extraction-refuse>` to extract links (hard or soft)
whose name refers to the destination directory itself.
This raises :class:`~tarfile.OutsideDestinationError`.
Note that such files are refused even on platforms that do not support
symbolic links.
- Clear high mode bits (setuid, setgid, sticky) and group/other write bits
(:attr:`~stat.S_IWGRP`|:attr:`~stat.S_IWOTH`).

Return the modified ``TarInfo`` member.

.. versionchanged:: 3.7.17.8

Filenames containing ``..`` components are now normalized.

.. function:: data_filter(/, member, path)

Implements the ``'data'`` filter.
In addition to what ``tar_filter`` does:

- Normalize link targets (:attr:`TarInfo.linkname`) using
:func:`os.path.normpath`.
Note that this removes internal ``..`` components, which may change the
meaning of the link if the path in :attr:`!TarInfo.linkname` traverses
symbolic links.

- :ref:`Refuse <tarfile-extraction-refuse>` to extract links (hard or soft)
that link to absolute paths, or ones that link outside the destination.

Expand Down Expand Up @@ -953,6 +986,10 @@ reused in custom filters:

Return the modified ``TarInfo`` member.

.. versionchanged:: 3.7.17.8

Link targets are now normalized.


.. _tarfile-extraction-refuse:

Expand All @@ -979,6 +1016,7 @@ Here is an incomplete list of things to consider:
* Extract to a :func:`new temporary directory <tempfile.mkdtemp>`
to prevent e.g. exploiting pre-existing links, and to make it easier to
clean up after a failed extraction.
* Disallow symbolic links if you do not need the functionality.
* When working with untrusted data, use external (e.g. OS-level) limits on
disk, memory and CPU usage.
* Check filenames against an allow-list of characters
Expand Down
Loading
Loading