diff options
author | AlexSm <alex@ydb.tech> | 2024-01-04 15:09:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-04 15:09:05 +0100 |
commit | dab291146f6cd7d35684e3a1150e5bb1c412982c (patch) | |
tree | 36ef35f6cacb6432845a4a33f940c95871036b32 /contrib/tools | |
parent | 63660ad5e7512029fd0218e7a636580695a24e1f (diff) | |
download | ydb-dab291146f6cd7d35684e3a1150e5bb1c412982c.tar.gz |
Library import 5, delete go dependencies (#832)
* Library import 5, delete go dependencies
* Fix yt client
Diffstat (limited to 'contrib/tools')
-rw-r--r-- | contrib/tools/cython/Cython/Compiler/TypeSlots.py | 1 | ||||
-rw-r--r-- | contrib/tools/cython/Cython/Utility/Profile.c | 12 | ||||
-rw-r--r-- | contrib/tools/cython/patches/fix-warning.patch | 10 | ||||
-rw-r--r-- | contrib/tools/cython/patches/pr5450-support-python-3.12.patch | 43 | ||||
-rw-r--r-- | contrib/tools/python/src/Modules/socketmodule.c | 15 | ||||
-rw-r--r-- | contrib/tools/python3/src/Modules/socketmodule.c | 10 | ||||
-rw-r--r-- | contrib/tools/python3/src/Objects/capsule.c | 5 | ||||
-rw-r--r-- | contrib/tools/python3/src/Objects/typeobject.c | 10 | ||||
-rw-r--r-- | contrib/tools/python3/src/Objects/unicodeobject.c | 5 | ||||
-rw-r--r-- | contrib/tools/python3/src/PC/dl_nt.c | 36 | ||||
-rw-r--r-- | contrib/tools/python3/src/PC/frozen_dllmain.c | 134 | ||||
-rw-r--r-- | contrib/tools/python3/src/Parser/tokenizer.c | 5 | ||||
-rw-r--r-- | contrib/tools/python3/src/Python/errors.c | 5 | ||||
-rw-r--r-- | contrib/tools/python3/src/Python/frozenmain.c | 85 | ||||
-rw-r--r-- | contrib/tools/python3/src/ya.make | 3 |
15 files changed, 97 insertions, 282 deletions
diff --git a/contrib/tools/cython/Cython/Compiler/TypeSlots.py b/contrib/tools/cython/Cython/Compiler/TypeSlots.py index 0ef17ede63..fe07e4a146 100644 --- a/contrib/tools/cython/Cython/Compiler/TypeSlots.py +++ b/contrib/tools/cython/Cython/Compiler/TypeSlots.py @@ -905,6 +905,7 @@ slot_table = ( EmptySlot("tp_finalize", ifdef="PY_VERSION_HEX >= 0x030400a1"), EmptySlot("tp_vectorcall", ifdef="PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)"), EmptySlot("tp_print", ifdef="PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000"), + EmptySlot("tp_watched", ifdef="PY_VERSION_HEX >= 0x030C0000"), # PyPy specific extension - only here to avoid C compiler warnings. EmptySlot("tp_pypy_flags", ifdef="CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000"), ) diff --git a/contrib/tools/cython/Cython/Utility/Profile.c b/contrib/tools/cython/Cython/Utility/Profile.c index a0ab1fa989..56ba4900a6 100644 --- a/contrib/tools/cython/Cython/Utility/Profile.c +++ b/contrib/tools/cython/Cython/Utility/Profile.c @@ -61,15 +61,21 @@ #define __Pyx_TraceFrameInit(codeobj) \ if (codeobj) $frame_code_cname = (PyCodeObject*) codeobj; + #if PY_VERSION_HEX >= 0x030b00a2 + #if PY_VERSION_HEX >= 0x030c00b1 + #define __Pyx_IsTracing(tstate, check_tracing, check_funcs) \ + ((!(check_tracing) || !(tstate)->tracing) && \ + (!(check_funcs) || (tstate)->c_profilefunc || (CYTHON_TRACE && (tstate)->c_tracefunc))) + #else #define __Pyx_IsTracing(tstate, check_tracing, check_funcs) \ (unlikely((tstate)->cframe->use_tracing) && \ (!(check_tracing) || !(tstate)->tracing) && \ (!(check_funcs) || (tstate)->c_profilefunc || (CYTHON_TRACE && (tstate)->c_tracefunc))) + #endif - #define __Pyx_EnterTracing(tstate) PyThreadState_EnterTracing(tstate) - - #define __Pyx_LeaveTracing(tstate) PyThreadState_LeaveTracing(tstate) + #define __Pyx_EnterTracing(tstate) PyThreadState_EnterTracing(tstate) + #define __Pyx_LeaveTracing(tstate) PyThreadState_LeaveTracing(tstate) #elif PY_VERSION_HEX >= 0x030a00b1 #define __Pyx_IsTracing(tstate, check_tracing, check_funcs) \ diff --git a/contrib/tools/cython/patches/fix-warning.patch b/contrib/tools/cython/patches/fix-warning.patch new file mode 100644 index 0000000000..ce9fee09c4 --- /dev/null +++ b/contrib/tools/cython/patches/fix-warning.patch @@ -0,0 +1,10 @@ +--- contrib/tools/cython/Cython/Compiler/TypeSlots.py (3fd698c83ff9f2a6d3e547d212fa364ce1cc0385) ++++ contrib/tools/cython/Cython/Compiler/TypeSlots.py (b4949f970eee8c854300ccfb54870046111161d3) +@@ -905,6 +905,7 @@ slot_table = ( + EmptySlot("tp_finalize", ifdef="PY_VERSION_HEX >= 0x030400a1"), + EmptySlot("tp_vectorcall", ifdef="PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)"), + EmptySlot("tp_print", ifdef="PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000"), ++ EmptySlot("tp_watched", ifdef="PY_VERSION_HEX >= 0x030C0000"), + # PyPy specific extension - only here to avoid C compiler warnings. + EmptySlot("tp_pypy_flags", ifdef="CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000"), + ) diff --git a/contrib/tools/cython/patches/pr5450-support-python-3.12.patch b/contrib/tools/cython/patches/pr5450-support-python-3.12.patch new file mode 100644 index 0000000000..b1f703fd75 --- /dev/null +++ b/contrib/tools/cython/patches/pr5450-support-python-3.12.patch @@ -0,0 +1,43 @@ +From 03c498d3142ccee2da258c540e96f12c863159fc Mon Sep 17 00:00:00 2001 +From: Stefan Behnel <stefan_ml@behnel.de> +Date: Mon, 29 May 2023 22:08:50 +0200 +Subject: [PATCH] Avoid using the thread state attribute "use_tracing" in + Python 3.12 where it was removed from the struct. + +See PEP-669 (https://peps.python.org/pep-0669/) and the implementation in https://github.com/python/cpython/pull/103083. +There is more to be done to properly support PEP-669, but this makes it compile. + +See https://github.com/cython/cython/issues/5450 +--- + Cython/Utility/Profile.c | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +diff --git a/Cython/Utility/Profile.c b/Cython/Utility/Profile.c +index 20b599e7979..2b8564b226f 100644 +--- a/Cython/Utility/Profile.c ++++ b/Cython/Utility/Profile.c +@@ -61,15 +61,21 @@ + #define __Pyx_TraceFrameInit(codeobj) \ + if (codeobj) $frame_code_cname = (PyCodeObject*) codeobj; + ++ + #if PY_VERSION_HEX >= 0x030b00a2 ++ #if PY_VERSION_HEX >= 0x030c00b1 ++ #define __Pyx_IsTracing(tstate, check_tracing, check_funcs) \ ++ ((!(check_tracing) || !(tstate)->tracing) && \ ++ (!(check_funcs) || (tstate)->c_profilefunc || (CYTHON_TRACE && (tstate)->c_tracefunc))) ++ #else + #define __Pyx_IsTracing(tstate, check_tracing, check_funcs) \ + (unlikely((tstate)->cframe->use_tracing) && \ + (!(check_tracing) || !(tstate)->tracing) && \ + (!(check_funcs) || (tstate)->c_profilefunc || (CYTHON_TRACE && (tstate)->c_tracefunc))) ++ #endif + +- #define __Pyx_EnterTracing(tstate) PyThreadState_EnterTracing(tstate) +- +- #define __Pyx_LeaveTracing(tstate) PyThreadState_LeaveTracing(tstate) ++ #define __Pyx_EnterTracing(tstate) PyThreadState_EnterTracing(tstate) ++ #define __Pyx_LeaveTracing(tstate) PyThreadState_LeaveTracing(tstate) + + #elif PY_VERSION_HEX >= 0x030a00b1 + #define __Pyx_IsTracing(tstate, check_tracing, check_funcs) \ diff --git a/contrib/tools/python/src/Modules/socketmodule.c b/contrib/tools/python/src/Modules/socketmodule.c index 5036325643..013975455c 100644 --- a/contrib/tools/python/src/Modules/socketmodule.c +++ b/contrib/tools/python/src/Modules/socketmodule.c @@ -81,13 +81,6 @@ Local naming conventions: */ -#include <stdbool.h> -bool IsReusePortAvailable(); - -#ifndef SO_REUSEPORT -#define SO_REUSEPORT 15 -#endif - #ifdef __APPLE__ #include <AvailabilityMacros.h> /* for getaddrinfo thread safety test on old versions of OS X */ @@ -4942,11 +4935,9 @@ init_socket(void) #ifdef SO_OOBINLINE PyModule_AddIntConstant(m, "SO_OOBINLINE", SO_OOBINLINE); #endif - - if (IsReusePortAvailable()) { - PyModule_AddIntConstant(m, "SO_REUSEPORT", SO_REUSEPORT); - } - +#ifdef SO_REUSEPORT + PyModule_AddIntConstant(m, "SO_REUSEPORT", SO_REUSEPORT); +#endif #ifdef SO_SNDBUF PyModule_AddIntConstant(m, "SO_SNDBUF", SO_SNDBUF); #endif diff --git a/contrib/tools/python3/src/Modules/socketmodule.c b/contrib/tools/python3/src/Modules/socketmodule.c index 5089a88444..997df43f20 100644 --- a/contrib/tools/python3/src/Modules/socketmodule.c +++ b/contrib/tools/python3/src/Modules/socketmodule.c @@ -85,13 +85,6 @@ Local naming conventions: */ -#include <stdbool.h> -bool IsReusePortAvailable(); - -#if !defined(SO_REUSEPORT) && defined(__linux__) -#define SO_REUSEPORT 15 -#endif - #ifndef Py_BUILD_CORE_BUILTIN # define Py_BUILD_CORE_MODULE 1 #endif @@ -7669,8 +7662,7 @@ PyInit__socket(void) #endif #ifndef __GNU__ #ifdef SO_REUSEPORT - if (IsReusePortAvailable()) - PyModule_AddIntMacro(m, SO_REUSEPORT); + PyModule_AddIntMacro(m, SO_REUSEPORT); #endif #endif #ifdef SO_SNDBUF diff --git a/contrib/tools/python3/src/Objects/capsule.c b/contrib/tools/python3/src/Objects/capsule.c index 606e50e696..e4c3c6b4be 100644 --- a/contrib/tools/python3/src/Objects/capsule.c +++ b/contrib/tools/python3/src/Objects/capsule.c @@ -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); diff --git a/contrib/tools/python3/src/Objects/typeobject.c b/contrib/tools/python3/src/Objects/typeobject.c index 8c2e725cac..983adee873 100644 --- a/contrib/tools/python3/src/Objects/typeobject.c +++ b/contrib/tools/python3/src/Objects/typeobject.c @@ -3421,6 +3421,11 @@ PyType_FromModuleAndSpec(PyObject *module, PyType_Spec *spec, PyObject *bases) type->tp_flags = spec->flags | Py_TPFLAGS_HEAPTYPE; /* Set the type name and qualname */ +#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; @@ -3531,6 +3536,11 @@ PyType_FromModuleAndSpec(PyObject *module, PyType_Spec *spec, PyObject *bases) type->tp_doc = NULL; continue; } +#if defined(__has_feature) +# if __has_feature(memory_sanitizer) + __msan_unpoison_string(slot->pfunc); +# endif +#endif size_t len = strlen(slot->pfunc)+1; char *tp_doc = PyObject_Malloc(len); if (tp_doc == NULL) { diff --git a/contrib/tools/python3/src/Objects/unicodeobject.c b/contrib/tools/python3/src/Objects/unicodeobject.c index c27fc009c5..0e3e6ccd1b 100644 --- a/contrib/tools/python3/src/Objects/unicodeobject.c +++ b/contrib/tools/python3/src/Objects/unicodeobject.c @@ -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"); diff --git a/contrib/tools/python3/src/PC/dl_nt.c b/contrib/tools/python3/src/PC/dl_nt.c deleted file mode 100644 index 7f17ee1687..0000000000 --- a/contrib/tools/python3/src/PC/dl_nt.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - -Entry point for the Windows NT DLL. - -About the only reason for having this, is so initall() can automatically -be called, removing that burden (and possible source of frustration if -forgotten) from the programmer. - -*/ - -#include "Python.h" -#include "windows.h" - -#ifdef Py_ENABLE_SHARED - -// Python Globals -HMODULE PyWin_DLLhModule = NULL; -const char *PyWin_DLLVersionString = MS_DLL_ID; - -BOOL WINAPI DllMain (HANDLE hInst, - ULONG ul_reason_for_call, - LPVOID lpReserved) -{ - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - PyWin_DLLhModule = hInst; - break; - - case DLL_PROCESS_DETACH: - break; - } - return TRUE; -} - -#endif /* Py_ENABLE_SHARED */ diff --git a/contrib/tools/python3/src/PC/frozen_dllmain.c b/contrib/tools/python3/src/PC/frozen_dllmain.c deleted file mode 100644 index 0156c5008b..0000000000 --- a/contrib/tools/python3/src/PC/frozen_dllmain.c +++ /dev/null @@ -1,134 +0,0 @@ -/* FreezeDLLMain.cpp - -This is a DLLMain suitable for frozen applications/DLLs on -a Windows platform. - -The general problem is that many Python extension modules may define -DLL main functions, but when statically linked together to form -a frozen application, this DLLMain symbol exists multiple times. - -The solution is: -* Each module checks for a frozen build, and if so, defines its DLLMain - function as "__declspec(dllexport) DllMain%module%" - (eg, DllMainpythoncom, or DllMainpywintypes) - -* The frozen .EXE/.DLL links against this module, which provides - the single DllMain. - -* This DllMain attempts to locate and call the DllMain for each - of the extension modules. - -* This code also has hooks to "simulate" DllMain when used from - a frozen .EXE. - -At this stage, there is a static table of "possibly embedded modules". -This should change to something better, but it will work OK for now. - -Note that this scheme does not handle dependencies in the order -of DllMain calls - except it does call pywintypes first :-) - -As an example of how an extension module with a DllMain should be -changed, here is a snippet from the pythoncom extension module. - - // end of example code from pythoncom's DllMain.cpp - #ifndef BUILD_FREEZE - #define DLLMAIN DllMain - #define DLLMAIN_DECL - #else - #define DLLMAIN DllMainpythoncom - #define DLLMAIN_DECL __declspec(dllexport) - #endif - - extern "C" DLLMAIN_DECL - BOOL WINAPI DLLMAIN(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) - // end of example code from pythoncom's DllMain.cpp - -***************************************************************************/ -#include "windows.h" - -static char *possibleModules[] = { - "pywintypes", - "pythoncom", - "win32ui", - NULL, -}; - -BOOL CallModuleDllMain(char *modName, DWORD dwReason); - - -/* - Called by a frozen .EXE only, so that built-in extension - modules are initialized correctly -*/ -void PyWinFreeze_ExeInit(void) -{ - char **modName; - for (modName = possibleModules;*modName;*modName++) { -/* printf("Initialising '%s'\n", *modName); */ - CallModuleDllMain(*modName, DLL_PROCESS_ATTACH); - } -} - -/* - Called by a frozen .EXE only, so that built-in extension - modules are cleaned up -*/ -void PyWinFreeze_ExeTerm(void) -{ - // Must go backwards - char **modName; - for (modName = possibleModules+Py_ARRAY_LENGTH(possibleModules)-2; - modName >= possibleModules; - *modName--) { -/* printf("Terminating '%s'\n", *modName);*/ - CallModuleDllMain(*modName, DLL_PROCESS_DETACH); - } -} - -BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) -{ - BOOL ret = TRUE; - switch (dwReason) { - case DLL_PROCESS_ATTACH: - { - char **modName; - for (modName = possibleModules;*modName;*modName++) { - BOOL ok = CallModuleDllMain(*modName, dwReason); - if (!ok) - ret = FALSE; - } - break; - } - case DLL_PROCESS_DETACH: - { - // Must go backwards - char **modName; - for (modName = possibleModules+Py_ARRAY_LENGTH(possibleModules)-2; - modName >= possibleModules; - *modName--) - CallModuleDllMain(*modName, DLL_PROCESS_DETACH); - break; - } - } - return ret; -} - -BOOL CallModuleDllMain(char *modName, DWORD dwReason) -{ - BOOL (WINAPI * pfndllmain)(HINSTANCE, DWORD, LPVOID); - - char funcName[255]; - HMODULE hmod = GetModuleHandleW(NULL); - strcpy(funcName, "_DllMain"); - strcat(funcName, modName); - strcat(funcName, "@12"); // stdcall convention. - pfndllmain = (BOOL (WINAPI *)(HINSTANCE, DWORD, LPVOID))GetProcAddress(hmod, funcName); - if (pfndllmain==NULL) { - /* No function by that name exported - then that module does - not appear in our frozen program - return OK - */ - return TRUE; - } - return (*pfndllmain)(hmod, dwReason, NULL); -} - diff --git a/contrib/tools/python3/src/Parser/tokenizer.c b/contrib/tools/python3/src/Parser/tokenizer.c index 566ad8dfa0..4bc72ae444 100644 --- a/contrib/tools/python3/src/Parser/tokenizer.c +++ b/contrib/tools/python3/src/Parser/tokenizer.c @@ -622,6 +622,11 @@ translate_into_utf8(const char* str, const char* enc) { static char * translate_newlines(const char *s, int exec_input, 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'; diff --git a/contrib/tools/python3/src/Python/errors.c b/contrib/tools/python3/src/Python/errors.c index 8e150c3d00..2dd5a87920 100644 --- a/contrib/tools/python3/src/Python/errors.c +++ b/contrib/tools/python3/src/Python/errors.c @@ -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/src/Python/frozenmain.c b/contrib/tools/python3/src/Python/frozenmain.c deleted file mode 100644 index 8743e082b4..0000000000 --- a/contrib/tools/python3/src/Python/frozenmain.c +++ /dev/null @@ -1,85 +0,0 @@ -/* Python interpreter main program for frozen scripts */ - -#include "Python.h" -#include "pycore_runtime.h" // _PyRuntime_Initialize() -#include <locale.h> - -#ifdef MS_WINDOWS -extern void PyWinFreeze_ExeInit(void); -extern void PyWinFreeze_ExeTerm(void); -extern int PyInitFrozenExtensions(void); -#endif - -/* Main program */ - -int -Py_FrozenMain(int argc, char **argv) -{ - PyStatus status = _PyRuntime_Initialize(); - if (PyStatus_Exception(status)) { - Py_ExitStatusException(status); - } - - PyConfig config; - PyConfig_InitPythonConfig(&config); - // Suppress errors from getpath.c - config.pathconfig_warnings = 0; - // Don't parse command line options like -E - config.parse_argv = 0; - - status = PyConfig_SetBytesArgv(&config, argc, argv); - if (PyStatus_Exception(status)) { - PyConfig_Clear(&config); - Py_ExitStatusException(status); - } - - const char *p; - int inspect = 0; - if ((p = Py_GETENV("PYTHONINSPECT")) && *p != '\0') { - inspect = 1; - } - -#ifdef MS_WINDOWS - PyInitFrozenExtensions(); -#endif /* MS_WINDOWS */ - - status = Py_InitializeFromConfig(&config); - PyConfig_Clear(&config); - if (PyStatus_Exception(status)) { - Py_ExitStatusException(status); - } - -#ifdef MS_WINDOWS - PyWinFreeze_ExeInit(); -#endif - - if (Py_VerboseFlag) { - fprintf(stderr, "Python %s\n%s\n", - Py_GetVersion(), Py_GetCopyright()); - } - - int sts = 1; - int n = PyImport_ImportFrozenModule("__main__"); - if (n == 0) { - Py_FatalError("the __main__ module is not frozen"); - } - if (n < 0) { - PyErr_Print(); - sts = 1; - } - else { - sts = 0; - } - - if (inspect && isatty((int)fileno(stdin))) { - sts = PyRun_AnyFile(stdin, "<stdin>") != 0; - } - -#ifdef MS_WINDOWS - PyWinFreeze_ExeTerm(); -#endif - if (Py_FinalizeEx() < 0) { - sts = 120; - } - return sts; -} diff --git a/contrib/tools/python3/src/ya.make b/contrib/tools/python3/src/ya.make index 905419e2f4..f38d3924ea 100644 --- a/contrib/tools/python3/src/ya.make +++ b/contrib/tools/python3/src/ya.make @@ -128,7 +128,6 @@ SRCS( Python/formatter_unicode.c Python/frame.c Python/frozen.c - Python/frozenmain.c Python/future.c Python/getargs.c Python/getcompiler.c @@ -171,8 +170,6 @@ SRCS( IF (OS_WINDOWS) SRCS( PC/WinMain.c - PC/dl_nt.c - PC/frozen_dllmain.c PC/invalid_parameter_handler.c PC/msvcrtmodule.c PC/winreg.c |