summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp
diff options
context:
space:
mode:
authorserge-sans-paille <sguelton@redhat.com>2019-11-05 14:15:09 +0100
committerserge-sans-paille <sguelton@redhat.com>2019-11-05 14:16:39 +0100
commitd590498829d8c0d4f4f673569949fa3850485c9c (patch)
tree4a0889e1fc8ad913928a48cf6ad91a0b0c5c6067 /lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp
parent9f294fc4977b361158107c389ce66d29a8f3b7ee (diff)
downloadbcm5719-llvm-d590498829d8c0d4f4f673569949fa3850485c9c.tar.gz
bcm5719-llvm-d590498829d8c0d4f4f673569949fa3850485c9c.zip
[lldb] Fix readline/libedit compat patch for py2
This is a follow-up to https://reviews.llvm.org/D69793
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp')
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp
index 616522f9de9..674ec9b6140 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp
@@ -49,7 +49,11 @@ simple_readline(FILE *stdin, FILE *stdout, char *prompt)
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;
@@ -57,7 +61,11 @@ 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) {
strncpy(ret, line, n);
free(line);
@@ -73,7 +81,7 @@ PyMODINIT_FUNC initlldb_readline(void) {
#if PY_MAJOR_VERSION >= 3
return PyModule_Create(&readline_module);
#else
- Py_InitModule4("lldb_readline", moduleMethods, moduleDocumentation,
+ Py_InitModule4("readline", moduleMethods, moduleDocumentation,
static_cast<PyObject *>(NULL), PYTHON_API_VERSION);
#endif
}
OpenPOWER on IntegriCloud