Skip to content

Commit

Permalink
Merge branch 'main' into pyarg_parse-nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiy-storchaka authored Jul 4, 2024
2 parents 2707238 + 2f5f19e commit d98debb
Show file tree
Hide file tree
Showing 136 changed files with 3,250 additions and 1,821 deletions.
4 changes: 2 additions & 2 deletions Doc/c-api/dict.rst
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ Dictionary Objects
.. c:function:: int PyDict_GetItemStringRef(PyObject *p, const char *key, PyObject **result)
Similar than :c:func:`PyDict_GetItemRef`, but *key* is specified as a
Similar to :c:func:`PyDict_GetItemRef`, but *key* is specified as a
:c:expr:`const char*` UTF-8 encoded bytes string, rather than a
:c:expr:`PyObject*`.
Expand Down Expand Up @@ -206,7 +206,7 @@ Dictionary Objects
``NULL``, and return ``0``.
- On error, raise an exception and return ``-1``.
This is similar to :meth:`dict.pop`, but without the default value and
Similar to :meth:`dict.pop`, but without the default value and
not raising :exc:`KeyError` if the key missing.
.. versionadded:: 3.13
Expand Down
4 changes: 2 additions & 2 deletions Doc/c-api/typeobj.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1592,7 +1592,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
weak references to the type object itself.

It is an error to set both the :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` bit and
:c:member:`~PyTypeObject.tp_weaklist`.
:c:member:`~PyTypeObject.tp_weaklistoffset`.

**Inheritance:**

Expand All @@ -1604,7 +1604,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
**Default:**

If the :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` bit is set in the
:c:member:`~PyTypeObject.tp_dict` field, then
:c:member:`~PyTypeObject.tp_flags` field, then
:c:member:`~PyTypeObject.tp_weaklistoffset` will be set to a negative value,
to indicate that it is unsafe to use this field.

Expand Down
40 changes: 40 additions & 0 deletions Doc/howto/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,46 @@ following diagram.
.. raw:: html
:file: logging_flow.svg

.. raw:: html

<script>
/*
* This snippet is needed to handle the case where a light or dark theme is
* chosen via the theme is selected in the page. We call the existing handler
* and then add a dark-theme class to the body when the dark theme is selected.
* The SVG styling (above) then does the rest.
*
* If the pydoc theme is updated to set the dark-theme class, this snippet
* won't be needed any more.
*/
(function() {
var oldActivateTheme = activateTheme;
function updateBody(theme) {
let elem = document.body;
elem.classList.remove('dark-theme');
elem.classList.remove('light-theme');
if (theme === 'dark') {
elem.classList.add('dark-theme');
}
else if (theme === 'light') {
elem.classList.add('light-theme');
}
}
activateTheme = function(theme) {
oldActivateTheme(theme);
updateBody(theme);
};
/*
* If the page is refreshed, make sure we update the body - the overriding
* of activateTheme won't have taken effect yet.
*/
updateBody(localStorage.getItem('currentTheme') || 'auto');
})();
</script>

Loggers
^^^^^^^

Expand Down
Binary file modified Doc/howto/logging_flow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
314 changes: 180 additions & 134 deletions Doc/howto/logging_flow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions Doc/library/ctypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,20 @@ Fundamental data types
(1)
The constructor accepts any object with a truth value.

Additionally, if IEC 60559 compatible complex arithmetic (Annex G) is supported, the following
complex types are available:

+----------------------------------+---------------------------------+-----------------+
| ctypes type | C type | Python type |
+==================================+=================================+=================+
| :class:`c_float_complex` | :c:expr:`float complex` | complex |
+----------------------------------+---------------------------------+-----------------+
| :class:`c_double_complex` | :c:expr:`double complex` | complex |
+----------------------------------+---------------------------------+-----------------+
| :class:`c_longdouble_complex` | :c:expr:`long double complex` | complex |
+----------------------------------+---------------------------------+-----------------+


All these types can be created by calling them with an optional initializer of
the correct type and value::

Expand Down Expand Up @@ -2284,6 +2298,30 @@ These are the fundamental ctypes data types:
optional float initializer.


.. class:: c_double_complex

Represents the C :c:expr:`double complex` datatype, if available. The
constructor accepts an optional :class:`complex` initializer.

.. versionadded:: 3.14


.. class:: c_float_complex

Represents the C :c:expr:`float complex` datatype, if available. The
constructor accepts an optional :class:`complex` initializer.

.. versionadded:: 3.14


.. class:: c_longdouble_complex

Represents the C :c:expr:`long double complex` datatype, if available. The
constructor accepts an optional :class:`complex` initializer.

.. versionadded:: 3.14


.. class:: c_int

Represents the C :c:expr:`signed int` datatype. The constructor accepts an
Expand Down
31 changes: 29 additions & 2 deletions Doc/library/os.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1724,10 +1724,27 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
Added support for pipes on Windows.


.. function:: splice(src, dst, count, offset_src=None, offset_dst=None)
.. function:: splice(src, dst, count, offset_src=None, offset_dst=None, flags=0)

Transfer *count* bytes from file descriptor *src*, starting from offset
*offset_src*, to file descriptor *dst*, starting from offset *offset_dst*.

The splicing behaviour can be modified by specifying a *flags* value.
Any of the following variables may used, combined using bitwise OR
(the ``|`` operator):

* If :const:`SPLICE_F_MOVE` is specified,
the kernel is asked to move pages instead of copying,
but pages may still be copied if the kernel cannot move the pages from the pipe.

* If :const:`SPLICE_F_NONBLOCK` is specified,
the kernel is asked to not block on I/O.
This makes the splice pipe operations nonblocking,
but splice may nevertheless block because the spliced file descriptors may block.

* If :const:`SPLICE_F_MORE` is specified,
it hints to the kernel that more data will be coming in a subsequent splice.

At least one of the file descriptors must refer to a pipe. If *offset_src*
is ``None``, then *src* is read from the current position; respectively for
*offset_dst*. The offset associated to the file descriptor that refers to a
Expand All @@ -1746,6 +1763,8 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
make sense to block because there are no writers connected to the write end
of the pipe.

.. seealso:: The :manpage:`splice(2)` man page.

.. availability:: Linux >= 2.6.17 with glibc >= 2.5

.. versionadded:: 3.10
Expand Down Expand Up @@ -4642,6 +4661,10 @@ written in Python, such as a mail server's external command delivery program.
Use :class:`subprocess.Popen` or :func:`subprocess.run` to
control options like encodings.

.. deprecated:: 3.14
The function is :term:`soft deprecated` and should no longer be used to
write new code. The :mod:`subprocess` module is recommended instead.


.. function:: posix_spawn(path, argv, env, *, file_actions=None, \
setpgroup=None, resetids=False, setsid=False, setsigmask=(), \
Expand Down Expand Up @@ -4868,6 +4891,10 @@ written in Python, such as a mail server's external command delivery program.
.. versionchanged:: 3.6
Accepts a :term:`path-like object`.

.. deprecated:: 3.14
These functions are :term:`soft deprecated` and should no longer be used
to write new code. The :mod:`subprocess` module is recommended instead.


.. data:: P_NOWAIT
P_NOWAITO
Expand Down Expand Up @@ -4972,7 +4999,7 @@ written in Python, such as a mail server's external command delivery program.
shell documentation.

The :mod:`subprocess` module provides more powerful facilities for spawning
new processes and retrieving their results; using that module is preferable
new processes and retrieving their results; using that module is recommended
to using this function. See the :ref:`subprocess-replacements` section in
the :mod:`subprocess` documentation for some helpful recipes.

Expand Down
5 changes: 0 additions & 5 deletions Doc/library/pathlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1554,11 +1554,6 @@ Copying, renaming and deleting
permissions. After the copy is complete, users may wish to call
:meth:`Path.chmod` to set the permissions of the target file.

.. warning::
On old builds of Windows (before Windows 10 build 19041), this method
raises :exc:`OSError` when a symlink to a directory is encountered and
*follow_symlinks* is false.

.. versionadded:: 3.14


Expand Down
6 changes: 6 additions & 0 deletions Doc/library/socketserver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ server is the address family.
waits until all non-daemon threads complete, except if
:attr:`block_on_close` attribute is ``False``.

.. attribute:: max_children

Specify how many child processes will exist to handle requests at a time
for :class:`ForkingMixIn`. If the limit is reached,
new requests will wait until one child process has finished.

.. attribute:: daemon_threads

For :class:`ThreadingMixIn` use daemonic threads by setting
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4565,7 +4565,7 @@ can be used interchangeably to index the same dictionary entry.

Return a shallow copy of the dictionary.

.. classmethod:: fromkeys(iterable, value=None)
.. classmethod:: fromkeys(iterable, value=None, /)

Create a new dictionary with keys from *iterable* and values set to *value*.

Expand Down
2 changes: 2 additions & 0 deletions Doc/library/warnings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ the disposition of the match. Each entry is a tuple of the form (*action*,
+---------------+----------------------------------------------+
| ``"always"`` | always print matching warnings |
+---------------+----------------------------------------------+
| ``"all"`` | alias to "always" |
+---------------+----------------------------------------------+
| ``"module"`` | print the first occurrence of matching |
| | warnings for each module where the warning |
| | is issued (regardless of line number) |
Expand Down
10 changes: 6 additions & 4 deletions Doc/reference/expressions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,12 @@ A comprehension in an :keyword:`!async def` function may consist of either a
:keyword:`!for` or :keyword:`!async for` clause following the leading
expression, may contain additional :keyword:`!for` or :keyword:`!async for`
clauses, and may also use :keyword:`await` expressions.
If a comprehension contains either :keyword:`!async for` clauses or
:keyword:`!await` expressions or other asynchronous comprehensions it is called
an :dfn:`asynchronous comprehension`. An asynchronous comprehension may
suspend the execution of the coroutine function in which it appears.

If a comprehension contains :keyword:`!async for` clauses, or if it contains
:keyword:`!await` expressions or other asynchronous comprehensions anywhere except
the iterable expression in the leftmost :keyword:`!for` clause, it is called an
:dfn:`asynchronous comprehension`. An asynchronous comprehension may suspend the
execution of the coroutine function in which it appears.
See also :pep:`530`.

.. versionadded:: 3.6
Expand Down
19 changes: 17 additions & 2 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,12 @@ Improved Modules
ast
---

Added :func:`ast.compare` for comparing two ASTs.
(Contributed by Batuhan Taskaya and Jeremy Hylton in :issue:`15987`.)
* Added :func:`ast.compare` for comparing two ASTs.
(Contributed by Batuhan Taskaya and Jeremy Hylton in :issue:`15987`.)

* Add support for :func:`copy.replace` for AST nodes.

(Contributed by Bénédikt Tran in :gh:`121141`.)

os
--
Expand Down Expand Up @@ -144,6 +148,11 @@ Deprecated
as a single positional argument.
(Contributed by Serhiy Storchaka in :gh:`109218`.)

* :term:`Soft deprecate <soft deprecated>` :func:`os.popen` and
:func:`os.spawn* <os.spawnl>` functions. They should no longer be used to
write new code. The :mod:`subprocess` module is recommended instead.
(Contributed by Victor Stinner in :gh:`120743`.)


Removed
=======
Expand Down Expand Up @@ -300,6 +309,12 @@ Porting to Python 3.14
This section lists previously described changes and other bugfixes
that may require changes to your code.

Changes in the Python API
-------------------------

* :class:`functools.partial` is now a method descriptor.
Wrap it in :func:`staticmethod` if you want to preserve the old behavior.
(Contributed by Serhiy Storchaka and Dominykas Grigonis in :gh:`121027`.)

Build Changes
=============
Expand Down
26 changes: 26 additions & 0 deletions Include/cpython/modsupport.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef Py_CPYTHON_MODSUPPORT_H
# error "this header file must not be included directly"
#endif

// A data structure that can be used to run initialization code once in a
// thread-safe manner. The C++11 equivalent is std::call_once.
typedef struct {
uint8_t v;
} _PyOnceFlag;

typedef struct _PyArg_Parser {
const char *format;
const char * const *keywords;
const char *fname;
const char *custom_msg;
_PyOnceFlag once; /* atomic one-time initialization flag */
int is_kwtuple_owned; /* does this parser own the kwtuple object? */
int pos; /* number of positional-only arguments */
int min; /* minimal number of arguments */
int max; /* maximal number of positional arguments */
PyObject *kwtuple; /* tuple of keyword parameter names */
struct _PyArg_Parser *next;
} _PyArg_Parser;

PyAPI_FUNC(int) _PyArg_ParseTupleAndKeywordsFast(PyObject *, PyObject *,
struct _PyArg_Parser *, ...);
8 changes: 4 additions & 4 deletions Include/internal/pycore_backoff.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ initial_jump_backoff_counter(void)
* otherwise when a side exit warms up we may construct
* a new trace before the Tier 1 code has properly re-specialized.
* Backoff sequence 64, 128, 256, 512, 1024, 2048, 4096. */
#define COLD_EXIT_INITIAL_VALUE 64
#define COLD_EXIT_INITIAL_BACKOFF 6
#define SIDE_EXIT_INITIAL_VALUE 64
#define SIDE_EXIT_INITIAL_BACKOFF 6

static inline _Py_BackoffCounter
initial_temperature_backoff_counter(void)
{
return make_backoff_counter(COLD_EXIT_INITIAL_VALUE,
COLD_EXIT_INITIAL_BACKOFF);
return make_backoff_counter(SIDE_EXIT_INITIAL_VALUE,
SIDE_EXIT_INITIAL_BACKOFF);
}

/* Unreachable backoff counter. */
Expand Down
2 changes: 1 addition & 1 deletion Include/internal/pycore_code.h
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ write_location_entry_start(uint8_t *ptr, int code, int length)
#define ADAPTIVE_COOLDOWN_BACKOFF 0

// Can't assert this in pycore_backoff.h because of header order dependencies
static_assert(COLD_EXIT_INITIAL_VALUE > ADAPTIVE_COOLDOWN_VALUE,
static_assert(SIDE_EXIT_INITIAL_VALUE > ADAPTIVE_COOLDOWN_VALUE,
"Cold exit value should be larger than adaptive cooldown value");

static inline _Py_BackoffCounter
Expand Down
6 changes: 0 additions & 6 deletions Include/internal/pycore_lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,6 @@ _PyRawMutex_Unlock(_PyRawMutex *m)
_PyRawMutex_UnlockSlow(m);
}

// A data structure that can be used to run initialization code once in a
// thread-safe manner. The C++11 equivalent is std::call_once.
typedef struct {
uint8_t v;
} _PyOnceFlag;

// Type signature for one-time initialization functions. The function should
// return 0 on success and -1 on failure.
typedef int _Py_once_fn_t(void *arg);
Expand Down
18 changes: 0 additions & 18 deletions Include/internal/pycore_modsupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,6 @@ PyAPI_FUNC(void) _PyArg_BadArgument(

// --- _PyArg_Parser API ---------------------------------------------------

typedef struct _PyArg_Parser {
const char *format;
const char * const *keywords;
const char *fname;
const char *custom_msg;
_PyOnceFlag once; /* atomic one-time initialization flag */
int is_kwtuple_owned; /* does this parser own the kwtuple object? */
int pos; /* number of positional-only arguments */
int min; /* minimal number of arguments */
int max; /* maximal number of positional arguments */
PyObject *kwtuple; /* tuple of keyword parameter names */
struct _PyArg_Parser *next;
} _PyArg_Parser;

// Export for '_testclinic' shared extension
PyAPI_FUNC(int) _PyArg_ParseTupleAndKeywordsFast(PyObject *, PyObject *,
struct _PyArg_Parser *, ...);

// Export for '_dbm' shared extension
PyAPI_FUNC(int) _PyArg_ParseStackAndKeywords(
PyObject *const *args,
Expand Down
Loading

0 comments on commit d98debb

Please sign in to comment.