From 280914cd46f4411a2e01150bf9d9c53dff19fa66 Mon Sep 17 00:00:00 2001 From: shadchin Date: Wed, 24 Jun 2026 07:09:14 +0300 Subject: Update Python 3 to 3.13.14 commit_hash:9913a0288f56b5ddd0f99e5b2ff1569d491cbe5d --- .../.yandex_meta/devtools.copyrights.report | 4 +- .../python3/.yandex_meta/devtools.licenses.report | 4 +- contrib/tools/python3/.yandex_meta/override.nix | 4 +- .../tools/python3/Include/dynamic_annotations.h | 3 + .../tools/python3/Include/internal/pycore_pyhash.h | 8 +- contrib/tools/python3/Include/patchlevel.h | 4 +- contrib/tools/python3/Include/pyexpat.h | 8 + contrib/tools/python3/Lib/_collections_abc.py | 29 +- contrib/tools/python3/Lib/_pydecimal.py | 107 +- contrib/tools/python3/Lib/_pyio.py | 126 +- contrib/tools/python3/Lib/argparse.py | 2 +- contrib/tools/python3/Lib/asyncio/__main__.py | 12 +- contrib/tools/python3/Lib/asyncio/base_events.py | 37 +- contrib/tools/python3/Lib/asyncio/events.py | 21 +- contrib/tools/python3/Lib/asyncio/locks.py | 18 +- .../tools/python3/Lib/asyncio/proactor_events.py | 3 +- contrib/tools/python3/Lib/asyncio/queues.py | 36 +- contrib/tools/python3/Lib/asyncio/runners.py | 3 +- .../tools/python3/Lib/asyncio/selector_events.py | 31 +- contrib/tools/python3/Lib/asyncio/streams.py | 14 +- contrib/tools/python3/Lib/asyncio/tasks.py | 57 +- contrib/tools/python3/Lib/asyncio/threads.py | 3 +- contrib/tools/python3/Lib/asyncio/timeouts.py | 3 +- contrib/tools/python3/Lib/asyncio/unix_events.py | 21 +- .../tools/python3/Lib/asyncio/windows_events.py | 3 + contrib/tools/python3/Lib/asyncio/windows_utils.py | 3 +- contrib/tools/python3/Lib/base64.py | 37 +- .../tools/python3/Lib/concurrent/futures/_base.py | 106 +- .../python3/Lib/concurrent/futures/process.py | 43 +- contrib/tools/python3/Lib/configparser.py | 17 +- contrib/tools/python3/Lib/curses/textpad.py | 12 +- contrib/tools/python3/Lib/dataclasses.py | 72 +- .../python3/Lib/email/_header_value_parser.py | 25 +- contrib/tools/python3/Lib/email/_parseaddr.py | 2 +- contrib/tools/python3/Lib/email/charset.py | 2 - contrib/tools/python3/Lib/email/generator.py | 2 +- contrib/tools/python3/Lib/email/quoprimime.py | 2 +- contrib/tools/python3/Lib/encodings/aliases.py | 8 + contrib/tools/python3/Lib/ensurepip/__init__.py | 2 +- contrib/tools/python3/Lib/enum.py | 25 +- contrib/tools/python3/Lib/ftplib.py | 11 +- contrib/tools/python3/Lib/functools.py | 12 +- contrib/tools/python3/Lib/glob.py | 34 +- contrib/tools/python3/Lib/gzip.py | 66 +- contrib/tools/python3/Lib/http/client.py | 11 +- contrib/tools/python3/Lib/http/cookies.py | 8 +- contrib/tools/python3/Lib/imaplib.py | 2 +- contrib/tools/python3/Lib/inspect.py | 2 +- contrib/tools/python3/Lib/json/__init__.py | 8 +- contrib/tools/python3/Lib/json/tool.py | 3 +- contrib/tools/python3/Lib/locale.py | 477 +++- .../python3/Lib/multiprocessing/connection.py | 6 +- .../python3/Lib/multiprocessing/popen_fork.py | 12 +- .../Lib/multiprocessing/resource_tracker.py | 89 +- contrib/tools/python3/Lib/ntpath.py | 16 +- contrib/tools/python3/Lib/pickle.py | 12 +- .../tools/python3/Lib/pydoc_data/module_docs.py | 2 +- contrib/tools/python3/Lib/pydoc_data/topics.py | 256 +- contrib/tools/python3/Lib/rlcompleter.py | 17 +- contrib/tools/python3/Lib/runpy.py | 25 +- contrib/tools/python3/Lib/shutil.py | 40 +- contrib/tools/python3/Lib/smtplib.py | 2 +- contrib/tools/python3/Lib/socket.py | 28 +- contrib/tools/python3/Lib/tarfile.py | 51 +- contrib/tools/python3/Lib/timeit.py | 2 +- contrib/tools/python3/Lib/tomllib/_parser.py | 14 +- contrib/tools/python3/Lib/traceback.py | 19 +- contrib/tools/python3/Lib/types.py | 25 +- contrib/tools/python3/Lib/typing.py | 229 +- contrib/tools/python3/Lib/unittest/mock.py | 4 + contrib/tools/python3/Lib/urllib/robotparser.py | 207 +- .../tools/python3/Lib/venv/scripts/common/activate | 4 +- contrib/tools/python3/Lib/webbrowser.py | 5 +- contrib/tools/python3/Lib/xml/etree/ElementTree.py | 96 +- contrib/tools/python3/Lib/xmlrpc/client.py | 2 +- contrib/tools/python3/Lib/ya.make | 4 +- contrib/tools/python3/Lib/zipfile/__init__.py | 68 +- contrib/tools/python3/Modules/_abc.c | 8 +- contrib/tools/python3/Modules/_asynciomodule.c | 31 +- contrib/tools/python3/Modules/_bisectmodule.c | 12 +- contrib/tools/python3/Modules/_bz2module.c | 42 +- contrib/tools/python3/Modules/_codecsmodule.c | 42 +- contrib/tools/python3/Modules/_collectionsmodule.c | 10 +- contrib/tools/python3/Modules/_csv.c | 6 + contrib/tools/python3/Modules/_ctypes/_ctypes.c | 2 +- contrib/tools/python3/Modules/_datetimemodule.c | 6 +- contrib/tools/python3/Modules/_elementtree.c | 57 +- contrib/tools/python3/Modules/_functoolsmodule.c | 3 +- contrib/tools/python3/Modules/_hashopenssl.c | 12 +- .../tools/python3/Modules/_interpchannelsmodule.c | 4 +- .../tools/python3/Modules/_interpqueuesmodule.c | 1 + contrib/tools/python3/Modules/_io/_iomodule.c | 88 +- contrib/tools/python3/Modules/_io/bytesio.c | 12 +- .../tools/python3/Modules/_io/clinic/_iomodule.c.h | 86 +- .../tools/python3/Modules/_io/clinic/bytesio.c.h | 10 +- .../tools/python3/Modules/_io/clinic/fileio.c.h | 53 +- .../tools/python3/Modules/_io/clinic/iobase.c.h | 16 +- .../tools/python3/Modules/_io/clinic/stringio.c.h | 5 +- .../tools/python3/Modules/_io/clinic/textio.c.h | 15 +- .../python3/Modules/_io/clinic/winconsoleio.c.h | 8 +- contrib/tools/python3/Modules/_io/fileio.c | 63 +- contrib/tools/python3/Modules/_io/iobase.c | 18 +- contrib/tools/python3/Modules/_io/stringio.c | 5 +- contrib/tools/python3/Modules/_io/textio.c | 20 +- contrib/tools/python3/Modules/_io/winconsoleio.c | 11 +- contrib/tools/python3/Modules/_json.c | 32 +- contrib/tools/python3/Modules/_lzmamodule.c | 24 +- .../Modules/_multiprocessing/clinic/posixshmem.c.h | 8 +- .../python3/Modules/_multiprocessing/posixshmem.c | 8 +- contrib/tools/python3/Modules/_opcode.c | 3 +- contrib/tools/python3/Modules/_posixsubprocess.c | 16 +- contrib/tools/python3/Modules/_queuemodule.c | 20 +- contrib/tools/python3/Modules/_sqlite/blob.c | 39 +- .../tools/python3/Modules/_sqlite/clinic/blob.c.h | 19 +- .../python3/Modules/_sqlite/clinic/connection.c.h | 41 +- contrib/tools/python3/Modules/_sqlite/connection.c | 96 +- contrib/tools/python3/Modules/_sqlite/ya.make | 4 +- contrib/tools/python3/Modules/_sre/sre.c | 4 +- contrib/tools/python3/Modules/_ssl.c | 79 +- contrib/tools/python3/Modules/_struct.c | 25 +- .../Modules/_testlimitedcapi/clinic/long.c.h | 6 +- .../tools/python3/Modules/_testlimitedcapi/long.c | 6 +- .../tools/python3/Modules/_testlimitedcapi/parts.h | 1 + .../python3/Modules/_testlimitedcapi/weakref.c | 78 + contrib/tools/python3/Modules/_winapi.c | 5 +- contrib/tools/python3/Modules/arraymodule.c | 42 +- contrib/tools/python3/Modules/binascii.c | 8 + .../Modules/cjkcodecs/clinic/multibytecodec.c.h | 18 +- .../python3/Modules/cjkcodecs/multibytecodec.c | 20 +- contrib/tools/python3/Modules/clinic/_abc.c.h | 8 +- .../python3/Modules/clinic/_asynciomodule.c.h | 19 +- .../tools/python3/Modules/clinic/_bisectmodule.c.h | 10 +- .../tools/python3/Modules/clinic/_bz2module.c.h | 23 +- .../tools/python3/Modules/clinic/_codecsmodule.c.h | 34 +- .../tools/python3/Modules/clinic/_curses_panel.c.h | 8 +- .../tools/python3/Modules/clinic/_cursesmodule.c.h | 282 ++- .../python3/Modules/clinic/_datetimemodule.c.h | 6 +- .../tools/python3/Modules/clinic/_dbmmodule.c.h | 5 +- .../tools/python3/Modules/clinic/_gdbmmodule.c.h | 18 +- .../tools/python3/Modules/clinic/_hashopenssl.c.h | 10 +- .../tools/python3/Modules/clinic/_lzmamodule.c.h | 23 +- .../python3/Modules/clinic/_posixsubprocess.c.h | 16 +- .../tools/python3/Modules/clinic/_queuemodule.c.h | 16 +- contrib/tools/python3/Modules/clinic/_ssl.c.h | 49 +- .../python3/Modules/clinic/_testmultiphase.c.h | 6 +- contrib/tools/python3/Modules/clinic/_tkinter.c.h | 5 +- .../tools/python3/Modules/clinic/arraymodule.c.h | 23 +- .../tools/python3/Modules/clinic/cmathmodule.c.h | 14 +- contrib/tools/python3/Modules/clinic/gcmodule.c.h | 13 +- .../python3/Modules/clinic/itertoolsmodule.c.h | 6 +- .../tools/python3/Modules/clinic/mathmodule.c.h | 11 +- .../tools/python3/Modules/clinic/overlapped.c.h | 7 +- contrib/tools/python3/Modules/clinic/pyexpat.c.h | 177 +- .../tools/python3/Modules/clinic/selectmodule.c.h | 35 +- .../tools/python3/Modules/clinic/signalmodule.c.h | 17 +- contrib/tools/python3/Modules/clinic/termios.c.h | 5 +- .../tools/python3/Modules/clinic/zlibmodule.c.h | 27 +- contrib/tools/python3/Modules/cmathmodule.c | 16 +- contrib/tools/python3/Modules/faulthandler.c | 15 - contrib/tools/python3/Modules/gcmodule.c | 15 +- contrib/tools/python3/Modules/itertoolsmodule.c | 12 +- contrib/tools/python3/Modules/main.c | 1 + contrib/tools/python3/Modules/mathmodule.c | 13 +- contrib/tools/python3/Modules/overlapped.c | 12 +- contrib/tools/python3/Modules/posixmodule.c | 2 +- contrib/tools/python3/Modules/pyexpat.c | 134 +- contrib/tools/python3/Modules/selectmodule.c | 45 +- contrib/tools/python3/Modules/signalmodule.c | 21 +- contrib/tools/python3/Modules/socketmodule.c | 3 + contrib/tools/python3/Modules/termios.c | 5 +- contrib/tools/python3/Modules/unicodedata.c | 175 +- contrib/tools/python3/Modules/zlibmodule.c | 30 +- contrib/tools/python3/Objects/bytearrayobject.c | 91 +- contrib/tools/python3/Objects/bytes_methods.c | 4 +- contrib/tools/python3/Objects/bytesobject.c | 94 +- .../python3/Objects/clinic/bytearrayobject.c.h | 73 +- .../tools/python3/Objects/clinic/bytesobject.c.h | 75 +- .../tools/python3/Objects/clinic/codeobject.c.h | 5 +- .../tools/python3/Objects/clinic/floatobject.c.h | 8 +- .../tools/python3/Objects/clinic/listobject.c.h | 10 +- .../tools/python3/Objects/clinic/longobject.c.h | 45 +- .../tools/python3/Objects/clinic/memoryobject.c.h | 17 +- .../tools/python3/Objects/clinic/odictobject.c.h | 5 +- .../tools/python3/Objects/clinic/unicodeobject.c.h | 162 +- contrib/tools/python3/Objects/codeobject.c | 5 +- contrib/tools/python3/Objects/descrobject.c | 2 +- contrib/tools/python3/Objects/dictobject.c | 3 +- contrib/tools/python3/Objects/enumobject.c | 2 +- contrib/tools/python3/Objects/exceptions.c | 4 +- contrib/tools/python3/Objects/floatobject.c | 8 +- contrib/tools/python3/Objects/genericaliasobject.c | 6 +- contrib/tools/python3/Objects/genobject.c | 8 +- contrib/tools/python3/Objects/listobject.c | 13 +- contrib/tools/python3/Objects/longobject.c | 50 +- contrib/tools/python3/Objects/memoryobject.c | 27 +- contrib/tools/python3/Objects/odictobject.c | 5 +- contrib/tools/python3/Objects/setobject.c | 6 +- contrib/tools/python3/Objects/sliceobject.c | 4 +- contrib/tools/python3/Objects/tupleobject.c | 8 +- contrib/tools/python3/Objects/typeobject.c | 12 +- contrib/tools/python3/Objects/unicodeobject.c | 212 +- contrib/tools/python3/Objects/weakrefobject.c | 3 +- contrib/tools/python3/PC/clinic/_wmimodule.cpp.h | 6 +- contrib/tools/python3/Parser/lexer/state.c | 5 +- .../python3/Parser/tokenizer/file_tokenizer.c | 1 + contrib/tools/python3/Parser/tokenizer/helpers.c | 2 + .../python3/Parser/tokenizer/readline_tokenizer.c | 1 + contrib/tools/python3/Python/asm_trampoline.S | 4 + .../tools/python3/Python/asm_trampoline_aarch64.h | 56 + contrib/tools/python3/Python/assemble.c | 6 +- contrib/tools/python3/Python/bltinmodule.c | 121 +- .../tools/python3/Python/clinic/bltinmodule.c.h | 59 +- contrib/tools/python3/Python/clinic/context.c.h | 27 +- contrib/tools/python3/Python/clinic/import.c.h | 7 +- contrib/tools/python3/Python/clinic/marshal.c.h | 10 +- contrib/tools/python3/Python/clinic/sysmodule.c.h | 5 +- contrib/tools/python3/Python/compile.c | 17 +- contrib/tools/python3/Python/context.c | 39 +- contrib/tools/python3/Python/flowgraph.c | 16 + .../Python/frozen_modules/_collections_abc.h | 1396 +++++------ .../tools/python3/Python/frozen_modules/ntpath.h | 2632 ++++++++++---------- .../tools/python3/Python/frozen_modules/runpy.h | 1191 ++++----- contrib/tools/python3/Python/hamt.c | 2 + contrib/tools/python3/Python/import.c | 9 +- contrib/tools/python3/Python/lock.c | 11 +- contrib/tools/python3/Python/marshal.c | 57 +- contrib/tools/python3/Python/parking_lot.c | 8 +- contrib/tools/python3/Python/perf_jit_trampoline.c | 13 + contrib/tools/python3/Python/perf_trampoline.c | 17 +- contrib/tools/python3/Python/pylifecycle.c | 4 +- contrib/tools/python3/Python/pythonrun.c | 1 + contrib/tools/python3/Python/sysmodule.c | 7 +- contrib/tools/python3/README.rst | 2 +- contrib/tools/python3/bin/ya.make | 4 +- contrib/tools/python3/patches/pr151320.patch | 31 + contrib/tools/python3/ya.make | 5 +- 236 files changed, 6961 insertions(+), 5186 deletions(-) create mode 100644 contrib/tools/python3/Modules/_testlimitedcapi/weakref.c create mode 100644 contrib/tools/python3/Python/asm_trampoline_aarch64.h create mode 100644 contrib/tools/python3/patches/pr151320.patch (limited to 'contrib/tools/python3') diff --git a/contrib/tools/python3/.yandex_meta/devtools.copyrights.report b/contrib/tools/python3/.yandex_meta/devtools.copyrights.report index 0623f023e63..c3428fe1aee 100644 --- a/contrib/tools/python3/.yandex_meta/devtools.copyrights.report +++ b/contrib/tools/python3/.yandex_meta/devtools.copyrights.report @@ -294,7 +294,7 @@ BELONGS ya.make Score : 100.00 Match type : COPYRIGHT Files with this license: - Modules/selectmodule.c [1731:1732] + Modules/selectmodule.c [1732:1733] KEEP COPYRIGHT_SERVICE_LABEL 4c4db466ec49df90501b3efa15b48115 BELONGS ya.make @@ -404,7 +404,7 @@ BELONGS ya.make Score : 100.00 Match type : COPYRIGHT Files with this license: - Modules/binascii.c [633:634] + Modules/binascii.c [641:642] KEEP COPYRIGHT_SERVICE_LABEL 6df801c8be98b70cf1e1bd99eee48534 BELONGS Lib/ya.make diff --git a/contrib/tools/python3/.yandex_meta/devtools.licenses.report b/contrib/tools/python3/.yandex_meta/devtools.licenses.report index 28aea9f03f3..f46af9bbf22 100644 --- a/contrib/tools/python3/.yandex_meta/devtools.licenses.report +++ b/contrib/tools/python3/.yandex_meta/devtools.licenses.report @@ -566,7 +566,7 @@ BELONGS ya.make Match type : TEXT Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/gary-s-brown.LICENSE Files with this license: - Modules/binascii.c [633:634] + Modules/binascii.c [641:642] KEEP Python-2.0 6a19cf8041a37669b2cd07b9cd3eace3 BELONGS ya.make @@ -1245,7 +1245,7 @@ BELONGS ya.make Match type : TEXT Links : http://opensource.org/licenses/bsd-license.php, http://www.opensource.org/licenses/BSD-2-Clause, https://spdx.org/licenses/BSD-2-Clause Files with this license: - Modules/selectmodule.c [1734:1753] + Modules/selectmodule.c [1735:1754] KEEP X11-Hanson fee24880a028f5d50965c0ed93a7a806 BELONGS ya.make diff --git a/contrib/tools/python3/.yandex_meta/override.nix b/contrib/tools/python3/.yandex_meta/override.nix index dbb217f044e..79d53ffada0 100644 --- a/contrib/tools/python3/.yandex_meta/override.nix +++ b/contrib/tools/python3/.yandex_meta/override.nix @@ -1,11 +1,11 @@ pkgs: attrs: with pkgs; with attrs; rec { - version = "3.13.13"; + version = "3.13.14"; src = fetchFromGitHub { owner = "python"; repo = "cpython"; rev = "v${version}"; - hash = "sha256-JUA430BZJ4cMS/0XLuuYsU85jPkDJLXtl+Jccdlm+fk="; + hash = "sha256-jqvOlqpH9gZtYhyLn+BeWeWj/YHZX3ine6X4NPc59fY="; }; patches = []; diff --git a/contrib/tools/python3/Include/dynamic_annotations.h b/contrib/tools/python3/Include/dynamic_annotations.h index 4d4def9bf89..5290319dd76 100644 --- a/contrib/tools/python3/Include/dynamic_annotations.h +++ b/contrib/tools/python3/Include/dynamic_annotations.h @@ -461,6 +461,7 @@ int RunningOnValgrind(void); #if DYNAMIC_ANNOTATIONS_ENABLED != 0 && defined(__cplusplus) +extern "C++" { /* _Py_ANNOTATE_UNPROTECTED_READ is the preferred way to annotate racey reads. Instead of doing @@ -476,6 +477,8 @@ int RunningOnValgrind(void); _Py_ANNOTATE_IGNORE_READS_END(); return res; } +} + /* Apply _Py_ANNOTATE_BENIGN_RACE_SIZED to a static variable. */ #define _Py_ANNOTATE_BENIGN_RACE_STATIC(static_var, description) \ namespace { \ diff --git a/contrib/tools/python3/Include/internal/pycore_pyhash.h b/contrib/tools/python3/Include/internal/pycore_pyhash.h index 0ce08900e96..9aff316ce62 100644 --- a/contrib/tools/python3/Include/internal/pycore_pyhash.h +++ b/contrib/tools/python3/Include/internal/pycore_pyhash.h @@ -30,14 +30,14 @@ PyAPI_FUNC(Py_hash_t) _Py_HashBytes(const void*, Py_ssize_t); * pppppppp ssssssss ........ fnv -- two Py_hash_t * k0k0k0k0 k1k1k1k1 ........ siphash -- two uint64_t * ........ ........ ssssssss djbx33a -- 16 bytes padding + one Py_hash_t - * ........ ........ eeeeeeee pyexpat XML hash salt + * eeeeeeee eeeeeeee eeeeeeee pyexpat XML hash salt * * memory layout on 32 bit systems * cccccccc cccccccc cccccccc uc * ppppssss ........ ........ fnv -- two Py_hash_t * k0k0k0k0 k1k1k1k1 ........ siphash -- two uint64_t (*) * ........ ........ ssss.... djbx33a -- 16 bytes padding + one Py_hash_t - * ........ ........ eeee.... pyexpat XML hash salt + * eeeeeeee eeeeeeee eeee.... pyexpat XML hash salt * * (*) The siphash member may not be available on 32 bit platforms without * an unsigned int64 data type. @@ -61,7 +61,9 @@ typedef union { Py_hash_t suffix; } djbx33a; struct { - unsigned char padding[16]; + /* 16 bytes for XML_SetHashSalt16Bytes */ + uint8_t hashsalt16[16]; + /* 4/8 bytes for legacy XML_SetHashSalt */ Py_hash_t hashsalt; } expat; } _Py_HashSecret_t; diff --git a/contrib/tools/python3/Include/patchlevel.h b/contrib/tools/python3/Include/patchlevel.h index 746b9fcaa5f..e33d30adf95 100644 --- a/contrib/tools/python3/Include/patchlevel.h +++ b/contrib/tools/python3/Include/patchlevel.h @@ -18,12 +18,12 @@ /*--start constants--*/ #define PY_MAJOR_VERSION 3 #define PY_MINOR_VERSION 13 -#define PY_MICRO_VERSION 13 +#define PY_MICRO_VERSION 14 #define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL #define PY_RELEASE_SERIAL 0 /* Version as a string */ -#define PY_VERSION "3.13.13" +#define PY_VERSION "3.13.14" /*--end constants--*/ /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. diff --git a/contrib/tools/python3/Include/pyexpat.h b/contrib/tools/python3/Include/pyexpat.h index 04548b7684a..a676e16a7a4 100644 --- a/contrib/tools/python3/Include/pyexpat.h +++ b/contrib/tools/python3/Include/pyexpat.h @@ -57,6 +57,14 @@ struct PyExpat_CAPI XML_Parser parser, unsigned long long activationThresholdBytes); XML_Bool (*SetAllocTrackerMaximumAmplification)( XML_Parser parser, float maxAmplificationFactor); + /* might be NULL for expat < 2.4.0 */ + XML_Bool (*SetBillionLaughsAttackProtectionActivationThreshold)( + XML_Parser parser, unsigned long long activationThresholdBytes); + XML_Bool (*SetBillionLaughsAttackProtectionMaximumAmplification)( + XML_Parser parser, float maxAmplificationFactor); + /* might be NULL for expat < 2.8.0 */ + XML_Bool (*SetHashSalt16Bytes)( + XML_Parser parser, const uint8_t entropy[16]); /* always add new stuff to the end! */ }; diff --git a/contrib/tools/python3/Lib/_collections_abc.py b/contrib/tools/python3/Lib/_collections_abc.py index 6e224d36001..da2d0c29f84 100644 --- a/contrib/tools/python3/Lib/_collections_abc.py +++ b/contrib/tools/python3/Lib/_collections_abc.py @@ -461,8 +461,8 @@ class Buffer(metaclass=ABCMeta): class _CallableGenericAlias(GenericAlias): """ Represent `Callable[argtypes, resulttype]`. - This sets ``__args__`` to a tuple containing the flattened ``argtypes`` - followed by ``resulttype``. + This sets ``__args__`` to a tuple containing the flattened + ``argtypes`` followed by ``resulttype``. Example: ``Callable[[int, str], float]`` sets ``__args__`` to ``(int, str, float)``. @@ -943,8 +943,9 @@ class MutableMapping(Mapping): __marker = object() def pop(self, key, default=__marker): - '''D.pop(k[,d]) -> v, remove specified key and return the corresponding value. - If key is not found, d is returned if given, otherwise KeyError is raised. + '''D.pop(k[,d]) -> v, remove specified key and return the corresponding + value. If key is not found, d is returned if given, otherwise + KeyError is raised. ''' try: value = self[key] @@ -978,9 +979,12 @@ class MutableMapping(Mapping): def update(self, other=(), /, **kwds): ''' D.update([E, ]**F) -> None. Update D from mapping/iterable E and F. - If E present and has a .keys() method, does: for k in E.keys(): D[k] = E[k] - If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v - In either case, this is followed by: for k, v in F.items(): D[k] = v + If E present and has a .keys() method, does: + for k in E.keys(): D[k] = E[k] + If E present and lacks .keys() method, does: + for (k, v) in E: D[k] = v + In either case, this is followed by: + for k, v in F.items(): D[k] = v ''' if isinstance(other, Mapping): for key in other: @@ -1045,8 +1049,8 @@ class Sequence(Reversible, Collection): yield self[i] def index(self, value, start=0, stop=None): - '''S.index(value, [start, [stop]]) -> integer -- return first index of value. - Raises ValueError if the value is not present. + '''S.index(value, [start, [stop]]) -> integer -- return first index of + value. Raises ValueError if the value is not present. Supporting start and stop arguments is optional, but recommended. @@ -1153,15 +1157,16 @@ class MutableSequence(Sequence): self[i], self[n-i-1] = self[n-i-1], self[i] def extend(self, values): - 'S.extend(iterable) -- extend sequence by appending elements from the iterable' + """S.extend(iterable) -- extend sequence by appending elements from the + iterable""" if values is self: values = list(values) for v in values: self.append(v) def pop(self, index=-1): - '''S.pop([index]) -> item -- remove and return item at index (default last). - Raise IndexError if list is empty or index is out of range. + '''S.pop([index]) -> item -- remove and return item at index (default + last). Raise IndexError if list is empty or index is out of range. ''' v = self[index] del self[index] diff --git a/contrib/tools/python3/Lib/_pydecimal.py b/contrib/tools/python3/Lib/_pydecimal.py index 49119ede7ce..f83524a2560 100644 --- a/contrib/tools/python3/Lib/_pydecimal.py +++ b/contrib/tools/python3/Lib/_pydecimal.py @@ -102,8 +102,8 @@ class DecimalException(ArithmeticError): anything, though. handle -- Called when context._raise_error is called and the - trap_enabler is not set. First argument is self, second is the - context. More arguments can be given, those being after + trap_enabler is not set. First argument is self, second is + the context. More arguments can be given, those being after the explanation in _raise_error (For example, context._raise_error(NewError, '(-x)!', self._sign) would call NewError().handle(context, self._sign).) @@ -220,11 +220,12 @@ class InvalidContext(InvalidOperation): """Invalid context. Unknown rounding, for example. This occurs and signals invalid-operation if an invalid context was - detected during an operation. This can occur if contexts are not checked - on creation and either the precision exceeds the capability of the - underlying concrete representation or an unknown or unsupported rounding - was specified. These aspects of the context need only be checked when - the values are required to be used. The result is [0,qNaN]. + detected during an operation. This can occur if contexts are not + checked on creation and either the precision exceeds the capability of + the underlying concrete representation or an unknown or unsupported + rounding was specified. These aspects of the context need only be + checked when the values are required to be used. The result is + [0,qNaN]. """ def handle(self, context, *args): @@ -317,8 +318,9 @@ class FloatOperation(DecimalException, TypeError): Decimal.from_float() or context.create_decimal_from_float() do not set the flag. - Otherwise (the signal is trapped), only equality comparisons and explicit - conversions are silent. All other mixed operations raise FloatOperation. + Otherwise (the signal is trapped), only equality comparisons and + explicit conversions are silent. All other mixed operations raise + FloatOperation. """ # List of public traps and flags @@ -2860,8 +2862,8 @@ class Decimal(object): """Compares self to other using the abstract representations. This is not like the standard compare, which use their numerical - value. Note that a total ordering is defined for all possible abstract - representations. + value. Note that a total ordering is defined for all possible + abstract representations. """ other = _convert_other(other, raiseit=True) @@ -2932,7 +2934,8 @@ class Decimal(object): def compare_total_mag(self, other, context=None): """Compares self to other using abstract repr., ignoring sign. - Like compare_total, but with operand's sign ignored and assumed to be 0. + Like compare_total, but with operand's sign ignored and assumed to + be 0. """ other = _convert_other(other, raiseit=True) @@ -4069,9 +4072,9 @@ class Context(object): def abs(self, a): """Returns the absolute value of the operand. - If the operand is negative, the result is the same as using the minus - operation on the operand. Otherwise, the result is the same as using - the plus operation on the operand. + If the operand is negative, the result is the same as using the + minus operation on the operand. Otherwise, the result is the same + as using the plus operation on the operand. >>> ExtendedContext.abs(Decimal('2.1')) Decimal('2.1') @@ -4127,16 +4130,17 @@ class Context(object): def compare(self, a, b): """Compares values numerically. - If the signs of the operands differ, a value representing each operand - ('-1' if the operand is less than zero, '0' if the operand is zero or - negative zero, or '1' if the operand is greater than zero) is used in - place of that operand for the comparison instead of the actual - operand. + If the signs of the operands differ, a value representing each + operand ('-1' if the operand is less than zero, '0' if the operand + is zero or negative zero, or '1' if the operand is greater than + zero) is used in place of that operand for the comparison instead of + the actual operand. - The comparison is then effected by subtracting the second operand from - the first and then returning a value according to the result of the - subtraction: '-1' if the result is less than zero, '0' if the result is - zero or negative zero, or '1' if the result is greater than zero. + The comparison is then effected by subtracting the second operand + from the first and then returning a value according to the result of + the subtraction: '-1' if the result is less than zero, '0' if the + result is zero or negative zero, or '1' if the result is greater + than zero. >>> ExtendedContext.compare(Decimal('2.1'), Decimal('3')) Decimal('-1') @@ -4199,8 +4203,8 @@ class Context(object): """Compares two operands using their abstract representation. This is not like the standard compare, which use their numerical - value. Note that a total ordering is defined for all possible abstract - representations. + value. Note that a total ordering is defined for all possible + abstract representations. >>> ExtendedContext.compare_total(Decimal('12.73'), Decimal('127.9')) Decimal('-1') @@ -4227,7 +4231,8 @@ class Context(object): def compare_total_mag(self, a, b): """Compares two operands using their abstract representation ignoring sign. - Like compare_total, but with operand's sign ignored and assumed to be 0. + Like compare_total, but with operand's sign ignored and assumed to + be 0. """ a = _convert_other(a, raiseit=True) return a.compare_total_mag(b) @@ -4885,8 +4890,8 @@ class Context(object): If either operand is a special value then the general rules apply. Otherwise, the operands are multiplied together - ('long multiplication'), resulting in a number which may be as long as - the sum of the lengths of the two operands. + ('long multiplication'), resulting in a number which may be as long + as the sum of the lengths of the two operands. >>> ExtendedContext.multiply(Decimal('1.20'), Decimal('3')) Decimal('3.60') @@ -5162,19 +5167,19 @@ class Context(object): """Returns a value equal to 'a' (rounded), having the exponent of 'b'. The coefficient of the result is derived from that of the left-hand - operand. It may be rounded using the current rounding setting (if the - exponent is being increased), multiplied by a positive power of ten (if - the exponent is being decreased), or is unchanged (if the exponent is - already equal to that of the right-hand operand). + operand. It may be rounded using the current rounding setting (if + the exponent is being increased), multiplied by a positive power of + ten (if the exponent is being decreased), or is unchanged (if the + exponent is already equal to that of the right-hand operand). Unlike other operations, if the length of the coefficient after the quantize operation would be greater than precision then an Invalid - operation condition is raised. This guarantees that, unless there is - an error condition, the exponent of the result of a quantize is always - equal to that of the right-hand operand. + operation condition is raised. This guarantees that, unless there + is an error condition, the exponent of the result of a quantize is + always equal to that of the right-hand operand. - Also unlike other operations, quantize will never raise Underflow, even - if the result is subnormal and inexact. + Also unlike other operations, quantize will never raise Underflow, + even if the result is subnormal and inexact. >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.001')) Decimal('2.170') @@ -5228,13 +5233,13 @@ class Context(object): """Returns the remainder from integer division. The result is the residue of the dividend after the operation of - calculating integer division as described for divide-integer, rounded - to precision digits if necessary. The sign of the result, if - non-zero, is the same as that of the original dividend. + calculating integer division as described for divide-integer, + rounded to precision digits if necessary. The sign of the result, + if non-zero, is the same as that of the original dividend. - This operation will fail under the same conditions as integer division - (that is, if integer division on the same two operands would fail, the - remainder cannot be calculated). + This operation will fail under the same conditions as integer + division (that is, if integer division on the same two operands + would fail, the remainder cannot be calculated). >>> ExtendedContext.remainder(Decimal('2.1'), Decimal('3')) Decimal('2.1') @@ -5268,9 +5273,9 @@ class Context(object): is chosen). If the result is equal to 0 then its sign will be the sign of a. - This operation will fail under the same conditions as integer division - (that is, if integer division on the same two operands would fail, the - remainder cannot be calculated). + This operation will fail under the same conditions as integer + division (that is, if integer division on the same two operands + would fail, the remainder cannot be calculated). >>> ExtendedContext.remainder_near(Decimal('2.1'), Decimal('3')) Decimal('-0.9') @@ -5328,8 +5333,8 @@ class Context(object): def same_quantum(self, a, b): """Returns True if the two operands have the same exponent. - The result is never affected by either the sign or the coefficient of - either operand. + The result is never affected by either the sign or the coefficient + of either operand. >>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('0.001')) False @@ -5401,8 +5406,8 @@ class Context(object): def sqrt(self, a): """Square root of a non-negative number to context precision. - If the result must be inexact, it is rounded using the round-half-even - algorithm. + If the result must be inexact, it is rounded using the + round-half-even algorithm. >>> ExtendedContext.sqrt(Decimal('0')) Decimal('0') diff --git a/contrib/tools/python3/Lib/_pyio.py b/contrib/tools/python3/Lib/_pyio.py index 9ed2e5b2aa0..7c1635cb331 100644 --- a/contrib/tools/python3/Lib/_pyio.py +++ b/contrib/tools/python3/Lib/_pyio.py @@ -82,27 +82,28 @@ def open(file, mode="r", buffering=-1, encoding=None, errors=None, wrapped. (If a file descriptor is given, it is closed when the returned I/O object is closed, unless closefd is set to False.) - mode is an optional string that specifies the mode in which the file is - opened. It defaults to 'r' which means open for reading in text mode. Other - common values are 'w' for writing (truncating the file if it already - exists), 'x' for exclusive creation of a new file, and 'a' for appending - (which on some Unix systems, means that all writes append to the end of the - file regardless of the current seek position). In text mode, if encoding is - not specified the encoding used is platform dependent. (For reading and - writing raw bytes use binary mode and leave encoding unspecified.) The - available modes are: - - ========= =============================================================== + mode is an optional string that specifies the mode in which the file + is opened. It defaults to 'r' which means open for reading in text + mode. Other common values are 'w' for writing (truncating the file if + it already exists), 'x' for exclusive creation of a new file, and + 'a' for appending (which on some Unix systems, means that all writes + append to the end of the file regardless of the current seek position). + In text mode, if encoding is not specified the encoding used is platform + dependent. (For reading and writing raw bytes use binary mode and leave + encoding unspecified.) The available modes are: + + ========= ========================================================== Character Meaning - --------- --------------------------------------------------------------- + --------- ---------------------------------------------------------- 'r' open for reading (default) 'w' open for writing, truncating the file first 'x' create a new file and open it for writing - 'a' open for writing, appending to the end of the file if it exists + 'a' open for writing, appending to the end of the file if it + exists 'b' binary mode 't' text mode (default) '+' open a disk file for updating (reading and writing) - ========= =============================================================== + ========= ========================================================== The default mode is 'rt' (open for reading text). For binary random access, the mode 'w+b' opens and truncates the file to 0 bytes, while @@ -110,22 +111,22 @@ def open(file, mode="r", buffering=-1, encoding=None, errors=None, raises an `FileExistsError` if the file already exists. Python distinguishes between files opened in binary and text modes, - even when the underlying operating system doesn't. Files opened in + even when the underlying operating system doesn't. Files opened in binary mode (appending 'b' to the mode argument) return contents as - bytes objects without any decoding. In text mode (the default, or when + bytes objects without any decoding. In text mode (the default, or when 't' is appended to the mode argument), the contents of the file are returned as strings, the bytes having been first decoded using a platform-dependent encoding or using the specified encoding if given. buffering is an optional integer used to set the buffering policy. - Pass 0 to switch buffering off (only allowed in binary mode), 1 to select - line buffering (only usable in text mode), and an integer > 1 to indicate - the size of a fixed-size chunk buffer. When no buffering argument is - given, the default buffering policy works as follows: + Pass 0 to switch buffering off (only allowed in binary mode), 1 to + select line buffering (only usable in text mode), and an integer > 1 to + indicate the size of a fixed-size chunk buffer. When no buffering + argument is given, the default buffering policy works as follows: * Binary files are buffered in fixed-size chunks; the size of the buffer - is chosen using a heuristic trying to determine the underlying device's - "block size" and falling back on `io.DEFAULT_BUFFER_SIZE`. + is chosen using a heuristic trying to determine the underlying + device's "block size" and falling back on `io.DEFAULT_BUFFER_SIZE`. On many systems, the buffer will typically be 4096 or 8192 bytes long. * "Interactive" text files (files for which isatty() returns True) @@ -146,8 +147,8 @@ def open(file, mode="r", buffering=-1, encoding=None, errors=None, encoding error strings. newline is a string controlling how universal newlines works (it only - applies to text mode). It can be None, '', '\n', '\r', and '\r\n'. It works - as follows: + applies to text mode). It can be None, '', '\n', '\r', and '\r\n'. It + works as follows: * On input, if newline is None, universal newlines mode is enabled. Lines in the input can end in '\n', '\r', or '\r\n', and @@ -163,17 +164,17 @@ def open(file, mode="r", buffering=-1, encoding=None, errors=None, other legal values, any '\n' characters written are translated to the given string. - closedfd is a bool. If closefd is False, the underlying file descriptor will - be kept open when the file is closed. This does not work when a file name is - given and must be True in that case. + closedfd is a bool. If closefd is False, the underlying file descriptor + will be kept open when the file is closed. This does not work when + a file name is given and must be True in that case. The newly created file is non-inheritable. A custom opener can be used by passing a callable as *opener*. The - underlying file descriptor for the file object is then obtained by calling - *opener* with (*file*, *flags*). *opener* must return an open file - descriptor (passing os.open as *opener* results in functionality similar to - passing None). + underlying file descriptor for the file object is then obtained by + calling *opener* with (*file*, *flags*). *opener* must return an open + file descriptor (passing os.open as *opener* results in functionality + similar to passing None). open() returns a file object whose type depends on the mode, and through which the standard file operations such as reading and writing @@ -357,10 +358,12 @@ class IOBase(metaclass=abc.ABCMeta): interpreted relative to the position indicated by whence. Values for whence are ints: - * 0 -- start of stream (the default); offset should be zero or positive + * 0 -- start of stream (the default); offset should be zero or + positive * 1 -- current stream position; offset may be negative * 2 -- end of stream; offset is usually negative - Some operating systems / file systems could provide additional values. + Some operating systems / file systems could provide additional + values. Return an int indicating the new absolute position. """ @@ -373,8 +376,8 @@ class IOBase(metaclass=abc.ABCMeta): def truncate(self, pos=None): """Truncate file to size bytes. - Size defaults to the current IO position as reported by tell(). Return - the new size. + Size defaults to the current IO position as reported by tell(). + Return the new size. """ self._unsupported("truncate") @@ -498,7 +501,8 @@ class IOBase(metaclass=abc.ABCMeta): def fileno(self): """Returns underlying file descriptor (an int) if one exists. - An OSError is raised if the IO object does not use a file descriptor. + An OSError is raised if the IO object does not use a file + descriptor. """ self._unsupported("fileno") @@ -1482,17 +1486,22 @@ class FileIO(RawIOBase): _closefd = True def __init__(self, file, mode='r', closefd=True, opener=None): - """Open a file. The mode can be 'r' (default), 'w', 'x' or 'a' for reading, - writing, exclusive creation or appending. The file will be created if it - doesn't exist when opened for writing or appending; it will be truncated - when opened for writing. A FileExistsError will be raised if it already - exists when opened for creating. Opening a file for creating implies - writing so this mode behaves in a similar way to 'w'. Add a '+' to the mode - to allow simultaneous reading and writing. A custom opener can be used by - passing a callable as *opener*. The underlying file descriptor for the file - object is then obtained by calling opener with (*name*, *flags*). - *opener* must return an open file descriptor (passing os.open as *opener* - results in functionality similar to passing None). + """Open a file. + + The mode can be 'r' (default), 'w', 'x' or 'a' for reading, + writing, exclusive creation or appending. The file will be created + if it doesn't exist when opened for writing or appending; it will be + truncated when opened for writing. A FileExistsError will be raised + if it already exists when opened for creating. Opening a file for + creating implies writing so this mode behaves in a similar way to + 'w'. Add a '+' to the mode to allow simultaneous reading and + writing. + + A custom opener can be used by passing a callable as *opener*. + The underlying file descriptor for the file object is then obtained + by calling opener with (*name*, *flags*). *opener* must return + an open file descriptor (passing os.open as *opener* results in + functionality similar to passing None). """ if self._fd >= 0: # Have to close the existing file first. @@ -1702,8 +1711,8 @@ class FileIO(RawIOBase): """Write bytes b to file, return number written. Only makes one system call, so not all of the data may be written. - The number of bytes actually written is returned. In non-blocking mode, - returns None if the write would block. + The number of bytes actually written is returned. In non-blocking + mode, returns None if the write would block. """ self._checkClosed() self._checkWritable() @@ -1715,11 +1724,12 @@ class FileIO(RawIOBase): def seek(self, pos, whence=SEEK_SET): """Move to new file position. - Argument offset is a byte count. Optional argument whence defaults to - SEEK_SET or 0 (offset from start of file, offset should be >= 0); other values - are SEEK_CUR or 1 (move relative to current position, positive or negative), - and SEEK_END or 2 (move relative to end of file, usually negative, although - many platforms allow seeking beyond the end of a file). + Argument offset is a byte count. Optional argument whence defaults + to SEEK_SET or 0 (offset from start of file, offset should be >= 0); + other values are SEEK_CUR or 1 (move relative to current position, + positive or negative), and SEEK_END or 2 (move relative to end of + file, usually negative, although many platforms allow seeking beyond + the end of a file). Note that not all file objects are seekable. """ @@ -1751,8 +1761,8 @@ class FileIO(RawIOBase): def close(self): """Close the file. - A closed file cannot be used for further I/O operations. close() may be - called more than once without error. + A closed file cannot be used for further I/O operations. + close() may be called more than once without error. """ if not self.closed: try: @@ -1831,8 +1841,8 @@ class TextIOBase(IOBase): def read(self, size=-1): """Read at most size characters from stream, where size is an int. - Read from underlying buffer until we have size characters or we hit EOF. - If size is negative or omitted, read until EOF. + Read from underlying buffer until we have size characters or we hit + EOF. If size is negative or omitted, read until EOF. Returns a string. """ diff --git a/contrib/tools/python3/Lib/argparse.py b/contrib/tools/python3/Lib/argparse.py index a0faa3f41e2..7d845175644 100644 --- a/contrib/tools/python3/Lib/argparse.py +++ b/contrib/tools/python3/Lib/argparse.py @@ -2601,7 +2601,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): choices = iter(choices) if value not in choices: args = {'value': str(value), - 'choices': ', '.join(map(str, action.choices))} + 'choices': ', '.join(repr(str(choice)) for choice in action.choices)} msg = _('invalid choice: %(value)r (choose from %(choices)s)') raise ArgumentError(action, msg % args) diff --git a/contrib/tools/python3/Lib/asyncio/__main__.py b/contrib/tools/python3/Lib/asyncio/__main__.py index 42bfcdbf50f..2effdbc38da 100644 --- a/contrib/tools/python3/Lib/asyncio/__main__.py +++ b/contrib/tools/python3/Lib/asyncio/__main__.py @@ -96,11 +96,15 @@ class REPLThread(threading.Thread): if not sys.flags.isolated and (startup_path := os.getenv("PYTHONSTARTUP")): sys.audit("cpython.run_startup", startup_path) - - import tokenize - with tokenize.open(startup_path) as f: - startup_code = compile(f.read(), startup_path, "exec") + try: + import tokenize + with tokenize.open(startup_path) as f: + startup_code = compile(f.read(), startup_path, "exec") exec(startup_code, console.locals) + except SystemExit: + raise + except BaseException: + console.showtraceback() ps1 = getattr(sys, "ps1", ">>> ") if can_colorize() and CAN_USE_PYREPL: diff --git a/contrib/tools/python3/Lib/asyncio/base_events.py b/contrib/tools/python3/Lib/asyncio/base_events.py index 84cad10636f..ec8e3b6f79f 100644 --- a/contrib/tools/python3/Lib/asyncio/base_events.py +++ b/contrib/tools/python3/Lib/asyncio/base_events.py @@ -489,10 +489,10 @@ class BaseEventLoop(events.AbstractEventLoop): If factory is None the default task factory will be set. If factory is a callable, it should have a signature matching - '(loop, coro, **kwargs)', where 'loop' will be a reference to the active - event loop, 'coro' will be a coroutine object, and **kwargs will be - arbitrary keyword arguments that should be passed on to Task. - The callable must return a Task. + '(loop, coro, **kwargs)', where 'loop' will be a reference to the + active event loop, 'coro' will be a coroutine object, and **kwargs + will be arbitrary keyword arguments that should be passed on to + Task. The callable must return a Task. """ if factory is not None and not callable(factory): raise TypeError('task factory must be a callable or None') @@ -727,8 +727,8 @@ class BaseEventLoop(events.AbstractEventLoop): def stop(self): """Stop running the event loop. - Every callback already scheduled will still run. This simply informs - run_forever to stop looping after a complete iteration. + Every callback already scheduled will still run. This simply + informs run_forever to stop looping after a complete iteration. """ self._stopping = True @@ -966,7 +966,7 @@ class BaseEventLoop(events.AbstractEventLoop): f"and file {file!r} combination") async def _sock_sendfile_fallback(self, sock, file, offset, count): - if offset: + if hasattr(file, 'seek'): file.seek(offset) blocksize = ( min(count, constants.SENDFILE_FALLBACK_READBUFFER_SIZE) @@ -1073,12 +1073,12 @@ class BaseEventLoop(events.AbstractEventLoop): Create a streaming transport connection to a given internet host and port: socket family AF_INET or socket.AF_INET6 depending on host (or - family if specified), socket type SOCK_STREAM. protocol_factory must be - a callable returning a protocol instance. + family if specified), socket type SOCK_STREAM. protocol_factory must + be a callable returning a protocol instance. - This method is a coroutine which will try to establish the connection - in the background. When successful, the coroutine returns a - (transport, protocol) pair. + This method is a coroutine which will try to establish the + connection in the background. When successful, the coroutine + returns a (transport, protocol) pair. """ if server_hostname is not None and not ssl: raise ValueError('server_hostname is only meaningful with ssl') @@ -1281,7 +1281,6 @@ class BaseEventLoop(events.AbstractEventLoop): raise RuntimeError( f"fallback is disabled and native sendfile is not " f"supported for transport {transport!r}") - return await self._sendfile_fallback(transport, file, offset, count) @@ -1290,7 +1289,7 @@ class BaseEventLoop(events.AbstractEventLoop): "sendfile syscall is not supported") async def _sendfile_fallback(self, transp, file, offset, count): - if offset: + if hasattr(file, 'seek'): file.seek(offset) blocksize = min(count, 16384) if count else 16384 buf = bytearray(blocksize) @@ -1546,11 +1545,11 @@ class BaseEventLoop(events.AbstractEventLoop): The host parameter can be a string, in that case the TCP server is bound to host and port. - The host parameter can also be a sequence of strings and in that case - the TCP server is bound to all hosts of the sequence. If a host - appears multiple times (possibly indirectly e.g. when hostnames - resolve to the same IP address), the server is only bound once to that - host. + The host parameter can also be a sequence of strings and in that + case the TCP server is bound to all hosts of the sequence. If + a host appears multiple times (possibly indirectly e.g. when + hostnames resolve to the same IP address), the server is only bound + once to that host. Return a Server object which can be used to stop the service. diff --git a/contrib/tools/python3/Lib/asyncio/events.py b/contrib/tools/python3/Lib/asyncio/events.py index 3b740b9b905..24e49d561e6 100644 --- a/contrib/tools/python3/Lib/asyncio/events.py +++ b/contrib/tools/python3/Lib/asyncio/events.py @@ -341,8 +341,8 @@ class AbstractEventLoop: If host is an empty string or None all interfaces are assumed and a list of multiple sockets will be returned (most likely - one for IPv4 and another one for IPv6). The host parameter can also be - a sequence (e.g. list) of hosts to bind to. + one for IPv4 and another one for IPv6). The host parameter can also + be a sequence (e.g. list) of hosts to bind to. family can be set to either AF_INET or AF_INET6 to force the socket to use IPv4 or IPv6. If not set it will be determined @@ -382,8 +382,9 @@ class AbstractEventLoop: start_serving set to True (default) causes the created server to start accepting connections immediately. When set to False, - the user should await Server.start_serving() or Server.serve_forever() - to make the server to start accepting connections. + the user should await Server.start_serving() or + Server.serve_forever() to make the server to start accepting + connections. """ raise NotImplementedError @@ -446,8 +447,9 @@ class AbstractEventLoop: start_serving set to True (default) causes the created server to start accepting connections immediately. When set to False, - the user should await Server.start_serving() or Server.serve_forever() - to make the server to start accepting connections. + the user should await Server.start_serving() or + Server.serve_forever() to make the server to start accepting + connections. """ raise NotImplementedError @@ -478,8 +480,8 @@ class AbstractEventLoop: protocol_factory must be a callable returning a protocol instance. - socket family AF_INET, socket.AF_INET6 or socket.AF_UNIX depending on - host (or family if specified), socket type SOCK_DGRAM. + socket family AF_INET, socket.AF_INET6 or socket.AF_UNIX depending + on host (or family if specified), socket type SOCK_DGRAM. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to @@ -519,7 +521,8 @@ class AbstractEventLoop: async def connect_write_pipe(self, protocol_factory, pipe): """Register write pipe in event loop. - protocol_factory should instantiate object with BaseProtocol interface. + protocol_factory should instantiate object with BaseProtocol + interface. Pipe is file-like object already switched to nonblocking. Return pair (transport, protocol), where transport support WriteTransport interface.""" diff --git a/contrib/tools/python3/Lib/asyncio/locks.py b/contrib/tools/python3/Lib/asyncio/locks.py index 3df4c693a91..22af506d497 100644 --- a/contrib/tools/python3/Lib/asyncio/locks.py +++ b/contrib/tools/python3/Lib/asyncio/locks.py @@ -158,10 +158,10 @@ class Lock(_ContextManagerMixin, mixins._LoopBoundMixin): class Event(mixins._LoopBoundMixin): """Asynchronous equivalent to threading.Event. - Class implementing event objects. An event manages a flag that can be set - to true with the set() method and reset to false with the clear() method. - The wait() method blocks until the flag is true. The flag is initially - false. + Class implementing event objects. An event manages a flag that can be + set to true with the set() method and reset to false with the clear() + method. The wait() method blocks until the flag is true. The flag is + initially false. """ def __init__(self): @@ -353,9 +353,9 @@ class Semaphore(_ContextManagerMixin, mixins._LoopBoundMixin): """A Semaphore implementation. A semaphore manages an internal counter which is decremented by each - acquire() call and incremented by each release() call. The counter - can never go below zero; when acquire() finds that it is zero, it blocks, - waiting until some other thread calls release(). + acquire() call and incremented by each release() call. The counter + can never go below zero; when acquire() finds that it is zero, it + blocks, waiting until some other thread calls release(). Semaphores also support the context management protocol. @@ -511,8 +511,8 @@ class Barrier(mixins._LoopBoundMixin): async def wait(self): """Wait for the barrier. - When the specified number of tasks have started waiting, they are all - simultaneously awoken. + When the specified number of tasks have started waiting, they are + all simultaneously awoken. Returns an unique and individual index number from 0 to 'parties-1'. """ async with self._cond: diff --git a/contrib/tools/python3/Lib/asyncio/proactor_events.py b/contrib/tools/python3/Lib/asyncio/proactor_events.py index f404273c3ae..6b94975d004 100644 --- a/contrib/tools/python3/Lib/asyncio/proactor_events.py +++ b/contrib/tools/python3/Lib/asyncio/proactor_events.py @@ -756,8 +756,7 @@ class BaseProactorEventLoop(base_events.BaseEventLoop): offset += blocksize total_sent += blocksize finally: - if total_sent > 0: - file.seek(offset) + file.seek(offset) async def _sendfile_native(self, transp, file, offset, count): resume_reading = transp.is_reading() diff --git a/contrib/tools/python3/Lib/asyncio/queues.py b/contrib/tools/python3/Lib/asyncio/queues.py index 756216fac80..30004f2bc9b 100644 --- a/contrib/tools/python3/Lib/asyncio/queues.py +++ b/contrib/tools/python3/Lib/asyncio/queues.py @@ -33,9 +33,9 @@ class QueueShutDown(Exception): class Queue(mixins._LoopBoundMixin): """A queue, useful for coordinating producer and consumer coroutines. - If maxsize is less than or equal to zero, the queue size is infinite. If it - is an integer greater than 0, then "await put()" will block when the - queue reaches maxsize, until an item is removed by get(). + If maxsize is less than or equal to zero, the queue size is infinite. + If it is an integer greater than 0, then "await put()" will block when + the queue reaches maxsize, until an item is removed by get(). Unlike queue.Queue, you can reliably know this Queue's size with qsize(), since your single-threaded asyncio application won't be @@ -174,8 +174,8 @@ class Queue(mixins._LoopBoundMixin): If queue is empty, wait until an item is available. - Raises QueueShutDown if the queue has been shut down and is empty, or - if the queue has been shut down immediately. + Raises QueueShutDown if the queue has been shut down and is empty, + or if the queue has been shut down immediately. """ while self.empty(): if self._is_shutdown and self.empty(): @@ -203,10 +203,11 @@ class Queue(mixins._LoopBoundMixin): def get_nowait(self): """Remove and return an item from the queue. - Return an item if one is immediately available, else raise QueueEmpty. + Return an item if one is immediately available, else raise + QueueEmpty. - Raises QueueShutDown if the queue has been shut down and is empty, or - if the queue has been shut down immediately. + Raises QueueShutDown if the queue has been shut down and is empty, + or if the queue has been shut down immediately. """ if self.empty(): if self._is_shutdown: @@ -223,12 +224,12 @@ class Queue(mixins._LoopBoundMixin): a subsequent call to task_done() tells the queue that the processing on the task is complete. - If a join() is currently blocking, it will resume when all items have - been processed (meaning that a task_done() call was received for every - item that had been put() into the queue). + If a join() is currently blocking, it will resume when all items + have been processed (meaning that a task_done() call was received + for every item that had been put() into the queue). - Raises ValueError if called more times than there were items placed in - the queue. + Raises ValueError if called more times than there were items placed + in the queue. """ if self._unfinished_tasks <= 0: raise ValueError('task_done() called too many times') @@ -239,10 +240,11 @@ class Queue(mixins._LoopBoundMixin): async def join(self): """Block until all items in the queue have been gotten and processed. - The count of unfinished tasks goes up whenever an item is added to the - queue. The count goes down whenever a consumer calls task_done() to - indicate that the item was retrieved and all work on it is complete. - When the count of unfinished tasks drops to zero, join() unblocks. + The count of unfinished tasks goes up whenever an item is added to + the queue. The count goes down whenever a consumer calls + task_done() to indicate that the item was retrieved and all work on + it is complete. When the count of unfinished tasks drops to zero, + join() unblocks. """ if self._unfinished_tasks > 0: await self._finished.wait() diff --git a/contrib/tools/python3/Lib/asyncio/runners.py b/contrib/tools/python3/Lib/asyncio/runners.py index 102ae78021b..c7bfdad319f 100644 --- a/contrib/tools/python3/Lib/asyncio/runners.py +++ b/contrib/tools/python3/Lib/asyncio/runners.py @@ -34,7 +34,8 @@ class Runner: with asyncio.Runner(debug=True) as runner: runner.run(main()) - The run() method can be called multiple times within the runner's context. + The run() method can be called multiple times within the runner's + context. This can be useful for interactive console (e.g. IPython), unittest runners, console tools, -- everywhere when async code diff --git a/contrib/tools/python3/Lib/asyncio/selector_events.py b/contrib/tools/python3/Lib/asyncio/selector_events.py index ff7e16df3c6..7c2062e3dd5 100644 --- a/contrib/tools/python3/Lib/asyncio/selector_events.py +++ b/contrib/tools/python3/Lib/asyncio/selector_events.py @@ -530,11 +530,12 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop): async def sock_sendall(self, sock, data): """Send data to the socket. - The socket must be connected to a remote socket. This method continues - to send data from data until either all data has been sent or an - error occurs. None is returned on success. On error, an exception is - raised, and there is no way to determine how much data, if any, was - successfully processed by the receiving end of the connection. + The socket must be connected to a remote socket. This method + continues to send data from data until either all data has been + sent or an error occurs. None is returned on success. On error, + an exception is raised, and there is no way to determine how much + data, if any, was successfully processed by the receiving end of + the connection. """ base_events._check_ssl_socket(sock) if self._debug and sock.gettimeout() != 0: @@ -583,11 +584,12 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop): async def sock_sendto(self, sock, data, address): """Send data to the socket. - The socket must be connected to a remote socket. This method continues - to send data from data until either all data has been sent or an - error occurs. None is returned on success. On error, an exception is - raised, and there is no way to determine how much data, if any, was - successfully processed by the receiving end of the connection. + The socket must be connected to a remote socket. This method + continues to send data from data until either all data has been + sent or an error occurs. None is returned on success. On error, + an exception is raised, and there is no way to determine how much + data, if any, was successfully processed by the receiving end of + the connection. """ base_events._check_ssl_socket(sock) if self._debug and sock.gettimeout() != 0: @@ -698,10 +700,11 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop): async def sock_accept(self, sock): """Accept a connection. - The socket must be bound to an address and listening for connections. - The return value is a pair (conn, address) where conn is a new socket - object usable to send and receive data on the connection, and address - is the address bound to the socket on the other end of the connection. + The socket must be bound to an address and listening for + connections. The return value is a pair (conn, address) where + conn is a new socket object usable to send and receive data on the + connection, and address is the address bound to the socket on the + other end of the connection. """ base_events._check_ssl_socket(sock) if self._debug and sock.gettimeout() != 0: diff --git a/contrib/tools/python3/Lib/asyncio/streams.py b/contrib/tools/python3/Lib/asyncio/streams.py index 64aac4cc50d..dd8f6618623 100644 --- a/contrib/tools/python3/Lib/asyncio/streams.py +++ b/contrib/tools/python3/Lib/asyncio/streams.py @@ -541,17 +541,17 @@ class StreamReader: self._waiter = None async def readline(self): - """Read chunk of data from the stream until newline (b'\n') is found. + r"""Read chunk of data from the stream until newline (b'\n') is found. - On success, return chunk that ends with newline. If only partial + On success, return chunk that ends with newline. If only partial line can be read due to EOF, return incomplete line without - terminating newline. When EOF was reached while no bytes read, empty - bytes object is returned. + terminating newline. When EOF was reached while no bytes read, + empty bytes object is returned. - If limit is reached, ValueError will be raised. In that case, if + If limit is reached, ValueError will be raised. In that case, if newline was found, complete line including newline will be removed - from internal buffer. Else, internal buffer will be cleared. Limit is - compared against part of the line without newline. + from internal buffer. Else, internal buffer will be cleared. + Limit is compared against part of the line without newline. If stream was paused, this function will automatically resume it if needed. diff --git a/contrib/tools/python3/Lib/asyncio/tasks.py b/contrib/tools/python3/Lib/asyncio/tasks.py index dadcb5b5f36..e5e7d3e4aa9 100644 --- a/contrib/tools/python3/Lib/asyncio/tasks.py +++ b/contrib/tools/python3/Lib/asyncio/tasks.py @@ -640,10 +640,11 @@ def as_completed(fs, *, timeout=None): Run the supplied awaitables concurrently. The returned object can be iterated to obtain the results of the awaitables as they finish. - The object returned can be iterated as an asynchronous iterator or a plain - iterator. When asynchronous iteration is used, the originally-supplied - awaitables are yielded if they are tasks or futures. This makes it easy to - correlate previously-scheduled tasks with their results: + The object returned can be iterated as an asynchronous iterator or + a plain iterator. When asynchronous iteration is used, the + originally-supplied awaitables are yielded if they are tasks or + futures. This makes it easy to correlate previously-scheduled tasks + with their results: ipv4_connect = create_task(open_connection("127.0.0.1", 80)) ipv6_connect = create_task(open_connection("::1", 80)) @@ -659,26 +660,27 @@ def as_completed(fs, *, timeout=None): else: print("IPv4 connection established.") - During asynchronous iteration, implicitly-created tasks will be yielded for - supplied awaitables that aren't tasks or futures. + During asynchronous iteration, implicitly-created tasks will be + yielded for supplied awaitables that aren't tasks or futures. - When used as a plain iterator, each iteration yields a new coroutine that - returns the result or raises the exception of the next completed awaitable. - This pattern is compatible with Python versions older than 3.13: + When used as a plain iterator, each iteration yields a new coroutine + that returns the result or raises the exception of the next completed + awaitable. This pattern is compatible with Python versions older than + 3.13: ipv4_connect = create_task(open_connection("127.0.0.1", 80)) ipv6_connect = create_task(open_connection("::1", 80)) tasks = [ipv4_connect, ipv6_connect] for next_connect in as_completed(tasks): - # next_connect is not one of the original task objects. It must be - # awaited to obtain the result value or raise the exception of the - # awaitable that finishes next. + # next_connect is not one of the original task objects. It must + # be awaited to obtain the result value or raise the exception + # of the awaitable that finishes next. reader, writer = await next_connect - A TimeoutError is raised if the timeout occurs before all awaitables are - done. This is raised by the async for loop during asynchronous iteration or - by the coroutines yielded during plain iteration. + A TimeoutError is raised if the timeout occurs before all awaitables + are done. This is raised by the async for loop during asynchronous + iteration or by the coroutines yielded during plain iteration. """ if inspect.isawaitable(fs): raise TypeError( @@ -1007,21 +1009,22 @@ def run_coroutine_threadsafe(coro, loop): def create_eager_task_factory(custom_task_constructor): """Create a function suitable for use as a task factory on an event-loop. - Example usage: + Example usage: - loop.set_task_factory( - asyncio.create_eager_task_factory(my_task_constructor)) + loop.set_task_factory( + asyncio.create_eager_task_factory(my_task_constructor)) - Now, tasks created will be started immediately (rather than being first - scheduled to an event loop). The constructor argument can be any callable - that returns a Task-compatible object and has a signature compatible - with `Task.__init__`; it must have the `eager_start` keyword argument. + Now, tasks created will be started immediately (rather than being first + scheduled to an event loop). The constructor argument can be any + callable that returns a Task-compatible object and has a signature + compatible with `Task.__init__`; it must have the `eager_start` + keyword argument. - Most applications will use `Task` for `custom_task_constructor` and in - this case there's no need to call `create_eager_task_factory()` - directly. Instead the global `eager_task_factory` instance can be - used. E.g. `loop.set_task_factory(asyncio.eager_task_factory)`. - """ + Most applications will use `Task` for `custom_task_constructor` and in + this case there's no need to call `create_eager_task_factory()` + directly. Instead the global `eager_task_factory` instance can be + used. E.g. `loop.set_task_factory(asyncio.eager_task_factory)`. + """ def factory(loop, coro, *, name=None, context=None): return custom_task_constructor( diff --git a/contrib/tools/python3/Lib/asyncio/threads.py b/contrib/tools/python3/Lib/asyncio/threads.py index db048a8231d..5001351b097 100644 --- a/contrib/tools/python3/Lib/asyncio/threads.py +++ b/contrib/tools/python3/Lib/asyncio/threads.py @@ -17,7 +17,8 @@ async def to_thread(func, /, *args, **kwargs): allowing context variables from the main thread to be accessed in the separate thread. - Return a coroutine that can be awaited to get the eventual result of *func*. + Return a coroutine that can be awaited to get the eventual result of + *func*. """ loop = events.get_running_loop() ctx = contextvars.copy_context() diff --git a/contrib/tools/python3/Lib/asyncio/timeouts.py b/contrib/tools/python3/Lib/asyncio/timeouts.py index e6f5100691d..7ac664be47c 100644 --- a/contrib/tools/python3/Lib/asyncio/timeouts.py +++ b/contrib/tools/python3/Lib/asyncio/timeouts.py @@ -27,7 +27,8 @@ class _State(enum.Enum): class Timeout: """Asynchronous context manager for cancelling overdue coroutines. - Use `timeout()` or `timeout_at()` rather than instantiating this class directly. + Use `timeout()` or `timeout_at()` rather than instantiating this class + directly. """ def __init__(self, when: Optional[float]) -> None: diff --git a/contrib/tools/python3/Lib/asyncio/unix_events.py b/contrib/tools/python3/Lib/asyncio/unix_events.py index 41ccf1b78fb..9222a8769e9 100644 --- a/contrib/tools/python3/Lib/asyncio/unix_events.py +++ b/contrib/tools/python3/Lib/asyncio/unix_events.py @@ -58,7 +58,8 @@ def waitstatus_to_exitcode(status): class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop): """Unix event loop. - Adds signal handling and UNIX Domain Socket support to SelectorEventLoop. + Adds signal handling and UNIX Domain Socket support to + SelectorEventLoop. """ def __init__(self, selector=None): @@ -395,12 +396,12 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop): # order to simplify the common case. self.remove_writer(registered_fd) if fut.cancelled(): - self._sock_sendfile_update_filepos(fileno, offset, total_sent) + self._sock_sendfile_update_filepos(fileno, offset) return if count: blocksize = count - total_sent if blocksize <= 0: - self._sock_sendfile_update_filepos(fileno, offset, total_sent) + self._sock_sendfile_update_filepos(fileno, offset) fut.set_result(total_sent) return @@ -434,20 +435,20 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop): # plain send(). err = exceptions.SendfileNotAvailableError( "os.sendfile call failed") - self._sock_sendfile_update_filepos(fileno, offset, total_sent) + self._sock_sendfile_update_filepos(fileno, offset) fut.set_exception(err) else: - self._sock_sendfile_update_filepos(fileno, offset, total_sent) + self._sock_sendfile_update_filepos(fileno, offset) fut.set_exception(exc) except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: - self._sock_sendfile_update_filepos(fileno, offset, total_sent) + self._sock_sendfile_update_filepos(fileno, offset) fut.set_exception(exc) else: if sent == 0: # EOF - self._sock_sendfile_update_filepos(fileno, offset, total_sent) + self._sock_sendfile_update_filepos(fileno, offset) fut.set_result(total_sent) else: offset += sent @@ -458,9 +459,9 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop): fd, sock, fileno, offset, count, blocksize, total_sent) - def _sock_sendfile_update_filepos(self, fileno, offset, total_sent): - if total_sent > 0: - os.lseek(fileno, offset, os.SEEK_SET) + def _sock_sendfile_update_filepos(self, fileno, offset): + # After this helper runs, the source fd's lseek pointer is at offset." + os.lseek(fileno, offset, os.SEEK_SET) def _sock_add_cancellation_callback(self, fut, sock): def cb(fut): diff --git a/contrib/tools/python3/Lib/asyncio/windows_events.py b/contrib/tools/python3/Lib/asyncio/windows_events.py index bf99bc271c7..a36832f7f9f 100644 --- a/contrib/tools/python3/Lib/asyncio/windows_events.py +++ b/contrib/tools/python3/Lib/asyncio/windows_events.py @@ -610,6 +610,9 @@ class IocpProactor: ov = _overlapped.Overlapped(NULL) offset_low = offset & 0xffff_ffff offset_high = (offset >> 32) & 0xffff_ffff + # TransmitFile ignores OVERLAPPED.Offset for handles not opened with + # FILE_FLAG_OVERLAPPED, so seek the CRT file pointer to match. + file.seek(offset) ov.TransmitFile(sock.fileno(), msvcrt.get_osfhandle(file.fileno()), offset_low, offset_high, diff --git a/contrib/tools/python3/Lib/asyncio/windows_utils.py b/contrib/tools/python3/Lib/asyncio/windows_utils.py index acd49441131..d6393f0b1ff 100644 --- a/contrib/tools/python3/Lib/asyncio/windows_utils.py +++ b/contrib/tools/python3/Lib/asyncio/windows_utils.py @@ -111,8 +111,9 @@ class PipeHandle: def close(self, *, CloseHandle=_winapi.CloseHandle): if self._handle is not None: - CloseHandle(self._handle) + handle = self._handle self._handle = None + CloseHandle(handle) def __del__(self, _warn=warnings.warn): if self._handle is not None: diff --git a/contrib/tools/python3/Lib/base64.py b/contrib/tools/python3/Lib/base64.py index 6636e06382f..888443c472c 100755 --- a/contrib/tools/python3/Lib/base64.py +++ b/contrib/tools/python3/Lib/base64.py @@ -328,17 +328,20 @@ def a85encode(b, *, foldspaces=False, wrapcol=0, pad=False, adobe=False): foldspaces is an optional flag that uses the special short sequence 'y' instead of 4 consecutive spaces (ASCII 0x20) as supported by 'btoa'. This - feature is not supported by the "standard" Adobe encoding. + feature is not supported by the standard encoding used in PDF. - wrapcol controls whether the output should have newline (b'\\n') characters - added to it. If this is non-zero, each output line will be at most this - many characters long, excluding the trailing newline. + If wrapcol is non-zero, insert a newline (b'\\n') character after at most + every wrapcol characters. - pad controls whether the input is padded to a multiple of 4 before - encoding. Note that the btoa implementation always pads. + pad controls whether zero-padding applied to the end of the input + is fully retained in the output encoding, as done by btoa, + producing an exact multiple of 5 bytes of output. + + adobe controls whether the encoded byte sequence is framed with <~ + and ~>, as in a PostScript base-85 string literal. Note that + while ASCII85Decode streams in PDF documents must be terminated + with ~>, they must not use a leading <~. - adobe controls whether the encoded byte sequence is framed with <~ and ~>, - which is used by the Adobe implementation. """ global _a85chars, _a85chars2 # Delay the initialization of tables to not waste memory @@ -367,12 +370,14 @@ def a85encode(b, *, foldspaces=False, wrapcol=0, pad=False, adobe=False): def a85decode(b, *, foldspaces=False, adobe=False, ignorechars=b' \t\n\r\v'): """Decode the Ascii85 encoded bytes-like object or ASCII string b. - foldspaces is a flag that specifies whether the 'y' short sequence should be - accepted as shorthand for 4 consecutive spaces (ASCII 0x20). This feature is - not supported by the "standard" Adobe encoding. + foldspaces is a flag that specifies whether the 'y' short sequence + should be accepted as shorthand for 4 consecutive spaces (ASCII + 0x20). This feature is not supported by the standard Ascii85 + encoding used in PDF and PostScript. - adobe controls whether the input sequence is in Adobe Ascii85 format (i.e. - is framed with <~ and ~>). + adobe controls whether the <~ and ~> markers are present. While + the leading <~ is not required, the input must end with ~>, or a + ValueError is raised. ignorechars should be a byte string containing characters to ignore from the input. This should only contain whitespace characters, and by default @@ -445,8 +450,10 @@ _b85dec = None def b85encode(b, pad=False): """Encode bytes-like object b in base85 format and return a bytes object. - If pad is true, the input is padded with b'\\0' so its length is a multiple of - 4 bytes before encoding. + The input is padded with b'\0' so its length is a multiple of 4 + bytes before encoding. If pad is true, all the resulting + characters are retained in the output, which will always be a + multiple of 5 bytes. """ global _b85chars, _b85chars2 # Delay the initialization of tables to not waste memory diff --git a/contrib/tools/python3/Lib/concurrent/futures/_base.py b/contrib/tools/python3/Lib/concurrent/futures/_base.py index 7d69a5baead..d4819f19e5e 100644 --- a/contrib/tools/python3/Lib/concurrent/futures/_base.py +++ b/contrib/tools/python3/Lib/concurrent/futures/_base.py @@ -200,15 +200,15 @@ def as_completed(fs, timeout=None): """An iterator over the given futures that yields each as it completes. Args: - fs: The sequence of Futures (possibly created by different Executors) to - iterate over. - timeout: The maximum number of seconds to wait. If None, then there - is no limit on the wait time. + fs: The sequence of Futures (possibly created by different + Executors) to iterate over. + timeout: The maximum number of seconds to wait. If None, then + there is no limit on the wait time. Returns: - An iterator that yields the given Futures as they complete (finished or - cancelled). If any given Futures are duplicated, they will be returned - once. + An iterator that yields the given Futures as they complete + (finished or cancelled). If any given Futures are duplicated, + they will be returned once. Raises: TimeoutError: If the entire result iterator could not be generated @@ -264,19 +264,20 @@ def wait(fs, timeout=None, return_when=ALL_COMPLETED): """Wait for the futures in the given sequence to complete. Args: - fs: The sequence of Futures (possibly created by different Executors) to - wait upon. - timeout: The maximum number of seconds to wait. If None, then there - is no limit on the wait time. - return_when: Indicates when this function should return. The options - are: + fs: The sequence of Futures (possibly created by different + Executors) to wait upon. + timeout: The maximum number of seconds to wait. If None, then + there is no limit on the wait time. + return_when: Indicates when this function should return. + The options are: FIRST_COMPLETED - Return when any future finishes or is cancelled. FIRST_EXCEPTION - Return when any future finishes by raising an - exception. If no future raises an exception + exception. If no future raises an exception then it is equivalent to ALL_COMPLETED. - ALL_COMPLETED - Return when all futures finish or are cancelled. + ALL_COMPLETED - Return when all futures finish or are + cancelled. Returns: A named 2-tuple of sets. The first set, named 'done', contains the @@ -410,11 +411,12 @@ class Future(object): Args: fn: A callable that will be called with this future as its only - argument when the future completes or is cancelled. The callable - will always be called by a thread in the same process in which - it was added. If the future has already completed or been - cancelled then the callable will be called immediately. These - callables are called in the order that they were added. + argument when the future completes or is cancelled. The + callable will always be called by a thread in the same + process in which it was added. If the future has already + completed or been cancelled then the callable will be + called immediately. These callables are called in the + order that they were added. """ with self._condition: if self._state not in [CANCELLED, CANCELLED_AND_NOTIFIED, FINISHED]: @@ -429,17 +431,19 @@ class Future(object): """Return the result of the call that the future represents. Args: - timeout: The number of seconds to wait for the result if the future - isn't done. If None, then there is no limit on the wait time. + timeout: The number of seconds to wait for the result if the + future isn't done. If None, then there is no limit on the + wait time. Returns: The result of the call that the future represents. Raises: CancelledError: If the future was cancelled. - TimeoutError: If the future didn't finish executing before the given - timeout. - Exception: If the call raised then that exception will be raised. + TimeoutError: If the future didn't finish executing before the + given timeout. + Exception: If the call raised then that exception will be + raised. """ try: with self._condition: @@ -465,17 +469,17 @@ class Future(object): Args: timeout: The number of seconds to wait for the exception if the - future isn't done. If None, then there is no limit on the wait - time. + future isn't done. If None, then there is no limit on the + wait time. Returns: - The exception raised by the call that the future represents or None - if the call completed without raising. + The exception raised by the call that the future represents or + None if the call completed without raising. Raises: CancelledError: If the future was cancelled. - TimeoutError: If the future didn't finish executing before the given - timeout. + TimeoutError: If the future didn't finish executing before the + given timeout. """ with self._condition: @@ -500,22 +504,23 @@ class Future(object): Should only be used by Executor implementations and unit tests. If the future has been cancelled (cancel() was called and returned - True) then any threads waiting on the future completing (though calls - to as_completed() or wait()) are notified and False is returned. + True) then any threads waiting on the future completing (though + calls to as_completed() or wait()) are notified and False is + returned. If the future was not cancelled then it is put in the running state (future calls to running() will return True) and True is returned. This method should be called by Executor implementations before - executing the work associated with this future. If this method returns - False then the work should not be executed. + executing the work associated with this future. If this method + returns False then the work should not be executed. Returns: False if the Future was cancelled, True otherwise. Raises: - RuntimeError: if this method was already called or if set_result() - or set_exception() was called. + RuntimeError: if this method was already called or if + set_result() or set_exception() was called. """ with self._condition: if self._state == CANCELLED: @@ -572,8 +577,9 @@ class Executor(object): def submit(self, fn, /, *args, **kwargs): """Submits a callable to be executed with the given arguments. - Schedules the callable to be executed as fn(*args, **kwargs) and returns - a Future instance representing the execution of the callable. + Schedules the callable to be executed as fn(*args, **kwargs) and + returns a Future instance representing the execution of the + callable. Returns: A Future representing the given call. @@ -586,20 +592,20 @@ class Executor(object): Args: fn: A callable that will take as many arguments as there are passed iterables. - timeout: The maximum number of seconds to wait. If None, then there - is no limit on the wait time. - chunksize: The size of the chunks the iterable will be broken into - before being passed to a child process. This argument is only - used by ProcessPoolExecutor; it is ignored by + timeout: The maximum number of seconds to wait. If None, then + there is no limit on the wait time. + chunksize: The size of the chunks the iterable will be broken + into before being passed to a child process. This argument + is only used by ProcessPoolExecutor; it is ignored by ThreadPoolExecutor. Returns: - An iterator equivalent to: map(func, *iterables) but the calls may - be evaluated out-of-order. + An iterator equivalent to: map(func, *iterables) but the calls + may be evaluated out-of-order. Raises: - TimeoutError: If the entire result iterator could not be generated - before the given timeout. + TimeoutError: If the entire result iterator could not be + generated before the given timeout. Exception: If fn(*args) raises for any values. """ if timeout is not None: @@ -632,8 +638,8 @@ class Executor(object): Args: wait: If True then shutdown will not return until all running - futures have finished executing and the resources used by the - executor have been reclaimed. + futures have finished executing and the resources used by + the executor have been reclaimed. cancel_futures: If True then shutdown will cancel all pending futures. Futures that are completed or running will not be cancelled. diff --git a/contrib/tools/python3/Lib/concurrent/futures/process.py b/contrib/tools/python3/Lib/concurrent/futures/process.py index 0dee8303ba2..8ff717f5e00 100644 --- a/contrib/tools/python3/Lib/concurrent/futures/process.py +++ b/contrib/tools/python3/Lib/concurrent/futures/process.py @@ -634,19 +634,21 @@ class ProcessPoolExecutor(_base.Executor): Args: max_workers: The maximum number of processes that can be used to - execute the given calls. If None or not given then as many - worker processes will be created as the machine has processors. - mp_context: A multiprocessing context to launch the workers created - using the multiprocessing.get_context('start method') API. This - object should provide SimpleQueue, Queue and Process. + execute the given calls. If None or not given then as many + worker processes will be created as the machine has + processors. + mp_context: A multiprocessing context to launch the workers + created using the multiprocessing.get_context('start method') + API. This object should provide SimpleQueue, Queue and + Process. initializer: A callable used to initialize worker processes. initargs: A tuple of arguments to pass to the initializer. - max_tasks_per_child: The maximum number of tasks a worker process - can complete before it will exit and be replaced with a fresh - worker process. The default of None means worker process will - live as long as the executor. Requires a non-'fork' mp_context - start method. When given, we default to using 'spawn' if no - mp_context is supplied. + max_tasks_per_child: The maximum number of tasks a worker + process can complete before it will exit and be replaced + with a fresh worker process. The default of None means + worker process will live as long as the executor. Requires + a non-'fork' mp_context start method. When given, we + default to using 'spawn' if no mp_context is supplied. """ _check_system_limits() @@ -816,19 +818,20 @@ class ProcessPoolExecutor(_base.Executor): Args: fn: A callable that will take as many arguments as there are passed iterables. - timeout: The maximum number of seconds to wait. If None, then there - is no limit on the wait time. - chunksize: If greater than one, the iterables will be chopped into - chunks of size chunksize and submitted to the process pool. - If set to one, the items in the list will be sent one at a time. + timeout: The maximum number of seconds to wait. If None, then + there is no limit on the wait time. + chunksize: If greater than one, the iterables will be chopped + into chunks of size chunksize and submitted to the process + pool. If set to one, the items in the list will be sent + one at a time. Returns: - An iterator equivalent to: map(func, *iterables) but the calls may - be evaluated out-of-order. + An iterator equivalent to: map(func, *iterables) but the calls + may be evaluated out-of-order. Raises: - TimeoutError: If the entire result iterator could not be generated - before the given timeout. + TimeoutError: If the entire result iterator could not be + generated before the given timeout. Exception: If fn(*args) raises for any values. """ if chunksize < 1: diff --git a/contrib/tools/python3/Lib/configparser.py b/contrib/tools/python3/Lib/configparser.py index 05b86acb919..3968ac45eed 100644 --- a/contrib/tools/python3/Lib/configparser.py +++ b/contrib/tools/python3/Lib/configparser.py @@ -316,12 +316,15 @@ class ParsingError(Error): def append(self, lineno, line): self.errors.append((lineno, line)) - self.message += '\n\t[line %2d]: %s' % (lineno, repr(line)) + self.message += f'\n\t[line {lineno:2d}]: {line!r}' def combine(self, others): + messages = [self.message] for other in others: - for error in other.errors: - self.append(*error) + for lineno, line in other.errors: + self.errors.append((lineno, line)) + messages.append(f'\n\t[line {lineno:2d}]: {line!r}') + self.message = "".join(messages) return self @staticmethod @@ -597,7 +600,9 @@ class RawConfigParser(MutableMapping): \] # ] """ _OPT_TMPL = r""" - (?P