Skip to content

Commit 2fcfb85

Browse files
committed
Update Python 3 to 3.12.11
commit_hash:0054a0810a95d3f1aa3d36410976d43e03ff7e86
1 parent 6635b88 commit 2fcfb85

File tree

23 files changed

+4405
-3530
lines changed

23 files changed

+4405
-3530
lines changed

contrib/tools/python3/.yandex_meta/devtools.licenses.report

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ BELONGS ya.make
464464
Match type : TAG
465465
Links : http://docs.python.org/license.html, http://spdx.org/licenses/Python-2.0, https://spdx.org/licenses/Python-2.0
466466
Files with this license:
467-
Python/deepfreeze/deepfreeze.c [127644:127644]
467+
Python/deepfreeze/deepfreeze.c [128179:128179]
468468

469469
KEEP LicenseRef-scancode-warranty-disclaimer 50a3e16ca7c1aaf79e69114d558b25a0
470470
BELONGS Lib/ya.make

contrib/tools/python3/.yandex_meta/override.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
pkgs: attrs: with pkgs; with attrs; rec {
2-
version = "3.12.10";
2+
version = "3.12.11";
33

44
src = fetchFromGitHub {
55
owner = "python";
66
repo = "cpython";
77
rev = "v${version}";
8-
hash = "sha256-cz3pDerJJRmaUKvYDrW7SuPiYEEUqXP3FSRVDOcAxlY=";
8+
hash = "sha256-vDczdMOTglDf5F+8PPkixvxScDCpedJCo0eL0VJJ/8g=";
99
};
1010

1111
patches = [];

contrib/tools/python3/Include/cpython/bytesobject.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ PyAPI_FUNC(PyObject*) _PyBytes_FromHex(
2525
int use_bytearray);
2626

2727
/* Helper for PyBytes_DecodeEscape that detects invalid escape chars. */
28+
PyAPI_FUNC(PyObject*) _PyBytes_DecodeEscape2(const char *, Py_ssize_t,
29+
const char *,
30+
int *, const char **);
31+
// Export for binary compatibility.
2832
PyAPI_FUNC(PyObject *) _PyBytes_DecodeEscape(const char *, Py_ssize_t,
2933
const char *, const char **);
3034

contrib/tools/python3/Include/cpython/unicodeobject.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,19 @@ PyAPI_FUNC(PyObject*) _PyUnicode_DecodeUnicodeEscapeStateful(
684684
);
685685
/* Helper for PyUnicode_DecodeUnicodeEscape that detects invalid escape
686686
chars. */
687+
PyAPI_FUNC(PyObject*) _PyUnicode_DecodeUnicodeEscapeInternal2(
688+
const char *string, /* Unicode-Escape encoded string */
689+
Py_ssize_t length, /* size of string */
690+
const char *errors, /* error handling */
691+
Py_ssize_t *consumed, /* bytes consumed */
692+
int *first_invalid_escape_char, /* on return, if not -1, contain the first
693+
invalid escaped char (<= 0xff) or invalid
694+
octal escape (> 0xff) in string. */
695+
const char **first_invalid_escape_ptr); /* on return, if not NULL, may
696+
point to the first invalid escaped
697+
char in string.
698+
May be NULL if errors is not NULL. */
699+
// Export for binary compatibility.
687700
PyAPI_FUNC(PyObject*) _PyUnicode_DecodeUnicodeEscapeInternal(
688701
const char *string, /* Unicode-Escape encoded string */
689702
Py_ssize_t length, /* size of string */

contrib/tools/python3/Include/patchlevel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
/*--start constants--*/
1919
#define PY_MAJOR_VERSION 3
2020
#define PY_MINOR_VERSION 12
21-
#define PY_MICRO_VERSION 10
21+
#define PY_MICRO_VERSION 11
2222
#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL
2323
#define PY_RELEASE_SERIAL 0
2424

2525
/* Version as a string */
26-
#define PY_VERSION "3.12.10"
26+
#define PY_VERSION "3.12.11"
2727
/*--end constants--*/
2828

2929
/* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2.

contrib/tools/python3/Lib/genericpath.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
__all__ = ['commonprefix', 'exists', 'getatime', 'getctime', 'getmtime',
1010
'getsize', 'isdir', 'isfile', 'islink', 'samefile', 'sameopenfile',
11-
'samestat']
11+
'samestat', 'ALLOW_MISSING']
1212

1313

1414
# Does a path exist?
@@ -165,3 +165,12 @@ def _check_arg_types(funcname, *args):
165165
f'os.PathLike object, not {s.__class__.__name__!r}') from None
166166
if hasstr and hasbytes:
167167
raise TypeError("Can't mix strings and bytes in path components") from None
168+
169+
# A singleton with a true boolean value.
170+
@object.__new__
171+
class ALLOW_MISSING:
172+
"""Special value for use in realpath()."""
173+
def __repr__(self):
174+
return 'os.path.ALLOW_MISSING'
175+
def __reduce__(self):
176+
return self.__class__.__name__

contrib/tools/python3/Lib/ipaddress.py

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ def __eq__(self, other):
734734
return NotImplemented
735735

736736
def __hash__(self):
737-
return hash(int(self.network_address) ^ int(self.netmask))
737+
return hash((int(self.network_address), int(self.netmask)))
738738

739739
def __contains__(self, other):
740740
# always false if one is v4 and the other is v6.
@@ -1664,8 +1664,18 @@ def _ip_int_from_string(cls, ip_str):
16641664
"""
16651665
if not ip_str:
16661666
raise AddressValueError('Address cannot be empty')
1667-
1668-
parts = ip_str.split(':')
1667+
if len(ip_str) > 45:
1668+
shorten = ip_str
1669+
if len(shorten) > 100:
1670+
shorten = f'{ip_str[:45]}({len(ip_str)-90} chars elided){ip_str[-45:]}'
1671+
raise AddressValueError(f"At most 45 characters expected in "
1672+
f"{shorten!r}")
1673+
1674+
# We want to allow more parts than the max to be 'split'
1675+
# to preserve the correct error message when there are
1676+
# too many parts combined with '::'
1677+
_max_parts = cls._HEXTET_COUNT + 1
1678+
parts = ip_str.split(':', maxsplit=_max_parts)
16691679

16701680
# An IPv6 address needs at least 2 colons (3 parts).
16711681
_min_parts = 3
@@ -1685,7 +1695,6 @@ def _ip_int_from_string(cls, ip_str):
16851695
# An IPv6 address can't have more than 8 colons (9 parts).
16861696
# The extra colon comes from using the "::" notation for a single
16871697
# leading or trailing zero part.
1688-
_max_parts = cls._HEXTET_COUNT + 1
16891698
if len(parts) > _max_parts:
16901699
msg = "At most %d colons permitted in %r" % (_max_parts-1, ip_str)
16911700
raise AddressValueError(msg)
@@ -1957,8 +1966,49 @@ def __init__(self, address):
19571966

19581967
self._ip = self._ip_int_from_string(addr_str)
19591968

1969+
def _explode_shorthand_ip_string(self):
1970+
ipv4_mapped = self.ipv4_mapped
1971+
if ipv4_mapped is None:
1972+
return super()._explode_shorthand_ip_string()
1973+
prefix_len = 30
1974+
raw_exploded_str = super()._explode_shorthand_ip_string()
1975+
return f"{raw_exploded_str[:prefix_len]}{ipv4_mapped!s}"
1976+
1977+
def _reverse_pointer(self):
1978+
ipv4_mapped = self.ipv4_mapped
1979+
if ipv4_mapped is None:
1980+
return super()._reverse_pointer()
1981+
prefix_len = 30
1982+
raw_exploded_str = super()._explode_shorthand_ip_string()[:prefix_len]
1983+
# ipv4 encoded using hexadecimal nibbles instead of decimals
1984+
ipv4_int = ipv4_mapped._ip
1985+
reverse_chars = f"{raw_exploded_str}{ipv4_int:008x}"[::-1].replace(':', '')
1986+
return '.'.join(reverse_chars) + '.ip6.arpa'
1987+
1988+
def _ipv4_mapped_ipv6_to_str(self):
1989+
"""Return convenient text representation of IPv4-mapped IPv6 address
1990+
1991+
See RFC 4291 2.5.5.2, 2.2 p.3 for details.
1992+
1993+
Returns:
1994+
A string, 'x:x:x:x:x:x:d.d.d.d', where the 'x's are the hexadecimal values of
1995+
the six high-order 16-bit pieces of the address, and the 'd's are
1996+
the decimal values of the four low-order 8-bit pieces of the
1997+
address (standard IPv4 representation) as defined in RFC 4291 2.2 p.3.
1998+
1999+
"""
2000+
ipv4_mapped = self.ipv4_mapped
2001+
if ipv4_mapped is None:
2002+
raise AddressValueError("Can not apply to non-IPv4-mapped IPv6 address %s" % str(self))
2003+
high_order_bits = self._ip >> 32
2004+
return "%s:%s" % (self._string_from_ip_int(high_order_bits), str(ipv4_mapped))
2005+
19602006
def __str__(self):
1961-
ip_str = super().__str__()
2007+
ipv4_mapped = self.ipv4_mapped
2008+
if ipv4_mapped is None:
2009+
ip_str = super().__str__()
2010+
else:
2011+
ip_str = self._ipv4_mapped_ipv6_to_str()
19622012
return ip_str + '%' + self._scope_id if self._scope_id else ip_str
19632013

19642014
def __hash__(self):

contrib/tools/python3/Lib/ntpath.py

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"ismount", "expanduser","expandvars","normpath","abspath",
3131
"curdir","pardir","sep","pathsep","defpath","altsep",
3232
"extsep","devnull","realpath","supports_unicode_filenames","relpath",
33-
"samefile", "sameopenfile", "samestat", "commonpath", "isjunction"]
33+
"samefile", "sameopenfile", "samestat", "commonpath", "isjunction",
34+
"ALLOW_MISSING"]
3435

3536
def _get_bothseps(path):
3637
if isinstance(path, bytes):
@@ -609,9 +610,10 @@ def abspath(path):
609610
from nt import _getfinalpathname, readlink as _nt_readlink
610611
except ImportError:
611612
# realpath is a no-op on systems without _getfinalpathname support.
612-
realpath = abspath
613+
def realpath(path, *, strict=False):
614+
return abspath(path)
613615
else:
614-
def _readlink_deep(path):
616+
def _readlink_deep(path, ignored_error=OSError):
615617
# These error codes indicate that we should stop reading links and
616618
# return the path we currently have.
617619
# 1: ERROR_INVALID_FUNCTION
@@ -644,7 +646,7 @@ def _readlink_deep(path):
644646
path = old_path
645647
break
646648
path = normpath(join(dirname(old_path), path))
647-
except OSError as ex:
649+
except ignored_error as ex:
648650
if ex.winerror in allowed_winerror:
649651
break
650652
raise
@@ -653,7 +655,7 @@ def _readlink_deep(path):
653655
break
654656
return path
655657

656-
def _getfinalpathname_nonstrict(path):
658+
def _getfinalpathname_nonstrict(path, ignored_error=OSError):
657659
# These error codes indicate that we should stop resolving the path
658660
# and return the value we currently have.
659661
# 1: ERROR_INVALID_FUNCTION
@@ -680,17 +682,18 @@ def _getfinalpathname_nonstrict(path):
680682
try:
681683
path = _getfinalpathname(path)
682684
return join(path, tail) if tail else path
683-
except OSError as ex:
685+
except ignored_error as ex:
684686
if ex.winerror not in allowed_winerror:
685687
raise
686688
try:
687689
# The OS could not resolve this path fully, so we attempt
688690
# to follow the link ourselves. If we succeed, join the tail
689691
# and return.
690-
new_path = _readlink_deep(path)
692+
new_path = _readlink_deep(path,
693+
ignored_error=ignored_error)
691694
if new_path != path:
692695
return join(new_path, tail) if tail else new_path
693-
except OSError:
696+
except ignored_error:
694697
# If we fail to readlink(), let's keep traversing
695698
pass
696699
path, name = split(path)
@@ -721,24 +724,32 @@ def realpath(path, *, strict=False):
721724
if normcase(path) == normcase(devnull):
722725
return '\\\\.\\NUL'
723726
had_prefix = path.startswith(prefix)
727+
728+
if strict is ALLOW_MISSING:
729+
ignored_error = FileNotFoundError
730+
strict = True
731+
elif strict:
732+
ignored_error = ()
733+
else:
734+
ignored_error = OSError
735+
724736
if not had_prefix and not isabs(path):
725737
path = join(cwd, path)
726738
try:
727739
path = _getfinalpathname(path)
728740
initial_winerror = 0
729741
except ValueError as ex:
730742
# gh-106242: Raised for embedded null characters
731-
# In strict mode, we convert into an OSError.
743+
# In strict modes, we convert into an OSError.
732744
# Non-strict mode returns the path as-is, since we've already
733745
# made it absolute.
734746
if strict:
735747
raise OSError(str(ex)) from None
736748
path = normpath(path)
737-
except OSError as ex:
738-
if strict:
739-
raise
749+
except ignored_error as ex:
740750
initial_winerror = ex.winerror
741-
path = _getfinalpathname_nonstrict(path)
751+
path = _getfinalpathname_nonstrict(path,
752+
ignored_error=ignored_error)
742753
# The path returned by _getfinalpathname will always start with \\?\ -
743754
# strip off that prefix unless it was already provided on the original
744755
# path.

contrib/tools/python3/Lib/posixpath.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"samefile","sameopenfile","samestat",
3636
"curdir","pardir","sep","pathsep","defpath","altsep","extsep",
3737
"devnull","realpath","supports_unicode_filenames","relpath",
38-
"commonpath", "isjunction"]
38+
"commonpath", "isjunction", "ALLOW_MISSING"]
3939

4040

4141
def _get_sep(path):
@@ -438,6 +438,15 @@ def _joinrealpath(path, rest, strict, seen):
438438
sep = '/'
439439
curdir = '.'
440440
pardir = '..'
441+
getcwd = os.getcwd
442+
if strict is ALLOW_MISSING:
443+
ignored_error = FileNotFoundError
444+
elif strict:
445+
ignored_error = ()
446+
else:
447+
ignored_error = OSError
448+
449+
maxlinks = None
441450

442451
if isabs(rest):
443452
rest = rest[1:]
@@ -460,9 +469,7 @@ def _joinrealpath(path, rest, strict, seen):
460469
newpath = join(path, name)
461470
try:
462471
st = os.lstat(newpath)
463-
except OSError:
464-
if strict:
465-
raise
472+
except ignored_error:
466473
is_link = False
467474
else:
468475
is_link = stat.S_ISLNK(st.st_mode)

contrib/tools/python3/Lib/pydoc_data/topics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Autogenerated by Sphinx on Tue Apr 8 13:35:42 2025
1+
# Autogenerated by Sphinx on Tue Jun 3 17:41:43 2025
22
# as part of the release process.
33

44
topics = {

0 commit comments

Comments
 (0)