10BC0 Merge branch 'main' into update-pep780-w-sys-abi-info · python/peps@683cf16 · GitHub
[go: up one dir, main page]

Skip to content

Commit 683cf16

Browse files
authored
Merge branch 'main' into update-pep780-w-sys-abi-info
2 parents 3a4baea + 433d904 commit 683cf16

File tree

2 files changed

+30
-38
lines changed

2 files changed

+30
-38
lines changed

peps/pep-0807.rst

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ apply to all parts of this PEP's specification:
125125
Receiving servers **SHOULD** respond with a ``406 Not Acceptable``
126126
status code if any other ``Accept`` header is present.
127127

128+
* Unless otherwise specified, all error (4xx and 5xx) responses from the server
129+
**MUST** use the :rfc:`9457` (Problem Details for HTTP APIs) format.
130+
In particular, the server **MUST** use the "Problem Details JSON Object"
131+
defined in :rfc:`Section 3 <9457#section-3>` and **SHOULD** use
132+
the ``application/problem+json`` media type in its responses.
128133

129134
Trusted Publishing Discovery
130135
----------------------------
@@ -189,16 +194,10 @@ The discovery mechanism is as follows:
189194
190195
If the server does not support Trusted Publishing for the given
191196
upload URL, it **MUST** respond with a ``404 Not Found`` status code.
192-
When responding with a ``404 Not Found``, the server **SHOULD NOT**
193-
include a response body. If a response body is included, it **MUST**
194-
be ignored by the client.
195197

196198
Servers **MAY** additionally respond with any other standard HTTP
197-
error code in the 400 or 500 range to indicate an error condition.
198-
199-
Non-``200 OK``, non-``404 Not Found`` responses **MAY** include a body which,
200-
if present, **MUST** be a JSON object containing an
201-
`Error Response <Error Responses_>`__.
199+
error code in the 400 or 500 range to indicate an appropriate error
200+
condition.
202201

203202
Trusted Publishing Token Exchange
204203
---------------------------------
@@ -233,11 +232,8 @@ containing a JSON object with the following field:
233232

234233
- ``audience``: a string containing the expected OIDC audience.
235234

236-
On failure, the server **MUST** respond with any standard HTTP
237-
error code in the 400 or 500 range to indicate an error condition.
238-
Failure responses **MAY** include a body which, if present,
239-
**MUST** be a JSON object containing an
240-
`Error Response <Error Responses_>`__.
235+
On failure, the server **MUST** respond with a standard HTTP
236+
error code in the 400 or 500 range to indicate the appropriate error condition.
241237

242238
Token Minting
243239
~~~~~~~~~~~~~
@@ -277,29 +273,7 @@ containing a JSON object with the following fields:
277273
above) to determine when to refresh the upload credential, if needed.
278274

279275
On failure, the server **MUST** respond with any standard HTTP
280-
error code in the 400 or 500 range to indicate an error condition.
281-
Failure responses **MUST** include a body which, if present,
282-
**MUST** be a JSON object containing an `Error Response <Error Responses_>`__.
283-
284-
Error Responses
285-
---------------
286-
287-
When an error response body is included, it **MUST** be a JSON object
288-
containing the following fields:
289-
290-
- ``message``: a string containing a short, high-level
291-
human-readable summary of the error.
292-
293-
- ``errors``: an array of one or more objects, each containing
294-
the following fields:
295-
296-
- ``code``: a string containing a machine-readable error code.
297-
- ``description``: a string containing a human-readable
298-
description of the error.
299-
300-
This PEP does not specify any particular error codes. Clients **SHOULD NOT**
301-
assume that error codes are consistent across different indices, and instead
302-
**MUST** treat error codes as opaque strings.
276+
error code in the 400 or 500 range to indicate the appropriate error condition.
303277

304278
Security Implications
305279
=====================
@@ -417,7 +391,7 @@ Footnotes
417391

418392
.. [#fn-hash]
419393
420-
The discovery key may be computed thus:
394+
The discovery key may be computed thusly:
421395
422396
.. code-block:: pycon
423397

peps/pep-0810.rst

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ Author: Pablo Galindo <pablogsal@python.org>,
88
Noah Kim <noahbkim@gmail.com>,
99
Tim Stumbaugh <me@tjstum.com>
1010
Discussions-To: https://discuss.python.org/t/104131
11-
Status: Draft
11+
Status: Accepted
1212
Type: Standards Track
1313
Created: 02-Oct-2025
1414
Python-Version: 3.15
1515
Post-History:
1616
`03-Oct-2025 <https://discuss.python.org/t/104131>`__,
17+
Resolution: `03-Nov-2025 <https://discuss.python.org/t/pep-810-explicit-lazy-imports/104131/466>`__
1718

1819

1920
Abstract
@@ -361,6 +362,15 @@ being imported, and (if applicable) the fromlist. An import remains lazy only
361362
if the filter function returns ``True``. If no lazy import filter is set, all
362363
*potentially lazy* imports are lazy.
363364

365+
Note on .pth files
366+
~~~~~~~~~~~~~~~~~~
367+
368+
The lazy import mechanism does not apply to .pth files processed by the
369+
``site`` module. While .pth files have special handling for lines that begin
370+
with ``import`` followed by a space or tab, this special handling will not be
371+
adapted to support lazy imports. Imports specified in .pth files remain eager
372+
as they always have been.
373+
364374
Lazy objects
365375
------------
366376

@@ -617,6 +627,9 @@ lazy imports filter:
617627
``"normal"`` (respect ``lazy`` keyword only), ``"all"`` (force all imports to be
618628
potentially lazy), or ``"none"`` (force all imports to be eager).
619629

630+
* ``sys.get_lazy_imports()`` - Returns the current lazy imports mode as a
631+
string: ``"normal"``, ``"all"``, or ``"none"``.
632+
620633
The filter function is called for every potentially lazy import, and must
621634
return ``True`` if the import should be lazy. This allows for fine-grained
622635
control over which imports should be lazy, useful for excluding modules with
@@ -692,6 +705,11 @@ The global lazy imports flag can be controlled through:
692705
* The ``PYTHON_LAZY_IMPORTS=<mode>`` environment variable
693706
* The ``sys.set_lazy_imports(mode)`` function (primarily for testing)
694707

708+
The precedence order for setting the lazy imports mode follows the standard
709+
Python pattern: ``sys.set_lazy_imports()`` takes highest precedence, followed
710+
by ``-X lazy_imports=<mode>``, then ``PYTHON_LAZY_IMPORTS=<mode>``. If none
711+
are specified, the mode defaults to ``"normal"``.
712+
695713
Where ``<mode>`` can be:
696714

697715
* ``"normal"`` (or unset): Only explicitly marked lazy imports are lazy

0 commit comments

Comments
 (0)
0