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/python3/src | |
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/python3/src')
-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 |
10 files changed, 31 insertions, 267 deletions
diff --git a/contrib/tools/python3/src/Modules/socketmodule.c b/contrib/tools/python3/src/Modules/socketmodule.c index 5089a884441..997df43f20c 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 606e50e6961..e4c3c6b4be3 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 8c2e725cac9..983adee8731 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 c27fc009c56..0e3e6ccd1b5 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 7f17ee16872..00000000000 --- 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 0156c5008bc..00000000000 --- 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 566ad8dfa00..4bc72ae444c 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 8e150c3d008..2dd5a87920a 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 8743e082b4f..00000000000 --- 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 905419e2f4a..f38d3924eaa 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 |