Skip to content

Commit f0a9e53

Browse files
Merge branch 'main' into per-thread-tasks
2 parents c45c9d7 + e119526 commit f0a9e53

File tree

22 files changed

+234
-149
lines changed

22 files changed

+234
-149
lines changed

Doc/library/http.cookies.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ Morsel Objects
142142
version
143143
httponly
144144
samesite
145+
partitioned
145146

146147
The attribute :attr:`httponly` specifies that the cookie is only transferred
147148
in HTTP requests, and is not accessible through JavaScript. This is intended
@@ -151,6 +152,19 @@ Morsel Objects
151152
send the cookie along with cross-site requests. This helps to mitigate CSRF
152153
attacks. Valid values for this attribute are "Strict" and "Lax".
153154

155+
The attribute :attr:`partitioned` indicates to user agents that these
156+
cross-site cookies *should* only be available in the same top-level context
157+
that the cookie was first set in. For this to be accepted by the user agent,
158+
you **must** also set ``Secure``.
159+
160+
In addition, it is recommended to use the ``__Host`` prefix when setting
161+
partitioned cookies to make them bound to the hostname and not the
162+
registrable domain. Read
163+
`CHIPS (Cookies Having Independent Partitioned State)`_
164+
for full details and examples.
165+
166+
.. _CHIPS (Cookies Having Independent Partitioned State): https://github.com/privacycg/CHIPS/blob/main/README.md
167+
154168
The keys are case-insensitive and their default value is ``''``.
155169

156170
.. versionchanged:: 3.5
@@ -165,6 +179,9 @@ Morsel Objects
165179
.. versionchanged:: 3.8
166180
Added support for the :attr:`samesite` attribute.
167181

182+
.. versionchanged:: 3.14
183+
Added support for the :attr:`partitioned` attribute.
184+
168185

169186
.. attribute:: Morsel.value
170187

Doc/license.rst

Lines changed: 58 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -11,59 +11,63 @@ History of the software
1111
=======================
1212

1313
Python was created in the early 1990s by Guido van Rossum at Stichting
14-
Mathematisch Centrum (CWI, see https://www.cwi.nl/) in the Netherlands as a
14+
Mathematisch Centrum (CWI, see https://www.cwi.nl) in the Netherlands as a
1515
successor of a language called ABC. Guido remains Python's principal author,
1616
although it includes many contributions from others.
1717

1818
In 1995, Guido continued his work on Python at the Corporation for National
19-
Research Initiatives (CNRI, see https://www.cnri.reston.va.us/) in Reston,
19+
Research Initiatives (CNRI, see https://www.cnri.reston.va.us) in Reston,
2020
Virginia where he released several versions of the software.
2121

2222
In May 2000, Guido and the Python core development team moved to BeOpen.com to
2323
form the BeOpen PythonLabs team. In October of the same year, the PythonLabs
24-
team moved to Digital Creations (now Zope Corporation; see
25-
https://www.zope.org/). In 2001, the Python Software Foundation (PSF, see
24+
team moved to Digital Creations, which became
25+
Zope Corporation. In 2001, the Python Software Foundation (PSF, see
2626
https://www.python.org/psf/) was formed, a non-profit organization created
27-
specifically to own Python-related Intellectual Property. Zope Corporation is a
27+
specifically to own Python-related Intellectual Property. Zope Corporation was a
2828
sponsoring member of the PSF.
2929

30-
All Python releases are Open Source (see https://opensource.org/ for the Open
30+
All Python releases are Open Source (see https://opensource.org for the Open
3131
Source Definition). Historically, most, but not all, Python releases have also
3232
been GPL-compatible; the table below summarizes the various releases.
3333

34-
+----------------+--------------+------------+------------+-----------------+
35-
| Release | Derived from | Year | Owner | GPL compatible? |
36-
+================+==============+============+============+=================+
37-
| 0.9.0 thru 1.2 | n/a | 1991-1995 | CWI | yes |
38-
+----------------+--------------+------------+------------+-----------------+
39-
| 1.3 thru 1.5.2 | 1.2 | 1995-1999 | CNRI | yes |
40-
+----------------+--------------+------------+------------+-----------------+
41-
| 1.6 | 1.5.2 | 2000 | CNRI | no |
42-
+----------------+--------------+------------+------------+-----------------+
43-
| 2.0 | 1.6 | 2000 | BeOpen.com | no |
44-
+----------------+--------------+------------+------------+-----------------+
45-
| 1.6.1 | 1.6 | 2001 | CNRI | no |
46-
+----------------+--------------+------------+------------+-----------------+
47-
| 2.1 | 2.0+1.6.1 | 2001 | PSF | no |
48-
+----------------+--------------+------------+------------+-----------------+
49-
| 2.0.1 | 2.0+1.6.1 | 2001 | PSF | yes |
50-
+----------------+--------------+------------+------------+-----------------+
51-
| 2.1.1 | 2.1+2.0.1 | 2001 | PSF | yes |
52-
+----------------+--------------+------------+------------+-----------------+
53-
| 2.1.2 | 2.1.1 | 2002 | PSF | yes |
54-
+----------------+--------------+------------+------------+-----------------+
55-
| 2.1.3 | 2.1.2 | 2002 | PSF | yes |
56-
+----------------+--------------+------------+------------+-----------------+
57-
| 2.2 and above | 2.1.1 | 2001-now | PSF | yes |
58-
+----------------+--------------+------------+------------+-----------------+
34+
+----------------+--------------+------------+------------+---------------------+
35+
| Release | Derived from | Year | Owner | GPL-compatible? (1) |
36+
+================+==============+============+============+=====================+
37+
| 0.9.0 thru 1.2 | n/a | 1991-1995 | CWI | yes |
38+
+----------------+--------------+------------+------------+---------------------+
39+
| 1.3 thru 1.5.2 | 1.2 | 1995-1999 | CNRI | yes |
40+
+----------------+--------------+------------+------------+---------------------+
41+
| 1.6 | 1.5.2 | 2000 | CNRI | no |
42+
+----------------+--------------+------------+------------+---------------------+
43+
| 2.0 | 1.6 | 2000 | BeOpen.com | no |
44+
+----------------+--------------+------------+------------+---------------------+
45+
| 1.6.1 | 1.6 | 2001 | CNRI | yes (2) |
46+
+----------------+--------------+------------+------------+---------------------+
47+
| 2.1 | 2.0+1.6.1 | 2001 | PSF | no |
48+
+----------------+--------------+------------+------------+---------------------+
49+
| 2.0.1 | 2.0+1.6.1 | 2001 | PSF | yes |
50+
+----------------+--------------+------------+------------+---------------------+
51+
| 2.1.1 | 2.1+2.0.1 | 2001 | PSF | yes |
52+
+----------------+--------------+------------+------------+---------------------+
53+
| 2.1.2 | 2.1.1 | 2002 | PSF | yes |
54+
+----------------+--------------+------------+------------+---------------------+
55+
| 2.1.3 | 2.1.2 | 2002 | PSF | yes |
56+
+----------------+--------------+------------+------------+---------------------+
57+
| 2.2 and above | 2.1.1 | 2001-now | PSF | yes |
58+
+----------------+--------------+------------+------------+---------------------+
5959

6060
.. note::
6161

62-
GPL-compatible doesn't mean that we're distributing Python under the GPL. All
63-
Python licenses, unlike the GPL, let you distribute a modified version without
64-
making your changes open source. The GPL-compatible licenses make it possible to
65-
combine Python with other software that is released under the GPL; the others
66-
don't.
62+
(1) GPL-compatible doesn't mean that we're distributing Python under the GPL.
63+
All Python licenses, unlike the GPL, let you distribute a modified version
64+
without making your changes open source. The GPL-compatible licenses make
65+
it possible to combine Python with other software that is released under
66+
the GPL; the others don't.
67+
68+
(2) According to Richard Stallman, 1.6.1 is not GPL-compatible, because its license
69+
has a choice of law clause. According to CNRI, however, Stallman's lawyer has
70+
told CNRI's lawyer that 1.6.1 is "not incompatible" with the GPL.
6771

6872
Thanks to the many outside volunteers who have worked under Guido's direction to
6973
make these releases possible.
@@ -73,10 +77,10 @@ Terms and conditions for accessing or otherwise using Python
7377
============================================================
7478

7579
Python software and documentation are licensed under the
76-
:ref:`PSF License Agreement <PSF-license>`.
80+
Python Software Foundation License Version 2.
7781

7882
Starting with Python 3.8.6, examples, recipes, and other code in
79-
the documentation are dual licensed under the PSF License Agreement
83+
the documentation are dual licensed under the PSF License Version 2
8084
and the :ref:`Zero-Clause BSD license <BSD0>`.
8185

8286
Some software incorporated into Python is under different licenses.
@@ -86,39 +90,38 @@ See :ref:`OtherLicenses` for an incomplete list of these licenses.
8690

8791
.. _PSF-license:
8892

89-
PSF LICENSE AGREEMENT FOR PYTHON |release|
90-
------------------------------------------
93+
PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
94+
--------------------------------------------
9195

9296
.. parsed-literal::
9397
9498
1. This LICENSE AGREEMENT is between the Python Software Foundation ("PSF"), and
95-
the Individual or Organization ("Licensee") accessing and otherwise using Python
96-
|release| software in source or binary form and its associated documentation.
99+
the Individual or Organization ("Licensee") accessing and otherwise using this
100+
software ("Python") in source or binary form and its associated documentation.
97101
98102
2. Subject to the terms and conditions of this License Agreement, PSF hereby
99103
grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
100104
analyze, test, perform and/or display publicly, prepare derivative works,
101-
distribute, and otherwise use Python |release| alone or in any derivative
105+
distribute, and otherwise use Python alone or in any derivative
102106
version, provided, however, that PSF's License Agreement and PSF's notice of
103107
copyright, i.e., "Copyright © 2001 Python Software Foundation; All Rights
104-
Reserved" are retained in Python |release| alone or in any derivative version
108+
Reserved" are retained in Python alone or in any derivative version
105109
prepared by Licensee.
106110
107111
3. In the event Licensee prepares a derivative work that is based on or
108-
incorporates Python |release| or any part thereof, and wants to make the
112+
incorporates Python or any part thereof, and wants to make the
109113
derivative work available to others as provided herein, then Licensee hereby
110-
agrees to include in any such work a brief summary of the changes made to Python
111-
|release|.
114+
agrees to include in any such work a brief summary of the changes made to Python.
112115
113-
4. PSF is making Python |release| available to Licensee on an "AS IS" basis.
116+
4. PSF is making Python available to Licensee on an "AS IS" basis.
114117
PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF
115118
EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY REPRESENTATION OR
116119
WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE
117-
USE OF PYTHON |release| WILL NOT INFRINGE ANY THIRD PARTY RIGHTS.
120+
USE OF PYTHON WILL NOT INFRINGE ANY THIRD PARTY RIGHTS.
118121
119-
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON |release|
122+
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
120123
FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF
121-
MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON |release|, OR ANY DERIVATIVE
124+
MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON, OR ANY DERIVATIVE
122125
THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
123126
124127
6. This License Agreement will automatically terminate upon a material breach of
@@ -130,7 +133,7 @@ PSF LICENSE AGREEMENT FOR PYTHON |release|
130133
trademark sense to endorse or promote products or services of Licensee, or any
131134
third party.
132135
133-
8. By copying, installing or otherwise using Python |release|, Licensee agrees
136+
8. By copying, installing or otherwise using Python, Licensee agrees
134137
to be bound by the terms and conditions of this License Agreement.
135138
136139
@@ -205,7 +208,7 @@ CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1
205208
Agreement. This Agreement together with Python 1.6.1 may be located on the
206209
internet using the following unique, persistent identifier (known as a handle):
207210
1895.22/1013. This Agreement may also be obtained from a proxy server on the
208-
internet using the following URL: http://hdl.handle.net/1895.22/1013."
211+
internet using the following URL: http://hdl.handle.net/1895.22/1013".
209212
210213
3. In the event Licensee prepares a derivative work that is based on or
211214
incorporates Python 1.6.1 or any part thereof, and wants to make the derivative
@@ -273,8 +276,8 @@ CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2
273276
274277
.. _BSD0:
275278

276-
ZERO-CLAUSE BSD LICENSE FOR CODE IN THE PYTHON |release| DOCUMENTATION
277-
----------------------------------------------------------------------
279+
ZERO-CLAUSE BSD LICENSE FOR CODE IN THE PYTHON DOCUMENTATION
280+
------------------------------------------------------------
278281

279282
.. parsed-literal::
280283

Doc/tools/extensions/pyspecific.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,6 @@
3434
Body.enum.converters['lowerroman'] = \
3535
Body.enum.converters['upperroman'] = lambda x: None
3636

37-
# monkey-patch the productionlist directive to allow hyphens in group names
38-
# https://github.com/sphinx-doc/sphinx/issues/11854
39-
from sphinx.domains import std
40-
41-
std.token_re = re.compile(r'`((~?[\w-]*:)?\w+)`')
42-
43-
# backport :no-index:
44-
PyModule.option_spec['no-index'] = directives.flag
45-
46-
4737
# Support for marking up and linking to bugs.python.org issues
4838

4939
def issue_role(typ, rawtext, text, lineno, inliner, options={}, content=[]):

Include/internal/pycore_ceval.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ PyAPI_DATA(const size_t) _Py_FunctionAttributeOffsets[];
264264

265265
PyAPI_FUNC(int) _PyEval_CheckExceptStarTypeValid(PyThreadState *tstate, PyObject* right);
266266
PyAPI_FUNC(int) _PyEval_CheckExceptTypeValid(PyThreadState *tstate, PyObject* right);
267-
PyAPI_FUNC(int) _PyEval_ExceptionGroupMatch(PyObject* exc_value, PyObject *match_type, PyObject **match, PyObject **rest);
267+
PyAPI_FUNC(int) _PyEval_ExceptionGroupMatch(_PyInterpreterFrame *, PyObject* exc_value, PyObject *match_type, PyObject **match, PyObject **rest);
268268
PyAPI_FUNC(void) _PyEval_FormatAwaitableError(PyThreadState *tstate, PyTypeObject *type, int oparg);
269269
PyAPI_FUNC(void) _PyEval_FormatExcCheckArg(PyThreadState *tstate, PyObject *exc, const char *format_str, PyObject *obj);
270270
PyAPI_FUNC(void) _PyEval_FormatExcUnbound(PyThreadState *tstate, PyCodeObject *co, int oparg);

Include/internal/pycore_debug_offsets.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,32 @@ extern "C" {
1717

1818
// Macros to burn global values in custom sections so out-of-process
1919
// profilers can locate them easily.
20-
21-
#define GENERATE_DEBUG_SECTION(name, declaration) \
22-
_GENERATE_DEBUG_SECTION_WINDOWS(name) \
23-
_GENERATE_DEBUG_SECTION_APPLE(name) \
24-
declaration \
25-
_GENERATE_DEBUG_SECTION_LINUX(name)
20+
#define GENERATE_DEBUG_SECTION(name, declaration) \
21+
_GENERATE_DEBUG_SECTION_WINDOWS(name) \
22+
_GENERATE_DEBUG_SECTION_APPLE(name) \
23+
declaration \
24+
_GENERATE_DEBUG_SECTION_LINUX(name)
2625

2726
#if defined(MS_WINDOWS)
2827
#define _GENERATE_DEBUG_SECTION_WINDOWS(name) \
29-
_Pragma(Py_STRINGIFY(section(Py_STRINGIFY(name), read, write))) \
30-
__declspec(allocate(Py_STRINGIFY(name)))
28+
_Pragma(Py_STRINGIFY(section(Py_STRINGIFY(name), read, write))) \
29+
__declspec(allocate(Py_STRINGIFY(name)))
3130
#else
3231
#define _GENERATE_DEBUG_SECTION_WINDOWS(name)
3332
#endif
3433

3534
#if defined(__APPLE__)
3635
#define _GENERATE_DEBUG_SECTION_APPLE(name) \
37-
__attribute__((section(SEG_DATA "," Py_STRINGIFY(name))))
36+
__attribute__((section(SEG_DATA "," Py_STRINGIFY(name)))) \
37+
__attribute__((used))
3838
#else
3939
#define _GENERATE_DEBUG_SECTION_APPLE(name)
4040
#endif
4141

4242
#if defined(__linux__) && (defined(__GNUC__) || defined(__clang__))
4343
#define _GENERATE_DEBUG_SECTION_LINUX(name) \
44-
__attribute__((section("." Py_STRINGIFY(name))))
44+
__attribute__((section("." Py_STRINGIFY(name)))) \
45+
__attribute__((used))
4546
#else
4647
#define _GENERATE_DEBUG_SECTION_LINUX(name)
4748
#endif

Lib/http/cookies.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,12 @@ class Morsel(dict):
264264
"httponly" : "HttpOnly",
265265
"version" : "Version",
266266
"samesite" : "SameSite",
267+
"partitioned": "Partitioned",
267268
}
268269

269270
_reserved_defaults = dict.fromkeys(_reserved, "")
270271

271-
_flags = {'secure', 'httponly'}
272+
_flags = {'secure', 'httponly', 'partitioned'}
272273

273274
def __init__(self):
274275
# Set defaults

Lib/test/test_http_cookies.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,14 @@ def test_set_secure_httponly_attrs(self):
205205
self.assertEqual(C.output(),
206206
'Set-Cookie: Customer="WILE_E_COYOTE"; HttpOnly; Secure')
207207

208+
def test_set_secure_httponly_partitioned_attrs(self):
209+
C = cookies.SimpleCookie('Customer="WILE_E_COYOTE"')
210+
C['Customer']['secure'] = True
211+
C['Customer']['httponly'] = True
212+
C['Customer']['partitioned'] = True
213+
self.assertEqual(C.output(),
214+
'Set-Cookie: Customer="WILE_E_COYOTE"; HttpOnly; Partitioned; Secure')
215+
208216
def test_samesite_attrs(self):
209217
samesite_values = ['Strict', 'Lax', 'strict', 'lax']
210218
for val in samesite_values:

Lib/test/test_traceback.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2937,6 +2937,33 @@ def exc():
29372937
report = self.get_report(exc)
29382938
self.assertEqual(report, expected)
29392939

2940+
def test_exception_group_wrapped_naked(self):
2941+
# See gh-128799
2942+
2943+
def exc():
2944+
try:
2945+
raise Exception(42)
2946+
except* Exception as e:
2947+
raise
2948+
2949+
expected = (f' + Exception Group Traceback (most recent call last):\n'
2950+
f' | File "{__file__}", line {self.callable_line}, in get_exception\n'
2951+
f' | exception_or_callable()\n'
2952+
f' | ~~~~~~~~~~~~~~~~~~~~~^^\n'
2953+
f' | File "{__file__}", line {exc.__code__.co_firstlineno + 3}, in exc\n'
2954+
f' | except* Exception as e:\n'
2955+
f' | raise\n'
2956+
f' | ExceptionGroup: (1 sub-exception)\n'
2957+
f' +-+---------------- 1 ----------------\n'
2958+
f' | Traceback (most recent call last):\n'
2959+
f' | File "{__file__}", line {exc.__code__.co_firstlineno + 2}, in exc\n'
2960+
f' | raise Exception(42)\n'
2961+
f' | Exception: 42\n'
2962+
f' +------------------------------------\n')
2963+
2964+
report = self.get_report(exc)
2965+
self.assertEqual(report, expected)
2966+
29402967
def test_KeyboardInterrupt_at_first_line_of_frame(self):
29412968
# see GH-93249
29422969
def f():
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added support for the ``Partitioned`` cookie flag in :mod:`http.cookies`.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add frame of ``except*`` to traceback when it wraps a naked exception.

0 commit comments

Comments
 (0)