aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/patches
diff options
context:
space:
mode:
authormaxim-yurchuk <maxim-yurchuk@yandex-team.com>2024-10-09 12:29:46 +0300
committermaxim-yurchuk <maxim-yurchuk@yandex-team.com>2024-10-09 13:14:22 +0300
commit9731d8a4bb7ee2cc8554eaf133bb85498a4c7d80 (patch)
treea8fb3181d5947c0d78cf402aa56e686130179049 /contrib/tools/python3/patches
parenta44b779cd359f06c3ebbef4ec98c6b38609d9d85 (diff)
downloadydb-9731d8a4bb7ee2cc8554eaf133bb85498a4c7d80.tar.gz
publishFullContrib: true for ydb
<HIDDEN_URL> commit_hash:c82a80ac4594723cebf2c7387dec9c60217f603e
Diffstat (limited to 'contrib/tools/python3/patches')
-rw-r--r--contrib/tools/python3/patches/_sysconfigdata_arcadia.patch5
-rw-r--r--contrib/tools/python3/patches/cut-backtrace.patch32
-rw-r--r--contrib/tools/python3/patches/disable-search-modules-on-filesystem.patch40
-rw-r--r--contrib/tools/python3/patches/embed-builtin-cadata.patch59
-rw-r--r--contrib/tools/python3/patches/fix-addr2line.patch11
-rw-r--r--contrib/tools/python3/patches/fix-blake2.patch11
-rw-r--r--contrib/tools/python3/patches/fix-build.patch17
-rw-r--r--contrib/tools/python3/patches/fix-ctypes.patch11
-rw-r--r--contrib/tools/python3/patches/fix-gettext.patch52
-rw-r--r--contrib/tools/python3/patches/fix-msan-for-pydantic-2.patch90
-rw-r--r--contrib/tools/python3/patches/fix-segfault-with-pydebug.patch20
-rw-r--r--contrib/tools/python3/patches/fix-traceback.patch32
-rw-r--r--contrib/tools/python3/patches/fix-ubuntu-20.patch26
-rw-r--r--contrib/tools/python3/patches/pr115350-win-lean-and-mean.patch24
-rw-r--r--contrib/tools/python3/patches/reduce-pydebug-2.patch11
-rw-r--r--contrib/tools/python3/patches/reduce-pydebug.patch16
-rw-r--r--contrib/tools/python3/patches/reduce-ssl-requirements.patch17
17 files changed, 474 insertions, 0 deletions
diff --git a/contrib/tools/python3/patches/_sysconfigdata_arcadia.patch b/contrib/tools/python3/patches/_sysconfigdata_arcadia.patch
new file mode 100644
index 0000000000..3044e0e7da
--- /dev/null
+++ b/contrib/tools/python3/patches/_sysconfigdata_arcadia.patch
@@ -0,0 +1,5 @@
+--- contrib/tools/python3/Lib/sysconfig.py (e47ebce7ac1bd4bee3e1de149401347ac4527193)
++++ contrib/tools/python3/Lib/sysconfig.py (index)
+@@ -459,1 +459,1 @@ def _get_sysconfigdata_name():
+- f'_sysconfigdata_{sys.abiflags}_{sys.platform}_{multiarch}',
++ '_sysconfigdata_arcadia' # f'_sysconfigdata_{sys.abiflags}_{sys.platform}_{multiarch}',
diff --git a/contrib/tools/python3/patches/cut-backtrace.patch b/contrib/tools/python3/patches/cut-backtrace.patch
new file mode 100644
index 0000000000..538ce57d9c
--- /dev/null
+++ b/contrib/tools/python3/patches/cut-backtrace.patch
@@ -0,0 +1,32 @@
+commit 2f67b87b07c235c9673305da4d5530e220bc740e
+merge: 2e2af14ef0720fef44002ed5f6941f229bdd7440 a53ffec0a5bd88ef05a9a011375afa2ccaa8cd8c
+author: orivej
+date: 2019-07-06T08:14:28+03:00
+revision: 5216645
+
+ Cut importlib._bootstrap and __res.ResourceImporter.exec_module from py3 backtraces. DEVTOOLS-5630
+
+ This is controlled by _call_with_frames_removed in __res.ResourceImporter.exec_module.
+
+ REVIEW: 869507
+
+--- contrib/tools/python3/Python/import.c (2e2af14ef0720fef44002ed5f6941f229bdd7440)
++++ contrib/tools/python3/Python/import.c (2f67b87b07c235c9673305da4d5530e220bc740e)
+@@ -1478,6 +1478,7 @@ remove_importlib_frames(PyThreadState *tstate)
+ {
+ const char *importlib_filename = "<frozen importlib._bootstrap>";
+ const char *external_filename = "<frozen importlib._bootstrap_external>";
++ const char *importer_filename = "library/python/runtime_py3/importer.pxi";
+ const char *remove_frames = "_call_with_frames_removed";
+ int always_trim = 0;
+ int in_importlib = 0;
+@@ -1508,7 +1509,8 @@ remove_importlib_frames(PyThreadState *tstate)
+ int now_in_importlib;
+
+ now_in_importlib = _PyUnicode_EqualToASCIIString(code->co_filename, importlib_filename) ||
+- _PyUnicode_EqualToASCIIString(code->co_filename, external_filename);
++ _PyUnicode_EqualToASCIIString(code->co_filename, external_filename) ||
++ _PyUnicode_EqualToASCIIString(code->co_filename, importer_filename);
+ if (now_in_importlib && !in_importlib) {
+ /* This is the link to this chunk of importlib tracebacks */
+ outer_link = prev_link;
diff --git a/contrib/tools/python3/patches/disable-search-modules-on-filesystem.patch b/contrib/tools/python3/patches/disable-search-modules-on-filesystem.patch
new file mode 100644
index 0000000000..70145318b2
--- /dev/null
+++ b/contrib/tools/python3/patches/disable-search-modules-on-filesystem.patch
@@ -0,0 +1,40 @@
+commit 6d00415ed919717959a3b801d1c71fb83b6bece8
+merge: 018629609ef9f3ae6ca5b2a2b0070fba40016b32 4883f0360b567e068fcca67261df7e13ce6a4a2c
+author: orivej
+date: 2019-07-22T03:09:30+03:00
+revision: 5328556
+
+ Do not let Python 3 search modules on filesystem by default. DEVTOOLS-4574
+
+ REVIEW: 885661
+ Note: mandatory check (NEED_CHECK) was skipped
+
+--- contrib/tools/python3/Lib/site.py (018629609ef9f3ae6ca5b2a2b0070fba40016b32)
++++ contrib/tools/python3/Lib/site.py (6d00415ed919717959a3b801d1c71fb83b6bece8)
+@@ -590,17 +590,17 @@ def main():
+ global ENABLE_USER_SITE
+
+ orig_path = sys.path[:]
+- known_paths = removeduppaths()
++ #known_paths = removeduppaths()
+ if orig_path != sys.path:
+ # removeduppaths() might make sys.path absolute.
+ # fix __file__ and __cached__ of already imported modules too.
+ abs_paths()
+
+- known_paths = venv(known_paths)
++ #known_paths = venv(known_paths)
+ if ENABLE_USER_SITE is None:
+ ENABLE_USER_SITE = check_enableusersite()
+- known_paths = addusersitepackages(known_paths)
+- known_paths = addsitepackages(known_paths)
++ #known_paths = addusersitepackages(known_paths)
++ #known_paths = addsitepackages(known_paths)
+ setquit()
+ setcopyright()
+ sethelper()
+--- contrib/tools/python3/Python/sysmodule.c (018629609ef9f3ae6ca5b2a2b0070fba40016b32)
++++ contrib/tools/python3/Python/sysmodule.c (6d00415ed919717959a3b801d1c71fb83b6bece8)
+@@ -3307,1 +3307,1 @@ PySys_SetArgvEx(int argc, wchar_t **argv, int updatepath)
+- PySys_SetArgvEx(argc, argv, Py_IsolatedFlag == 0);
++ PySys_SetArgvEx(argc, argv, 0);
diff --git a/contrib/tools/python3/patches/embed-builtin-cadata.patch b/contrib/tools/python3/patches/embed-builtin-cadata.patch
new file mode 100644
index 0000000000..e260a2ff65
--- /dev/null
+++ b/contrib/tools/python3/patches/embed-builtin-cadata.patch
@@ -0,0 +1,59 @@
+commit f973b22a716935e4ceb507dd6738236570cd2b98
+merge: d4c608daaa9086189bbbb3214113edddc2082069 02c93d0cdd494ecb2b95524fd0619931975fb0cb
+author: orivej
+date: 2019-07-03T18:34:12+03:00
+revision: 5208986
+
+ Embed builtin_cadata() into ssl module. CONTRIB-1287
+
+ Fixes using ssl from python started with Y_PYTHON_ENTRY_POINT=:main.
+
+ REVIEW: 865741
+ Note: mandatory check (NEED_CHECK) was skipped
+
+commit 4a060eba5386ec1fc4b7f2d0cafffff8832cae5f
+merge: dc1ec05cf5f3db39c49ec0d03a06e14e330637f5 8277f2d7d63229e5c85ef55ba84285dd59576365
+author: orivej
+date: 2019-07-01T16:12:03+03:00
+revision: 5191643
+
+ Load certs/cacert.pem into the default Python SSL context. CONTRIB-1287
+
+ This allows to enable SSL verification in Python 2 by default.
+
+ REVIEW: 861704
+ Note: mandatory check (NEED_CHECK) was skipped
+
+--- contrib/tools/python3/Lib/ssl.py (index)
++++ contrib/tools/python3/Lib/ssl.py (working tree)
+@@ -481,6 +481,20 @@ class Purpose(_ASN1Object, _Enum):
+ CLIENT_AUTH = '1.3.6.1.5.5.7.3.2'
+
+
++_builtin_cadata = None
++
++
++def builtin_cadata():
++ global _builtin_cadata
++ if _builtin_cadata is None:
++ import __res
++ data = __res.find(b'/builtin/cacert')
++ # load_verify_locations expects PEM cadata to be an ASCII-only unicode
++ # object, so we discard unicode in comments.
++ _builtin_cadata = data.decode('ASCII', errors='ignore')
++ return _builtin_cadata
++
++
+ class SSLContext(_SSLContext):
+ """An SSLContext holds various SSL-related configuration options and
+ data, such as certificates and possibly a private key."""
+@@ -591,6 +605,9 @@ class SSLContext(_SSLContext):
+ def load_default_certs(self, purpose=Purpose.SERVER_AUTH):
+ if not isinstance(purpose, _ASN1Object):
+ raise TypeError(purpose)
++
++ self.load_verify_locations(cadata=builtin_cadata())
++
+ if sys.platform == "win32":
+ for storename in self._windows_cert_stores:
+ self._load_windows_store_certs(storename, purpose)
diff --git a/contrib/tools/python3/patches/fix-addr2line.patch b/contrib/tools/python3/patches/fix-addr2line.patch
new file mode 100644
index 0000000000..af66f6da03
--- /dev/null
+++ b/contrib/tools/python3/patches/fix-addr2line.patch
@@ -0,0 +1,11 @@
+--- contrib/tools/python3/Objects/codeobject.c (index)
++++ contrib/tools/python3/Objects/codeobject.c (working tree)
+@@ -768,7 +768,7 @@ PyCode_Addr2Line(PyCodeObject *co, int addrq)
+ if (addrq < 0) {
+ return co->co_firstlineno;
+ }
+- assert(addrq >= 0 && addrq < _PyCode_NBYTES(co));
++ assert(addrq >= 0 && addrq <= _PyCode_NBYTES(co));
+ PyCodeAddressRange bounds;
+ _PyCode_InitAddressRange(co, &bounds);
+ return _PyCode_CheckLineNumber(addrq, &bounds);
diff --git a/contrib/tools/python3/patches/fix-blake2.patch b/contrib/tools/python3/patches/fix-blake2.patch
new file mode 100644
index 0000000000..aa5a458722
--- /dev/null
+++ b/contrib/tools/python3/patches/fix-blake2.patch
@@ -0,0 +1,11 @@
+--- contrib/tools/python3/Modules/_blake2/blake2module.h (index)
++++ contrib/tools/python3/Modules/_blake2/blake2module.h (working tree)
+@@ -2,7 +2,7 @@
+ #define Py_BLAKE2MODULE_H
+
+ #ifdef HAVE_LIBB2
+-#include <blake2.h>
++#error #include <blake2.h>
+
+ #else
+ // use vendored copy of blake2
diff --git a/contrib/tools/python3/patches/fix-build.patch b/contrib/tools/python3/patches/fix-build.patch
new file mode 100644
index 0000000000..573eebb467
--- /dev/null
+++ b/contrib/tools/python3/patches/fix-build.patch
@@ -0,0 +1,17 @@
+commit 9b726d183d9b023f472f788f4e87136eaee3edf8
+author: shadchin
+date: 2023-01-09T20:49:50+03:00
+
+ Fix devtools/dummy_arcadia/test/system_python
+
+--- contrib/tools/python3/Include/cpython/pythread.h (a09217b707768f106bfed2d616636b38cfce2f13)
++++ contrib/tools/python3/Include/cpython/pythread.h (9b726d183d9b023f472f788f4e87136eaee3edf8)
+@@ -21,7 +21,7 @@ PyAPI_FUNC(int) _PyThread_at_fork_reinit(PyThread_type_lock *lock);
+ */
+ # define NATIVE_TSS_KEY_T unsigned long
+ #elif defined(HAVE_PTHREAD_STUBS)
+-# include "cpython/pthread_stubs.h"
++#error # include "cpython/pthread_stubs.h"
+ # define NATIVE_TSS_KEY_T pthread_key_t
+ #else
+ # error "Require native threads. See https://bugs.python.org/issue31370"
diff --git a/contrib/tools/python3/patches/fix-ctypes.patch b/contrib/tools/python3/patches/fix-ctypes.patch
new file mode 100644
index 0000000000..4c8417e14e
--- /dev/null
+++ b/contrib/tools/python3/patches/fix-ctypes.patch
@@ -0,0 +1,11 @@
+--- contrib/tools/python3/Lib/ctypes/__init__.py (index)
++++ contrib/tools/python3/Lib/ctypes/__init__.py (working tree)
+@@ -345,7 +345,7 @@ class CDLL(object):
+ use_errno=False,
+ use_last_error=False,
+ winmode=None):
+- if name:
++ if name and not isinstance(name, dict):
+ name = _os.fspath(name)
+ self._name = name
+ flags = self._func_flags_
diff --git a/contrib/tools/python3/patches/fix-gettext.patch b/contrib/tools/python3/patches/fix-gettext.patch
new file mode 100644
index 0000000000..9815bbfb3c
--- /dev/null
+++ b/contrib/tools/python3/patches/fix-gettext.patch
@@ -0,0 +1,52 @@
+commit 6df9d7282117d14575cba802978b635e0661ce0d
+merge: c7e3ec07a5a75dde4da2c0954eae709906150ee7 56e45ed36ba8ee900952583c2c47040314676f6a
+author: orlovgb
+date: 2019-08-28T21:12:31+03:00
+revision: 5552086
+
+ fix py3 gettext to use resorces from __res
+
+ Скопипастил с https://a.yandex-team.ru/arc/trunk/arcadia/contrib/tools/python/Lib/gettext.py
+ Дописал, чтобы в resfs_src и resfs_read уходила байтовая строка
+
+ REVIEW: 930161
+
+--- contrib/tools/python3/Lib/gettext.py (c7e3ec07a5a75dde4da2c0954eae709906150ee7)
++++ contrib/tools/python3/Lib/gettext.py (6df9d7282117d14575cba802978b635e0661ce0d)
+@@ -49,7 +49,12 @@ import locale
+ import os
+ import re
+ import sys
++import io
+
++try:
++ import __res
++except ImportError:
++ __res = None
+
+ __all__ = ['NullTranslations', 'GNUTranslations', 'Catalog',
+ 'bindtextdomain', 'find', 'translation', 'install',
+@@ -492,7 +497,7 @@ def find(domain, localedir=None, languages=None, all=False):
+ if lang == 'C':
+ break
+ mofile = os.path.join(localedir, lang, 'LC_MESSAGES', '%s.mo' % domain)
+- if os.path.exists(mofile):
++ if __res and __res.resfs_src(mofile.encode('utf-8'), resfs_file=True) or os.path.exists(mofile):
+ if all:
+ result.append(mofile)
+ else:
+@@ -522,8 +527,12 @@ def translation(domain, localedir=None, languages=None,
+ key = (class_, os.path.abspath(mofile))
+ t = _translations.get(key)
+ if t is None:
+- with open(mofile, 'rb') as fp:
+- t = _translations.setdefault(key, class_(fp))
++ mores = __res and __res.resfs_read(mofile.encode('utf-8'))
++ if mores:
++ t = _translations.setdefault(key, class_(io.BytesIO(mores)))
++ else:
++ with open(mofile, 'rb') as fp:
++ t = _translations.setdefault(key, class_(fp))
+ # Copy the translation object to allow setting fallbacks and
+ # output charset. All other instance data is shared with the
+ # cached object.
diff --git a/contrib/tools/python3/patches/fix-msan-for-pydantic-2.patch b/contrib/tools/python3/patches/fix-msan-for-pydantic-2.patch
new file mode 100644
index 0000000000..c6893ffe3c
--- /dev/null
+++ b/contrib/tools/python3/patches/fix-msan-for-pydantic-2.patch
@@ -0,0 +1,90 @@
+commit c6da6f130038532c120beefe89fcbab987434d66
+author: serjflint
+committer: shadchin
+date: 2023-12-29T07:22:46+03:00
+
+ fix msan
+
+--- contrib/tools/python3/Objects/capsule.c (66e7c1ee23780a1434d1b4140c654a63ccd65503)
++++ contrib/tools/python3/Objects/capsule.c (c6da6f130038532c120beefe89fcbab987434d66)
+@@ -197,6 +197,11 @@ PyCapsule_Import(const char *name, int no_block)
+ PyObject *object = NULL;
+ void *return_value = NULL;
+ char *trace;
++#if defined(__has_feature)
++# if __has_feature(memory_sanitizer)
++ __msan_unpoison_string(name);
++# endif
++#endif
+ size_t name_length = (strlen(name) + 1) * sizeof(char);
+ char *name_dup = (char *)PyMem_Malloc(name_length);
+
+--- contrib/tools/python3/Objects/typeobject.c (66e7c1ee23780a1434d1b4140c654a63ccd65503)
++++ contrib/tools/python3/Objects/typeobject.c (c6da6f130038532c120beefe89fcbab987434d66)
+@@ -4140,6 +4140,11 @@ _PyType_FromMetaclass_impl(
+ tp_doc = NULL;
+ }
+ else {
++#if defined(__has_feature)
++# if __has_feature(memory_sanitizer)
++ __msan_unpoison_string(slot->pfunc);
++# endif
++#endif
+ size_t len = strlen(slot->pfunc)+1;
+ tp_doc = PyObject_Malloc(len);
+ if (tp_doc == NULL) {
+@@ -4160,6 +4165,12 @@ _PyType_FromMetaclass_impl(
+ goto finally;
+ }
+
++
++#if defined(__has_feature)
++# if __has_feature(memory_sanitizer)
++ __msan_unpoison_string(spec->name);
++# endif
++#endif
+ const char *s = strrchr(spec->name, '.');
+ if (s == NULL) {
+ s = spec->name;
+--- contrib/tools/python3/Objects/unicodeobject.c (66e7c1ee23780a1434d1b4140c654a63ccd65503)
++++ contrib/tools/python3/Objects/unicodeobject.c (c6da6f130038532c120beefe89fcbab987434d66)
+@@ -2269,6 +2269,11 @@ PyUnicode_FromStringAndSize(const char *u, Py_ssize_t size)
+ PyObject *
+ PyUnicode_FromString(const char *u)
+ {
++#if defined(__has_feature)
++# if __has_feature(memory_sanitizer)
++ __msan_unpoison_string(u);
++# endif
++#endif
+ size_t size = strlen(u);
+ if (size > PY_SSIZE_T_MAX) {
+ PyErr_SetString(PyExc_OverflowError, "input too long");
+--- contrib/tools/python3/Parser/tokenizer.c (index)
++++ contrib/tools/python3/Parser/tokenizer.c (working tree)
+@@ -823,6 +823,11 @@ static char *
+ static char *translate_newlines(const char *s, int exec_input,
+ int preserve_crlf, struct tok_state *tok) {
+ int skip_next_lf = 0;
++#if defined(__has_feature)
++# if __has_feature(memory_sanitizer)
++ __msan_unpoison_string(s);
++# endif
++#endif
+ size_t needed_length = strlen(s) + 2, final_length;
+ char *buf, *current;
+ char c = '\0';
+--- contrib/tools/python3/Python/errors.c (66e7c1ee23780a1434d1b4140c654a63ccd65503)
++++ contrib/tools/python3/Python/errors.c (c6da6f130038532c120beefe89fcbab987434d66)
+@@ -1161,6 +1161,11 @@ PyErr_NewException(const char *name, PyObject *base, PyObject *dict)
+ PyObject *bases = NULL;
+ PyObject *result = NULL;
+
++#if defined(__has_feature)
++# if __has_feature(memory_sanitizer)
++ __msan_unpoison_string(name);
++# endif
++#endif
+ const char *dot = strrchr(name, '.');
+ if (dot == NULL) {
+ _PyErr_SetString(tstate, PyExc_SystemError,
diff --git a/contrib/tools/python3/patches/fix-segfault-with-pydebug.patch b/contrib/tools/python3/patches/fix-segfault-with-pydebug.patch
new file mode 100644
index 0000000000..3f6dd1c470
--- /dev/null
+++ b/contrib/tools/python3/patches/fix-segfault-with-pydebug.patch
@@ -0,0 +1,20 @@
+commit fc804aedfe1e844aaed4aa196830ca057f89361c (HEAD)
+author: shadchin
+date: 2024-02-07T11:13:39+03:00
+
+ Fix segfault
+
+--- contrib/tools/python3/Python/pystate.c (bacb745829a9c01a81284c346946097c868084e0)
++++ contrib/tools/python3/Python/pystate.c (fc804aedfe1e844aaed4aa196830ca057f89361c)
+@@ -354,6 +354,11 @@ holds_gil(PyThreadState *tstate)
+ // XXX Fall back to tstate->interp->runtime->ceval.gil.last_holder
+ // (and tstate->interp->runtime->ceval.gil.locked).
+ assert(tstate != NULL);
++#ifndef NDEBUG
++ if (!tstate_is_alive(tstate)) {
++ return PyGILState_Check();
++ }
++#endif
+ _PyRuntimeState *runtime = tstate->interp->runtime;
+ /* Must be the tstate for this thread */
+ assert(tstate == gilstate_tss_get(runtime));
diff --git a/contrib/tools/python3/patches/fix-traceback.patch b/contrib/tools/python3/patches/fix-traceback.patch
new file mode 100644
index 0000000000..03df3b52a0
--- /dev/null
+++ b/contrib/tools/python3/patches/fix-traceback.patch
@@ -0,0 +1,32 @@
+commit 8a9d74e955c9e66e23ca423181d6b4f3b2f35234
+merge: 69071b279955ab8dd08fad10b2540b9f6bae2825 efd33904df73f0175583058fedc0d7234cac6b45
+author: orivej
+date: 2019-07-06T14:14:55+03:00
+revision: 5216942
+
+ Fix tracebacks in py2 import_test and do not read builtin source from FS. DEVTOOLS-5629
+
+ REVIEW: 869505
+ Note: mandatory check (NEED_CHECK) was skipped
+
+--- contrib/tools/python3/Lib/linecache.py (69071b279955ab8dd08fad10b2540b9f6bae2825)
++++ contrib/tools/python3/Lib/linecache.py (8a9d74e955c9e66e23ca423181d6b4f3b2f35234)
+@@ -88,6 +88,18 @@ def updatecache(filename, module_globals=None):
+ if not filename or (filename.startswith('<') and filename.endswith('>')):
+ return []
+
++ if not os.path.isabs(filename):
++ # Do not read builtin code from the filesystem.
++ import __res
++
++ key = __res.py_src_key(filename)
++ if data := __res.resfs_read(key):
++ assert data is not None, filename
++ data = data.decode('UTF-8')
++ lines = [line + '\n' for line in data.splitlines()]
++ cache[filename] = (len(data), None, lines, filename)
++ return cache[filename][2]
++
+ fullname = filename
+ try:
+ stat = os.stat(fullname)
diff --git a/contrib/tools/python3/patches/fix-ubuntu-20.patch b/contrib/tools/python3/patches/fix-ubuntu-20.patch
new file mode 100644
index 0000000000..5917869d93
--- /dev/null
+++ b/contrib/tools/python3/patches/fix-ubuntu-20.patch
@@ -0,0 +1,26 @@
+commit 327e85a6f8e93f45bc8e7912eb2f66546ce3d840
+merge: bc4798e932a2fef2882b465be6e88bf5072bcdfa 74cd5597376b47de689f5f5b5c6ac641cb230aba
+author: thegeorg
+date: 2021-09-18T01:17:41+03:00
+revision: 8642929
+
+ Make python3 compile under ubuntu-20
+
+ `stropts.h` выпилили из libc6 из ubuntu-20. Сломалась компиляция двух файлов: `fcntlmodule.c` и `posixmodule.c`.
+
+ В первом правок не потребовалось, во втором добавил недостающий `#define I_PUSH` через `#ifdef` (скопировал значение из старой libc).
+
+ REVIEW: 2025707
+
+--- contrib/tools/python3/Modules/posixmodule.c (bc4798e932a2fef2882b465be6e88bf5072bcdfa)
++++ contrib/tools/python3/Modules/posixmodule.c (327e85a6f8e93f45bc8e7912eb2f66546ce3d840)
+@@ -7289,6 +7289,9 @@ error:
+ #endif /* HAVE_PTY_H */
+ #ifdef HAVE_STROPTS_H
+ #include <stropts.h>
++#else
++ #define __SID ('S' << 8)
++ #define I_PUSH (__SID | 2)
+ #endif
+ #endif /* defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) || defined(HAVE_LOGIN_TTY) || defined(HAVE_DEV_PTMX) */
+
diff --git a/contrib/tools/python3/patches/pr115350-win-lean-and-mean.patch b/contrib/tools/python3/patches/pr115350-win-lean-and-mean.patch
new file mode 100644
index 0000000000..1a32028b7a
--- /dev/null
+++ b/contrib/tools/python3/patches/pr115350-win-lean-and-mean.patch
@@ -0,0 +1,24 @@
+From 5114e70b87cda3644f689026265797ec68a345eb Mon Sep 17 00:00:00 2001
+From: Yuriy Chernyshov <thegeorg@yandex-team.com>
+Date: Mon, 12 Feb 2024 16:52:32 +0100
+Subject: [PATCH 1/2] Add missing #include <Unknwn.h> on Windows
+
+---
+ Modules/_ctypes/ctypes.h | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/Modules/_ctypes/ctypes.h b/Modules/_ctypes/ctypes.h
+index 1989723f6f3dbb..02f48a9ed55843 100644
+--- a/Modules/_ctypes/ctypes.h
++++ b/Modules/_ctypes/ctypes.h
+@@ -32,6 +32,10 @@
+ #endif
+ #endif
+
++#ifdef MS_WIN32
++#include <Unknwn.h> // for IUnknown interface
++#endif
++
+ typedef struct {
+ PyTypeObject *DictRemover_Type;
+ PyTypeObject *PyCArg_Type;
diff --git a/contrib/tools/python3/patches/reduce-pydebug-2.patch b/contrib/tools/python3/patches/reduce-pydebug-2.patch
new file mode 100644
index 0000000000..0316bc20fb
--- /dev/null
+++ b/contrib/tools/python3/patches/reduce-pydebug-2.patch
@@ -0,0 +1,11 @@
+--- contrib/tools/python3/Include/cpython/pystate.h (index)
++++ contrib/tools/python3/Include/cpython/pystate.h (working tree)
+@@ -255,7 +255,7 @@ struct _ts {
+ # if defined(__wasi__)
+ # define C_RECURSION_LIMIT 150
+ # else
+-# define C_RECURSION_LIMIT 500
++# define C_RECURSION_LIMIT 1500
+ # endif
+ #else
+ # if defined(__wasi__)
diff --git a/contrib/tools/python3/patches/reduce-pydebug.patch b/contrib/tools/python3/patches/reduce-pydebug.patch
new file mode 100644
index 0000000000..6ad8ac1f3d
--- /dev/null
+++ b/contrib/tools/python3/patches/reduce-pydebug.patch
@@ -0,0 +1,16 @@
+ YT-18818: Disable GC_DEBUG in relwithdebinfo mode
+
+ REVIEW: 3716232
+--- contrib/tools/python3/Modules/gcmodule.c (11f41021041cc1f16e346fd25bc37037b47700ea)
++++ contrib/tools/python3/Modules/gcmodule.c (32de4cb7380e0b1efe00e6abf514e690933e781c)
+@@ -41,7 +41,9 @@ module gc
+
+
+ #ifdef Py_DEBUG
+-# define GC_DEBUG
++# ifndef GC_NDEBUG
++# define GC_DEBUG
++# endif
+ #endif
+
+ #define GC_NEXT _PyGCHead_NEXT
diff --git a/contrib/tools/python3/patches/reduce-ssl-requirements.patch b/contrib/tools/python3/patches/reduce-ssl-requirements.patch
new file mode 100644
index 0000000000..bd450d114c
--- /dev/null
+++ b/contrib/tools/python3/patches/reduce-ssl-requirements.patch
@@ -0,0 +1,17 @@
+commit b8e049facd44969b04f6348de63384686e4c924e
+author: shadchin
+date: 2022-03-24T17:42:39+03:00
+
+ Reduce ssl requirements
+
+--- contrib/tools/python3/Modules/_ssl.c (7d5969ad8d55d9636131a4f1567d36a4b8afb5b7)
++++ contrib/tools/python3/Modules/_ssl.c (b8e049facd44969b04f6348de63384686e4c924e)
+@@ -171,7 +171,7 @@ extern const SSL_METHOD *TLSv1_2_method(void);
+ * Based on Hynek's excellent blog post (update 2021-02-11)
+ * https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
+ */
+- #define PY_SSL_DEFAULT_CIPHER_STRING "@SECLEVEL=2:ECDH+AESGCM:ECDH+CHACHA20:ECDH+AES:DHE+AES:!aNULL:!eNULL:!aDSS:!SHA1:!AESCCM"
++ #define PY_SSL_DEFAULT_CIPHER_STRING "DEFAULT:ECDH+AESGCM:ECDH+CHACHA20:ECDH+AES:DHE+AES:!aNULL:!eNULL:!aDSS:!SHA1:!AESCCM"
+ #ifndef PY_SSL_MIN_PROTOCOL
+ #define PY_SSL_MIN_PROTOCOL TLS1_2_VERSION
+ #endif