From 90537673302f13e92ffabba84901164c6b974b2d Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Mon, 25 Apr 2022 20:14:44 -0700 Subject: Remove Python 2 support from the ScriptInterpreter plugin We dropped downstream support for Python 2 in the previous release. Now that we have branched for the next release the window where this kind of change could introduce conflicts is closing too. Start by getting rid of Python 2 support in the Script Interpreter plugin. Differential revision: https://reviews.llvm.org/D124429 --- .../ScriptInterpreter/Python/PythonReadline.cpp | 25 +--------------------- 1 file changed, 1 insertion(+), 24 deletions(-) (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp') diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp index 95a3365..2753847f 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp @@ -22,7 +22,6 @@ PyDoc_STRVAR(moduleDocumentation, "Simple readline module implementation based on libedit."); -#if PY_MAJOR_VERSION >= 3 static struct PyModuleDef readline_module = { PyModuleDef_HEAD_INIT, // m_base "lldb_editline", // m_name @@ -34,26 +33,13 @@ static struct PyModuleDef readline_module = { nullptr, // m_clear nullptr, // m_free }; -#else -static struct PyMethodDef moduleMethods[] = {{nullptr, nullptr, 0, nullptr}}; -#endif -static char * -#if PY_MAJOR_VERSION >= 3 -simple_readline(FILE *stdin, FILE *stdout, const char *prompt) -#else -simple_readline(FILE *stdin, FILE *stdout, char *prompt) -#endif -{ +static char *simple_readline(FILE *stdin, FILE *stdout, const char *prompt) { rl_instream = stdin; rl_outstream = stdout; char *line = readline(prompt); if (!line) { -#if PY_MAJOR_VERSION >= 3 char *ret = (char *)PyMem_RawMalloc(1); -#else - char *ret = (char *)PyMem_Malloc(1); -#endif if (ret != NULL) *ret = '\0'; return ret; @@ -61,11 +47,7 @@ simple_readline(FILE *stdin, FILE *stdout, char *prompt) if (*line) add_history(line); int n = strlen(line); -#if PY_MAJOR_VERSION >= 3 char *ret = (char *)PyMem_RawMalloc(n + 2); -#else - char *ret = (char *)PyMem_Malloc(n + 2); -#endif if (ret) { memcpy(ret, line, n); free(line); @@ -78,11 +60,6 @@ simple_readline(FILE *stdin, FILE *stdout, char *prompt) PyMODINIT_FUNC initlldb_readline(void) { PyOS_ReadlineFunctionPointer = simple_readline; -#if PY_MAJOR_VERSION >= 3 return PyModule_Create(&readline_module); -#else - Py_InitModule4("readline", moduleMethods, moduleDocumentation, - static_cast(NULL), PYTHON_API_VERSION); -#endif } #endif -- cgit v1.1