diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2022-07-03 14:10:23 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2022-07-03 14:10:23 +0000 |
| commit | 145449b1e420787bb99721a429341fa6be3adfb6 (patch) | |
| tree | 1d56ae694a6de602e348dd80165cf881a36600ed /lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp | |
| parent | ecbca9f5fb7d7613d2b94982c4825eb0d33d6842 (diff) | |
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp')
| -rw-r--r-- | lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp | 25 |
1 files changed, 1 insertions, 24 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp index 95a3365ed983..2753847f39f8 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<PyObject *>(NULL), PYTHON_API_VERSION); -#endif } #endif |
