Skip to content

Commit 9b2d207

Browse files
author
serge-sans-paille
committed
[lldb] Fix readline/libedit compat patch for py2
This is a follow-up to https://reviews.llvm.org/D69793 (cherry picked from commit d590498)
1 parent 62a16ca commit 9b2d207

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,23 @@ simple_readline(FILE *stdin, FILE *stdout, char *prompt)
4949
rl_outstream = stdout;
5050
char *line = readline(prompt);
5151
if (!line) {
52+
#if PY_MAJOR_VERSION >= 3
5253
char *ret = (char *)PyMem_RawMalloc(1);
54+
#else
55+
char *ret = (char *)PyMem_Malloc(1);
56+
#endif
5357
if (ret != NULL)
5458
*ret = '\0';
5559
return ret;
5660
}
5761
if (*line)
5862
add_history(line);
5963
int n = strlen(line);
64+
#if PY_MAJOR_VERSION >= 3
6065
char *ret = (char *)PyMem_RawMalloc(n + 2);
66+
#else
67+
char *ret = (char *)PyMem_Malloc(n + 2);
68+
#endif
6169
if (ret) {
6270
strncpy(ret, line, n);
6371
free(line);
@@ -73,7 +81,7 @@ PyMODINIT_FUNC initlldb_readline(void) {
7381
#if PY_MAJOR_VERSION >= 3
7482
return PyModule_Create(&readline_module);
7583
#else
76-
Py_InitModule4("lldb_readline", moduleMethods, moduleDocumentation,
84+
Py_InitModule4("readline", moduleMethods, moduleDocumentation,
7785
static_cast<PyObject *>(NULL), PYTHON_API_VERSION);
7886
#endif
7987
}

0 commit comments

Comments
 (0)