Skip to content

Commit 5976df9

Browse files
committed
Merge branch 'main' into fixloadsuperspec
* main: pythonGH-102181: Improve specialization stats for SEND (pythonGH-102182) pythongh-103000: Optimise `dataclasses.asdict` for the common case (python#104364) pythongh-103538: Remove unused TK_AQUA code (pythonGH-103539) pythonGH-87695: Fix OSError from `pathlib.Path.glob()` (pythonGH-104292) pythongh-104263: Rely on Py_NAN and introduce Py_INFINITY (pythonGH-104202) pythongh-104010: Separate and improve docs for `typing.get_origin` and `typing.get_args` (python#104013) pythongh-101819: Adapt _io._BufferedIOBase_Type methods to Argument Clinic (python#104355) pythongh-103960: Dark mode: invert image brightness (python#103983) pythongh-104252: Immortalize Py_EMPTY_KEYS (pythongh-104253) pythongh-101819: Clean up _io windows console io after pythongh-104197 (python#104354) pythongh-101819: Harden _io init (python#104352) pythongh-103247: clear the module cache in a test in test_importlib/extensions/test_loader.py (pythonGH-104226) pythongh-103848: Adds checks to ensure that bracketed hosts found by urlsplit are of IPv6 or IPvFuture format (python#103849) pythongh-74895: adjust tests to work on Solaris (python#104326) pythongh-101819: Refactor _io in preparation for module isolation (python#104334) pythongh-90953: Don't use deprecated AST nodes in clinic.py (python#104322) pythongh-102327: Extend docs for "url" and "headers" parameters to HTTPConnection.request() pythongh-104328: Fix typo in ``typing.Generic`` multiple inheritance error message (python#104335)
2 parents cf11908 + 373bca0 commit 5976df9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+579
-456
lines changed

Doc/howto/logging.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ The flow of log event information in loggers and handlers is illustrated in the
418418
following diagram.
419419

420420
.. image:: logging_flow.png
421+
:class: invert-in-dark-mode
421422

422423
Loggers
423424
^^^^^^^

Doc/library/hashlib.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ Constructor functions also accept the following tree hashing parameters:
430430

431431
.. figure:: hashlib-blake2-tree.png
432432
:alt: Explanation of tree mode parameters.
433+
:class: invert-in-dark-mode
433434

434435
See section 2.10 in `BLAKE2 specification
435436
<https://www.blake2.net/blake2_20130129.pdf>`_ for comprehensive review of tree

Doc/library/http.client.rst

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,10 @@ HTTPConnection Objects
264264
encode_chunked=False)
265265

266266
This will send a request to the server using the HTTP request
267-
method *method* and the selector *url*.
267+
method *method* and the request URI *url*. The provided *url* must be
268+
an absolute path to conform with :rfc:`RFC 2616 §5.1.2 <2616#section-5.1.2>`
269+
(unless connecting to an HTTP proxy server or using the ``OPTIONS`` or
270+
``CONNECT`` methods).
268271

269272
If *body* is specified, the specified data is sent after the headers are
270273
finished. It may be a :class:`str`, a :term:`bytes-like object`, an
@@ -279,7 +282,10 @@ HTTPConnection Objects
279282
iterable are sent as is until the iterable is exhausted.
280283

281284
The *headers* argument should be a mapping of extra HTTP headers to send
282-
with the request.
285+
with the request. A :rfc:`Host header <2616#section-14.23>`
286+
must be provided to conform with :rfc:`RFC 2616 §5.1.2 <2616#section-5.1.2>`
287+
(unless connecting to an HTTP proxy server or using the ``OPTIONS`` or
288+
``CONNECT`` methods).
283289

284290
If *headers* contains neither Content-Length nor Transfer-Encoding,
285291
but there is a request body, one of those
@@ -298,6 +304,16 @@ HTTPConnection Objects
298304
HTTPConnection object assumes that all encoding is handled by the
299305
calling code. If it is ``True``, the body will be chunk-encoded.
300306

307+
For example, to perform a ``GET`` request to ``https://docs.python.org/3/``::
308+
309+
>>> import http.client
310+
>>> host = "docs.python.org"
311+
>>> conn = http.client.HTTPSConnection(host)
312+
>>> conn.request("GET", "/3/", headers={"Host": host})
313+
>>> response = conn.getresponse()
314+
>>> print(response.status, response.reason)
315+
200 OK
316+
301317
.. note::
302318
Chunked transfer encoding has been added to the HTTP protocol
303319
version 1.1. Unless the HTTP server is known to handle HTTP 1.1,

Doc/library/pathlib.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ inherit from pure paths but also provide I/O operations.
2121

2222
.. image:: pathlib-inheritance.png
2323
:align: center
24+
:class: invert-in-dark-mode
2425

2526
If you've never used this module before or just aren't sure which class is
2627
right for your task, :class:`Path` is most likely what you need. It instantiates

Doc/library/typing.rst

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2876,24 +2876,37 @@ Introspection helpers
28762876
if a default value equal to ``None`` was set.
28772877
Now the annotation is returned unchanged.
28782878

2879-
.. function:: get_args(tp)
28802879
.. function:: get_origin(tp)
28812880

2882-
Provide basic introspection for generic types and special typing forms.
2883-
2884-
For a typing object of the form ``X[Y, Z, ...]`` these functions return
2885-
``X`` and ``(Y, Z, ...)``. If ``X`` is a generic alias for a builtin or
2881+
Get the unsubscripted version of a type: for a typing object of the form
2882+
``X[Y, Z, ...]`` return ``X``. If ``X`` is a generic alias for a builtin or
28862883
:mod:`collections` class, it gets normalized to the original class.
2884+
If ``X`` is an instance of :class:`ParamSpecArgs` or :class:`ParamSpecKwargs`,
2885+
return the underlying :class:`ParamSpec`.
2886+
Return ``None`` for unsupported objects.
2887+
Examples::
2888+
2889+
assert get_origin(str) is None
2890+
assert get_origin(Dict[str, int]) is dict
2891+
assert get_origin(Union[int, str]) is Union
2892+
P = ParamSpec('P')
2893+
assert get_origin(P.args) is P
2894+
assert get_origin(P.kwargs) is P
2895+
2896+
.. versionadded:: 3.8
2897+
2898+
.. function:: get_args(tp)
2899+
2900+
Get type arguments with all substitutions performed: for a typing object
2901+
of the form ``X[Y, Z, ...]`` return ``(Y, Z, ...)``.
28872902
If ``X`` is a union or :class:`Literal` contained in another
28882903
generic type, the order of ``(Y, Z, ...)`` may be different from the order
28892904
of the original arguments ``[Y, Z, ...]`` due to type caching.
2890-
For unsupported objects return ``None`` and ``()`` correspondingly.
2905+
Return ``()`` for unsupported objects.
28912906
Examples::
28922907

2893-
assert get_origin(Dict[str, int]) is dict
2908+
assert get_args(int) == ()
28942909
assert get_args(Dict[int, str]) == (int, str)
2895-
2896-
assert get_origin(Union[int, str]) is Union
28972910
assert get_args(Union[int, str]) == (int, str)
28982911

28992912
.. versionadded:: 3.8

Include/cpython/genobject.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ PyAPI_FUNC(PyObject *) PyAsyncGen_New(PyFrameObject *,
7777

7878
#define PyAsyncGen_CheckExact(op) Py_IS_TYPE((op), &PyAsyncGen_Type)
7979

80+
#define PyAsyncGenASend_CheckExact(op) Py_IS_TYPE((op), &_PyAsyncGenASend_Type)
81+
8082

8183
#undef _PyGenObject_HEAD
8284

Include/internal/pycore_dict_state.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ struct _Py_dict_state {
3838
PyDict_WatchCallback watchers[DICT_MAX_WATCHERS];
3939
};
4040

41+
#define _dict_state_INIT \
42+
{ \
43+
.next_keys_version = 2, \
44+
}
45+
4146

4247
#ifdef __cplusplus
4348
}

Include/internal/pycore_dtoa.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ PyAPI_FUNC(double) _Py_dg_strtod(const char *str, char **ptr);
6464
PyAPI_FUNC(char *) _Py_dg_dtoa(double d, int mode, int ndigits,
6565
int *decpt, int *sign, char **rve);
6666
PyAPI_FUNC(void) _Py_dg_freedtoa(char *s);
67-
PyAPI_FUNC(double) _Py_dg_stdnan(int sign);
68-
PyAPI_FUNC(double) _Py_dg_infinity(int sign);
6967

7068
#endif // _PY_SHORT_FLOAT_REPR == 1
7169

Include/internal/pycore_runtime_init.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ extern PyTypeObject _PyExc_MemoryError;
107107
}, \
108108
}, \
109109
.dtoa = _dtoa_state_INIT(&(INTERP)), \
110-
.dict_state = { \
111-
.next_keys_version = 2, \
112-
}, \
110+
.dict_state = _dict_state_INIT, \
113111
.func_state = { \
114112
.next_version = 1, \
115113
}, \

Include/pymath.h

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,24 @@
3939
// Return 1 if float or double arg is neither infinite nor NAN, else 0.
4040
#define Py_IS_FINITE(X) isfinite(X)
4141

42-
/* HUGE_VAL is supposed to expand to a positive double infinity. Python
43-
* uses Py_HUGE_VAL instead because some platforms are broken in this
44-
* respect. We used to embed code in pyport.h to try to worm around that,
45-
* but different platforms are broken in conflicting ways. If you're on
46-
* a platform where HUGE_VAL is defined incorrectly, fiddle your Python
47-
* config to #define Py_HUGE_VAL to something that works on your platform.
42+
// Py_INFINITY: Value that evaluates to a positive double infinity.
43+
#ifndef Py_INFINITY
44+
# define Py_INFINITY ((double)INFINITY)
45+
#endif
46+
47+
/* Py_HUGE_VAL should always be the same as Py_INFINITY. But historically
48+
* this was not reliable and Python did not require IEEE floats and C99
49+
* conformity. Prefer Py_INFINITY for new code.
4850
*/
4951
#ifndef Py_HUGE_VAL
5052
# define Py_HUGE_VAL HUGE_VAL
5153
#endif
5254

53-
// Py_NAN: Value that evaluates to a quiet Not-a-Number (NaN).
55+
/* Py_NAN: Value that evaluates to a quiet Not-a-Number (NaN). The sign is
56+
* undefined and normally not relevant, but e.g. fixed for float("nan").
57+
*/
5458
#if !defined(Py_NAN)
55-
# if _Py__has_builtin(__builtin_nan)
56-
// Built-in implementation of the ISO C99 function nan(): quiet NaN.
57-
# define Py_NAN (__builtin_nan(""))
58-
#else
59-
// Use C99 NAN constant: quiet Not-A-Number.
60-
// NAN is a float, Py_NAN is a double: cast to double.
6159
# define Py_NAN ((double)NAN)
62-
# endif
6360
#endif
6461

6562
#endif /* Py_PYMATH_H */

0 commit comments

Comments
 (0)