summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3
diff options
context:
space:
mode:
authorarcadia-devtools <[email protected]>2022-06-09 19:02:01 +0300
committerarcadia-devtools <[email protected]>2022-06-09 19:02:01 +0300
commit4a29d649866ff133e0b8f8a1009e1000a44d7279 (patch)
tree547229aded91b3760628c646a144af604f1c3e2b /contrib/tools/python3
parent782f2445a283aed9a66e699137b3349af1689c29 (diff)
intermediate changes
ref:478170c7a5a1c0788ddd0d6513ce4ed86d7d7c99
Diffstat (limited to 'contrib/tools/python3')
-rw-r--r--contrib/tools/python3/src/Include/internal/pycore_hamt.h14
-rw-r--r--contrib/tools/python3/src/Include/patchlevel.h4
-rw-r--r--contrib/tools/python3/src/Lib/argparse.py1
-rw-r--r--contrib/tools/python3/src/Lib/asyncio/base_events.py2
-rw-r--r--contrib/tools/python3/src/Lib/asyncio/selector_events.py3
-rw-r--r--contrib/tools/python3/src/Lib/concurrent/futures/_base.py2
-rw-r--r--contrib/tools/python3/src/Lib/concurrent/futures/process.py45
-rw-r--r--contrib/tools/python3/src/Lib/datetime.py4
-rw-r--r--contrib/tools/python3/src/Lib/difflib.py2
-rw-r--r--contrib/tools/python3/src/Lib/doctest.py14
-rw-r--r--contrib/tools/python3/src/Lib/email/_encoded_words.py10
-rw-r--r--contrib/tools/python3/src/Lib/email/_header_value_parser.py4
-rw-r--r--contrib/tools/python3/src/Lib/email/charset.py10
-rw-r--r--contrib/tools/python3/src/Lib/fnmatch.py30
-rw-r--r--contrib/tools/python3/src/Lib/html/entities.py1
-rw-r--r--contrib/tools/python3/src/Lib/ipaddress.py15
-rw-r--r--contrib/tools/python3/src/Lib/multiprocessing/managers.py2
-rw-r--r--contrib/tools/python3/src/Lib/multiprocessing/queues.py23
-rw-r--r--contrib/tools/python3/src/Lib/multiprocessing/util.py2
-rw-r--r--contrib/tools/python3/src/Lib/pathlib.py2
-rw-r--r--contrib/tools/python3/src/Lib/pydoc_data/topics.py60
-rw-r--r--contrib/tools/python3/src/Lib/queue.py2
-rw-r--r--contrib/tools/python3/src/Lib/runpy.py36
-rw-r--r--contrib/tools/python3/src/Lib/shutil.py8
-rw-r--r--[-rwxr-xr-x]contrib/tools/python3/src/Lib/socket.py0
-rw-r--r--contrib/tools/python3/src/Lib/sqlite3/__init__.py2
-rw-r--r--contrib/tools/python3/src/Lib/sre_compile.py30
-rw-r--r--contrib/tools/python3/src/Lib/sre_constants.py2
-rw-r--r--contrib/tools/python3/src/Lib/sre_parse.py14
-rw-r--r--contrib/tools/python3/src/Lib/ssl.py7
-rw-r--r--contrib/tools/python3/src/Lib/subprocess.py3
-rw-r--r--contrib/tools/python3/src/Lib/threading.py21
-rw-r--r--contrib/tools/python3/src/Lib/unittest/async_case.py2
-rw-r--r--contrib/tools/python3/src/Lib/urllib/request.py36
-rw-r--r--contrib/tools/python3/src/Lib/xml/etree/ElementPath.py1
-rw-r--r--contrib/tools/python3/src/Lib/xml/etree/ElementTree.py23
-rw-r--r--contrib/tools/python3/src/Lib/zipfile.py2
-rw-r--r--contrib/tools/python3/src/Modules/_bisectmodule.c4
-rw-r--r--contrib/tools/python3/src/Modules/_ctypes/_ctypes.c56
-rw-r--r--contrib/tools/python3/src/Modules/_ctypes/callbacks.c2
-rw-r--r--contrib/tools/python3/src/Modules/_ctypes/callproc.c32
-rw-r--r--contrib/tools/python3/src/Modules/_ctypes/cfield.c2
-rw-r--r--contrib/tools/python3/src/Modules/_datetimemodule.c4
-rw-r--r--contrib/tools/python3/src/Modules/_hashopenssl.c13
-rw-r--r--contrib/tools/python3/src/Modules/_posixsubprocess.c33
-rw-r--r--contrib/tools/python3/src/Modules/_sqlite/connection.c63
-rw-r--r--contrib/tools/python3/src/Modules/_sqlite/cursor.c46
-rw-r--r--contrib/tools/python3/src/Modules/clinic/_curses_panel.c.h112
-rw-r--r--contrib/tools/python3/src/Modules/clinic/_dbmmodule.c.h17
-rw-r--r--contrib/tools/python3/src/Modules/clinic/_gdbmmodule.c.h62
-rw-r--r--contrib/tools/python3/src/Modules/clinic/_lsprof.c.h17
-rw-r--r--contrib/tools/python3/src/Modules/clinic/_queuemodule.c.h39
-rw-r--r--contrib/tools/python3/src/Modules/clinic/_sre.c.h294
-rw-r--r--contrib/tools/python3/src/Modules/clinic/arraymodule.c.h10
-rw-r--r--contrib/tools/python3/src/Modules/clinic/md5module.c.h17
-rw-r--r--contrib/tools/python3/src/Modules/clinic/posixmodule.c.h56
-rw-r--r--contrib/tools/python3/src/Modules/clinic/pyexpat.c.h83
-rw-r--r--contrib/tools/python3/src/Modules/clinic/sha1module.c.h17
-rw-r--r--contrib/tools/python3/src/Modules/clinic/sha256module.c.h17
-rw-r--r--contrib/tools/python3/src/Modules/clinic/sha512module.c.h17
-rw-r--r--contrib/tools/python3/src/Modules/clinic/zlibmodule.c.h161
-rw-r--r--contrib/tools/python3/src/Modules/gcmodule.c6
-rw-r--r--contrib/tools/python3/src/Modules/posixmodule.c12
-rw-r--r--contrib/tools/python3/src/Modules/socketmodule.c7
-rw-r--r--contrib/tools/python3/src/Objects/clinic/unicodeobject.c.h34
-rw-r--r--contrib/tools/python3/src/Objects/exceptions.c9
-rw-r--r--contrib/tools/python3/src/Objects/floatobject.c2
-rw-r--r--contrib/tools/python3/src/Objects/frameobject.c5
-rw-r--r--contrib/tools/python3/src/Objects/genericaliasobject.c10
-rw-r--r--contrib/tools/python3/src/Objects/genobject.c14
-rw-r--r--contrib/tools/python3/src/Objects/listobject.c33
-rw-r--r--contrib/tools/python3/src/Objects/picklebufobject.c2
-rw-r--r--contrib/tools/python3/src/Objects/stringlib/codecs.h15
-rw-r--r--contrib/tools/python3/src/Objects/stringlib/fastsearch.h3
-rw-r--r--contrib/tools/python3/src/Objects/typeobject.c20
-rw-r--r--contrib/tools/python3/src/Objects/unicodeobject.c90
-rw-r--r--contrib/tools/python3/src/Objects/unionobject.c4
-rw-r--r--contrib/tools/python3/src/Parser/parser.c6
-rw-r--r--contrib/tools/python3/src/Parser/pegen.c11
-rw-r--r--contrib/tools/python3/src/Parser/pegen.h1
-rw-r--r--contrib/tools/python3/src/Parser/string_parser.c4
-rw-r--r--contrib/tools/python3/src/Python/ceval.c2
-rw-r--r--contrib/tools/python3/src/Python/compile.c2
-rw-r--r--contrib/tools/python3/src/Python/fileutils.c9
-rw-r--r--contrib/tools/python3/src/Python/hamt.c14
-rw-r--r--contrib/tools/python3/src/Python/initconfig.c7
-rw-r--r--contrib/tools/python3/src/README.rst2
87 files changed, 1251 insertions, 686 deletions
diff --git a/contrib/tools/python3/src/Include/internal/pycore_hamt.h b/contrib/tools/python3/src/Include/internal/pycore_hamt.h
index aaf65590955..357d9661627 100644
--- a/contrib/tools/python3/src/Include/internal/pycore_hamt.h
+++ b/contrib/tools/python3/src/Include/internal/pycore_hamt.h
@@ -5,7 +5,19 @@
# error "this header requires Py_BUILD_CORE define"
#endif
-#define _Py_HAMT_MAX_TREE_DEPTH 7
+
+/*
+HAMT tree is shaped by hashes of keys. Every group of 5 bits of a hash denotes
+the exact position of the key in one level of the tree. Since we're using
+32 bit hashes, we can have at most 7 such levels. Although if there are
+two distinct keys with equal hashes, they will have to occupy the same
+cell in the 7th level of the tree -- so we'd put them in a "collision" node.
+Which brings the total possible tree depth to 8. Read more about the actual
+layout of the HAMT tree in `hamt.c`.
+
+This constant is used to define a datastucture for storing iteration state.
+*/
+#define _Py_HAMT_MAX_TREE_DEPTH 8
#define PyHamt_Check(o) Py_IS_TYPE(o, &_PyHamt_Type)
diff --git a/contrib/tools/python3/src/Include/patchlevel.h b/contrib/tools/python3/src/Include/patchlevel.h
index 482069c791a..2d30d350da8 100644
--- a/contrib/tools/python3/src/Include/patchlevel.h
+++ b/contrib/tools/python3/src/Include/patchlevel.h
@@ -18,12 +18,12 @@
/*--start constants--*/
#define PY_MAJOR_VERSION 3
#define PY_MINOR_VERSION 10
-#define PY_MICRO_VERSION 4
+#define PY_MICRO_VERSION 5
#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL
#define PY_RELEASE_SERIAL 0
/* Version as a string */
-#define PY_VERSION "3.10.4"
+#define PY_VERSION "3.10.5"
/*--end constants--*/
/* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2.
diff --git a/contrib/tools/python3/src/Lib/argparse.py b/contrib/tools/python3/src/Lib/argparse.py
index 2c0dd853a5b..9be18488abe 100644
--- a/contrib/tools/python3/src/Lib/argparse.py
+++ b/contrib/tools/python3/src/Lib/argparse.py
@@ -848,6 +848,7 @@ class Action(_AttributeHolder):
'default',
'type',
'choices',
+ 'required',
'help',
'metavar',
]
diff --git a/contrib/tools/python3/src/Lib/asyncio/base_events.py b/contrib/tools/python3/src/Lib/asyncio/base_events.py
index 952da11064f..ea10399b941 100644
--- a/contrib/tools/python3/src/Lib/asyncio/base_events.py
+++ b/contrib/tools/python3/src/Lib/asyncio/base_events.py
@@ -884,7 +884,7 @@ class BaseEventLoop(events.AbstractEventLoop):
# non-mmap files even if sendfile is supported by OS
raise exceptions.SendfileNotAvailableError(
f"syscall sendfile is not available for socket {sock!r} "
- "and file {file!r} combination")
+ f"and file {file!r} combination")
async def _sock_sendfile_fallback(self, sock, file, offset, count):
if offset:
diff --git a/contrib/tools/python3/src/Lib/asyncio/selector_events.py b/contrib/tools/python3/src/Lib/asyncio/selector_events.py
index 71080b8ad16..572d4a8ce12 100644
--- a/contrib/tools/python3/src/Lib/asyncio/selector_events.py
+++ b/contrib/tools/python3/src/Lib/asyncio/selector_events.py
@@ -487,7 +487,8 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
if self._debug and sock.gettimeout() != 0:
raise ValueError("the socket must be non-blocking")
- if not hasattr(socket, 'AF_UNIX') or sock.family != socket.AF_UNIX:
+ if sock.family == socket.AF_INET or (
+ base_events._HAS_IPv6 and sock.family == socket.AF_INET6):
resolved = await self._ensure_resolved(
address, family=sock.family, type=sock.type, proto=sock.proto,
loop=self,
diff --git a/contrib/tools/python3/src/Lib/concurrent/futures/_base.py b/contrib/tools/python3/src/Lib/concurrent/futures/_base.py
index 5c00f2edbe5..cf119ac6437 100644
--- a/contrib/tools/python3/src/Lib/concurrent/futures/_base.py
+++ b/contrib/tools/python3/src/Lib/concurrent/futures/_base.py
@@ -381,7 +381,7 @@ class Future(object):
return self._state == RUNNING
def done(self):
- """Return True of the future was cancelled or finished executing."""
+ """Return True if the future was cancelled or finished executing."""
with self._condition:
return self._state in [CANCELLED, CANCELLED_AND_NOTIFIED, FINISHED]
diff --git a/contrib/tools/python3/src/Lib/concurrent/futures/process.py b/contrib/tools/python3/src/Lib/concurrent/futures/process.py
index 6ee2ce626e4..57941e485d8 100644
--- a/contrib/tools/python3/src/Lib/concurrent/futures/process.py
+++ b/contrib/tools/python3/src/Lib/concurrent/futures/process.py
@@ -126,6 +126,9 @@ class _ExceptionWithTraceback:
tb = traceback.format_exception(type(exc), exc, tb)
tb = ''.join(tb)
self.exc = exc
+ # Traceback object needs to be garbage-collected as its frames
+ # contain references to all the objects in the exception scope
+ self.exc.__traceback__ = None
self.tb = '\n"""\n%s"""' % tb
def __reduce__(self):
return _rebuild_exc, (self.exc, self.tb)
@@ -612,6 +615,10 @@ class ProcessPoolExecutor(_base.Executor):
mp_context = mp.get_context()
self._mp_context = mp_context
+ # https://github.com/python/cpython/issues/90622
+ self._safe_to_dynamically_spawn_children = (
+ self._mp_context.get_start_method(allow_none=False) != "fork")
+
if initializer is not None and not callable(initializer):
raise TypeError("initializer must be a callable")
self._initializer = initializer
@@ -662,6 +669,8 @@ class ProcessPoolExecutor(_base.Executor):
def _start_executor_manager_thread(self):
if self._executor_manager_thread is None:
# Start the processes so that their sentinels are known.
+ if not self._safe_to_dynamically_spawn_children: # ie, using fork.
+ self._launch_processes()
self._executor_manager_thread = _ExecutorManagerThread(self)
self._executor_manager_thread.start()
_threads_wakeups[self._executor_manager_thread] = \
@@ -674,14 +683,31 @@ class ProcessPoolExecutor(_base.Executor):
process_count = len(self._processes)
if process_count < self._max_workers:
- p = self._mp_context.Process(
- target=_process_worker,
- args=(self._call_queue,
- self._result_queue,
- self._initializer,
- self._initargs))
- p.start()
- self._processes[p.pid] = p
+ # Assertion disabled as this codepath is also used to replace a
+ # worker that unexpectedly dies, even when using the 'fork' start
+ # method. That means there is still a potential deadlock bug. If a
+ # 'fork' mp_context worker dies, we'll be forking a new one when
+ # we know a thread is running (self._executor_manager_thread).
+ #assert self._safe_to_dynamically_spawn_children or not self._executor_manager_thread, 'https://github.com/python/cpython/issues/90622'
+ self._spawn_process()
+
+ def _launch_processes(self):
+ # https://github.com/python/cpython/issues/90622
+ assert not self._executor_manager_thread, (
+ 'Processes cannot be fork()ed after the thread has started, '
+ 'deadlock in the child processes could result.')
+ for _ in range(len(self._processes), self._max_workers):
+ self._spawn_process()
+
+ def _spawn_process(self):
+ p = self._mp_context.Process(
+ target=_process_worker,
+ args=(self._call_queue,
+ self._result_queue,
+ self._initializer,
+ self._initargs))
+ p.start()
+ self._processes[p.pid] = p
def submit(self, fn, /, *args, **kwargs):
with self._shutdown_lock:
@@ -702,7 +728,8 @@ class ProcessPoolExecutor(_base.Executor):
# Wake up queue management thread
self._executor_manager_thread_wakeup.wakeup()
- self._adjust_process_count()
+ if self._safe_to_dynamically_spawn_children:
+ self._adjust_process_count()
self._start_executor_manager_thread()
return f
submit.__doc__ = _base.Executor.submit.__doc__
diff --git a/contrib/tools/python3/src/Lib/datetime.py b/contrib/tools/python3/src/Lib/datetime.py
index 6bf37ccfab7..d087c9852c7 100644
--- a/contrib/tools/python3/src/Lib/datetime.py
+++ b/contrib/tools/python3/src/Lib/datetime.py
@@ -1652,7 +1652,7 @@ class datetime(date):
y, m, d, hh, mm, ss, weekday, jday, dst = converter(t)
ss = min(ss, 59) # clamp out leap seconds if the platform has them
result = cls(y, m, d, hh, mm, ss, us, tz)
- if tz is None:
+ if tz is None and not utc:
# As of version 2015f max fold in IANA database is
# 23 hours at 1969-09-30 13:00:00 in Kwajalein.
# Let's probe 24 hours in the past to detect a transition:
@@ -1673,7 +1673,7 @@ class datetime(date):
probe2 = cls(y, m, d, hh, mm, ss, us, tz)
if probe2 == result:
result._fold = 1
- else:
+ elif tz is not None:
result = tz.fromutc(result)
return result
diff --git a/contrib/tools/python3/src/Lib/difflib.py b/contrib/tools/python3/src/Lib/difflib.py
index afd8a0c7c5b..ba0b256969e 100644
--- a/contrib/tools/python3/src/Lib/difflib.py
+++ b/contrib/tools/python3/src/Lib/difflib.py
@@ -837,7 +837,7 @@ class Differ:
Each sequence must contain individual single-line strings ending with
newlines. Such sequences can be obtained from the `readlines()` method
of file-like objects. The delta generated also consists of newline-
- terminated strings, ready to be printed as-is via the writeline()
+ terminated strings, ready to be printed as-is via the writelines()
method of a file-like object.
Example:
diff --git a/contrib/tools/python3/src/Lib/doctest.py b/contrib/tools/python3/src/Lib/doctest.py
index 80a14bccfbf..8db1ef92936 100644
--- a/contrib/tools/python3/src/Lib/doctest.py
+++ b/contrib/tools/python3/src/Lib/doctest.py
@@ -1088,19 +1088,21 @@ class DocTestFinder:
def _find_lineno(self, obj, source_lines):
"""
- Return a line number of the given object's docstring. Note:
- this method assumes that the object has a docstring.
+ Return a line number of the given object's docstring.
+
+ Returns `None` if the given object does not have a docstring.
"""
lineno = None
+ docstring = getattr(obj, '__doc__', None)
# Find the line number for modules.
- if inspect.ismodule(obj):
+ if inspect.ismodule(obj) and docstring is not None:
lineno = 0
# Find the line number for classes.
# Note: this could be fooled if a class is defined multiple
# times in a single file.
- if inspect.isclass(obj):
+ if inspect.isclass(obj) and docstring is not None:
if source_lines is None:
return None
pat = re.compile(r'^\s*class\s*%s\b' %
@@ -1112,7 +1114,9 @@ class DocTestFinder:
# Find the line number for functions & methods.
if inspect.ismethod(obj): obj = obj.__func__
- if inspect.isfunction(obj): obj = obj.__code__
+ if inspect.isfunction(obj) and getattr(obj, '__doc__', None):
+ # We don't use `docstring` var here, because `obj` can be changed.
+ obj = obj.__code__
if inspect.istraceback(obj): obj = obj.tb_frame
if inspect.isframe(obj): obj = obj.f_code
if inspect.iscode(obj):
diff --git a/contrib/tools/python3/src/Lib/email/_encoded_words.py b/contrib/tools/python3/src/Lib/email/_encoded_words.py
index 295ae7eb212..6795a606de0 100644
--- a/contrib/tools/python3/src/Lib/email/_encoded_words.py
+++ b/contrib/tools/python3/src/Lib/email/_encoded_words.py
@@ -179,15 +179,15 @@ def decode(ew):
# Turn the CTE decoded bytes into unicode.
try:
string = bstring.decode(charset)
- except UnicodeError:
+ except UnicodeDecodeError:
defects.append(errors.UndecodableBytesDefect("Encoded word "
- "contains bytes not decodable using {} charset".format(charset)))
+ f"contains bytes not decodable using {charset!r} charset"))
string = bstring.decode(charset, 'surrogateescape')
- except LookupError:
+ except (LookupError, UnicodeEncodeError):
string = bstring.decode('ascii', 'surrogateescape')
if charset.lower() != 'unknown-8bit':
- defects.append(errors.CharsetError("Unknown charset {} "
- "in encoded word; decoded as unknown bytes".format(charset)))
+ defects.append(errors.CharsetError(f"Unknown charset {charset!r} "
+ f"in encoded word; decoded as unknown bytes"))
return string, charset, lang, defects
diff --git a/contrib/tools/python3/src/Lib/email/_header_value_parser.py b/contrib/tools/python3/src/Lib/email/_header_value_parser.py
index 51d355fbb0a..e637e6df066 100644
--- a/contrib/tools/python3/src/Lib/email/_header_value_parser.py
+++ b/contrib/tools/python3/src/Lib/email/_header_value_parser.py
@@ -781,7 +781,7 @@ class MimeParameters(TokenList):
else:
try:
value = value.decode(charset, 'surrogateescape')
- except LookupError:
+ except (LookupError, UnicodeEncodeError):
# XXX: there should really be a custom defect for
# unknown character set to make it easy to find,
# because otherwise unknown charset is a silent
@@ -2379,7 +2379,7 @@ def get_section(value):
digits += value[0]
value = value[1:]
if digits[0] == '0' and digits != '0':
- section.defects.append(errors.InvalidHeaderError(
+ section.defects.append(errors.InvalidHeaderDefect(
"section number has an invalid leading 0"))
section.number = int(digits)
section.append(ValueTerminal(digits, 'digits'))
diff --git a/contrib/tools/python3/src/Lib/email/charset.py b/contrib/tools/python3/src/Lib/email/charset.py
index d3d759ad911..791b6584b24 100644
--- a/contrib/tools/python3/src/Lib/email/charset.py
+++ b/contrib/tools/python3/src/Lib/email/charset.py
@@ -112,8 +112,8 @@ def add_charset(charset, header_enc=None, body_enc=None, output_charset=None):
charset is the input character set, and must be the canonical name of a
character set.
- Optional header_enc and body_enc is either Charset.QP for
- quoted-printable, Charset.BASE64 for base64 encoding, Charset.SHORTEST for
+ Optional header_enc and body_enc is either charset.QP for
+ quoted-printable, charset.BASE64 for base64 encoding, charset.SHORTEST for
the shortest of qp or base64 encoding, or None for no encoding. SHORTEST
is only valid for header_enc. It describes how message headers and
message bodies in the input charset are to be encoded. Default is no
@@ -185,13 +185,13 @@ class Charset:
header_encoding: If the character set must be encoded before it can be
used in an email header, this attribute will be set to
- Charset.QP (for quoted-printable), Charset.BASE64 (for
- base64 encoding), or Charset.SHORTEST for the shortest of
+ charset.QP (for quoted-printable), charset.BASE64 (for
+ base64 encoding), or charset.SHORTEST for the shortest of
QP or BASE64 encoding. Otherwise, it will be None.
body_encoding: Same as header_encoding, but describes the encoding for the
mail message's body, which indeed may be different than the
- header encoding. Charset.SHORTEST is not allowed for
+ header encoding. charset.SHORTEST is not allowed for
body_encoding.
output_charset: Some character sets must be converted before they can be
diff --git a/contrib/tools/python3/src/Lib/fnmatch.py b/contrib/tools/python3/src/Lib/fnmatch.py
index 7c52c23067d..fee59bf73ff 100644
--- a/contrib/tools/python3/src/Lib/fnmatch.py
+++ b/contrib/tools/python3/src/Lib/fnmatch.py
@@ -108,7 +108,7 @@ def translate(pat):
add('\\[')
else:
stuff = pat[i:j]
- if '--' not in stuff:
+ if '-' not in stuff:
stuff = stuff.replace('\\', r'\\')
else:
chunks = []
@@ -120,7 +120,16 @@ def translate(pat):
chunks.append(pat[i:k])
i = k+1
k = k+3
- chunks.append(pat[i:j])
+ chunk = pat[i:j]
+ if chunk:
+ chunks.append(chunk)
+ else:
+ chunks[-1] += '-'
+ # Remove empty ranges -- invalid in RE.
+ for k in range(len(chunks)-1, 0, -1):
+ if chunks[k-1][-1] > chunks[k][0]:
+ chunks[k-1] = chunks[k-1][:-1] + chunks[k][1:]
+ del chunks[k]
# Escape backslashes and hyphens for set difference (--).
# Hyphens that create ranges shouldn't be escaped.
stuff = '-'.join(s.replace('\\', r'\\').replace('-', r'\-')
@@ -128,11 +137,18 @@ def translate(pat):
# Escape set operations (&&, ~~ and ||).
stuff = re.sub(r'([&~|])', r'\\\1', stuff)
i = j+1
- if stuff[0] == '!':
- stuff = '^' + stuff[1:]
- elif stuff[0] in ('^', '['):
- stuff = '\\' + stuff
- add(f'[{stuff}]')
+ if not stuff:
+ # Empty range: never match.
+ add('(?!)')
+ elif stuff == '!':
+ # Negated empty range: match any character.
+ add('.')
+ else:
+ if stuff[0] == '!':
+ stuff = '^' + stuff[1:]
+ elif stuff[0] in ('^', '['):
+ stuff = '\\' + stuff
+ add(f'[{stuff}]')
else:
add(re.escape(c))
assert i == n
diff --git a/contrib/tools/python3/src/Lib/html/entities.py b/contrib/tools/python3/src/Lib/html/entities.py
index 91ea5da2af4..dc508631ac4 100644
--- a/contrib/tools/python3/src/Lib/html/entities.py
+++ b/contrib/tools/python3/src/Lib/html/entities.py
@@ -4,6 +4,7 @@ __all__ = ['html5', 'name2codepoint', 'codepoint2name', 'entitydefs']
# maps the HTML entity name to the Unicode code point
+# from https://html.spec.whatwg.org/multipage/named-characters.html
name2codepoint = {
'AElig': 0x00c6, # latin capital letter AE = latin capital ligature AE, U+00C6 ISOlat1
'Aacute': 0x00c1, # latin capital letter A with acute, U+00C1 ISOlat1
diff --git a/contrib/tools/python3/src/Lib/ipaddress.py b/contrib/tools/python3/src/Lib/ipaddress.py
index 4a6496a5da3..756f1bc38c9 100644
--- a/contrib/tools/python3/src/Lib/ipaddress.py
+++ b/contrib/tools/python3/src/Lib/ipaddress.py
@@ -51,8 +51,7 @@ def ip_address(address):
except (AddressValueError, NetmaskValueError):
pass
- raise ValueError('%r does not appear to be an IPv4 or IPv6 address' %
- address)
+ raise ValueError(f'{address!r} does not appear to be an IPv4 or IPv6 address')
def ip_network(address, strict=True):
@@ -81,8 +80,7 @@ def ip_network(address, strict=True):
except (AddressValueError, NetmaskValueError):
pass
- raise ValueError('%r does not appear to be an IPv4 or IPv6 network' %
- address)
+ raise ValueError(f'{address!r} does not appear to be an IPv4 or IPv6 network')
def ip_interface(address):
@@ -116,8 +114,7 @@ def ip_interface(address):
except (AddressValueError, NetmaskValueError):
pass
- raise ValueError('%r does not appear to be an IPv4 or IPv6 interface' %
- address)
+ raise ValueError(f'{address!r} does not appear to be an IPv4 or IPv6 interface')
def v4_int_to_packed(address):
@@ -160,7 +157,7 @@ def _split_optional_netmask(address):
"""Helper to split the netmask and raise AddressValueError if needed"""
addr = str(address).split('/')
if len(addr) > 2:
- raise AddressValueError("Only one '/' permitted in %r" % address)
+ raise AddressValueError(f"Only one '/' permitted in {address!r}")
return addr
@@ -1304,7 +1301,7 @@ class IPv4Address(_BaseV4, _BaseAddress):
# which converts into a formatted IP string.
addr_str = str(address)
if '/' in addr_str:
- raise AddressValueError("Unexpected '/' in %r" % address)
+ raise AddressValueError(f"Unexpected '/' in {address!r}")
self._ip = self._ip_int_from_string(addr_str)
@property
@@ -1913,7 +1910,7 @@ class IPv6Address(_BaseV6, _BaseAddress):
# which converts into a formatted IP string.
addr_str = str(address)
if '/' in addr_str:
- raise AddressValueError("Unexpected '/' in %r" % address)
+ raise AddressValueError(f"Unexpected '/' in {address!r}")
addr_str, self._scope_id = self._split_scope_id(addr_str)
self._ip = self._ip_int_from_string(addr_str)
diff --git a/contrib/tools/python3/src/Lib/multiprocessing/managers.py b/contrib/tools/python3/src/Lib/multiprocessing/managers.py
index b6b4cdd9ac1..22292c78b7b 100644
--- a/contrib/tools/python3/src/Lib/multiprocessing/managers.py
+++ b/contrib/tools/python3/src/Lib/multiprocessing/managers.py
@@ -677,7 +677,7 @@ class BaseManager(object):
if hasattr(process, 'terminate'):
util.info('trying to `terminate()` manager process')
process.terminate()
- process.join(timeout=0.1)
+ process.join(timeout=1.0)
if process.is_alive():
util.info('manager still alive after terminate')
diff --git a/contrib/tools/python3/src/Lib/multiprocessing/queues.py b/contrib/tools/python3/src/Lib/multiprocessing/queues.py
index a2901814876..f37f114a968 100644
--- a/contrib/tools/python3/src/Lib/multiprocessing/queues.py
+++ b/contrib/tools/python3/src/Lib/multiprocessing/queues.py
@@ -139,13 +139,10 @@ class Queue(object):
def close(self):
self._closed = True
- try:
- self._reader.close()
- finally:
- close = self._close
- if close:
- self._close = None
- close()
+ close = self._close
+ if close:
+ self._close = None
+ close()
def join_thread(self):
debug('Queue.join_thread()')
@@ -169,8 +166,9 @@ class Queue(object):
self._thread = threading.Thread(
target=Queue._feed,
args=(self._buffer, self._notempty, self._send_bytes,
- self._wlock, self._writer.close, self._ignore_epipe,
- self._on_queue_feeder_error, self._sem),
+ self._wlock, self._reader.close, self._writer.close,
+ self._ignore_epipe, self._on_queue_feeder_error,
+ self._sem),
name='QueueFeederThread'
)
self._thread.daemon = True
@@ -211,8 +209,8 @@ class Queue(object):
notempty.notify()
@staticmethod
- def _feed(buffer, notempty, send_bytes, writelock, close, ignore_epipe,
- onerror, queue_sem):
+ def _feed(buffer, notempty, send_bytes, writelock, reader_close,
+ writer_close, ignore_epipe, onerror, queue_sem):
debug('starting thread to feed data to pipe')
nacquire = notempty.acquire
nrelease = notempty.release
@@ -238,7 +236,8 @@ class Queue(object):
obj = bpopleft()
if obj is sentinel:
debug('feeder thread got sentinel -- exiting')
- close()
+ reader_close()
+ writer_close()
return
# serialize the data before acquiring the lock
diff --git a/contrib/tools/python3/src/Lib/multiprocessing/util.py b/contrib/tools/python3/src/Lib/multiprocessing/util.py
index 230ffd11e64..a17f0f5f92d 100644
--- a/contrib/tools/python3/src/Lib/multiprocessing/util.py
+++ b/contrib/tools/python3/src/Lib/multiprocessing/util.py
@@ -120,7 +120,7 @@ def is_abstract_socket_namespace(address):
return address[0] == 0
elif isinstance(address, str):
return address[0] == "\0"
- raise TypeError('address type of {address!r} unrecognized')
+ raise TypeError(f'address type of {address!r} unrecognized')
abstract_sockets_supported = _platform_supports_abstract_sockets()
diff --git a/contrib/tools/python3/src/Lib/pathlib.py b/contrib/tools/python3/src/Lib/pathlib.py
index 621fba0e75c..97b23ca45a3 100644
--- a/contrib/tools/python3/src/Lib/pathlib.py
+++ b/contrib/tools/python3/src/Lib/pathlib.py
@@ -528,6 +528,8 @@ class _PathParents(Sequence):
if idx >= len(self) or idx < -len(self):
raise IndexError(idx)
+ if idx < 0:
+ idx += len(self)
return self._pathcls._from_parsed_parts(self._drv, self._root,
self._parts[:-idx - 1])
diff --git a/contrib/tools/python3/src/Lib/pydoc_data/topics.py b/contrib/tools/python3/src/Lib/pydoc_data/topics.py
index 76db0426df3..17f0cb4f204 100644
--- a/contrib/tools/python3/src/Lib/pydoc_data/topics.py
+++ b/contrib/tools/python3/src/Lib/pydoc_data/topics.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-# Autogenerated by Sphinx on Wed Mar 23 20:11:40 2022
+# Autogenerated by Sphinx on Mon Jun 6 12:53:10 2022
topics = {'assert': 'The "assert" statement\n'
'**********************\n'
'\n'
@@ -93,11 +93,7 @@ topics = {'assert': 'The "assert" statement\n'
' optionally in parentheses, the object is assigned to that '
'target.\n'
'\n'
- '* Else: The object must be an iterable with the same number of '
- 'items\n'
- ' as there are targets in the target list, and the items are '
- 'assigned,\n'
- ' from left to right, to the corresponding targets.\n'
+ '* Else:\n'
'\n'
' * If the target list contains one target prefixed with an '
'asterisk,\n'
@@ -4812,7 +4808,10 @@ topics = {'assert': 'The "assert" statement\n'
'is\n'
'applied to separating the commands; the input is split at the '
'first\n'
- '";;" pair, even if it is in the middle of a quoted string.\n'
+ '";;" pair, even if it is in the middle of a quoted string. A\n'
+ 'workaround for strings with double semicolons is to use '
+ 'implicit\n'
+ 'string concatenation "\';\'\';\'" or "";"";"".\n'
'\n'
'If a file ".pdbrc" exists in the user’s home directory or in '
'the\n'
@@ -7269,12 +7268,12 @@ topics = {'assert': 'The "assert" statement\n'
'Examples:\n'
'\n'
' import foo # foo imported and bound locally\n'
- ' import foo.bar.baz # foo.bar.baz imported, foo bound '
- 'locally\n'
- ' import foo.bar.baz as fbb # foo.bar.baz imported and bound as '
- 'fbb\n'
- ' from foo.bar import baz # foo.bar.baz imported and bound as '
- 'baz\n'
+ ' import foo.bar.baz # foo, foo.bar, and foo.bar.baz '
+ 'imported, foo bound locally\n'
+ ' import foo.bar.baz as fbb # foo, foo.bar, and foo.bar.baz '
+ 'imported, foo.bar.baz bound as fbb\n'
+ ' from foo.bar import baz # foo, foo.bar, and foo.bar.baz '
+ 'imported, foo.bar.baz bound as baz\n'
' from foo import attr # foo imported and foo.attr bound as '
'attr\n'
'\n'
@@ -8189,7 +8188,7 @@ topics = {'assert': 'The "assert" statement\n'
'| "x(arguments...)", "x.attribute" | '
'attribute reference |\n'
'+-------------------------------------------------+---------------------------------------+\n'
- '| "await" "x" | '
+ '| "await x" | '
'Await expression |\n'
'+-------------------------------------------------+---------------------------------------+\n'
'| "**" | '
@@ -8225,7 +8224,7 @@ topics = {'assert': 'The "assert" statement\n'
'| ">=", "!=", "==" | '
'tests and identity tests |\n'
'+-------------------------------------------------+---------------------------------------+\n'
- '| "not" "x" | '
+ '| "not x" | '
'Boolean NOT |\n'
'+-------------------------------------------------+---------------------------------------+\n'
'| "and" | '
@@ -11988,9 +11987,13 @@ topics = {'assert': 'The "assert" statement\n'
' >>> "they\'re bill\'s friends from the UK".title()\n'
' "They\'Re Bill\'S Friends From The Uk"\n'
'\n'
- ' A workaround for apostrophes can be constructed using '
- 'regular\n'
- ' expressions:\n'
+ ' The "string.capwords()" function does not have this '
+ 'problem, as it\n'
+ ' splits words on spaces only.\n'
+ '\n'
+ ' Alternatively, a workaround for apostrophes can be '
+ 'constructed\n'
+ ' using regular expressions:\n'
'\n'
' >>> import re\n'
' >>> def titlecase(s):\n'
@@ -12112,12 +12115,15 @@ topics = {'assert': 'The "assert" statement\n'
'single quotes ("\'") or double quotes ("""). They can also be '
'enclosed\n'
'in matching groups of three single or double quotes (these are\n'
- 'generally referred to as *triple-quoted strings*). The '
- 'backslash\n'
- '("\\") character is used to escape characters that otherwise have '
- 'a\n'
- 'special meaning, such as newline, backslash itself, or the quote\n'
+ 'generally referred to as *triple-quoted strings*). The backslash '
+ '("\\")\n'
+ 'character is used to give special meaning to otherwise ordinary\n'
+ 'characters like "n", which means ‘newline’ when escaped ("\\n"). '
+ 'It can\n'
+ 'also be used to escape characters that otherwise have a special\n'
+ 'meaning, such as newline, backslash itself, or the quote '
'character.\n'
+ 'See escape sequences below for examples.\n'
'\n'
'Bytes literals are always prefixed with "\'b\'" or "\'B\'"; they '
'produce\n'
@@ -13735,14 +13741,6 @@ topics = {'assert': 'The "assert" statement\n'
'unwise to use\n'
'them as dictionary keys.)\n'
'\n'
- 'Dictionaries can be created by placing a comma-separated '
- 'list of "key:\n'
- 'value" pairs within braces, for example: "{\'jack\': 4098, '
- "'sjoerd':\n"
- '4127}" or "{4098: \'jack\', 4127: \'sjoerd\'}", or by the '
- '"dict"\n'
- 'constructor.\n'
- '\n'
'class dict(**kwargs)\n'
'class dict(mapping, **kwargs)\n'
'class dict(iterable, **kwargs)\n'
diff --git a/contrib/tools/python3/src/Lib/queue.py b/contrib/tools/python3/src/Lib/queue.py
index 10dbcbc18ec..55f50088460 100644
--- a/contrib/tools/python3/src/Lib/queue.py
+++ b/contrib/tools/python3/src/Lib/queue.py
@@ -298,7 +298,7 @@ class _PySimpleQueue:
def put_nowait(self, item):
'''Put an item into the queue without blocking.
- This is exactly equivalent to `put(item)` and is only provided
+ This is exactly equivalent to `put(item, block=False)` and is only provided
for compatibility with the Queue class.
'''
return self.put(item, block=False)
diff --git a/contrib/tools/python3/src/Lib/runpy.py b/contrib/tools/python3/src/Lib/runpy.py
index caba1214262..c7d3d8caad1 100644
--- a/contrib/tools/python3/src/Lib/runpy.py
+++ b/contrib/tools/python3/src/Lib/runpy.py
@@ -198,9 +198,24 @@ def _run_module_as_main(mod_name, alter_argv=True):
def run_module(mod_name, init_globals=None,
run_name=None, alter_sys=False):
- """Execute a module's code without importing it
+ """Execute a module's code without importing it.
- Returns the resulting top level namespace dictionary
+ mod_name -- an absolute module name or package name.
+
+ Optional arguments:
+ init_globals -- dictionary used to pre-populate the module’s
+ globals dictionary before the code is executed.
+
+ run_name -- if not None, this will be used for setting __name__;
+ otherwise, __name__ will be set to mod_name + '__main__' if the
+ named module is a package and to just mod_name otherwise.
+
+ alter_sys -- if True, sys.argv[0] is updated with the value of
+ __file__ and sys.modules[__name__] is updated with a temporary
+ module object for the module being executed. Both are
+ restored to their original values before the function returns.
+
+ Returns the resulting module globals dictionary.
"""
mod_name, mod_spec, code = _get_module_details(mod_name)
if run_name is None:
@@ -243,14 +258,19 @@ def _get_code_from_file(run_name, fname):
return code, fname
def run_path(path_name, init_globals=None, run_name=None):
- """Execute code located at the specified filesystem location
+ """Execute code located at the specified filesystem location.
+
+ path_name -- filesystem location of a Python script, zipfile,
+ or directory containing a top level __main__.py script.
+
+ Optional arguments:
+ init_globals -- dictionary used to pre-populate the module’s
+ globals dictionary before the code is executed.
- Returns the resulting top level namespace dictionary
+ run_name -- if not None, this will be used to set __name__;
+ otherwise, '<run_path>' will be used for __name__.
- The file path may refer directly to a Python script (i.e.
- one that could be directly executed with execfile) or else
- it may refer to a zipfile or directory containing a top
- level __main__.py script.
+ Returns the resulting module globals dictionary.
"""
if run_name is None:
run_name = "<run_path>"
diff --git a/contrib/tools/python3/src/Lib/shutil.py b/contrib/tools/python3/src/Lib/shutil.py
index 37bf98df796..2768bcf6ab8 100644
--- a/contrib/tools/python3/src/Lib/shutil.py
+++ b/contrib/tools/python3/src/Lib/shutil.py
@@ -516,9 +516,6 @@ def copytree(src, dst, symlinks=False, ignore=None, copy_function=copy2,
ignore_dangling_symlinks=False, dirs_exist_ok=False):
"""Recursively copy a directory tree and return the destination directory.
- dirs_exist_ok dictates whether to raise an exception in case dst or any
- missing parent directory already exists.
-
If exception(s) occur, an Error is raised with a list of reasons.
If the optional symlinks flag is true, symbolic links in the
@@ -549,6 +546,11 @@ def copytree(src, dst, symlinks=False, ignore=None, copy_function=copy2,
destination path as arguments. By default, copy2() is used, but any
function that supports the same signature (like copy()) can be used.
+ If dirs_exist_ok is false (the default) and `dst` already exists, a
+ `FileExistsError` is raised. If `dirs_exist_ok` is true, the copying
+ operation will continue if it encounters existing directories, and files
+ within the `dst` tree will be overwritten by corresponding files from the
+ `src` tree.
"""
sys.audit("shutil.copytree", src, dst)
with os.scandir(src) as itr:
diff --git a/contrib/tools/python3/src/Lib/socket.py b/contrib/tools/python3/src/Lib/socket.py
index 63ba0acc908..63ba0acc908 100755..100644
--- a/contrib/tools/python3/src/Lib/socket.py
+++ b/contrib/tools/python3/src/Lib/socket.py
diff --git a/contrib/tools/python3/src/Lib/sqlite3/__init__.py b/contrib/tools/python3/src/Lib/sqlite3/__init__.py
index 0dedf186b1a..5a2dbd360fb 100644
--- a/contrib/tools/python3/src/Lib/sqlite3/__init__.py
+++ b/contrib/tools/python3/src/Lib/sqlite3/__init__.py
@@ -21,7 +21,7 @@
# 3. This notice may not be removed or altered from any source distribution.
"""
-The sqlite3 extension module provides a DB-API 2.0 (PEP 249) compilant
+The sqlite3 extension module provides a DB-API 2.0 (PEP 249) compliant
interface to the SQLite library, and requires SQLite 3.7.15 or newer.
To use the module, start by creating a database Connection object:
diff --git a/contrib/tools/python3/src/Lib/sre_compile.py b/contrib/tools/python3/src/Lib/sre_compile.py
index c6398bfb83a..aed752d11d2 100644
--- a/contrib/tools/python3/src/Lib/sre_compile.py
+++ b/contrib/tools/python3/src/Lib/sre_compile.py
@@ -52,6 +52,22 @@ _equivalences = (
(0x3c2, 0x3c3), # ςσ
# GREEK SMALL LETTER PHI, GREEK PHI SYMBOL
(0x3c6, 0x3d5), # φϕ
+ # CYRILLIC SMALL LETTER VE, CYRILLIC SMALL LETTER ROUNDED VE
+ (0x432, 0x1c80), # вᲀ
+ # CYRILLIC SMALL LETTER DE, CYRILLIC SMALL LETTER LONG-LEGGED DE
+ (0x434, 0x1c81), # дᲁ
+ # CYRILLIC SMALL LETTER O, CYRILLIC SMALL LETTER NARROW O
+ (0x43e, 0x1c82), # оᲂ
+ # CYRILLIC SMALL LETTER ES, CYRILLIC SMALL LETTER WIDE ES
+ (0x441, 0x1c83), # сᲃ
+ # CYRILLIC SMALL LETTER TE, CYRILLIC SMALL LETTER TALL TE, CYRILLIC SMALL LETTER THREE-LEGGED TE
+ (0x442, 0x1c84, 0x1c85), # тᲄᲅ
+ # CYRILLIC SMALL LETTER HARD SIGN, CYRILLIC SMALL LETTER TALL HARD SIGN
+ (0x44a, 0x1c86), # ъᲆ
+ # CYRILLIC SMALL LETTER YAT, CYRILLIC SMALL LETTER TALL YAT
+ (0x463, 0x1c87), # ѣᲇ
+ # CYRILLIC SMALL LETTER UNBLENDED UK, CYRILLIC SMALL LETTER MONOGRAPH UK
+ (0x1c88, 0xa64b), # ᲈꙋ
# LATIN SMALL LETTER S WITH DOT ABOVE, LATIN SMALL LETTER LONG S WITH DOT ABOVE
(0x1e61, 0x1e9b), # ṡẛ
# LATIN SMALL LIGATURE LONG S T, LATIN SMALL LIGATURE ST
@@ -320,11 +336,19 @@ def _optimize_charset(charset, iscased=None, fixup=None, fixes=None):
charmap += b'\0' * 0xff00
continue
# Character set contains non-BMP character codes.
+ # For range, all BMP characters in the range are already
+ # proceeded.
if fixup:
hascased = True
- # There are only two ranges of cased non-BMP characters:
- # 10400-1044F (Deseret) and 118A0-118DF (Warang Citi),
- # and for both ranges RANGE_UNI_IGNORE works.
+ # For now, IN_UNI_IGNORE+LITERAL and
+ # IN_UNI_IGNORE+RANGE_UNI_IGNORE work for all non-BMP
+ # characters, because two characters (at least one of
+ # which is not in the BMP) match case-insensitively
+ # if and only if:
+ # 1) c1.lower() == c2.lower()
+ # 2) c1.lower() == c2 or c1.lower().upper() == c2
+ # Also, both c.lower() and c.lower().upper() are single
+ # characters for every non-BMP character.
if op is RANGE:
op = RANGE_UNI_IGNORE
tail.append((op, av))
diff --git a/contrib/tools/python3/src/Lib/sre_constants.py b/contrib/tools/python3/src/Lib/sre_constants.py
index 8e613cb3fa5..db3ca51e830 100644
--- a/contrib/tools/python3/src/Lib/sre_constants.py
+++ b/contrib/tools/python3/src/Lib/sre_constants.py
@@ -62,6 +62,8 @@ class _NamedIntConstant(int):
def __repr__(self):
return self.name
+ __reduce__ = None
+
MAXREPEAT = _NamedIntConstant(MAXREPEAT, 'MAXREPEAT')
def _makecodes(names):
diff --git a/contrib/tools/python3/src/Lib/sre_parse.py b/contrib/tools/python3/src/Lib/sre_parse.py
index 53706676e9f..20a60250119 100644
--- a/contrib/tools/python3/src/Lib/sre_parse.py
+++ b/contrib/tools/python3/src/Lib/sre_parse.py
@@ -78,6 +78,7 @@ class State:
self.groupdict = {}
self.groupwidths = [None] # group 0
self.lookbehindgroups = None
+ self.grouprefpos = {}
@property
def groups(self):
return len(self.groupwidths)
@@ -330,7 +331,7 @@ def _class_escape(source, escape):
charname = source.getuntil('}', 'character name')
try:
c = ord(unicodedata.lookup(charname))
- except KeyError:
+ except (KeyError, TypeError):
raise source.error("undefined character name %r" % charname,
len(charname) + len(r'\N{}'))
return LITERAL, c
@@ -390,7 +391,7 @@ def _escape(source, escape, state):
charname = source.getuntil('}', 'character name')
try:
c = ord(unicodedata.lookup(charname))
- except KeyError:
+ except (KeyError, TypeError):
raise source.error("undefined character name %r" % charname,
len(charname) + len(r'\N{}'))
return LITERAL, c
@@ -786,6 +787,10 @@ def _parse(source, state, verbose, nested, first=False):
if condgroup >= MAXGROUPS:
msg = "invalid group reference %d" % condgroup
raise source.error(msg, len(condname) + 1)
+ if condgroup not in state.grouprefpos:
+ state.grouprefpos[condgroup] = (
+ source.tell() - len(condname) - 1
+ )
state.checklookbehindgroup(condgroup, source)
item_yes = _parse(source, state, verbose, nested + 1)
if source.match("|"):
@@ -963,6 +968,11 @@ def parse(str, flags=0, state=None):
assert source.next == ")"
raise source.error("unbalanced parenthesis")
+ for g in p.state.grouprefpos:
+ if g >= p.state.groups:
+ msg = "invalid group reference %d" % g
+ raise error(msg, str, p.state.grouprefpos[g])
+
if flags & SRE_FLAG_DEBUG:
p.dump()
diff --git a/contrib/tools/python3/src/Lib/ssl.py b/contrib/tools/python3/src/Lib/ssl.py
index 26f7bd0a74b..c4ee9fb5bb4 100644
--- a/contrib/tools/python3/src/Lib/ssl.py
+++ b/contrib/tools/python3/src/Lib/ssl.py
@@ -18,9 +18,10 @@ Functions:
seconds past the Epoch (the time values
returned from time.time())
- fetch_server_certificate (HOST, PORT) -- fetch the certificate provided
- by the server running on HOST at port PORT. No
- validation of the certificate is performed.
+ get_server_certificate (addr, ssl_version, ca_certs, timeout) -- Retrieve the
+ certificate from the server at the specified
+ address and return it as a PEM-encoded string
+
Integer constants:
diff --git a/contrib/tools/python3/src/Lib/subprocess.py b/contrib/tools/python3/src/Lib/subprocess.py
index ccb46a6337b..a414321b9d1 100644
--- a/contrib/tools/python3/src/Lib/subprocess.py
+++ b/contrib/tools/python3/src/Lib/subprocess.py
@@ -691,7 +691,10 @@ def _use_posix_spawn():
return False
+# These are primarily fail-safe knobs for negatives. A True value does not
+# guarantee the given libc/syscall API will be used.
_USE_POSIX_SPAWN = _use_posix_spawn()
+_USE_VFORK = True
class Popen:
diff --git a/contrib/tools/python3/src/Lib/threading.py b/contrib/tools/python3/src/Lib/threading.py
index 2d897429136..668126523d5 100644
--- a/contrib/tools/python3/src/Lib/threading.py
+++ b/contrib/tools/python3/src/Lib/threading.py
@@ -368,14 +368,21 @@ class Condition:
"""
if not self._is_owned():
raise RuntimeError("cannot notify on un-acquired lock")
- all_waiters = self._waiters
- waiters_to_notify = _deque(_islice(all_waiters, n))
- if not waiters_to_notify:
- return
- for waiter in waiters_to_notify:
- waiter.release()
+ waiters = self._waiters
+ while waiters and n > 0:
+ waiter = waiters[0]
+ try:
+ waiter.release()
+ except RuntimeError:
+ # gh-92530: The previous call of notify() released the lock,
+ # but was interrupted before removing it from the queue.
+ # It can happen if a signal handler raises an exception,
+ # like CTRL+C which raises KeyboardInterrupt.
+ pass
+ else:
+ n -= 1
try:
- all_waiters.remove(waiter)
+ waiters.remove(waiter)
except ValueError:
pass
diff --git a/contrib/tools/python3/src/Lib/unittest/async_case.py b/contrib/tools/python3/src/Lib/unittest/async_case.py
index 23231199f98..d9c694e3682 100644
--- a/contrib/tools/python3/src/Lib/unittest/async_case.py
+++ b/contrib/tools/python3/src/Lib/unittest/async_case.py
@@ -148,6 +148,8 @@ class IsolatedAsyncioTestCase(TestCase):
# shutdown asyncgens
loop.run_until_complete(loop.shutdown_asyncgens())
finally:
+ # Prevent our executor environment from leaking to future tests.
+ loop.run_until_complete(loop.shutdown_default_executor())
asyncio.set_event_loop(None)
loop.close()
diff --git a/contrib/tools/python3/src/Lib/urllib/request.py b/contrib/tools/python3/src/Lib/urllib/request.py
index 34b1b0b0b76..a0ef60b30de 100644
--- a/contrib/tools/python3/src/Lib/urllib/request.py
+++ b/contrib/tools/python3/src/Lib/urllib/request.py
@@ -2674,22 +2674,26 @@ elif os.name == 'nt':
# Returned as Unicode but problems if not converted to ASCII
proxyServer = str(winreg.QueryValueEx(internetSettings,
'ProxyServer')[0])
- if '=' in proxyServer:
- # Per-protocol settings
- for p in proxyServer.split(';'):
- protocol, address = p.split('=', 1)
- # See if address has a type:// prefix
- if not re.match('(?:[^/:]+)://', address):
- address = '%s://%s' % (protocol, address)
- proxies[protocol] = address
- else:
- # Use one setting for all protocols
- if proxyServer[:5] == 'http:':
- proxies['http'] = proxyServer
- else:
- proxies['http'] = 'http://%s' % proxyServer
- proxies['https'] = 'https://%s' % proxyServer
- proxies['ftp'] = 'ftp://%s' % proxyServer
+ if '=' not in proxyServer and ';' not in proxyServer:
+ # Use one setting for all protocols.
+ proxyServer = 'http={0};https={0};ftp={0}'.format(proxyServer)
+ for p in proxyServer.split(';'):
+ protocol, address = p.split('=', 1)
+ # See if address has a type:// prefix
+ if not re.match('(?:[^/:]+)://', address):
+ # Add type:// prefix to address without specifying type
+ if protocol in ('http', 'https', 'ftp'):
+ # The default proxy type of Windows is HTTP
+ address = 'http://' + address
+ elif protocol == 'socks':
+ address = 'socks://' + address
+ proxies[protocol] = address
+ # Use SOCKS proxy for HTTP(S) protocols
+ if proxies.get('socks'):
+ # The default SOCKS proxy type of Windows is SOCKS4
+ address = re.sub(r'^socks://', 'socks4://', proxies['socks'])
+ proxies['http'] = proxies.get('http') or address
+ proxies['https'] = proxies.get('https') or address
internetSettings.Close()
except (OSError, ValueError, TypeError):
# Either registry key not found etc, or the value in an
diff --git a/contrib/tools/python3/src/Lib/xml/etree/ElementPath.py b/contrib/tools/python3/src/Lib/xml/etree/ElementPath.py
index a1170b572fe..cd3c354d081 100644
--- a/contrib/tools/python3/src/Lib/xml/etree/ElementPath.py
+++ b/contrib/tools/python3/src/Lib/xml/etree/ElementPath.py
@@ -226,7 +226,6 @@ def prepare_parent(next, token):
def prepare_predicate(next, token):
# FIXME: replace with real parser!!! refs:
- # http://effbot.org/zone/simple-iterator-parser.htm
# http://javascript.crockford.com/tdop/tdop.html
signature = []
predicate = []
diff --git a/contrib/tools/python3/src/Lib/xml/etree/ElementTree.py b/contrib/tools/python3/src/Lib/xml/etree/ElementTree.py
index 07be8609b83..58da7c8d156 100644
--- a/contrib/tools/python3/src/Lib/xml/etree/ElementTree.py
+++ b/contrib/tools/python3/src/Lib/xml/etree/ElementTree.py
@@ -728,16 +728,10 @@ class ElementTree:
encoding = "utf-8"
else:
encoding = "us-ascii"
- enc_lower = encoding.lower()
- with _get_writer(file_or_filename, enc_lower) as write:
+ with _get_writer(file_or_filename, encoding) as (write, declared_encoding):
if method == "xml" and (xml_declaration or
(xml_declaration is None and
- enc_lower not in ("utf-8", "us-ascii", "unicode"))):
- declared_encoding = encoding
- if enc_lower == "unicode":
- # Retrieve the default encoding for the xml declaration
- import locale
- declared_encoding = locale.getpreferredencoding()
+ declared_encoding.lower() not in ("utf-8", "us-ascii"))):
write("<?xml version='1.0' encoding='%s'?>\n" % (
declared_encoding,))
if method == "text":
@@ -762,19 +756,20 @@ def _get_writer(file_or_filename, encoding):
write = file_or_filename.write
except AttributeError:
# file_or_filename is a file name
- if encoding == "unicode":
- file = open(file_or_filename, "w")
+ if encoding.lower() == "unicode":
+ file = open(file_or_filename, "w",
+ errors="xmlcharrefreplace")
else:
file = open(file_or_filename, "w", encoding=encoding,
errors="xmlcharrefreplace")
with file:
- yield file.write
+ yield file.write, file.encoding
else:
# file_or_filename is a file-like object
# encoding determines if it is a text or binary writer
- if encoding == "unicode":
+ if encoding.lower() == "unicode":
# use a text writer as is
- yield write
+ yield write, getattr(file_or_filename, "encoding", None) or "utf-8"
else:
# wrap a binary writer with TextIOWrapper
with contextlib.ExitStack() as stack:
@@ -805,7 +800,7 @@ def _get_writer(file_or_filename, encoding):
# Keep the original file open when the TextIOWrapper is
# destroyed
stack.callback(file.detach)
- yield file.write
+ yield file.write, encoding
def _namespaces(elem, default_namespace=None):
# identify namespaces used in this tree
diff --git a/contrib/tools/python3/src/Lib/zipfile.py b/contrib/tools/python3/src/Lib/zipfile.py
index 34d2fa4b864..eee1f47ed09 100644
--- a/contrib/tools/python3/src/Lib/zipfile.py
+++ b/contrib/tools/python3/src/Lib/zipfile.py
@@ -1349,6 +1349,8 @@ class ZipFile:
print("given, inferred, offset", offset_cd, inferred, concat)
# self.start_dir: Position of start of central directory
self.start_dir = offset_cd + concat
+ if self.start_dir < 0:
+ raise BadZipFile("Bad offset for central directory")
fp.seek(self.start_dir, 0)
data = fp.read(size_cd)
fp = io.BytesIO(data)
diff --git a/contrib/tools/python3/src/Modules/_bisectmodule.c b/contrib/tools/python3/src/Modules/_bisectmodule.c
index 26c4b9bfb26..16f981e7296 100644
--- a/contrib/tools/python3/src/Modules/_bisectmodule.c
+++ b/contrib/tools/python3/src/Modules/_bisectmodule.c
@@ -118,7 +118,7 @@ _bisect_insort_right_impl(PyObject *module, PyObject *a, PyObject *x,
index = internal_bisect_right(a, x, lo, hi, key);
} else {
key_x = PyObject_CallOneArg(key, x);
- if (x == NULL) {
+ if (key_x == NULL) {
return NULL;
}
index = internal_bisect_right(a, key_x, lo, hi, key);
@@ -245,7 +245,7 @@ _bisect_insort_left_impl(PyObject *module, PyObject *a, PyObject *x,
index = internal_bisect_left(a, x, lo, hi, key);
} else {
key_x = PyObject_CallOneArg(key, x);
- if (x == NULL) {
+ if (key_x == NULL) {
return NULL;
}
index = internal_bisect_left(a, key_x, lo, hi, key);
diff --git a/contrib/tools/python3/src/Modules/_ctypes/_ctypes.c b/contrib/tools/python3/src/Modules/_ctypes/_ctypes.c
index 198bdd444b5..4a698e07221 100644
--- a/contrib/tools/python3/src/Modules/_ctypes/_ctypes.c
+++ b/contrib/tools/python3/src/Modules/_ctypes/_ctypes.c
@@ -188,7 +188,7 @@ static PyTypeObject DictRemover_Type = {
0, /* tp_as_buffer */
/* XXX should participate in GC? */
Py_TPFLAGS_DEFAULT, /* tp_flags */
- "deletes a key from a dictionary", /* tp_doc */
+ PyDoc_STR("deletes a key from a dictionary"), /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
@@ -571,8 +571,8 @@ UnionType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return StructUnionType_new(type, args, kwds, 0);
}
-static const char from_address_doc[] =
-"C.from_address(integer) -> C instance\naccess a C instance at the specified address";
+PyDoc_STRVAR(from_address_doc,
+"C.from_address(integer) -> C instance\naccess a C instance at the specified address");
static PyObject *
CDataType_from_address(PyObject *type, PyObject *value)
@@ -589,8 +589,8 @@ CDataType_from_address(PyObject *type, PyObject *value)
return PyCData_AtAddress(type, buf);
}
-static const char from_buffer_doc[] =
-"C.from_buffer(object, offset=0) -> C instance\ncreate a C instance from a writeable buffer";
+PyDoc_STRVAR(from_buffer_doc,
+"C.from_buffer(object, offset=0) -> C instance\ncreate a C instance from a writeable buffer");
static int
KeepRef(CDataObject *target, Py_ssize_t index, PyObject *keep);
@@ -669,8 +669,8 @@ CDataType_from_buffer(PyObject *type, PyObject *args)
return result;
}
-static const char from_buffer_copy_doc[] =
-"C.from_buffer_copy(object, offset=0) -> C instance\ncreate a C instance from a readable buffer";
+PyDoc_STRVAR(from_buffer_copy_doc,
+"C.from_buffer_copy(object, offset=0) -> C instance\ncreate a C instance from a readable buffer");
static PyObject *
GenericPyCData_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
@@ -720,8 +720,8 @@ CDataType_from_buffer_copy(PyObject *type, PyObject *args)
return result;
}
-static const char in_dll_doc[] =
-"C.in_dll(dll, name) -> C instance\naccess a C instance in a dll";
+PyDoc_STRVAR(in_dll_doc,
+"C.in_dll(dll, name) -> C instance\naccess a C instance in a dll");
static PyObject *
CDataType_in_dll(PyObject *type, PyObject *args)
@@ -782,8 +782,8 @@ CDataType_in_dll(PyObject *type, PyObject *args)
return PyCData_AtAddress(type, address);
}
-static const char from_param_doc[] =
-"Convert a Python object into a function call parameter.";
+PyDoc_STRVAR(from_param_doc,
+"Convert a Python object into a function call parameter.");
static PyObject *
CDataType_from_param(PyObject *type, PyObject *value)
@@ -937,7 +937,7 @@ PyTypeObject PyCStructType_Type = {
PyCStructType_setattro, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_flags */
- "metatype for the CData Objects", /* tp_doc */
+ PyDoc_STR("metatype for the CData Objects"), /* tp_doc */
(traverseproc)CDataType_traverse, /* tp_traverse */
(inquiry)CDataType_clear, /* tp_clear */
0, /* tp_richcompare */
@@ -979,7 +979,7 @@ static PyTypeObject UnionType_Type = {
UnionType_setattro, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_flags */
- "metatype for the CData Objects", /* tp_doc */
+ PyDoc_STR("metatype for the CData Objects"), /* tp_doc */
(traverseproc)CDataType_traverse, /* tp_traverse */
(inquiry)CDataType_clear, /* tp_clear */
0, /* tp_richcompare */
@@ -1237,7 +1237,7 @@ PyTypeObject PyCPointerType_Type = {
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_flags */
- "metatype for the Pointer Objects", /* tp_doc */
+ PyDoc_STR("metatype for the Pointer Objects"), /* tp_doc */
(traverseproc)CDataType_traverse, /* tp_traverse */
(inquiry)CDataType_clear, /* tp_clear */
0, /* tp_richcompare */
@@ -1649,7 +1649,7 @@ PyTypeObject PyCArrayType_Type = {
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- "metatype for the Array Objects", /* tp_doc */
+ PyDoc_STR("metatype for the Array Objects"), /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
@@ -2343,7 +2343,7 @@ PyTypeObject PyCSimpleType_Type = {
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- "metatype for the PyCSimpleType Objects", /* tp_doc */
+ PyDoc_STR("metatype for the PyCSimpleType Objects"), /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
@@ -2625,7 +2625,7 @@ PyTypeObject PyCFuncPtrType_Type = {
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_flags */
- "metatype for C function pointers", /* tp_doc */
+ PyDoc_STR("metatype for C function pointers"), /* tp_doc */
(traverseproc)CDataType_traverse, /* tp_traverse */
(inquiry)CDataType_clear, /* tp_clear */
0, /* tp_richcompare */
@@ -2930,7 +2930,7 @@ PyTypeObject PyCData_Type = {
0, /* tp_setattro */
&PyCData_as_buffer, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- "XXX to be provided", /* tp_doc */
+ PyDoc_STR("XXX to be provided"), /* tp_doc */
(traverseproc)PyCData_traverse, /* tp_traverse */
(inquiry)PyCData_clear, /* tp_clear */
0, /* tp_richcompare */
@@ -4328,7 +4328,7 @@ PyTypeObject PyCFuncPtr_Type = {
0, /* tp_setattro */
&PyCData_as_buffer, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- "Function Pointer", /* tp_doc */
+ PyDoc_STR("Function Pointer"), /* tp_doc */
(traverseproc)PyCFuncPtr_traverse, /* tp_traverse */
(inquiry)PyCFuncPtr_clear, /* tp_clear */
0, /* tp_richcompare */
@@ -4480,7 +4480,7 @@ static PyTypeObject Struct_Type = {
0, /* tp_setattro */
&PyCData_as_buffer, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- "Structure base class", /* tp_doc */
+ PyDoc_STR("Structure base class"), /* tp_doc */
(traverseproc)PyCData_traverse, /* tp_traverse */
(inquiry)PyCData_clear, /* tp_clear */
0, /* tp_richcompare */
@@ -4522,7 +4522,7 @@ static PyTypeObject Union_Type = {
0, /* tp_setattro */
&PyCData_as_buffer, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- "Union base class", /* tp_doc */
+ PyDoc_STR("Union base class"), /* tp_doc */
(traverseproc)PyCData_traverse, /* tp_traverse */
(inquiry)PyCData_clear, /* tp_clear */
0, /* tp_richcompare */
@@ -4842,7 +4842,7 @@ PyTypeObject PyCArray_Type = {
0, /* tp_setattro */
&PyCData_as_buffer, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- "XXX to be provided", /* tp_doc */
+ PyDoc_STR("XXX to be provided"), /* tp_doc */
(traverseproc)PyCData_traverse, /* tp_traverse */
(inquiry)PyCData_clear, /* tp_clear */
0, /* tp_richcompare */
@@ -5061,7 +5061,7 @@ static PyTypeObject Simple_Type = {
0, /* tp_setattro */
&PyCData_as_buffer, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- "XXX to be provided", /* tp_doc */
+ PyDoc_STR("XXX to be provided"), /* tp_doc */
(traverseproc)PyCData_traverse, /* tp_traverse */
(inquiry)PyCData_clear, /* tp_clear */
0, /* tp_richcompare */
@@ -5443,7 +5443,7 @@ PyTypeObject PyCPointer_Type = {
0, /* tp_setattro */
&PyCData_as_buffer, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- "XXX to be provided", /* tp_doc */
+ PyDoc_STR("XXX to be provided"), /* tp_doc */
(traverseproc)PyCData_traverse, /* tp_traverse */
(inquiry)PyCData_clear, /* tp_clear */
0, /* tp_richcompare */
@@ -5470,12 +5470,12 @@ PyTypeObject PyCPointer_Type = {
* Module initialization.
*/
-static const char module_docs[] =
-"Create and manipulate C compatible data types in Python.";
+PyDoc_STRVAR(_ctypes__doc__,
+"Create and manipulate C compatible data types in Python.");
#ifdef MS_WIN32
-static const char comerror_doc[] = "Raised when a COM method call failed.";
+PyDoc_STRVAR(comerror_doc, "Raised when a COM method call failed.");
int
comerror_init(PyObject *self, PyObject *args, PyObject *kwds)
@@ -5664,7 +5664,7 @@ wstring_at(const wchar_t *ptr, int size)
static struct PyModuleDef _ctypesmodule = {
PyModuleDef_HEAD_INIT,
.m_name = "_ctypes",
- .m_doc = module_docs,
+ .m_doc = _ctypes__doc__,
.m_size = -1,
.m_methods = _ctypes_module_methods,
};
diff --git a/contrib/tools/python3/src/Modules/_ctypes/callbacks.c b/contrib/tools/python3/src/Modules/_ctypes/callbacks.c
index 1afbd617c72..0896d57d402 100644
--- a/contrib/tools/python3/src/Modules/_ctypes/callbacks.c
+++ b/contrib/tools/python3/src/Modules/_ctypes/callbacks.c
@@ -66,7 +66,7 @@ PyTypeObject PyCThunk_Type = {
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
- "CThunkObject", /* tp_doc */
+ PyDoc_STR("CThunkObject"), /* tp_doc */
CThunkObject_traverse, /* tp_traverse */
CThunkObject_clear, /* tp_clear */
0, /* tp_richcompare */
diff --git a/contrib/tools/python3/src/Modules/_ctypes/callproc.c b/contrib/tools/python3/src/Modules/_ctypes/callproc.c
index ce148e0ecd5..72ffde09687 100644
--- a/contrib/tools/python3/src/Modules/_ctypes/callproc.c
+++ b/contrib/tools/python3/src/Modules/_ctypes/callproc.c
@@ -1313,11 +1313,11 @@ _parse_voidp(PyObject *obj, void **address)
#ifdef MS_WIN32
-static const char format_error_doc[] =
+PyDoc_STRVAR(format_error_doc,
"FormatError([integer]) -> string\n\
\n\
Convert a win32 error code into a string. If the error code is not\n\
-given, the return value of a call to GetLastError() is used.\n";
+given, the return value of a call to GetLastError() is used.\n");
static PyObject *format_error(PyObject *self, PyObject *args)
{
PyObject *result;
@@ -1337,13 +1337,13 @@ static PyObject *format_error(PyObject *self, PyObject *args)
return result;
}
-static const char load_library_doc[] =
+PyDoc_STRVAR(load_library_doc,
"LoadLibrary(name, load_flags) -> handle\n\
\n\
Load an executable (usually a DLL), and return a handle to it.\n\
The handle may be used to locate exported functions in this\n\
module. load_flags are as defined for LoadLibraryEx in the\n\
-Windows API.\n";
+Windows API.\n");
static PyObject *load_library(PyObject *self, PyObject *args)
{
PyObject *nameobj;
@@ -1388,10 +1388,10 @@ static PyObject *load_library(PyObject *self, PyObject *args)
#endif
}
-static const char free_library_doc[] =
+PyDoc_STRVAR(free_library_doc,
"FreeLibrary(handle) -> void\n\
\n\
-Free the handle of an executable previously loaded by LoadLibrary.\n";
+Free the handle of an executable previously loaded by LoadLibrary.\n");
static PyObject *free_library(PyObject *self, PyObject *args)
{
void *hMod;
@@ -1411,8 +1411,8 @@ static PyObject *free_library(PyObject *self, PyObject *args)
Py_RETURN_NONE;
}
-static const char copy_com_pointer_doc[] =
-"CopyComPointer(src, dst) -> HRESULT value\n";
+PyDoc_STRVAR(copy_com_pointer_doc,
+"CopyComPointer(src, dst) -> HRESULT value\n");
static PyObject *
copy_com_pointer(PyObject *self, PyObject *args)
@@ -1650,10 +1650,10 @@ call_cdeclfunction(PyObject *self, PyObject *args)
/*****************************************************************
* functions
*/
-static const char sizeof_doc[] =
+PyDoc_STRVAR(sizeof_doc,
"sizeof(C type) -> integer\n"
"sizeof(C instance) -> integer\n"
-"Return the size in bytes of a C instance";
+"Return the size in bytes of a C instance");
static PyObject *
sizeof_func(PyObject *self, PyObject *obj)
@@ -1671,10 +1671,10 @@ sizeof_func(PyObject *self, PyObject *obj)
return NULL;
}
-static const char alignment_doc[] =
+PyDoc_STRVAR(alignment_doc,
"alignment(C type) -> integer\n"
"alignment(C instance) -> integer\n"
-"Return the alignment requirements of a C instance";
+"Return the alignment requirements of a C instance");
static PyObject *
align_func(PyObject *self, PyObject *obj)
@@ -1694,10 +1694,10 @@ align_func(PyObject *self, PyObject *obj)
return NULL;
}
-static const char byref_doc[] =
+PyDoc_STRVAR(byref_doc,
"byref(C instance[, offset=0]) -> byref-object\n"
"Return a pointer lookalike to a C instance, only usable\n"
-"as function argument";
+"as function argument");
/*
* We must return something which can be converted to a parameter,
@@ -1738,9 +1738,9 @@ byref(PyObject *self, PyObject *args)
return (PyObject *)parg;
}
-static const char addressof_doc[] =
+PyDoc_STRVAR(addressof_doc,
"addressof(C instance) -> integer\n"
-"Return the address of the C instance internal buffer";
+"Return the address of the C instance internal buffer");
static PyObject *
addressof(PyObject *self, PyObject *obj)
diff --git a/contrib/tools/python3/src/Modules/_ctypes/cfield.c b/contrib/tools/python3/src/Modules/_ctypes/cfield.c
index eed06289f00..425a4570db8 100644
--- a/contrib/tools/python3/src/Modules/_ctypes/cfield.c
+++ b/contrib/tools/python3/src/Modules/_ctypes/cfield.c
@@ -319,7 +319,7 @@ PyTypeObject PyCField_Type = {
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
- "Structure/Union member", /* tp_doc */
+ PyDoc_STR("Structure/Union member"), /* tp_doc */
(traverseproc)PyCField_traverse, /* tp_traverse */
(inquiry)PyCField_clear, /* tp_clear */
0, /* tp_richcompare */
diff --git a/contrib/tools/python3/src/Modules/_datetimemodule.c b/contrib/tools/python3/src/Modules/_datetimemodule.c
index e54a01b44c5..ec823ae52c6 100644
--- a/contrib/tools/python3/src/Modules/_datetimemodule.c
+++ b/contrib/tools/python3/src/Modules/_datetimemodule.c
@@ -5004,6 +5004,10 @@ datetime_from_timet_and_us(PyObject *cls, TM_FUNC f, time_t timet, int us,
result_seconds = utc_to_seconds(year, month, day,
hour, minute, second);
+ if (result_seconds == -1 && PyErr_Occurred()) {
+ return NULL;
+ }
+
/* Probe max_fold_seconds to detect a fold. */
probe_seconds = local(epoch + timet - max_fold_seconds);
if (probe_seconds == -1)
diff --git a/contrib/tools/python3/src/Modules/_hashopenssl.c b/contrib/tools/python3/src/Modules/_hashopenssl.c
index 65538f63f7b..75063fa1536 100644
--- a/contrib/tools/python3/src/Modules/_hashopenssl.c
+++ b/contrib/tools/python3/src/Modules/_hashopenssl.c
@@ -1836,15 +1836,21 @@ typedef struct _internal_name_mapper_state {
/* A callback function to pass to OpenSSL's OBJ_NAME_do_all(...) */
static void
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
+_openssl_hash_name_mapper(EVP_MD *md, void *arg)
+#else
_openssl_hash_name_mapper(const EVP_MD *md, const char *from,
const char *to, void *arg)
+#endif
{
_InternalNameMapperState *state = (_InternalNameMapperState *)arg;
PyObject *py_name;
assert(state != NULL);
- if (md == NULL)
+ // ignore all undefined providers
+ if ((md == NULL) || (EVP_MD_nid(md) == NID_undef)) {
return;
+ }
py_name = py_digest_name(md);
if (py_name == NULL) {
@@ -1870,7 +1876,12 @@ hashlib_md_meth_names(PyObject *module)
return -1;
}
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
+ // get algorithms from all activated providers in default context
+ EVP_MD_do_all_provided(NULL, &_openssl_hash_name_mapper, &state);
+#else
EVP_MD_do_all(&_openssl_hash_name_mapper, &state);
+#endif
if (state.error) {
Py_DECREF(state.set);
diff --git a/contrib/tools/python3/src/Modules/_posixsubprocess.c b/contrib/tools/python3/src/Modules/_posixsubprocess.c
index a58159a277b..b852ad71d72 100644
--- a/contrib/tools/python3/src/Modules/_posixsubprocess.c
+++ b/contrib/tools/python3/src/Modules/_posixsubprocess.c
@@ -681,6 +681,12 @@ do_fork_exec(char *const exec_array[],
assert(preexec_fn == Py_None);
pid = vfork();
+ if (pid == -1) {
+ /* If vfork() fails, fall back to using fork(). When it isn't
+ * allowed in a process by the kernel, vfork can return -1
+ * with errno EINVAL. https://bugs.python.org/issue47151. */
+ pid = fork();
+ }
} else
#endif
{
@@ -930,8 +936,31 @@ subprocess_fork_exec(PyObject *module, PyObject *args)
#ifdef VFORK_USABLE
/* Use vfork() only if it's safe. See the comment above child_exec(). */
sigset_t old_sigs;
- if (preexec_fn == Py_None &&
- !call_setuid && !call_setgid && !call_setgroups) {
+ int allow_vfork;
+ if (preexec_fn == Py_None) {
+ allow_vfork = 1; /* 3.10.0 behavior */
+ PyObject *subprocess_module = PyImport_ImportModule("subprocess");
+ if (subprocess_module != NULL) {
+ PyObject *allow_vfork_obj = PyObject_GetAttrString(
+ subprocess_module, "_USE_VFORK");
+ Py_DECREF(subprocess_module);
+ if (allow_vfork_obj != NULL) {
+ allow_vfork = PyObject_IsTrue(allow_vfork_obj);
+ Py_DECREF(allow_vfork_obj);
+ if (allow_vfork < 0) {
+ PyErr_Clear(); /* Bad _USE_VFORK attribute. */
+ allow_vfork = 1; /* 3.10.0 behavior */
+ }
+ } else {
+ PyErr_Clear(); /* No _USE_VFORK attribute. */
+ }
+ } else {
+ PyErr_Clear(); /* no subprocess module? suspicious; don't care. */
+ }
+ } else {
+ allow_vfork = 0;
+ }
+ if (allow_vfork && !call_setuid && !call_setgid && !call_setgroups) {
/* Block all signals to ensure that no signal handlers are run in the
* child process while it shares memory with us. Note that signals
* used internally by C libraries won't be blocked by
diff --git a/contrib/tools/python3/src/Modules/_sqlite/connection.c b/contrib/tools/python3/src/Modules/_sqlite/connection.c
index c9c10b41398..68c5aee79ab 100644
--- a/contrib/tools/python3/src/Modules/_sqlite/connection.c
+++ b/contrib/tools/python3/src/Modules/_sqlite/connection.c
@@ -1050,33 +1050,65 @@ static int _progress_handler(void* user_arg)
* may change in future releases. Callback implementations should return zero
* to ensure future compatibility.
*/
-static int _trace_callback(unsigned int type, void* user_arg, void* prepared_statement, void* statement_string)
+static int
+_trace_callback(unsigned int type, void *callable, void *stmt, void *sql)
#else
-static void _trace_callback(void* user_arg, const char* statement_string)
+static void
+_trace_callback(void *callable, const char *sql)
#endif
{
- PyObject *py_statement = NULL;
- PyObject *ret = NULL;
-
- PyGILState_STATE gilstate;
-
#ifdef HAVE_TRACE_V2
if (type != SQLITE_TRACE_STMT) {
return 0;
}
#endif
- gilstate = PyGILState_Ensure();
- py_statement = PyUnicode_DecodeUTF8(statement_string,
- strlen(statement_string), "replace");
+ PyGILState_STATE gilstate = PyGILState_Ensure();
+
+ PyObject *py_statement = NULL;
+#ifdef HAVE_TRACE_V2
+ const char *expanded_sql = sqlite3_expanded_sql((sqlite3_stmt *)stmt);
+ if (expanded_sql == NULL) {
+ sqlite3 *db = sqlite3_db_handle((sqlite3_stmt *)stmt);
+ if (sqlite3_errcode(db) == SQLITE_NOMEM) {
+ (void)PyErr_NoMemory();
+ goto exit;
+ }
+
+ PyErr_SetString(pysqlite_DataError,
+ "Expanded SQL string exceeds the maximum string length");
+ if (_pysqlite_enable_callback_tracebacks) {
+ PyErr_Print();
+ } else {
+ PyErr_Clear();
+ }
+
+ // Fall back to unexpanded sql
+ py_statement = PyUnicode_FromString((const char *)sql);
+ }
+ else {
+ py_statement = PyUnicode_FromString(expanded_sql);
+ sqlite3_free((void *)expanded_sql);
+ }
+#else
+ if (sql == NULL) {
+ PyErr_SetString(pysqlite_DataError,
+ "Expanded SQL string exceeds the maximum string length");
+ if (_pysqlite_enable_callback_tracebacks) {
+ PyErr_Print();
+ } else {
+ PyErr_Clear();
+ }
+ goto exit;
+ }
+ py_statement = PyUnicode_FromString(sql);
+#endif
if (py_statement) {
- ret = PyObject_CallOneArg((PyObject*)user_arg, py_statement);
+ PyObject *ret = PyObject_CallOneArg((PyObject *)callable, py_statement);
Py_DECREF(py_statement);
+ Py_XDECREF(ret);
}
-
- if (ret) {
- Py_DECREF(ret);
- } else {
+ if (PyErr_Occurred()) {
if (_pysqlite_enable_callback_tracebacks) {
PyErr_Print();
} else {
@@ -1084,6 +1116,7 @@ static void _trace_callback(void* user_arg, const char* statement_string)
}
}
+exit:
PyGILState_Release(gilstate);
#ifdef HAVE_TRACE_V2
return 0;
diff --git a/contrib/tools/python3/src/Modules/_sqlite/cursor.c b/contrib/tools/python3/src/Modules/_sqlite/cursor.c
index 85267cc9e77..ac80c285fe9 100644
--- a/contrib/tools/python3/src/Modules/_sqlite/cursor.c
+++ b/contrib/tools/python3/src/Modules/_sqlite/cursor.c
@@ -26,6 +26,17 @@
#include "util.h"
#include "clinic/cursor.c.h"
+static inline int
+check_cursor_locked(pysqlite_Cursor *cur)
+{
+ if (cur->locked) {
+ PyErr_SetString(pysqlite_ProgrammingError,
+ "Recursive use of cursors not allowed.");
+ return 0;
+ }
+ return 1;
+}
+
/*[clinic input]
module _sqlite3
class _sqlite3.Cursor "pysqlite_Cursor *" "pysqlite_CursorType"
@@ -47,6 +58,10 @@ pysqlite_cursor_init_impl(pysqlite_Cursor *self,
pysqlite_Connection *connection)
/*[clinic end generated code: output=ac59dce49a809ca8 input=a8a4f75ac90999b2]*/
{
+ if (!check_cursor_locked(self)) {
+ return -1;
+ }
+
Py_INCREF(connection);
Py_XSETREF(self->connection, connection);
Py_CLEAR(self->statement);
@@ -407,12 +422,9 @@ static int check_cursor(pysqlite_Cursor* cur)
return 0;
}
- if (cur->locked) {
- PyErr_SetString(pysqlite_ProgrammingError, "Recursive use of cursors not allowed.");
- return 0;
- }
-
- return pysqlite_check_thread(cur->connection) && pysqlite_check_connection(cur->connection);
+ return (pysqlite_check_thread(cur->connection)
+ && pysqlite_check_connection(cur->connection)
+ && check_cursor_locked(cur));
}
static PyObject *
@@ -810,27 +822,29 @@ pysqlite_cursor_iternext(pysqlite_Cursor *self)
if (self->statement) {
rc = pysqlite_step(self->statement->st, self->connection);
if (PyErr_Occurred()) {
- (void)pysqlite_statement_reset(self->statement);
- Py_DECREF(next_row);
- return NULL;
+ goto error;
}
if (rc != SQLITE_DONE && rc != SQLITE_ROW) {
- (void)pysqlite_statement_reset(self->statement);
- Py_DECREF(next_row);
_pysqlite_seterror(self->connection->db, NULL);
- return NULL;
+ goto error;
}
if (rc == SQLITE_ROW) {
+ self->locked = 1; // GH-80254: Prevent recursive use of cursors.
self->next_row = _pysqlite_fetch_one_row(self);
+ self->locked = 0;
if (self->next_row == NULL) {
- (void)pysqlite_statement_reset(self->statement);
- return NULL;
+ goto error;
}
}
}
return next_row;
+
+error:
+ (void)pysqlite_statement_reset(self->statement);
+ Py_DECREF(next_row);
+ return NULL;
}
/*[clinic input]
@@ -973,6 +987,10 @@ static PyObject *
pysqlite_cursor_close_impl(pysqlite_Cursor *self)
/*[clinic end generated code: output=b6055e4ec6fe63b6 input=08b36552dbb9a986]*/
{
+ if (!check_cursor_locked(self)) {
+ return NULL;
+ }
+
if (!self->connection) {
PyErr_SetString(pysqlite_ProgrammingError,
"Base Cursor.__init__ not called.");
diff --git a/contrib/tools/python3/src/Modules/clinic/_curses_panel.c.h b/contrib/tools/python3/src/Modules/clinic/_curses_panel.c.h
index 45898070b1f..e4642b58332 100644
--- a/contrib/tools/python3/src/Modules/clinic/_curses_panel.c.h
+++ b/contrib/tools/python3/src/Modules/clinic/_curses_panel.c.h
@@ -17,18 +17,11 @@ _curses_panel_panel_bottom_impl(PyCursesPanelObject *self, PyTypeObject *cls);
static PyObject *
_curses_panel_panel_bottom(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
- PyObject *return_value = NULL;
- static const char * const _keywords[] = { NULL};
- static _PyArg_Parser _parser = {":bottom", _keywords, 0};
-
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser
- )) {
- goto exit;
+ if (nargs) {
+ PyErr_SetString(PyExc_TypeError, "bottom() takes no arguments");
+ return NULL;
}
- return_value = _curses_panel_panel_bottom_impl(self, cls);
-
-exit:
- return return_value;
+ return _curses_panel_panel_bottom_impl(self, cls);
}
PyDoc_STRVAR(_curses_panel_panel_hide__doc__,
@@ -48,18 +41,11 @@ _curses_panel_panel_hide_impl(PyCursesPanelObject *self, PyTypeObject *cls);
static PyObject *
_curses_panel_panel_hide(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
- PyObject *return_value = NULL;
- static const char * const _keywords[] = { NULL};
- static _PyArg_Parser _parser = {":hide", _keywords, 0};
-
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser
- )) {
- goto exit;
+ if (nargs) {
+ PyErr_SetString(PyExc_TypeError, "hide() takes no arguments");
+ return NULL;
}
- return_value = _curses_panel_panel_hide_impl(self, cls);
-
-exit:
- return return_value;
+ return _curses_panel_panel_hide_impl(self, cls);
}
PyDoc_STRVAR(_curses_panel_panel_show__doc__,
@@ -77,18 +63,11 @@ _curses_panel_panel_show_impl(PyCursesPanelObject *self, PyTypeObject *cls);
static PyObject *
_curses_panel_panel_show(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
- PyObject *return_value = NULL;
- static const char * const _keywords[] = { NULL};
- static _PyArg_Parser _parser = {":show", _keywords, 0};
-
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser
- )) {
- goto exit;
+ if (nargs) {
+ PyErr_SetString(PyExc_TypeError, "show() takes no arguments");
+ return NULL;
}
- return_value = _curses_panel_panel_show_impl(self, cls);
-
-exit:
- return return_value;
+ return _curses_panel_panel_show_impl(self, cls);
}
PyDoc_STRVAR(_curses_panel_panel_top__doc__,
@@ -106,18 +85,11 @@ _curses_panel_panel_top_impl(PyCursesPanelObject *self, PyTypeObject *cls);
static PyObject *
_curses_panel_panel_top(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
- PyObject *return_value = NULL;
- static const char * const _keywords[] = { NULL};
- static _PyArg_Parser _parser = {":top", _keywords, 0};
-
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser
- )) {
- goto exit;
+ if (nargs) {
+ PyErr_SetString(PyExc_TypeError, "top() takes no arguments");
+ return NULL;
}
- return_value = _curses_panel_panel_top_impl(self, cls);
-
-exit:
- return return_value;
+ return _curses_panel_panel_top_impl(self, cls);
}
PyDoc_STRVAR(_curses_panel_panel_above__doc__,
@@ -192,12 +164,21 @@ _curses_panel_panel_move(PyCursesPanelObject *self, PyTypeObject *cls, PyObject
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"", "", NULL};
- static _PyArg_Parser _parser = {"ii:move", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "move", 0};
+ PyObject *argsbuf[2];
int y;
int x;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &y, &x)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ y = _PyLong_AsInt(args[0]);
+ if (y == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ x = _PyLong_AsInt(args[1]);
+ if (x == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _curses_panel_panel_move_impl(self, cls, y, x);
@@ -243,13 +224,19 @@ _curses_panel_panel_replace(PyCursesPanelObject *self, PyTypeObject *cls, PyObje
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"", NULL};
- static _PyArg_Parser _parser = {"O!:replace", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "replace", 0};
+ PyObject *argsbuf[1];
PyCursesWindowObject *win;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &PyCursesWindow_Type, &win)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ if (!PyObject_TypeCheck(args[0], &PyCursesWindow_Type)) {
+ _PyArg_BadArgument("replace", "argument 1", (&PyCursesWindow_Type)->tp_name, args[0]);
goto exit;
}
+ win = (PyCursesWindowObject *)args[0];
return_value = _curses_panel_panel_replace_impl(self, cls, win);
exit:
@@ -274,13 +261,15 @@ _curses_panel_panel_set_userptr(PyCursesPanelObject *self, PyTypeObject *cls, Py
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"", NULL};
- static _PyArg_Parser _parser = {"O:set_userptr", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "set_userptr", 0};
+ PyObject *argsbuf[1];
PyObject *obj;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &obj)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
+ if (!args) {
goto exit;
}
+ obj = args[0];
return_value = _curses_panel_panel_set_userptr_impl(self, cls, obj);
exit:
@@ -303,18 +292,11 @@ _curses_panel_panel_userptr_impl(PyCursesPanelObject *self,
static PyObject *
_curses_panel_panel_userptr(PyCursesPanelObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
- PyObject *return_value = NULL;
- static const char * const _keywords[] = { NULL};
- static _PyArg_Parser _parser = {":userptr", _keywords, 0};
-
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser
- )) {
- goto exit;
+ if (nargs) {
+ PyErr_SetString(PyExc_TypeError, "userptr() takes no arguments");
+ return NULL;
}
- return_value = _curses_panel_panel_userptr_impl(self, cls);
-
-exit:
- return return_value;
+ return _curses_panel_panel_userptr_impl(self, cls);
}
PyDoc_STRVAR(_curses_panel_bottom_panel__doc__,
@@ -401,4 +383,4 @@ _curses_panel_update_panels(PyObject *module, PyObject *Py_UNUSED(ignored))
{
return _curses_panel_update_panels_impl(module);
}
-/*[clinic end generated code: output=3081ef24e5560cb0 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=c552457e8067bb0a input=a9049054013a1b77]*/
diff --git a/contrib/tools/python3/src/Modules/clinic/_dbmmodule.c.h b/contrib/tools/python3/src/Modules/clinic/_dbmmodule.c.h
index af288c2586a..beb26f61202 100644
--- a/contrib/tools/python3/src/Modules/clinic/_dbmmodule.c.h
+++ b/contrib/tools/python3/src/Modules/clinic/_dbmmodule.c.h
@@ -35,18 +35,11 @@ _dbm_dbm_keys_impl(dbmobject *self, PyTypeObject *cls);
static PyObject *
_dbm_dbm_keys(dbmobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
- PyObject *return_value = NULL;
- static const char * const _keywords[] = { NULL};
- static _PyArg_Parser _parser = {":keys", _keywords, 0};
-
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser
- )) {
- goto exit;
+ if (nargs) {
+ PyErr_SetString(PyExc_TypeError, "keys() takes no arguments");
+ return NULL;
}
- return_value = _dbm_dbm_keys_impl(self, cls);
-
-exit:
- return return_value;
+ return _dbm_dbm_keys_impl(self, cls);
}
PyDoc_STRVAR(_dbm_dbm_get__doc__,
@@ -187,4 +180,4 @@ skip_optional:
exit:
return return_value;
}
-/*[clinic end generated code: output=6947b1115df66f7c input=a9049054013a1b77]*/
+/*[clinic end generated code: output=a4599b89ce338b08 input=a9049054013a1b77]*/
diff --git a/contrib/tools/python3/src/Modules/clinic/_gdbmmodule.c.h b/contrib/tools/python3/src/Modules/clinic/_gdbmmodule.c.h
index ea4ee7df001..630cb499ae1 100644
--- a/contrib/tools/python3/src/Modules/clinic/_gdbmmodule.c.h
+++ b/contrib/tools/python3/src/Modules/clinic/_gdbmmodule.c.h
@@ -104,18 +104,11 @@ _gdbm_gdbm_keys_impl(gdbmobject *self, PyTypeObject *cls);
static PyObject *
_gdbm_gdbm_keys(gdbmobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
- PyObject *return_value = NULL;
- static const char * const _keywords[] = { NULL};
- static _PyArg_Parser _parser = {":keys", _keywords, 0};
-
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser
- )) {
- goto exit;
+ if (nargs) {
+ PyErr_SetString(PyExc_TypeError, "keys() takes no arguments");
+ return NULL;
}
- return_value = _gdbm_gdbm_keys_impl(self, cls);
-
-exit:
- return return_value;
+ return _gdbm_gdbm_keys_impl(self, cls);
}
PyDoc_STRVAR(_gdbm_gdbm_firstkey__doc__,
@@ -137,18 +130,11 @@ _gdbm_gdbm_firstkey_impl(gdbmobject *self, PyTypeObject *cls);
static PyObject *
_gdbm_gdbm_firstkey(gdbmobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
- PyObject *return_value = NULL;
- static const char * const _keywords[] = { NULL};
- static _PyArg_Parser _parser = {":firstkey", _keywords, 0};
-
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser
- )) {
- goto exit;
+ if (nargs) {
+ PyErr_SetString(PyExc_TypeError, "firstkey() takes no arguments");
+ return NULL;
}
- return_value = _gdbm_gdbm_firstkey_impl(self, cls);
-
-exit:
- return return_value;
+ return _gdbm_gdbm_firstkey_impl(self, cls);
}
PyDoc_STRVAR(_gdbm_gdbm_nextkey__doc__,
@@ -212,18 +198,11 @@ _gdbm_gdbm_reorganize_impl(gdbmobject *self, PyTypeObject *cls);
static PyObject *
_gdbm_gdbm_reorganize(gdbmobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
- PyObject *return_value = NULL;
- static const char * const _keywords[] = { NULL};
- static _PyArg_Parser _parser = {":reorganize", _keywords, 0};
-
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser
- )) {
- goto exit;
+ if (nargs) {
+ PyErr_SetString(PyExc_TypeError, "reorganize() takes no arguments");
+ return NULL;
}
- return_value = _gdbm_gdbm_reorganize_impl(self, cls);
-
-exit:
- return return_value;
+ return _gdbm_gdbm_reorganize_impl(self, cls);
}
PyDoc_STRVAR(_gdbm_gdbm_sync__doc__,
@@ -244,18 +223,11 @@ _gdbm_gdbm_sync_impl(gdbmobject *self, PyTypeObject *cls);
static PyObject *
_gdbm_gdbm_sync(gdbmobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
- PyObject *return_value = NULL;
- static const char * const _keywords[] = { NULL};
- static _PyArg_Parser _parser = {":sync", _keywords, 0};
-
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser
- )) {
- goto exit;
+ if (nargs) {
+ PyErr_SetString(PyExc_TypeError, "sync() takes no arguments");
+ return NULL;
}
- return_value = _gdbm_gdbm_sync_impl(self, cls);
-
-exit:
- return return_value;
+ return _gdbm_gdbm_sync_impl(self, cls);
}
PyDoc_STRVAR(dbmopen__doc__,
@@ -340,4 +312,4 @@ skip_optional:
exit:
return return_value;
}
-/*[clinic end generated code: output=3b88446433e43d96 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=125f5bc685304744 input=a9049054013a1b77]*/
diff --git a/contrib/tools/python3/src/Modules/clinic/_lsprof.c.h b/contrib/tools/python3/src/Modules/clinic/_lsprof.c.h
index 5d9c209eab8..b0adb746974 100644
--- a/contrib/tools/python3/src/Modules/clinic/_lsprof.c.h
+++ b/contrib/tools/python3/src/Modules/clinic/_lsprof.c.h
@@ -39,17 +39,10 @@ _lsprof_Profiler_getstats_impl(ProfilerObject *self, PyTypeObject *cls);
static PyObject *
_lsprof_Profiler_getstats(ProfilerObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
- PyObject *return_value = NULL;
- static const char * const _keywords[] = { NULL};
- static _PyArg_Parser _parser = {":getstats", _keywords, 0};
-
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser
- )) {
- goto exit;
+ if (nargs) {
+ PyErr_SetString(PyExc_TypeError, "getstats() takes no arguments");
+ return NULL;
}
- return_value = _lsprof_Profiler_getstats_impl(self, cls);
-
-exit:
- return return_value;
+ return _lsprof_Profiler_getstats_impl(self, cls);
}
-/*[clinic end generated code: output=b4727cfebecdd22d input=a9049054013a1b77]*/
+/*[clinic end generated code: output=57c7b6b0b8666429 input=a9049054013a1b77]*/
diff --git a/contrib/tools/python3/src/Modules/clinic/_queuemodule.c.h b/contrib/tools/python3/src/Modules/clinic/_queuemodule.c.h
index 8741f7d9aff..29e4c60cfa7 100644
--- a/contrib/tools/python3/src/Modules/clinic/_queuemodule.c.h
+++ b/contrib/tools/python3/src/Modules/clinic/_queuemodule.c.h
@@ -144,14 +144,30 @@ _queue_SimpleQueue_get(simplequeueobject *self, PyTypeObject *cls, PyObject *con
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"block", "timeout", NULL};
- static _PyArg_Parser _parser = {"|pO:get", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "get", 0};
+ PyObject *argsbuf[2];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
int block = 1;
PyObject *timeout = Py_None;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &block, &timeout)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 2, 0, argsbuf);
+ if (!args) {
goto exit;
}
+ if (!noptargs) {
+ goto skip_optional_pos;
+ }
+ if (args[0]) {
+ block = PyObject_IsTrue(args[0]);
+ if (block < 0) {
+ goto exit;
+ }
+ if (!--noptargs) {
+ goto skip_optional_pos;
+ }
+ }
+ timeout = args[1];
+skip_optional_pos:
return_value = _queue_SimpleQueue_get_impl(self, cls, block, timeout);
exit:
@@ -177,18 +193,11 @@ _queue_SimpleQueue_get_nowait_impl(simplequeueobject *self,
static PyObject *
_queue_SimpleQueue_get_nowait(simplequeueobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
- PyObject *return_value = NULL;
- static const char * const _keywords[] = { NULL};
- static _PyArg_Parser _parser = {":get_nowait", _keywords, 0};
-
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser
- )) {
- goto exit;
+ if (nargs) {
+ PyErr_SetString(PyExc_TypeError, "get_nowait() takes no arguments");
+ return NULL;
}
- return_value = _queue_SimpleQueue_get_nowait_impl(self, cls);
-
-exit:
- return return_value;
+ return _queue_SimpleQueue_get_nowait_impl(self, cls);
}
PyDoc_STRVAR(_queue_SimpleQueue_empty__doc__,
@@ -246,4 +255,4 @@ _queue_SimpleQueue_qsize(simplequeueobject *self, PyObject *Py_UNUSED(ignored))
exit:
return return_value;
}
-/*[clinic end generated code: output=ce56b46fac150909 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=a9d567e8a64e6170 input=a9049054013a1b77]*/
diff --git a/contrib/tools/python3/src/Modules/clinic/_sre.c.h b/contrib/tools/python3/src/Modules/clinic/_sre.c.h
index 72d772c289a..d60827db24b 100644
--- a/contrib/tools/python3/src/Modules/clinic/_sre.c.h
+++ b/contrib/tools/python3/src/Modules/clinic/_sre.c.h
@@ -176,15 +176,51 @@ _sre_SRE_Pattern_match(PatternObject *self, PyTypeObject *cls, PyObject *const *
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"string", "pos", "endpos", NULL};
- static _PyArg_Parser _parser = {"O|nn:match", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "match", 0};
+ PyObject *argsbuf[3];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
PyObject *string;
Py_ssize_t pos = 0;
Py_ssize_t endpos = PY_SSIZE_T_MAX;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &string, &pos, &endpos)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf);
+ if (!args) {
goto exit;
}
+ string = args[0];
+ if (!noptargs) {
+ goto skip_optional_pos;
+ }
+ if (args[1]) {
+ {
+ Py_ssize_t ival = -1;
+ PyObject *iobj = _PyNumber_Index(args[1]);
+ if (iobj != NULL) {
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ pos = ival;
+ }
+ if (!--noptargs) {
+ goto skip_optional_pos;
+ }
+ }
+ {
+ Py_ssize_t ival = -1;
+ PyObject *iobj = _PyNumber_Index(args[2]);
+ if (iobj != NULL) {
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ endpos = ival;
+ }
+skip_optional_pos:
return_value = _sre_SRE_Pattern_match_impl(self, cls, string, pos, endpos);
exit:
@@ -210,15 +246,51 @@ _sre_SRE_Pattern_fullmatch(PatternObject *self, PyTypeObject *cls, PyObject *con
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"string", "pos", "endpos", NULL};
- static _PyArg_Parser _parser = {"O|nn:fullmatch", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "fullmatch", 0};
+ PyObject *argsbuf[3];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
PyObject *string;
Py_ssize_t pos = 0;
Py_ssize_t endpos = PY_SSIZE_T_MAX;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &string, &pos, &endpos)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf);
+ if (!args) {
goto exit;
}
+ string = args[0];
+ if (!noptargs) {
+ goto skip_optional_pos;
+ }
+ if (args[1]) {
+ {
+ Py_ssize_t ival = -1;
+ PyObject *iobj = _PyNumber_Index(args[1]);
+ if (iobj != NULL) {
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ pos = ival;
+ }
+ if (!--noptargs) {
+ goto skip_optional_pos;
+ }
+ }
+ {
+ Py_ssize_t ival = -1;
+ PyObject *iobj = _PyNumber_Index(args[2]);
+ if (iobj != NULL) {
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ endpos = ival;
+ }
+skip_optional_pos:
return_value = _sre_SRE_Pattern_fullmatch_impl(self, cls, string, pos, endpos);
exit:
@@ -246,15 +318,51 @@ _sre_SRE_Pattern_search(PatternObject *self, PyTypeObject *cls, PyObject *const
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"string", "pos", "endpos", NULL};
- static _PyArg_Parser _parser = {"O|nn:search", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "search", 0};
+ PyObject *argsbuf[3];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
PyObject *string;
Py_ssize_t pos = 0;
Py_ssize_t endpos = PY_SSIZE_T_MAX;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &string, &pos, &endpos)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf);
+ if (!args) {
goto exit;
}
+ string = args[0];
+ if (!noptargs) {
+ goto skip_optional_pos;
+ }
+ if (args[1]) {
+ {
+ Py_ssize_t ival = -1;
+ PyObject *iobj = _PyNumber_Index(args[1]);
+ if (iobj != NULL) {
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ pos = ival;
+ }
+ if (!--noptargs) {
+ goto skip_optional_pos;
+ }
+ }
+ {
+ Py_ssize_t ival = -1;
+ PyObject *iobj = _PyNumber_Index(args[2]);
+ if (iobj != NULL) {
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ endpos = ival;
+ }
+skip_optional_pos:
return_value = _sre_SRE_Pattern_search_impl(self, cls, string, pos, endpos);
exit:
@@ -351,15 +459,51 @@ _sre_SRE_Pattern_finditer(PatternObject *self, PyTypeObject *cls, PyObject *cons
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"string", "pos", "endpos", NULL};
- static _PyArg_Parser _parser = {"O|nn:finditer", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "finditer", 0};
+ PyObject *argsbuf[3];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
PyObject *string;
Py_ssize_t pos = 0;
Py_ssize_t endpos = PY_SSIZE_T_MAX;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &string, &pos, &endpos)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf);
+ if (!args) {
goto exit;
}
+ string = args[0];
+ if (!noptargs) {
+ goto skip_optional_pos;
+ }
+ if (args[1]) {
+ {
+ Py_ssize_t ival = -1;
+ PyObject *iobj = _PyNumber_Index(args[1]);
+ if (iobj != NULL) {
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ pos = ival;
+ }
+ if (!--noptargs) {
+ goto skip_optional_pos;
+ }
+ }
+ {
+ Py_ssize_t ival = -1;
+ PyObject *iobj = _PyNumber_Index(args[2]);
+ if (iobj != NULL) {
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ endpos = ival;
+ }
+skip_optional_pos:
return_value = _sre_SRE_Pattern_finditer_impl(self, cls, string, pos, endpos);
exit:
@@ -384,15 +528,51 @@ _sre_SRE_Pattern_scanner(PatternObject *self, PyTypeObject *cls, PyObject *const
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"string", "pos", "endpos", NULL};
- static _PyArg_Parser _parser = {"O|nn:scanner", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "scanner", 0};
+ PyObject *argsbuf[3];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
PyObject *string;
Py_ssize_t pos = 0;
Py_ssize_t endpos = PY_SSIZE_T_MAX;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &string, &pos, &endpos)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf);
+ if (!args) {
goto exit;
}
+ string = args[0];
+ if (!noptargs) {
+ goto skip_optional_pos;
+ }
+ if (args[1]) {
+ {
+ Py_ssize_t ival = -1;
+ PyObject *iobj = _PyNumber_Index(args[1]);
+ if (iobj != NULL) {
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ pos = ival;
+ }
+ if (!--noptargs) {
+ goto skip_optional_pos;
+ }
+ }
+ {
+ Py_ssize_t ival = -1;
+ PyObject *iobj = _PyNumber_Index(args[2]);
+ if (iobj != NULL) {
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ endpos = ival;
+ }
+skip_optional_pos:
return_value = _sre_SRE_Pattern_scanner_impl(self, cls, string, pos, endpos);
exit:
@@ -468,15 +648,35 @@ _sre_SRE_Pattern_sub(PatternObject *self, PyTypeObject *cls, PyObject *const *ar
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"repl", "string", "count", NULL};
- static _PyArg_Parser _parser = {"OO|n:sub", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "sub", 0};
+ PyObject *argsbuf[3];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2;
PyObject *repl;
PyObject *string;
Py_ssize_t count = 0;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &repl, &string, &count)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf);
+ if (!args) {
goto exit;
}
+ repl = args[0];
+ string = args[1];
+ if (!noptargs) {
+ goto skip_optional_pos;
+ }
+ {
+ Py_ssize_t ival = -1;
+ PyObject *iobj = _PyNumber_Index(args[2]);
+ if (iobj != NULL) {
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ count = ival;
+ }
+skip_optional_pos:
return_value = _sre_SRE_Pattern_sub_impl(self, cls, repl, string, count);
exit:
@@ -502,15 +702,35 @@ _sre_SRE_Pattern_subn(PatternObject *self, PyTypeObject *cls, PyObject *const *a
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"repl", "string", "count", NULL};
- static _PyArg_Parser _parser = {"OO|n:subn", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "subn", 0};
+ PyObject *argsbuf[3];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2;
PyObject *repl;
PyObject *string;
Py_ssize_t count = 0;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &repl, &string, &count)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf);
+ if (!args) {
goto exit;
}
+ repl = args[0];
+ string = args[1];
+ if (!noptargs) {
+ goto skip_optional_pos;
+ }
+ {
+ Py_ssize_t ival = -1;
+ PyObject *iobj = _PyNumber_Index(args[2]);
+ if (iobj != NULL) {
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ count = ival;
+ }
+skip_optional_pos:
return_value = _sre_SRE_Pattern_subn_impl(self, cls, repl, string, count);
exit:
@@ -869,18 +1089,11 @@ _sre_SRE_Scanner_match_impl(ScannerObject *self, PyTypeObject *cls);
static PyObject *
_sre_SRE_Scanner_match(ScannerObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
- PyObject *return_value = NULL;
- static const char * const _keywords[] = { NULL};
- static _PyArg_Parser _parser = {":match", _keywords, 0};
-
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser
- )) {
- goto exit;
+ if (nargs) {
+ PyErr_SetString(PyExc_TypeError, "match() takes no arguments");
+ return NULL;
}
- return_value = _sre_SRE_Scanner_match_impl(self, cls);
-
-exit:
- return return_value;
+ return _sre_SRE_Scanner_match_impl(self, cls);
}
PyDoc_STRVAR(_sre_SRE_Scanner_search__doc__,
@@ -897,17 +1110,10 @@ _sre_SRE_Scanner_search_impl(ScannerObject *self, PyTypeObject *cls);
static PyObject *
_sre_SRE_Scanner_search(ScannerObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
- PyObject *return_value = NULL;
- static const char * const _keywords[] = { NULL};
- static _PyArg_Parser _parser = {":search", _keywords, 0};
-
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser
- )) {
- goto exit;
+ if (nargs) {
+ PyErr_SetString(PyExc_TypeError, "search() takes no arguments");
+ return NULL;
}
- return_value = _sre_SRE_Scanner_search_impl(self, cls);
-
-exit:
- return return_value;
+ return _sre_SRE_Scanner_search_impl(self, cls);
}
-/*[clinic end generated code: output=518f7bb775c1184f input=a9049054013a1b77]*/
+/*[clinic end generated code: output=ead5eb818b7771f8 input=a9049054013a1b77]*/
diff --git a/contrib/tools/python3/src/Modules/clinic/arraymodule.c.h b/contrib/tools/python3/src/Modules/clinic/arraymodule.c.h
index c46cc738de9..ce98e411f0f 100644
--- a/contrib/tools/python3/src/Modules/clinic/arraymodule.c.h
+++ b/contrib/tools/python3/src/Modules/clinic/arraymodule.c.h
@@ -155,13 +155,15 @@ array_array_extend(arrayobject *self, PyTypeObject *cls, PyObject *const *args,
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"", NULL};
- static _PyArg_Parser _parser = {"O:extend", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "extend", 0};
+ PyObject *argsbuf[1];
PyObject *bb;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &bb)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
+ if (!args) {
goto exit;
}
+ bb = args[0];
return_value = array_array_extend_impl(self, cls, bb);
exit:
@@ -572,4 +574,4 @@ PyDoc_STRVAR(array_arrayiterator___setstate____doc__,
#define ARRAY_ARRAYITERATOR___SETSTATE___METHODDEF \
{"__setstate__", (PyCFunction)array_arrayiterator___setstate__, METH_O, array_arrayiterator___setstate____doc__},
-/*[clinic end generated code: output=f130a994f98f1227 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=eb727e087d64f017 input=a9049054013a1b77]*/
diff --git a/contrib/tools/python3/src/Modules/clinic/md5module.c.h b/contrib/tools/python3/src/Modules/clinic/md5module.c.h
index 4762f2800d4..0ff09b0050a 100644
--- a/contrib/tools/python3/src/Modules/clinic/md5module.c.h
+++ b/contrib/tools/python3/src/Modules/clinic/md5module.c.h
@@ -17,18 +17,11 @@ MD5Type_copy_impl(MD5object *self, PyTypeObject *cls);
static PyObject *
MD5Type_copy(MD5object *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
- PyObject *return_value = NULL;
- static const char * const _keywords[] = { NULL};
- static _PyArg_Parser _parser = {":copy", _keywords, 0};
-
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser
- )) {
- goto exit;
+ if (nargs) {
+ PyErr_SetString(PyExc_TypeError, "copy() takes no arguments");
+ return NULL;
}
- return_value = MD5Type_copy_impl(self, cls);
-
-exit:
- return return_value;
+ return MD5Type_copy_impl(self, cls);
}
PyDoc_STRVAR(MD5Type_digest__doc__,
@@ -126,4 +119,4 @@ skip_optional_kwonly:
exit:
return return_value;
}
-/*[clinic end generated code: output=53ff7f22dbaaea36 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=3061297a669c645c input=a9049054013a1b77]*/
diff --git a/contrib/tools/python3/src/Modules/clinic/posixmodule.c.h b/contrib/tools/python3/src/Modules/clinic/posixmodule.c.h
index 7921c222b90..742acb8e6c0 100644
--- a/contrib/tools/python3/src/Modules/clinic/posixmodule.c.h
+++ b/contrib/tools/python3/src/Modules/clinic/posixmodule.c.h
@@ -8254,12 +8254,10 @@ static PyObject *
os_DirEntry_is_symlink(DirEntry *self, PyTypeObject *defining_class, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
- static const char * const _keywords[] = { NULL};
- static _PyArg_Parser _parser = {":is_symlink", _keywords, 0};
int _return_value;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser
- )) {
+ if (nargs) {
+ PyErr_SetString(PyExc_TypeError, "is_symlink() takes no arguments");
goto exit;
}
_return_value = os_DirEntry_is_symlink_impl(self, defining_class);
@@ -8290,13 +8288,23 @@ os_DirEntry_stat(DirEntry *self, PyTypeObject *defining_class, PyObject *const *
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"follow_symlinks", NULL};
- static _PyArg_Parser _parser = {"|$p:stat", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "stat", 0};
+ PyObject *argsbuf[1];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
int follow_symlinks = 1;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &follow_symlinks)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf);
+ if (!args) {
goto exit;
}
+ if (!noptargs) {
+ goto skip_optional_kwonly;
+ }
+ follow_symlinks = PyObject_IsTrue(args[0]);
+ if (follow_symlinks < 0) {
+ goto exit;
+ }
+skip_optional_kwonly:
return_value = os_DirEntry_stat_impl(self, defining_class, follow_symlinks);
exit:
@@ -8321,14 +8329,24 @@ os_DirEntry_is_dir(DirEntry *self, PyTypeObject *defining_class, PyObject *const
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"follow_symlinks", NULL};
- static _PyArg_Parser _parser = {"|$p:is_dir", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "is_dir", 0};
+ PyObject *argsbuf[1];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
int follow_symlinks = 1;
int _return_value;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &follow_symlinks)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf);
+ if (!args) {
goto exit;
}
+ if (!noptargs) {
+ goto skip_optional_kwonly;
+ }
+ follow_symlinks = PyObject_IsTrue(args[0]);
+ if (follow_symlinks < 0) {
+ goto exit;
+ }
+skip_optional_kwonly:
_return_value = os_DirEntry_is_dir_impl(self, defining_class, follow_symlinks);
if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
@@ -8357,14 +8375,24 @@ os_DirEntry_is_file(DirEntry *self, PyTypeObject *defining_class, PyObject *cons
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"follow_symlinks", NULL};
- static _PyArg_Parser _parser = {"|$p:is_file", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "is_file", 0};
+ PyObject *argsbuf[1];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
int follow_symlinks = 1;
int _return_value;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &follow_symlinks)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf);
+ if (!args) {
goto exit;
}
+ if (!noptargs) {
+ goto skip_optional_kwonly;
+ }
+ follow_symlinks = PyObject_IsTrue(args[0]);
+ if (follow_symlinks < 0) {
+ goto exit;
+ }
+skip_optional_kwonly:
_return_value = os_DirEntry_is_file_impl(self, defining_class, follow_symlinks);
if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
@@ -9263,4 +9291,4 @@ exit:
#ifndef OS_WAITSTATUS_TO_EXITCODE_METHODDEF
#define OS_WAITSTATUS_TO_EXITCODE_METHODDEF
#endif /* !defined(OS_WAITSTATUS_TO_EXITCODE_METHODDEF) */
-/*[clinic end generated code: output=65a85d7d3f2c487e input=a9049054013a1b77]*/
+/*[clinic end generated code: output=debefcf43738ec66 input=a9049054013a1b77]*/
diff --git a/contrib/tools/python3/src/Modules/clinic/pyexpat.c.h b/contrib/tools/python3/src/Modules/clinic/pyexpat.c.h
index 7c56d6a8b25..bee2ee66950 100644
--- a/contrib/tools/python3/src/Modules/clinic/pyexpat.c.h
+++ b/contrib/tools/python3/src/Modules/clinic/pyexpat.c.h
@@ -22,14 +22,24 @@ pyexpat_xmlparser_Parse(xmlparseobject *self, PyTypeObject *cls, PyObject *const
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"", "", NULL};
- static _PyArg_Parser _parser = {"O|i:Parse", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "Parse", 0};
+ PyObject *argsbuf[2];
PyObject *data;
int isfinal = 0;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &data, &isfinal)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ data = args[0];
+ if (nargs < 2) {
+ goto skip_optional_posonly;
+ }
+ isfinal = _PyLong_AsInt(args[1]);
+ if (isfinal == -1 && PyErr_Occurred()) {
goto exit;
}
+skip_optional_posonly:
return_value = pyexpat_xmlparser_Parse_impl(self, cls, data, isfinal);
exit:
@@ -54,13 +64,15 @@ pyexpat_xmlparser_ParseFile(xmlparseobject *self, PyTypeObject *cls, PyObject *c
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"", NULL};
- static _PyArg_Parser _parser = {"O:ParseFile", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "ParseFile", 0};
+ PyObject *argsbuf[1];
PyObject *file;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &file)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
+ if (!args) {
goto exit;
}
+ file = args[0];
return_value = pyexpat_xmlparser_ParseFile_impl(self, cls, file);
exit:
@@ -164,14 +176,50 @@ pyexpat_xmlparser_ExternalEntityParserCreate(xmlparseobject *self, PyTypeObject
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"", "", NULL};
- static _PyArg_Parser _parser = {"z|s:ExternalEntityParserCreate", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "ExternalEntityParserCreate", 0};
+ PyObject *argsbuf[2];
const char *context;
const char *encoding = NULL;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &context, &encoding)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ if (args[0] == Py_None) {
+ context = NULL;
+ }
+ else if (PyUnicode_Check(args[0])) {
+ Py_ssize_t context_length;
+ context = PyUnicode_AsUTF8AndSize(args[0], &context_length);
+ if (context == NULL) {
+ goto exit;
+ }
+ if (strlen(context) != (size_t)context_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ }
+ else {
+ _PyArg_BadArgument("ExternalEntityParserCreate", "argument 1", "str or None", args[0]);
+ goto exit;
+ }
+ if (nargs < 2) {
+ goto skip_optional_posonly;
+ }
+ if (!PyUnicode_Check(args[1])) {
+ _PyArg_BadArgument("ExternalEntityParserCreate", "argument 2", "str", args[1]);
goto exit;
}
+ Py_ssize_t encoding_length;
+ encoding = PyUnicode_AsUTF8AndSize(args[1], &encoding_length);
+ if (encoding == NULL) {
+ goto exit;
+ }
+ if (strlen(encoding) != (size_t)encoding_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+skip_optional_posonly:
return_value = pyexpat_xmlparser_ExternalEntityParserCreate_impl(self, cls, context, encoding);
exit:
@@ -235,13 +283,22 @@ pyexpat_xmlparser_UseForeignDTD(xmlparseobject *self, PyTypeObject *cls, PyObjec
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"", NULL};
- static _PyArg_Parser _parser = {"|p:UseForeignDTD", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "UseForeignDTD", 0};
+ PyObject *argsbuf[1];
int flag = 1;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &flag)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ if (nargs < 1) {
+ goto skip_optional_posonly;
+ }
+ flag = PyObject_IsTrue(args[0]);
+ if (flag < 0) {
goto exit;
}
+skip_optional_posonly:
return_value = pyexpat_xmlparser_UseForeignDTD_impl(self, cls, flag);
exit:
@@ -368,4 +425,4 @@ exit:
#ifndef PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
#define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
#endif /* !defined(PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF) */
-/*[clinic end generated code: output=612b9d6a17a679a7 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=5d60049d385d5d56 input=a9049054013a1b77]*/
diff --git a/contrib/tools/python3/src/Modules/clinic/sha1module.c.h b/contrib/tools/python3/src/Modules/clinic/sha1module.c.h
index 3a3ab58c123..d9a2e150f6d 100644
--- a/contrib/tools/python3/src/Modules/clinic/sha1module.c.h
+++ b/contrib/tools/python3/src/Modules/clinic/sha1module.c.h
@@ -17,18 +17,11 @@ SHA1Type_copy_impl(SHA1object *self, PyTypeObject *cls);
static PyObject *
SHA1Type_copy(SHA1object *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
- PyObject *return_value = NULL;
- static const char * const _keywords[] = { NULL};
- static _PyArg_Parser _parser = {":copy", _keywords, 0};
-
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser
- )) {
- goto exit;
+ if (nargs) {
+ PyErr_SetString(PyExc_TypeError, "copy() takes no arguments");
+ return NULL;
}
- return_value = SHA1Type_copy_impl(self, cls);
-
-exit:
- return return_value;
+ return SHA1Type_copy_impl(self, cls);
}
PyDoc_STRVAR(SHA1Type_digest__doc__,
@@ -126,4 +119,4 @@ skip_optional_kwonly:
exit:
return return_value;
}
-/*[clinic end generated code: output=abf1ab2545cea5a2 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=93ced3c8f8fa4f21 input=a9049054013a1b77]*/
diff --git a/contrib/tools/python3/src/Modules/clinic/sha256module.c.h b/contrib/tools/python3/src/Modules/clinic/sha256module.c.h
index 89205c4f14f..619fab1a6fe 100644
--- a/contrib/tools/python3/src/Modules/clinic/sha256module.c.h
+++ b/contrib/tools/python3/src/Modules/clinic/sha256module.c.h
@@ -17,18 +17,11 @@ SHA256Type_copy_impl(SHAobject *self, PyTypeObject *cls);
static PyObject *
SHA256Type_copy(SHAobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
- PyObject *return_value = NULL;
- static const char * const _keywords[] = { NULL};
- static _PyArg_Parser _parser = {":copy", _keywords, 0};
-
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser
- )) {
- goto exit;
+ if (nargs) {
+ PyErr_SetString(PyExc_TypeError, "copy() takes no arguments");
+ return NULL;
}
- return_value = SHA256Type_copy_impl(self, cls);
-
-exit:
- return return_value;
+ return SHA256Type_copy_impl(self, cls);
}
PyDoc_STRVAR(SHA256Type_digest__doc__,
@@ -177,4 +170,4 @@ skip_optional_kwonly:
exit:
return return_value;
}
-/*[clinic end generated code: output=b7283f75c9d08f30 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=4f9fe3ca546b0c58 input=a9049054013a1b77]*/
diff --git a/contrib/tools/python3/src/Modules/clinic/sha512module.c.h b/contrib/tools/python3/src/Modules/clinic/sha512module.c.h
index f1192d74f9a..fada35eff22 100644
--- a/contrib/tools/python3/src/Modules/clinic/sha512module.c.h
+++ b/contrib/tools/python3/src/Modules/clinic/sha512module.c.h
@@ -17,18 +17,11 @@ SHA512Type_copy_impl(SHAobject *self, PyTypeObject *cls);
static PyObject *
SHA512Type_copy(SHAobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
- PyObject *return_value = NULL;
- static const char * const _keywords[] = { NULL};
- static _PyArg_Parser _parser = {":copy", _keywords, 0};
-
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser
- )) {
- goto exit;
+ if (nargs) {
+ PyErr_SetString(PyExc_TypeError, "copy() takes no arguments");
+ return NULL;
}
- return_value = SHA512Type_copy_impl(self, cls);
-
-exit:
- return return_value;
+ return SHA512Type_copy_impl(self, cls);
}
PyDoc_STRVAR(SHA512Type_digest__doc__,
@@ -177,4 +170,4 @@ skip_optional_kwonly:
exit:
return return_value;
}
-/*[clinic end generated code: output=9ff9f11937fabf35 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=26d2fe27b9673ac2 input=a9049054013a1b77]*/
diff --git a/contrib/tools/python3/src/Modules/clinic/zlibmodule.c.h b/contrib/tools/python3/src/Modules/clinic/zlibmodule.c.h
index 14e955db64e..43948398590 100644
--- a/contrib/tools/python3/src/Modules/clinic/zlibmodule.c.h
+++ b/contrib/tools/python3/src/Modules/clinic/zlibmodule.c.h
@@ -340,11 +340,19 @@ zlib_Compress_compress(compobject *self, PyTypeObject *cls, PyObject *const *arg
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"", NULL};
- static _PyArg_Parser _parser = {"y*:compress", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "compress", 0};
+ PyObject *argsbuf[1];
Py_buffer data = {NULL, NULL};
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &data)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
+ goto exit;
+ }
+ if (!PyBuffer_IsContiguous(&data, 'C')) {
+ _PyArg_BadArgument("compress", "argument 1", "contiguous buffer", args[0]);
goto exit;
}
return_value = zlib_Compress_compress_impl(self, cls, &data);
@@ -387,14 +395,39 @@ zlib_Decompress_decompress(compobject *self, PyTypeObject *cls, PyObject *const
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"", "max_length", NULL};
- static _PyArg_Parser _parser = {"y*|n:decompress", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "decompress", 0};
+ PyObject *argsbuf[2];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
Py_buffer data = {NULL, NULL};
Py_ssize_t max_length = 0;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &data, &max_length)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
goto exit;
}
+ if (!PyBuffer_IsContiguous(&data, 'C')) {
+ _PyArg_BadArgument("decompress", "argument 1", "contiguous buffer", args[0]);
+ goto exit;
+ }
+ if (!noptargs) {
+ goto skip_optional_pos;
+ }
+ {
+ Py_ssize_t ival = -1;
+ PyObject *iobj = _PyNumber_Index(args[1]);
+ if (iobj != NULL) {
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ max_length = ival;
+ }
+skip_optional_pos:
return_value = zlib_Decompress_decompress_impl(self, cls, &data, max_length);
exit:
@@ -429,13 +462,22 @@ zlib_Compress_flush(compobject *self, PyTypeObject *cls, PyObject *const *args,
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"", NULL};
- static _PyArg_Parser _parser = {"|i:flush", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "flush", 0};
+ PyObject *argsbuf[1];
int mode = Z_FINISH;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &mode)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ if (nargs < 1) {
+ goto skip_optional_posonly;
+ }
+ mode = _PyLong_AsInt(args[0]);
+ if (mode == -1 && PyErr_Occurred()) {
goto exit;
}
+skip_optional_posonly:
return_value = zlib_Compress_flush_impl(self, cls, mode);
exit:
@@ -459,18 +501,11 @@ zlib_Compress_copy_impl(compobject *self, PyTypeObject *cls);
static PyObject *
zlib_Compress_copy(compobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
- PyObject *return_value = NULL;
- static const char * const _keywords[] = { NULL};
- static _PyArg_Parser _parser = {":copy", _keywords, 0};
-
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser
- )) {
- goto exit;
+ if (nargs) {
+ PyErr_SetString(PyExc_TypeError, "copy() takes no arguments");
+ return NULL;
}
- return_value = zlib_Compress_copy_impl(self, cls);
-
-exit:
- return return_value;
+ return zlib_Compress_copy_impl(self, cls);
}
#endif /* defined(HAVE_ZLIB_COPY) */
@@ -491,18 +526,11 @@ zlib_Compress___copy___impl(compobject *self, PyTypeObject *cls);
static PyObject *
zlib_Compress___copy__(compobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
- PyObject *return_value = NULL;
- static const char * const _keywords[] = { NULL};
- static _PyArg_Parser _parser = {":__copy__", _keywords, 0};
-
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser
- )) {
- goto exit;
+ if (nargs) {
+ PyErr_SetString(PyExc_TypeError, "__copy__() takes no arguments");
+ return NULL;
}
- return_value = zlib_Compress___copy___impl(self, cls);
-
-exit:
- return return_value;
+ return zlib_Compress___copy___impl(self, cls);
}
#endif /* defined(HAVE_ZLIB_COPY) */
@@ -526,13 +554,15 @@ zlib_Compress___deepcopy__(compobject *self, PyTypeObject *cls, PyObject *const
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"", NULL};
- static _PyArg_Parser _parser = {"O:__deepcopy__", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "__deepcopy__", 0};
+ PyObject *argsbuf[1];
PyObject *memo;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &memo)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
+ if (!args) {
goto exit;
}
+ memo = args[0];
return_value = zlib_Compress___deepcopy___impl(self, cls, memo);
exit:
@@ -558,18 +588,11 @@ zlib_Decompress_copy_impl(compobject *self, PyTypeObject *cls);
static PyObject *
zlib_Decompress_copy(compobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
- PyObject *return_value = NULL;
- static const char * const _keywords[] = { NULL};
- static _PyArg_Parser _parser = {":copy", _keywords, 0};
-
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser
- )) {
- goto exit;
+ if (nargs) {
+ PyErr_SetString(PyExc_TypeError, "copy() takes no arguments");
+ return NULL;
}
- return_value = zlib_Decompress_copy_impl(self, cls);
-
-exit:
- return return_value;
+ return zlib_Decompress_copy_impl(self, cls);
}
#endif /* defined(HAVE_ZLIB_COPY) */
@@ -590,18 +613,11 @@ zlib_Decompress___copy___impl(compobject *self, PyTypeObject *cls);
static PyObject *
zlib_Decompress___copy__(compobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
- PyObject *return_value = NULL;
- static const char * const _keywords[] = { NULL};
- static _PyArg_Parser _parser = {":__copy__", _keywords, 0};
-
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser
- )) {
- goto exit;
+ if (nargs) {
+ PyErr_SetString(PyExc_TypeError, "__copy__() takes no arguments");
+ return NULL;
}
- return_value = zlib_Decompress___copy___impl(self, cls);
-
-exit:
- return return_value;
+ return zlib_Decompress___copy___impl(self, cls);
}
#endif /* defined(HAVE_ZLIB_COPY) */
@@ -625,13 +641,15 @@ zlib_Decompress___deepcopy__(compobject *self, PyTypeObject *cls, PyObject *cons
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"", NULL};
- static _PyArg_Parser _parser = {"O:__deepcopy__", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "__deepcopy__", 0};
+ PyObject *argsbuf[1];
PyObject *memo;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &memo)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
+ if (!args) {
goto exit;
}
+ memo = args[0];
return_value = zlib_Decompress___deepcopy___impl(self, cls, memo);
exit:
@@ -661,13 +679,30 @@ zlib_Decompress_flush(compobject *self, PyTypeObject *cls, PyObject *const *args
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"", NULL};
- static _PyArg_Parser _parser = {"|n:flush", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "flush", 0};
+ PyObject *argsbuf[1];
Py_ssize_t length = DEF_BUF_SIZE;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &length)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
+ if (!args) {
goto exit;
}
+ if (nargs < 1) {
+ goto skip_optional_posonly;
+ }
+ {
+ Py_ssize_t ival = -1;
+ PyObject *iobj = _PyNumber_Index(args[0]);
+ if (iobj != NULL) {
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ length = ival;
+ }
+skip_optional_posonly:
return_value = zlib_Decompress_flush_impl(self, cls, length);
exit:
@@ -803,4 +838,4 @@ exit:
#ifndef ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF
#define ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF
#endif /* !defined(ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF) */
-/*[clinic end generated code: output=6736bae59fab268b input=a9049054013a1b77]*/
+/*[clinic end generated code: output=1bda0d996fb51269 input=a9049054013a1b77]*/
diff --git a/contrib/tools/python3/src/Modules/gcmodule.c b/contrib/tools/python3/src/Modules/gcmodule.c
index 805a159d53d..43ae6fa98be 100644
--- a/contrib/tools/python3/src/Modules/gcmodule.c
+++ b/contrib/tools/python3/src/Modules/gcmodule.c
@@ -2170,6 +2170,12 @@ gc_fini_untrack(PyGC_Head *list)
for (gc = GC_NEXT(list); gc != list; gc = GC_NEXT(list)) {
PyObject *op = FROM_GC(gc);
_PyObject_GC_UNTRACK(op);
+ // gh-92036: If a deallocator function expect the object to be tracked
+ // by the GC (ex: func_dealloc()), it can crash if called on an object
+ // which is no longer tracked by the GC. Leak one strong reference on
+ // purpose so the object is never deleted and its deallocator is not
+ // called.
+ Py_INCREF(op);
}
}
diff --git a/contrib/tools/python3/src/Modules/posixmodule.c b/contrib/tools/python3/src/Modules/posixmodule.c
index 7b1b2cd2524..b39dcfdef98 100644
--- a/contrib/tools/python3/src/Modules/posixmodule.c
+++ b/contrib/tools/python3/src/Modules/posixmodule.c
@@ -1907,7 +1907,17 @@ win32_xstat_impl(const wchar_t *path, struct _Py_stat_struct *result,
/* Try reading the parent directory. */
if (!attributes_from_dir(path, &fileInfo, &tagInfo.ReparseTag)) {
/* Cannot read the parent directory. */
- SetLastError(error);
+ switch (GetLastError()) {
+ case ERROR_FILE_NOT_FOUND: /* File cannot be found */
+ case ERROR_PATH_NOT_FOUND: /* File parent directory cannot be found */
+ case ERROR_NOT_READY: /* Drive exists but unavailable */
+ case ERROR_BAD_NET_NAME: /* Remote drive unavailable */
+ break;
+ /* Restore the error from CreateFileW(). */
+ default:
+ SetLastError(error);
+ }
+
return -1;
}
if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
diff --git a/contrib/tools/python3/src/Modules/socketmodule.c b/contrib/tools/python3/src/Modules/socketmodule.c
index e1b8b13d883..32a11464834 100644
--- a/contrib/tools/python3/src/Modules/socketmodule.c
+++ b/contrib/tools/python3/src/Modules/socketmodule.c
@@ -1687,6 +1687,8 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
"AF_UNIX path too long");
goto unix_out;
}
+
+ *len_ret = path.len + offsetof(struct sockaddr_un, sun_path);
}
else
#endif /* linux */
@@ -1698,10 +1700,13 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
goto unix_out;
}
addr->sun_path[path.len] = 0;
+
+ /* including the tailing NUL */
+ *len_ret = path.len + offsetof(struct sockaddr_un, sun_path) + 1;
}
addr->sun_family = s->sock_family;
memcpy(addr->sun_path, path.buf, path.len);
- *len_ret = path.len + offsetof(struct sockaddr_un, sun_path);
+
retval = 1;
unix_out:
PyBuffer_Release(&path);
diff --git a/contrib/tools/python3/src/Objects/clinic/unicodeobject.c.h b/contrib/tools/python3/src/Objects/clinic/unicodeobject.c.h
index 9ef8ce2e353..803b5f2353f 100644
--- a/contrib/tools/python3/src/Objects/clinic/unicodeobject.c.h
+++ b/contrib/tools/python3/src/Objects/clinic/unicodeobject.c.h
@@ -858,15 +858,21 @@ PyDoc_STRVAR(unicode_split__doc__,
"split($self, /, sep=None, maxsplit=-1)\n"
"--\n"
"\n"
-"Return a list of the words in the string, using sep as the delimiter string.\n"
+"Return a list of the substrings in the string, using sep as the separator string.\n"
"\n"
" sep\n"
-" The delimiter according which to split the string.\n"
-" None (the default value) means split according to any whitespace,\n"
-" and discard empty strings from the result.\n"
+" The separator used to split the string.\n"
+"\n"
+" When set to None (the default value), will split on any whitespace\n"
+" character (including \\\\n \\\\r \\\\t \\\\f and spaces) and will discard\n"
+" empty strings from the result.\n"
" maxsplit\n"
-" Maximum number of splits to do.\n"
-" -1 (the default value) means no limit.");
+" Maximum number of splits (starting from the left).\n"
+" -1 (the default value) means no limit.\n"
+"\n"
+"Note, str.split() is mainly useful for data that has been intentionally\n"
+"delimited. With natural text that includes punctuation, consider using\n"
+"the regular expression module.");
#define UNICODE_SPLIT_METHODDEF \
{"split", (PyCFunction)(void(*)(void))unicode_split, METH_FASTCALL|METH_KEYWORDS, unicode_split__doc__},
@@ -953,17 +959,19 @@ PyDoc_STRVAR(unicode_rsplit__doc__,
"rsplit($self, /, sep=None, maxsplit=-1)\n"
"--\n"
"\n"
-"Return a list of the words in the string, using sep as the delimiter string.\n"
+"Return a list of the substrings in the string, using sep as the separator string.\n"
"\n"
" sep\n"
-" The delimiter according which to split the string.\n"
-" None (the default value) means split according to any whitespace,\n"
-" and discard empty strings from the result.\n"
+" The separator used to split the string.\n"
+"\n"
+" When set to None (the default value), will split on any whitespace\n"
+" character (including \\\\n \\\\r \\\\t \\\\f and spaces) and will discard\n"
+" empty strings from the result.\n"
" maxsplit\n"
-" Maximum number of splits to do.\n"
+" Maximum number of splits (starting from the left).\n"
" -1 (the default value) means no limit.\n"
"\n"
-"Splits are done starting at the end of the string and working to the front.");
+"Splitting starts at the end of the string and works to the front.");
#define UNICODE_RSPLIT_METHODDEF \
{"rsplit", (PyCFunction)(void(*)(void))unicode_rsplit, METH_FASTCALL|METH_KEYWORDS, unicode_rsplit__doc__},
@@ -1327,4 +1335,4 @@ skip_optional_pos:
exit:
return return_value;
}
-/*[clinic end generated code: output=f10cf85d3935b3b7 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=c494bed46209961d input=a9049054013a1b77]*/
diff --git a/contrib/tools/python3/src/Objects/exceptions.c b/contrib/tools/python3/src/Objects/exceptions.c
index 6537a7ccd1e..9639b4436a0 100644
--- a/contrib/tools/python3/src/Objects/exceptions.c
+++ b/contrib/tools/python3/src/Objects/exceptions.c
@@ -847,14 +847,7 @@ oserror_parse_args(PyObject **p_args,
winerrcode = PyLong_AsLong(*winerror);
if (winerrcode == -1 && PyErr_Occurred())
return -1;
- /* Set errno to the corresponding POSIX errno (overriding
- first argument). Windows Socket error codes (>= 10000)
- have the same value as their POSIX counterparts.
- */
- if (winerrcode < 10000)
- errcode = winerror_to_errno(winerrcode);
- else
- errcode = winerrcode;
+ errcode = winerror_to_errno(winerrcode);
*myerrno = PyLong_FromLong(errcode);
if (!*myerrno)
return -1;
diff --git a/contrib/tools/python3/src/Objects/floatobject.c b/contrib/tools/python3/src/Objects/floatobject.c
index 2e02f37f4a5..5af26787731 100644
--- a/contrib/tools/python3/src/Objects/floatobject.c
+++ b/contrib/tools/python3/src/Objects/floatobject.c
@@ -64,7 +64,7 @@ static PyStructSequence_Field floatinfo_fields[] = {
{"min_exp", "DBL_MIN_EXP -- minimum int e such that radix**(e-1) "
"is a normalized float"},
{"min_10_exp", "DBL_MIN_10_EXP -- minimum int e such that 10**e is "
- "a normalized"},
+ "a normalized float"},
{"dig", "DBL_DIG -- maximum number of decimal digits that "
"can be faithfully represented in a float"},
{"mant_dig", "DBL_MANT_DIG -- mantissa digits"},
diff --git a/contrib/tools/python3/src/Objects/frameobject.c b/contrib/tools/python3/src/Objects/frameobject.c
index d02cf9d3ba9..be84d33bf52 100644
--- a/contrib/tools/python3/src/Objects/frameobject.c
+++ b/contrib/tools/python3/src/Objects/frameobject.c
@@ -195,7 +195,10 @@ markblocks(PyCodeObject *code_obj, int len)
break;
case GET_ITER:
case GET_AITER:
- block_stack = push_block(block_stack, Loop);
+ // For-loops get a Loop block, but comprehensions do not.
+ if (_Py_OPCODE(code[i + 1]) != CALL_FUNCTION) {
+ block_stack = push_block(block_stack, Loop);
+ }
blocks[i+1] = block_stack;
break;
case FOR_ITER:
diff --git a/contrib/tools/python3/src/Objects/genericaliasobject.c b/contrib/tools/python3/src/Objects/genericaliasobject.c
index dbe5d89b739..f52bc974f4d 100644
--- a/contrib/tools/python3/src/Objects/genericaliasobject.c
+++ b/contrib/tools/python3/src/Objects/genericaliasobject.c
@@ -349,6 +349,11 @@ _Py_subs_parameters(PyObject *self, PyObject *args, PyObject *parameters, PyObje
return newargs;
}
+PyDoc_STRVAR(genericalias__doc__,
+"Represent a PEP 585 generic type\n"
+"\n"
+"E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).");
+
static PyObject *
ga_getitem(PyObject *self, PyObject *item)
{
@@ -628,14 +633,11 @@ static PyNumberMethods ga_as_number = {
// TODO:
// - argument clinic?
-// - __doc__?
// - cache?
PyTypeObject Py_GenericAliasType = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
.tp_name = "types.GenericAlias",
- .tp_doc = "Represent a PEP 585 generic type\n"
- "\n"
- "E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).",
+ .tp_doc = genericalias__doc__,
.tp_basicsize = sizeof(gaobject),
.tp_dealloc = ga_dealloc,
.tp_repr = ga_repr,
diff --git a/contrib/tools/python3/src/Objects/genobject.c b/contrib/tools/python3/src/Objects/genobject.c
index 33fc4a59249..123c17aae7e 100644
--- a/contrib/tools/python3/src/Objects/genobject.c
+++ b/contrib/tools/python3/src/Objects/genobject.c
@@ -403,8 +403,11 @@ gen_close(PyGenObject *gen, PyObject *args)
PyDoc_STRVAR(throw_doc,
-"throw(typ[,val[,tb]]) -> raise exception in generator,\n\
-return next yielded value or raise StopIteration.");
+"throw(value)\n\
+throw(type[,value[,tb]])\n\
+\n\
+Raise exception in generator, return next yielded value or raise\n\
+StopIteration.");
static PyObject *
_gen_throw(PyGenObject *gen, int close_on_genexit,
@@ -1001,8 +1004,11 @@ PyDoc_STRVAR(coro_send_doc,
return next iterated value or raise StopIteration.");
PyDoc_STRVAR(coro_throw_doc,
-"throw(typ[,val[,tb]]) -> raise exception in coroutine,\n\
-return next iterated value or raise StopIteration.");
+"throw(value)\n\
+throw(type[,value[,traceback]])\n\
+\n\
+Raise exception in coroutine, return next iterated value or raise\n\
+StopIteration.");
PyDoc_STRVAR(coro_close_doc,
"close() -> raise GeneratorExit inside coroutine.");
diff --git a/contrib/tools/python3/src/Objects/listobject.c b/contrib/tools/python3/src/Objects/listobject.c
index 533ee7436d3..7f37b738605 100644
--- a/contrib/tools/python3/src/Objects/listobject.c
+++ b/contrib/tools/python3/src/Objects/listobject.c
@@ -863,7 +863,6 @@ list_extend(PyListObject *self, PyObject *iterable)
PyObject *it; /* iter(v) */
Py_ssize_t m; /* size of self */
Py_ssize_t n; /* guess for size of iterable */
- Py_ssize_t mn; /* m + n */
Py_ssize_t i;
PyObject *(*iternext)(PyObject *);
@@ -887,7 +886,13 @@ list_extend(PyListObject *self, PyObject *iterable)
/* It should not be possible to allocate a list large enough to cause
an overflow on any relevant platform */
assert(m < PY_SSIZE_T_MAX - n);
- if (list_resize(self, m + n) < 0) {
+ if (self->ob_item == NULL) {
+ if (list_preallocate_exact(self, n) < 0) {
+ return NULL;
+ }
+ Py_SET_SIZE(self, n);
+ }
+ else if (list_resize(self, m + n) < 0) {
Py_DECREF(iterable);
return NULL;
}
@@ -926,10 +931,13 @@ list_extend(PyListObject *self, PyObject *iterable)
* eventually run out of memory during the loop.
*/
}
+ else if (self->ob_item == NULL) {
+ if (n && list_preallocate_exact(self, n) < 0)
+ goto error;
+ }
else {
- mn = m + n;
/* Make room. */
- if (list_resize(self, mn) < 0)
+ if (list_resize(self, m + n) < 0)
goto error;
/* Make the list sane again. */
Py_SET_SIZE(self, m);
@@ -1548,8 +1556,10 @@ static void
merge_freemem(MergeState *ms)
{
assert(ms != NULL);
- if (ms->a.keys != ms->temparray)
+ if (ms->a.keys != ms->temparray) {
PyMem_Free(ms->a.keys);
+ ms->a.keys = NULL;
+ }
}
/* Ensure enough temp memory for 'need' array slots is available.
@@ -2715,19 +2725,6 @@ list___init___impl(PyListObject *self, PyObject *iterable)
(void)_list_clear(self);
}
if (iterable != NULL) {
- if (_PyObject_HasLen(iterable)) {
- Py_ssize_t iter_len = PyObject_Size(iterable);
- if (iter_len == -1) {
- if (!PyErr_ExceptionMatches(PyExc_TypeError)) {
- return -1;
- }
- PyErr_Clear();
- }
- if (iter_len > 0 && self->ob_item == NULL
- && list_preallocate_exact(self, iter_len)) {
- return -1;
- }
- }
PyObject *rv = list_extend(self, iterable);
if (rv == NULL)
return -1;
diff --git a/contrib/tools/python3/src/Objects/picklebufobject.c b/contrib/tools/python3/src/Objects/picklebufobject.c
index a135e5575e2..aaa852cfbb0 100644
--- a/contrib/tools/python3/src/Objects/picklebufobject.c
+++ b/contrib/tools/python3/src/Objects/picklebufobject.c
@@ -206,7 +206,7 @@ static PyMethodDef picklebuf_methods[] = {
PyTypeObject PyPickleBuffer_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "pickle.PickleBuffer",
- .tp_doc = "Wrapper for potentially out-of-band buffers",
+ .tp_doc = PyDoc_STR("Wrapper for potentially out-of-band buffers"),
.tp_basicsize = sizeof(PyPickleBufferObject),
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
.tp_new = picklebuf_new,
diff --git a/contrib/tools/python3/src/Objects/stringlib/codecs.h b/contrib/tools/python3/src/Objects/stringlib/codecs.h
index b17cda18f54..958cc861478 100644
--- a/contrib/tools/python3/src/Objects/stringlib/codecs.h
+++ b/contrib/tools/python3/src/Objects/stringlib/codecs.h
@@ -387,8 +387,19 @@ STRINGLIB(utf8_encoder)(_PyBytesWriter *writer,
if (!rep)
goto error;
- /* subtract preallocated bytes */
- writer->min_size -= max_char_size * (newpos - startpos);
+ if (newpos < startpos) {
+ writer->overallocate = 1;
+ p = _PyBytesWriter_Prepare(writer, p,
+ max_char_size * (startpos - newpos));
+ if (p == NULL)
+ goto error;
+ }
+ else {
+ /* subtract preallocated bytes */
+ writer->min_size -= max_char_size * (newpos - startpos);
+ /* Only overallocate the buffer if it's not the last write */
+ writer->overallocate = (newpos < size);
+ }
if (PyBytes_Check(rep)) {
p = _PyBytesWriter_WriteBytes(writer, p,
diff --git a/contrib/tools/python3/src/Objects/stringlib/fastsearch.h b/contrib/tools/python3/src/Objects/stringlib/fastsearch.h
index 6574720b609..7b8be5d6492 100644
--- a/contrib/tools/python3/src/Objects/stringlib/fastsearch.h
+++ b/contrib/tools/python3/src/Objects/stringlib/fastsearch.h
@@ -4,7 +4,8 @@
/* fast search/count implementation, based on a mix between boyer-
moore and horspool, with a few more bells and whistles on the top.
- for some more background, see: http://effbot.org/zone/stringlib.htm */
+ for some more background, see:
+ https://web.archive.org/web/20201107074620/http://effbot.org/zone/stringlib.htm */
/* note: fastsearch may access s[n], which isn't a problem when using
Python's ordinary string types, but may cause problems if you're
diff --git a/contrib/tools/python3/src/Objects/typeobject.c b/contrib/tools/python3/src/Objects/typeobject.c
index b3ba1208eb2..50f2742f676 100644
--- a/contrib/tools/python3/src/Objects/typeobject.c
+++ b/contrib/tools/python3/src/Objects/typeobject.c
@@ -369,22 +369,26 @@ type_mro_modified(PyTypeObject *type, PyObject *bases) {
Py_ssize_t i, n;
int custom = !Py_IS_TYPE(type, &PyType_Type);
int unbound;
- PyObject *mro_meth = NULL;
- PyObject *type_mro_meth = NULL;
if (custom) {
+ PyObject *mro_meth, *type_mro_meth;
mro_meth = lookup_maybe_method(
(PyObject *)type, &PyId_mro, &unbound);
- if (mro_meth == NULL)
+ if (mro_meth == NULL) {
goto clear;
+ }
type_mro_meth = lookup_maybe_method(
(PyObject *)&PyType_Type, &PyId_mro, &unbound);
- if (type_mro_meth == NULL)
+ if (type_mro_meth == NULL) {
+ Py_DECREF(mro_meth);
goto clear;
- if (mro_meth != type_mro_meth)
+ }
+ int custom_mro = (mro_meth != type_mro_meth);
+ Py_DECREF(mro_meth);
+ Py_DECREF(type_mro_meth);
+ if (custom_mro) {
goto clear;
- Py_XDECREF(mro_meth);
- Py_XDECREF(type_mro_meth);
+ }
}
n = PyTuple_GET_SIZE(bases);
for (i = 0; i < n; i++) {
@@ -400,8 +404,6 @@ type_mro_modified(PyTypeObject *type, PyObject *bases) {
}
return;
clear:
- Py_XDECREF(mro_meth);
- Py_XDECREF(type_mro_meth);
type->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG;
type->tp_version_tag = 0; /* 0 is not a valid version tag */
}
diff --git a/contrib/tools/python3/src/Objects/unicodeobject.c b/contrib/tools/python3/src/Objects/unicodeobject.c
index 077cf8d7f45..b7ec1f28d7e 100644
--- a/contrib/tools/python3/src/Objects/unicodeobject.c
+++ b/contrib/tools/python3/src/Objects/unicodeobject.c
@@ -5373,7 +5373,7 @@ _Py_DecodeUTF8Ex(const char *s, Py_ssize_t size, wchar_t **wstr, size_t *wlen,
/* Note: size will always be longer than the resulting Unicode
character count */
- if (PY_SSIZE_T_MAX / (Py_ssize_t)sizeof(wchar_t) < (size + 1)) {
+ if (PY_SSIZE_T_MAX / (Py_ssize_t)sizeof(wchar_t) - 1 < size) {
return -1;
}
@@ -5959,7 +5959,7 @@ _PyUnicode_EncodeUTF32(PyObject *str,
pos = 0;
while (pos < len) {
- Py_ssize_t repsize, moreunits;
+ Py_ssize_t newpos, repsize, moreunits;
if (kind == PyUnicode_2BYTE_KIND) {
pos += ucs2lib_utf32_encode((const Py_UCS2 *)data + pos, len - pos,
@@ -5976,7 +5976,7 @@ _PyUnicode_EncodeUTF32(PyObject *str,
rep = unicode_encode_call_errorhandler(
errors, &errorHandler,
encoding, "surrogates not allowed",
- str, &exc, pos, pos + 1, &pos);
+ str, &exc, pos, pos + 1, &newpos);
if (!rep)
goto error;
@@ -5984,7 +5984,7 @@ _PyUnicode_EncodeUTF32(PyObject *str,
repsize = PyBytes_GET_SIZE(rep);
if (repsize & 3) {
raise_encode_exception(&exc, encoding,
- str, pos - 1, pos,
+ str, pos, pos + 1,
"surrogates not allowed");
goto error;
}
@@ -5997,28 +5997,30 @@ _PyUnicode_EncodeUTF32(PyObject *str,
moreunits = repsize = PyUnicode_GET_LENGTH(rep);
if (!PyUnicode_IS_ASCII(rep)) {
raise_encode_exception(&exc, encoding,
- str, pos - 1, pos,
+ str, pos, pos + 1,
"surrogates not allowed");
goto error;
}
}
+ moreunits += pos - newpos;
+ pos = newpos;
/* four bytes are reserved for each surrogate */
- if (moreunits > 1) {
+ if (moreunits > 0) {
Py_ssize_t outpos = out - (uint32_t*) PyBytes_AS_STRING(v);
if (moreunits >= (PY_SSIZE_T_MAX - PyBytes_GET_SIZE(v)) / 4) {
/* integer overflow */
PyErr_NoMemory();
goto error;
}
- if (_PyBytes_Resize(&v, PyBytes_GET_SIZE(v) + 4 * (moreunits - 1)) < 0)
+ if (_PyBytes_Resize(&v, PyBytes_GET_SIZE(v) + 4 * moreunits) < 0)
goto error;
out = (uint32_t*) PyBytes_AS_STRING(v) + outpos;
}
if (PyBytes_Check(rep)) {
memcpy(out, PyBytes_AS_STRING(rep), repsize);
- out += moreunits;
+ out += repsize / 4;
} else /* rep is unicode */ {
assert(PyUnicode_KIND(rep) == PyUnicode_1BYTE_KIND);
ucs1lib_utf32_encode(PyUnicode_1BYTE_DATA(rep), repsize,
@@ -6311,7 +6313,7 @@ _PyUnicode_EncodeUTF16(PyObject *str,
pos = 0;
while (pos < len) {
- Py_ssize_t repsize, moreunits;
+ Py_ssize_t newpos, repsize, moreunits;
if (kind == PyUnicode_2BYTE_KIND) {
pos += ucs2lib_utf16_encode((const Py_UCS2 *)data + pos, len - pos,
@@ -6328,7 +6330,7 @@ _PyUnicode_EncodeUTF16(PyObject *str,
rep = unicode_encode_call_errorhandler(
errors, &errorHandler,
encoding, "surrogates not allowed",
- str, &exc, pos, pos + 1, &pos);
+ str, &exc, pos, pos + 1, &newpos);
if (!rep)
goto error;
@@ -6336,7 +6338,7 @@ _PyUnicode_EncodeUTF16(PyObject *str,
repsize = PyBytes_GET_SIZE(rep);
if (repsize & 1) {
raise_encode_exception(&exc, encoding,
- str, pos - 1, pos,
+ str, pos, pos + 1,
"surrogates not allowed");
goto error;
}
@@ -6349,28 +6351,30 @@ _PyUnicode_EncodeUTF16(PyObject *str,
moreunits = repsize = PyUnicode_GET_LENGTH(rep);
if (!PyUnicode_IS_ASCII(rep)) {
raise_encode_exception(&exc, encoding,
- str, pos - 1, pos,
+ str, pos, pos + 1,
"surrogates not allowed");
goto error;
}
}
+ moreunits += pos - newpos;
+ pos = newpos;
/* two bytes are reserved for each surrogate */
- if (moreunits > 1) {
+ if (moreunits > 0) {
Py_ssize_t outpos = out - (unsigned short*) PyBytes_AS_STRING(v);
if (moreunits >= (PY_SSIZE_T_MAX - PyBytes_GET_SIZE(v)) / 2) {
/* integer overflow */
PyErr_NoMemory();
goto error;
}
- if (_PyBytes_Resize(&v, PyBytes_GET_SIZE(v) + 2 * (moreunits - 1)) < 0)
+ if (_PyBytes_Resize(&v, PyBytes_GET_SIZE(v) + 2 * moreunits) < 0)
goto error;
out = (unsigned short*) PyBytes_AS_STRING(v) + outpos;
}
if (PyBytes_Check(rep)) {
memcpy(out, PyBytes_AS_STRING(rep), repsize);
- out += moreunits;
+ out += repsize / 2;
} else /* rep is unicode */ {
assert(PyUnicode_KIND(rep) == PyUnicode_1BYTE_KIND);
ucs1lib_utf16_encode(PyUnicode_1BYTE_DATA(rep), repsize,
@@ -7297,8 +7301,19 @@ unicode_encode_ucs1(PyObject *unicode,
if (rep == NULL)
goto onError;
- /* subtract preallocated bytes */
- writer.min_size -= newpos - collstart;
+ if (newpos < collstart) {
+ writer.overallocate = 1;
+ str = _PyBytesWriter_Prepare(&writer, str,
+ collstart - newpos);
+ if (str == NULL)
+ goto onError;
+ }
+ else {
+ /* subtract preallocated bytes */
+ writer.min_size -= newpos - collstart;
+ /* Only overallocate the buffer if it's not the last write */
+ writer.overallocate = (newpos < size);
+ }
if (PyBytes_Check(rep)) {
/* Directly copy bytes result to output. */
@@ -8104,13 +8119,14 @@ encode_code_page_errors(UINT code_page, PyObject **outbytes,
pos, pos + 1, &newpos);
if (rep == NULL)
goto error;
- pos = newpos;
+ Py_ssize_t morebytes = pos - newpos;
if (PyBytes_Check(rep)) {
outsize = PyBytes_GET_SIZE(rep);
- if (outsize != 1) {
+ morebytes += outsize;
+ if (morebytes > 0) {
Py_ssize_t offset = out - PyBytes_AS_STRING(*outbytes);
- newoutsize = PyBytes_GET_SIZE(*outbytes) + (outsize - 1);
+ newoutsize = PyBytes_GET_SIZE(*outbytes) + morebytes;
if (_PyBytes_Resize(outbytes, newoutsize) < 0) {
Py_DECREF(rep);
goto error;
@@ -8131,9 +8147,10 @@ encode_code_page_errors(UINT code_page, PyObject **outbytes,
}
outsize = PyUnicode_GET_LENGTH(rep);
- if (outsize != 1) {
+ morebytes += outsize;
+ if (morebytes > 0) {
Py_ssize_t offset = out - PyBytes_AS_STRING(*outbytes);
- newoutsize = PyBytes_GET_SIZE(*outbytes) + (outsize - 1);
+ newoutsize = PyBytes_GET_SIZE(*outbytes) + morebytes;
if (_PyBytes_Resize(outbytes, newoutsize) < 0) {
Py_DECREF(rep);
goto error;
@@ -8156,6 +8173,7 @@ encode_code_page_errors(UINT code_page, PyObject **outbytes,
out++;
}
}
+ pos = newpos;
Py_DECREF(rep);
}
/* write a NUL byte */
@@ -13478,19 +13496,26 @@ PyUnicode_Split(PyObject *s, PyObject *sep, Py_ssize_t maxsplit)
str.split as unicode_split
sep: object = None
- The delimiter according which to split the string.
- None (the default value) means split according to any whitespace,
- and discard empty strings from the result.
+ The separator used to split the string.
+
+ When set to None (the default value), will split on any whitespace
+ character (including \\n \\r \\t \\f and spaces) and will discard
+ empty strings from the result.
maxsplit: Py_ssize_t = -1
- Maximum number of splits to do.
+ Maximum number of splits (starting from the left).
-1 (the default value) means no limit.
-Return a list of the words in the string, using sep as the delimiter string.
+Return a list of the substrings in the string, using sep as the separator string.
+
+Note, str.split() is mainly useful for data that has been intentionally
+delimited. With natural text that includes punctuation, consider using
+the regular expression module.
+
[clinic start generated code]*/
static PyObject *
unicode_split_impl(PyObject *self, PyObject *sep, Py_ssize_t maxsplit)
-/*[clinic end generated code: output=3a65b1db356948dc input=606e750488a82359]*/
+/*[clinic end generated code: output=3a65b1db356948dc input=906d953b44efc43b]*/
{
if (sep == Py_None)
return split(self, NULL, maxsplit);
@@ -13661,14 +13686,14 @@ PyUnicode_RSplit(PyObject *s, PyObject *sep, Py_ssize_t maxsplit)
/*[clinic input]
str.rsplit as unicode_rsplit = str.split
-Return a list of the words in the string, using sep as the delimiter string.
+Return a list of the substrings in the string, using sep as the separator string.
-Splits are done starting at the end of the string and working to the front.
+Splitting starts at the end of the string and works to the front.
[clinic start generated code]*/
static PyObject *
unicode_rsplit_impl(PyObject *self, PyObject *sep, Py_ssize_t maxsplit)
-/*[clinic end generated code: output=c2b815c63bcabffc input=12ad4bf57dd35f15]*/
+/*[clinic end generated code: output=c2b815c63bcabffc input=ea78406060fce33c]*/
{
if (sep == Py_None)
return rsplit(self, NULL, maxsplit);
@@ -16352,6 +16377,9 @@ _PyUnicode_Fini(PyInterpreterState *interp)
if (_Py_IsMainInterpreter(interp)) {
// _PyUnicode_ClearInterned() must be called before _PyUnicode_Fini()
assert(interned == NULL);
+ // bpo-47182: force a unicodedata CAPI capsule re-import on
+ // subsequent initialization of main interpreter.
+ ucnhash_capi = NULL;
}
_PyUnicode_FiniEncodings(&state->fs_codec);
diff --git a/contrib/tools/python3/src/Objects/unionobject.c b/contrib/tools/python3/src/Objects/unionobject.c
index 80c70389ab3..6d8bb021421 100644
--- a/contrib/tools/python3/src/Objects/unionobject.c
+++ b/contrib/tools/python3/src/Objects/unionobject.c
@@ -447,9 +447,9 @@ union_getattro(PyObject *self, PyObject *name)
PyTypeObject _PyUnion_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
.tp_name = "types.UnionType",
- .tp_doc = "Represent a PEP 604 union type\n"
+ .tp_doc = PyDoc_STR("Represent a PEP 604 union type\n"
"\n"
- "E.g. for int | str",
+ "E.g. for int | str"),
.tp_basicsize = sizeof(unionobject),
.tp_dealloc = unionobject_dealloc,
.tp_alloc = PyType_GenericAlloc,
diff --git a/contrib/tools/python3/src/Parser/parser.c b/contrib/tools/python3/src/Parser/parser.c
index 3f73003b789..862950018a3 100644
--- a/contrib/tools/python3/src/Parser/parser.c
+++ b/contrib/tools/python3/src/Parser/parser.c
@@ -18419,7 +18419,7 @@ invalid_arguments_rule(Parser *p)
)
{
D(fprintf(stderr, "%*c+ invalid_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]"));
- _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , PyPegen_last_item ( b , comprehension_ty ) -> target , "Generator expression must be parenthesized" );
+ _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , _PyPegen_get_last_comprehension_item ( PyPegen_last_item ( b , comprehension_ty ) ) , "Generator expression must be parenthesized" );
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
p->level--;
@@ -18512,7 +18512,7 @@ invalid_arguments_rule(Parser *p)
)
{
D(fprintf(stderr, "%*c+ invalid_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ',' expression for_if_clauses"));
- _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , asdl_seq_GET ( b , b -> size - 1 ) -> target , "Generator expression must be parenthesized" );
+ _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , _PyPegen_get_last_comprehension_item ( PyPegen_last_item ( b , comprehension_ty ) ) , "Generator expression must be parenthesized" );
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
p->level--;
@@ -20804,7 +20804,7 @@ invalid_except_stmt_indent_rule(Parser *p)
)
{
D(fprintf(stderr, "%*c+ invalid_except_stmt_indent[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' ':' NEWLINE !INDENT"));
- _res = RAISE_SYNTAX_ERROR ( "expected an indented block after except statement on line %d" , a -> lineno );
+ _res = RAISE_INDENTATION_ERROR ( "expected an indented block after 'except' statement on line %d" , a -> lineno );
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
p->level--;
diff --git a/contrib/tools/python3/src/Parser/pegen.c b/contrib/tools/python3/src/Parser/pegen.c
index df174760134..c04824315c7 100644
--- a/contrib/tools/python3/src/Parser/pegen.c
+++ b/contrib/tools/python3/src/Parser/pegen.c
@@ -435,7 +435,12 @@ get_error_line(Parser *p, Py_ssize_t lineno)
assert((p->tok->fp == NULL && p->tok->str != NULL) || p->tok->fp == stdin);
char *cur_line = p->tok->fp_interactive ? p->tok->interactive_src_start : p->tok->str;
- assert(cur_line != NULL);
+ if (cur_line == NULL) {
+ assert(p->tok->fp_interactive);
+ // We can reach this point if the tokenizer buffers for interactive source have not been
+ // initialized because we failed to decode the original source with the given locale.
+ return PyUnicode_FromStringAndSize("", 0);
+ }
const char* buf_end = p->tok->fp_interactive ? p->tok->interactive_src_end : p->tok->inp;
Py_ssize_t relative_lineno = p->starting_lineno ? lineno - p->starting_lineno + 1 : lineno;
@@ -495,7 +500,7 @@ _PyPegen_raise_error_known_location(Parser *p, PyObject *errtype,
goto error;
}
- if (p->tok->fp_interactive) {
+ if (p->tok->fp_interactive && p->tok->interactive_src_start != NULL) {
error_line = get_error_line(p, lineno);
}
else if (p->start_rule == Py_file_input) {
@@ -2563,7 +2568,7 @@ void *_PyPegen_arguments_parsing_error(Parser *p, expr_ty e) {
}
-static inline expr_ty
+expr_ty
_PyPegen_get_last_comprehension_item(comprehension_ty comprehension) {
if (comprehension->ifs == NULL || asdl_seq_LEN(comprehension->ifs) == 0) {
return comprehension->iter;
diff --git a/contrib/tools/python3/src/Parser/pegen.h b/contrib/tools/python3/src/Parser/pegen.h
index 0e5a057c1f1..118fbc7b3b7 100644
--- a/contrib/tools/python3/src/Parser/pegen.h
+++ b/contrib/tools/python3/src/Parser/pegen.h
@@ -327,6 +327,7 @@ _RAISE_SYNTAX_ERROR_INVALID_TARGET(Parser *p, TARGETS_TYPE type, void *e)
}
void *_PyPegen_arguments_parsing_error(Parser *, expr_ty);
+expr_ty _PyPegen_get_last_comprehension_item(comprehension_ty comprehension);
void *_PyPegen_nonparen_genexp_in_call(Parser *p, expr_ty args, asdl_comprehension_seq *comprehensions);
diff --git a/contrib/tools/python3/src/Parser/string_parser.c b/contrib/tools/python3/src/Parser/string_parser.c
index dac8dbb8464..80f158b5a65 100644
--- a/contrib/tools/python3/src/Parser/string_parser.c
+++ b/contrib/tools/python3/src/Parser/string_parser.c
@@ -740,7 +740,9 @@ fstring_find_expr(Parser *p, const char **str, const char *end, int raw, int rec
while (Py_ISSPACE(**str)) {
*str += 1;
}
-
+ if (*str >= end) {
+ goto unexpected_end_of_string;
+ }
/* Set *expr_text to the text of the expression. */
*expr_text = PyUnicode_FromStringAndSize(expr_start, *str-expr_start);
if (!*expr_text) {
diff --git a/contrib/tools/python3/src/Python/ceval.c b/contrib/tools/python3/src/Python/ceval.c
index 21674e0be13..9a193c994d1 100644
--- a/contrib/tools/python3/src/Python/ceval.c
+++ b/contrib/tools/python3/src/Python/ceval.c
@@ -5377,6 +5377,8 @@ prtrace(PyThreadState *tstate, PyObject *v, const char *str)
}
printf("\n");
PyErr_Restore(type, value, traceback);
+ // gh-91924: PyObject_Print() can indirectly set lltrace to 0
+ lltrace = 1;
return 1;
}
#endif
diff --git a/contrib/tools/python3/src/Python/compile.c b/contrib/tools/python3/src/Python/compile.c
index f012406c066..7210d42fc76 100644
--- a/contrib/tools/python3/src/Python/compile.c
+++ b/contrib/tools/python3/src/Python/compile.c
@@ -2925,6 +2925,8 @@ compiler_async_for(struct compiler *c, stmt_ty s)
/* Success block for __anext__ */
VISIT(c, expr, s->v.AsyncFor.target);
VISIT_SEQ(c, stmt, s->v.AsyncFor.body);
+ /* Mark jump as artificial */
+ c->u->u_lineno = -1;
ADDOP_JUMP(c, JUMP_ABSOLUTE, start);
compiler_pop_fblock(c, FOR_LOOP, start);
diff --git a/contrib/tools/python3/src/Python/fileutils.c b/contrib/tools/python3/src/Python/fileutils.c
index c3144ee4078..3b53baa00ee 100644
--- a/contrib/tools/python3/src/Python/fileutils.c
+++ b/contrib/tools/python3/src/Python/fileutils.c
@@ -2395,10 +2395,11 @@ _Py_closerange(int first, int last)
first = Py_MAX(first, 0);
_Py_BEGIN_SUPPRESS_IPH
#ifdef HAVE_CLOSE_RANGE
- if (close_range(first, last, 0) == 0 || errno != ENOSYS) {
- /* Any errors encountered while closing file descriptors are ignored;
- * ENOSYS means no kernel support, though,
- * so we'll fallback to the other methods. */
+ if (close_range(first, last, 0) == 0) {
+ /* close_range() ignores errors when it closes file descriptors.
+ * Possible reasons of an error return are lack of kernel support
+ * or denial of the underlying syscall by a seccomp sandbox on Linux.
+ * Fallback to other methods in case of any error. */
}
else
#endif /* HAVE_CLOSE_RANGE */
diff --git a/contrib/tools/python3/src/Python/hamt.c b/contrib/tools/python3/src/Python/hamt.c
index e272e8808fd..6572a554311 100644
--- a/contrib/tools/python3/src/Python/hamt.c
+++ b/contrib/tools/python3/src/Python/hamt.c
@@ -408,14 +408,22 @@ hamt_hash(PyObject *o)
return -1;
}
- /* While it's suboptimal to reduce Python's 64 bit hash to
+ /* While it's somewhat suboptimal to reduce Python's 64 bit hash to
32 bits via XOR, it seems that the resulting hash function
is good enough (this is also how Long type is hashed in Java.)
Storing 10, 100, 1000 Python strings results in a relatively
shallow and uniform tree structure.
- Please don't change this hashing algorithm, as there are many
- tests that test some exact tree shape to cover all code paths.
+ Also it's worth noting that it would be possible to adapt the tree
+ structure to 64 bit hashes, but that would increase memory pressure
+ and provide little to no performance benefits for collections with
+ fewer than billions of key/value pairs.
+
+ Important: do not change this hash reducing function. There are many
+ tests that need an exact tree shape to cover all code paths and
+ we do that by specifying concrete values for test data's `__hash__`.
+ If this function is changed most of the regression tests would
+ become useless.
*/
int32_t xored = (int32_t)(hash & 0xffffffffl) ^ (int32_t)(hash >> 32);
return xored == -1 ? -2 : xored;
diff --git a/contrib/tools/python3/src/Python/initconfig.c b/contrib/tools/python3/src/Python/initconfig.c
index 86472c0ff8f..e0b65e86678 100644
--- a/contrib/tools/python3/src/Python/initconfig.c
+++ b/contrib/tools/python3/src/Python/initconfig.c
@@ -41,7 +41,7 @@ Options and arguments (and corresponding environment variables):\n\
-d : turn on parser debugging output (for experts only, only works on\n\
debug builds); also PYTHONDEBUG=x\n\
-E : ignore PYTHON* environment variables (such as PYTHONPATH)\n\
--h : print this help message and exit (also --help)\n\
+-h : print this help message and exit (also -? or --help)\n\
";
static const char usage_2[] = "\
-i : inspect interactively after running script; forces a prompt even\n\
@@ -67,7 +67,6 @@ static const char usage_3[] = "\
also PYTHONWARNINGS=arg\n\
-x : skip first line of source, allowing use of non-Unix forms of #!cmd\n\
-X opt : set implementation-specific option. The following options are available:\n\
-\n\
-X faulthandler: enable faulthandler\n\
-X showrefcount: output the total reference count and number of used\n\
memory blocks when the program finishes or after each statement in the\n\
@@ -84,7 +83,8 @@ static const char usage_3[] = "\
checks which are too expensive to be enabled by default. Effect of the\n\
developer mode:\n\
* Add default warning filter, as -W default\n\
- * Install debug hooks on memory allocators: see the PyMem_SetupDebugHooks() C function\n\
+ * Install debug hooks on memory allocators: see the PyMem_SetupDebugHooks()\n\
+ C function\n\
* Enable the faulthandler module to dump the Python traceback on a crash\n\
* Enable asyncio debug mode\n\
* Set the dev_mode attribute of sys.flags to True\n\
@@ -95,7 +95,6 @@ static const char usage_3[] = "\
-X pycache_prefix=PATH: enable writing .pyc files to a parallel tree rooted at the\n\
given directory instead of to the code tree\n\
-X warn_default_encoding: enable opt-in EncodingWarning for 'encoding=None'\n\
-\n\
--check-hash-based-pycs always|default|never:\n\
control how Python invalidates hash-based .pyc files\n\
";
diff --git a/contrib/tools/python3/src/README.rst b/contrib/tools/python3/src/README.rst
index 215ff1e5b94..99db9b30c8f 100644
--- a/contrib/tools/python3/src/README.rst
+++ b/contrib/tools/python3/src/README.rst
@@ -1,4 +1,4 @@
-This is Python version 3.10.4
+This is Python version 3.10.5
=============================
.. image:: https://travis-ci.com/python/cpython.svg?branch=master