--- work/Python-2.7.9/Modules/readline.c.orig 2015-06-05 18:40:48.377722000 -0400 +++ work/Python-2.7.9/Modules/readline.c 2015-06-05 18:46:14.483509000 -0400 @@ -45,7 +45,7 @@ #endif #endif -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__FreeBSD__) /* * It is possible to link the readline module to the readline * emulation library of editline/libedit. @@ -64,7 +64,7 @@ static const char libedit_version_tag[] = "EditLine wrapper"; static int libedit_history_start = 0; -#endif /* __APPLE__ */ +#endif /* __APPLE__ || __FreeBSD__ */ static void on_completion_display_matches_hook(char **matches, @@ -554,7 +554,7 @@ if (!PyArg_ParseTuple(args, "i:index", &idx)) return NULL; -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__FreeBSD__) if (using_libedit_emulation) { /* Older versions of libedit's readline emulation * use 0-based indexes, while readline and newer @@ -574,7 +574,7 @@ Py_RETURN_NONE; } } -#endif /* __APPLE__ */ +#endif /* __APPLE__ || __FreeBSD__ */ if ((hist_ent = history_get(idx))) return PyString_FromString(hist_ent->line); else { @@ -886,7 +886,7 @@ Py_FatalError("not enough memory to save locale"); #endif -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__FreeBSD__) /* the libedit readline emulation resets key bindings etc * when calling rl_initialize. So call it upfront */ @@ -903,7 +903,7 @@ libedit_history_start = 1; } clear_history(); -#endif /* __APPLE__ */ +#endif /* __APPLE__ || __FreeBSD__ */ using_history(); @@ -952,7 +952,7 @@ * XXX: A bug in the readline-2.2 library causes a memory leak * inside this function. Nothing we can do about it. */ -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__FreeBSD__) if (using_libedit_emulation) rl_read_init_file(NULL); else @@ -1123,12 +1123,12 @@ const char *line; int length = _py_get_history_length(); if (length > 0) -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__FreeBSD__) if (using_libedit_emulation) { /* handle older 0-based or newer 1-based indexing */ line = history_get(length + libedit_history_start - 1)->line; } else -#endif /* __APPLE__ */ +#endif /* __APPLE__ || __FreeBSD__ */ line = history_get(length)->line; else line = ""; @@ -1155,7 +1155,7 @@ PyDoc_STRVAR(doc_module, "Importing this module enables command line editing using GNU readline."); -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__FreeBSD__) PyDoc_STRVAR(doc_module_le, "Importing this module enables command line editing using libedit readline."); #endif /* __APPLE__ */ @@ -1165,7 +1165,7 @@ { PyObject *m; -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__FreeBSD__) if (strncmp(rl_library_version, libedit_version_tag, strlen(libedit_version_tag)) == 0) { using_libedit_emulation = 1; }