Index: python25/files/patch-libedit.diff
===================================================================
--- python25/files/patch-libedit.diff	(revision 0)
+++ python25/files/patch-libedit.diff	(working copy)
@@ -0,0 +1,132 @@
+--- configure.orig	2011-10-31 13:23:35.000000000 +1100
++++ configure	2011-10-31 13:28:19.000000000 +1100
+@@ -20985,9 +20985,9 @@
+ echo $ECHO_N "checking how to link readline libs... $ECHO_C" >&6; }
+ for py_libtermcap in "" ncursesw ncurses curses termcap; do
+   if test -z "$py_libtermcap"; then
+-    READLINE_LIBS="-lreadline"
++    READLINE_LIBS="-ledit"
+   else
+-    READLINE_LIBS="-lreadline -l$py_libtermcap"
++    READLINE_LIBS="-ledit -l$py_libtermcap"
+   fi
+   LIBS="$READLINE_LIBS $LIBS_no_readline"
+   cat >conftest.$ac_ext <<_ACEOF
+@@ -21060,13 +21060,13 @@
+ fi
+ 
+ # check for readline 2.1
+-{ echo "$as_me:$LINENO: checking for rl_callback_handler_install in -lreadline" >&5
+-echo $ECHO_N "checking for rl_callback_handler_install in -lreadline... $ECHO_C" >&6; }
++{ echo "$as_me:$LINENO: checking for rl_callback_handler_install in -ledit" >&5
++echo $ECHO_N "checking for rl_callback_handler_install in -ledit... $ECHO_C" >&6; }
+ if test "${ac_cv_lib_readline_rl_callback_handler_install+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   ac_check_lib_save_LIBS=$LIBS
+-LIBS="-lreadline $READLINE_LIBS $LIBS"
++LIBS="-ledit $READLINE_LIBS $LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
+ /* confdefs.h.  */
+ _ACEOF
+@@ -21137,7 +21137,7 @@
+ cat confdefs.h >>conftest.$ac_ext
+ cat >>conftest.$ac_ext <<_ACEOF
+ /* end confdefs.h.  */
+-#include <readline/readline.h>
++#include <editline/readline.h>
+ _ACEOF
+ if { (ac_try="$ac_cpp conftest.$ac_ext"
+ case "(($ac_try" in
+@@ -21172,7 +21172,7 @@
+ cat confdefs.h >>conftest.$ac_ext
+ cat >>conftest.$ac_ext <<_ACEOF
+ /* end confdefs.h.  */
+-#include <readline/readline.h>
++#include <editline/readline.h>
+ 
+ _ACEOF
+ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+@@ -21188,13 +21188,13 @@
+ fi
+ 
+ # check for readline 4.0
+-{ echo "$as_me:$LINENO: checking for rl_pre_input_hook in -lreadline" >&5
+-echo $ECHO_N "checking for rl_pre_input_hook in -lreadline... $ECHO_C" >&6; }
++{ echo "$as_me:$LINENO: checking for rl_pre_input_hook in -ledit" >&5
++echo $ECHO_N "checking for rl_pre_input_hook in -ledit... $ECHO_C" >&6; }
+ if test "${ac_cv_lib_readline_rl_pre_input_hook+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   ac_check_lib_save_LIBS=$LIBS
+-LIBS="-lreadline $READLINE_LIBS $LIBS"
++LIBS="-ledit $READLINE_LIBS $LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
+ /* confdefs.h.  */
+ _ACEOF
+@@ -21259,13 +21259,13 @@
+ 
+ 
+ # check for readline 4.2
+-{ echo "$as_me:$LINENO: checking for rl_completion_matches in -lreadline" >&5
+-echo $ECHO_N "checking for rl_completion_matches in -lreadline... $ECHO_C" >&6; }
++{ echo "$as_me:$LINENO: checking for rl_completion_matches in -ledit" >&5
++echo $ECHO_N "checking for rl_completion_matches in -ledit... $ECHO_C" >&6; }
+ if test "${ac_cv_lib_readline_rl_completion_matches+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   ac_check_lib_save_LIBS=$LIBS
+-LIBS="-lreadline $READLINE_LIBS $LIBS"
++LIBS="-ledit $READLINE_LIBS $LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
+ /* confdefs.h.  */
+ _ACEOF
+@@ -21336,7 +21336,7 @@
+ cat confdefs.h >>conftest.$ac_ext
+ cat >>conftest.$ac_ext <<_ACEOF
+ /* end confdefs.h.  */
+-#include <readline/readline.h>
++#include <editline/readline.h>
+ _ACEOF
+ if { (ac_try="$ac_cpp conftest.$ac_ext"
+ case "(($ac_try" in
+@@ -21371,7 +21371,7 @@
+ cat confdefs.h >>conftest.$ac_ext
+ cat >>conftest.$ac_ext <<_ACEOF
+ /* end confdefs.h.  */
+-#include <readline/readline.h>
++#include <editline/readline.h>
+ 
+ _ACEOF
+ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+--- setup.py.orig	2011-10-31 13:23:35.000000000 +1100
++++ setup.py	2011-10-31 13:32:40.000000000 +1100
+@@ -488,7 +488,7 @@
+             else:
+                 readline_extra_link_args = ()
+ 
+-            readline_libs = ['readline']
++            readline_libs = ['edit']
+             if self.compiler.find_library_file(lib_dirs,
+                                                  'ncursesw'):
+                 readline_libs.append('ncursesw')
+--- Modules/readline.c.orig	2007-01-23 03:10:27.000000000 +1100
++++ Modules/readline.c	2011-10-31 14:00:36.000000000 +1100
+@@ -28,8 +28,7 @@
+ 
+ /* GNU readline definitions */
+ #undef HAVE_CONFIG_H /* Else readline/chardefs.h includes strings.h */
+-#include <readline/readline.h>
+-#include <readline/history.h>
++#include <editline/readline.h>
+ 
+ #ifdef HAVE_RL_COMPLETION_MATCHES
+ #define completion_matches(x, y) \
+@@ -794,7 +793,6 @@ readline_until_enter_or_signal(char *pro
+ 			PyEval_SaveThread();	
+ #endif
+ 			if (s < 0) {
+-				rl_free_line_state();
+ 				rl_cleanup_after_signal();
+ 				rl_callback_handler_remove();
+ 				*signal = 1;
Index: python25/Portfile
===================================================================
--- python25/Portfile	(revision 86638)
+++ python25/Portfile	(working copy)
@@ -6,7 +6,7 @@
 
 name                    python25
 version                 2.5.6
-revision                1
+revision                2
 
 set branch              [join [lrange [split ${version} .] 0 1] .]
 categories              lang
@@ -37,11 +37,12 @@
                         patch-configure.diff \
                         patch-64bit.diff \
                         patch-setup_no_tkinter.py.diff \
-                        patch-mac_ver.diff
+                        patch-mac_ver.diff \
+                        patch-libedit.diff
 
 depends_lib             port:gettext port:zlib port:openssl \
                         port:sqlite3 port:db46 port:bzip2 \
-                        port:gdbm port:readline port:ncurses
+                        port:gdbm port:libedit port:ncurses
 depends_run             port:python_select
 
 configure.args          --enable-shared \
Index: python26/files/patch-libedit.diff
===================================================================
--- python26/files/patch-libedit.diff	(revision 0)
+++ python26/files/patch-libedit.diff	(working copy)
@@ -0,0 +1,199 @@
+--- configure.orig	2010-05-25 12:27:03.000000000 +1000
++++ configure	2011-10-31 14:15:56.000000000 +1100
+@@ -11947,9 +11947,9 @@
+ $as_echo_n "checking how to link readline libs... " >&6; }
+ for py_libtermcap in "" ncursesw ncurses curses termcap; do
+   if test -z "$py_libtermcap"; then
+-    READLINE_LIBS="-lreadline"
++    READLINE_LIBS="-ledit"
+   else
+-    READLINE_LIBS="-lreadline -l$py_libtermcap"
++    READLINE_LIBS="-ledit -l$py_libtermcap"
+   fi
+   LIBS="$READLINE_LIBS $LIBS_no_readline"
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+@@ -11993,13 +11993,13 @@
+ fi
+ 
+ # check for readline 2.1
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_callback_handler_install in -lreadline" >&5
+-$as_echo_n "checking for rl_callback_handler_install in -lreadline... " >&6; }
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_callback_handler_install in -ledit" >&5
++$as_echo_n "checking for rl_callback_handler_install in -ledit... " >&6; }
+ if test "${ac_cv_lib_readline_rl_callback_handler_install+set}" = set; then :
+   $as_echo_n "(cached) " >&6
+ else
+   ac_check_lib_save_LIBS=$LIBS
+-LIBS="-lreadline $READLINE_LIBS $LIBS"
++LIBS="-ledit $READLINE_LIBS $LIBS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
+@@ -12039,7 +12039,7 @@
+ # check for readline 2.2
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+-#include <readline/readline.h>
++#include <editline/readline.h>
+ _ACEOF
+ if ac_fn_c_try_cpp "$LINENO"; then :
+   have_readline=yes
+@@ -12051,7 +12051,7 @@
+ then
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+-#include <readline/readline.h>
++#include <editline/readline.h>
+ 
+ _ACEOF
+ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+@@ -12064,7 +12064,7 @@
+ 
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+-#include <readline/readline.h>
++#include <editline/readline.h>
+ 
+ _ACEOF
+ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+@@ -12078,13 +12078,13 @@
+ fi
+ 
+ # check for readline 4.0
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_pre_input_hook in -lreadline" >&5
+-$as_echo_n "checking for rl_pre_input_hook in -lreadline... " >&6; }
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_pre_input_hook in -ledit" >&5
++$as_echo_n "checking for rl_pre_input_hook in -ledit... " >&6; }
+ if test "${ac_cv_lib_readline_rl_pre_input_hook+set}" = set; then :
+   $as_echo_n "(cached) " >&6
+ else
+   ac_check_lib_save_LIBS=$LIBS
+-LIBS="-lreadline $READLINE_LIBS $LIBS"
++LIBS="-ledit $READLINE_LIBS $LIBS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
+@@ -12122,13 +12122,13 @@
+ 
+ 
+ # also in 4.0
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_completion_display_matches_hook in -lreadline" >&5
+-$as_echo_n "checking for rl_completion_display_matches_hook in -lreadline... " >&6; }
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_completion_display_matches_hook in -ledit" >&5
++$as_echo_n "checking for rl_completion_display_matches_hook in -ledit... " >&6; }
+ if test "${ac_cv_lib_readline_rl_completion_display_matches_hook+set}" = set; then :
+   $as_echo_n "(cached) " >&6
+ else
+   ac_check_lib_save_LIBS=$LIBS
+-LIBS="-lreadline $READLINE_LIBS $LIBS"
++LIBS="-ledit $READLINE_LIBS $LIBS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
+@@ -12166,13 +12166,13 @@
+ 
+ 
+ # check for readline 4.2
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_completion_matches in -lreadline" >&5
+-$as_echo_n "checking for rl_completion_matches in -lreadline... " >&6; }
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_completion_matches in -ledit" >&5
++$as_echo_n "checking for rl_completion_matches in -ledit... " >&6; }
+ if test "${ac_cv_lib_readline_rl_completion_matches+set}" = set; then :
+   $as_echo_n "(cached) " >&6
+ else
+   ac_check_lib_save_LIBS=$LIBS
+-LIBS="-lreadline $READLINE_LIBS $LIBS"
++LIBS="-ledit $READLINE_LIBS $LIBS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
+@@ -12212,7 +12212,7 @@
+ # also in readline 4.2
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+-#include <readline/readline.h>
++#include <editline/readline.h>
+ _ACEOF
+ if ac_fn_c_try_cpp "$LINENO"; then :
+   have_readline=yes
+@@ -12224,7 +12224,7 @@
+ then
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+-#include <readline/readline.h>
++#include <editline/readline.h>
+ 
+ _ACEOF
+ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+--- setup.py.orig	2011-10-31 14:13:22.000000000 +1100
++++ setup.py	2011-10-31 14:18:07.000000000 +1100
+@@ -601,7 +601,7 @@
+             missing.extend(['imageop'])
+ 
+         # readline
+-        do_readline = self.compiler.find_library_file(lib_dirs, 'readline')
++        do_readline = self.compiler.find_library_file(lib_dirs, 'edit')
+         readline_termcap_library = ""
+         curses_library = ""
+         # Determine if readline is already linked against curses or tinfo.
+@@ -656,7 +656,7 @@
+             else:
+                 readline_extra_link_args = ()
+ 
+-            readline_libs = ['readline']
++            readline_libs = ['edit']
+             if readline_termcap_library:
+                 pass # Issue 7384: Already linked against curses or tinfo.
+             elif curses_library:
+--- Modules/readline.c.orig	2010-05-10 01:15:40.000000000 +1000
++++ Modules/readline.c	2011-10-31 14:43:16.000000000 +1100
+@@ -28,8 +28,7 @@
+ 
+ /* GNU readline definitions */
+ #undef HAVE_CONFIG_H /* Else readline/chardefs.h includes strings.h */
+-#include <readline/readline.h>
+-#include <readline/history.h>
++#include <editline/readline.h>
+ 
+ #ifdef HAVE_RL_COMPLETION_MATCHES
+ #define completion_matches(x, y) \
+@@ -510,14 +509,12 @@ get_history_item(PyObject *self, PyObjec
+         HISTORY_STATE *hist_st;
+         hist_st = history_get_history_state();
+ 
+-        idx --;
+-
+         /*
+          * Apple's readline emulation crashes when
+          * the index is out of range, therefore
+          * test for that and fail gracefully.
+          */
+-        if (idx < 0 || idx >= hist_st->length) {
++        if (idx < 1 || idx > hist_st->length) {
+             Py_RETURN_NONE;
+         }
+     }
+@@ -926,7 +923,6 @@ readline_until_enter_or_signal(char *pro
+             PyEval_SaveThread();
+ #endif
+             if (s < 0) {
+-                rl_free_line_state();
+                 rl_cleanup_after_signal();
+                 rl_callback_handler_remove();
+                 *signal = 1;
+@@ -1025,15 +1021,6 @@ call_readline(FILE *sys_stdin, FILE *sys
+         char *line;
+         HISTORY_STATE *state = history_get_history_state();
+         if (state->length > 0)
+-#ifdef __APPLE__
+-            if (using_libedit_emulation) {
+-                /*
+-                 * Libedit's emulation uses 0-based indexes,
+-                 * the real readline uses 1-based indexes.
+-                 */
+-                line = history_get(state->length - 1)->line;
+-            } else
+-#endif /* __APPLE__ */
+             line = history_get(state->length)->line;
+         else
+             line = "";
Index: python26/Portfile
===================================================================
--- python26/Portfile	(revision 86638)
+++ python26/Portfile	(working copy)
@@ -7,7 +7,7 @@
 name                    python26
 # Remember to keep py26-tkinter's version sync'd with this
 version                 2.6.7
-revision                1
+revision                2
 set major               [lindex [split $version .] 0]
 set branch              [join [lrange [split ${version} .] 0 1] .]
 categories              lang
@@ -44,11 +44,12 @@
                         patch-Mac-Tools-Doc-setup.py.diff \
                         patch-setup.py-db46.diff \
                         patch-Lib-ctypes-macholib-dyld.py.diff \
-                        patch-setup_no_tkinter.py.diff
+                        patch-setup_no_tkinter.py.diff \
+                        patch-libedit.diff
 
 depends_lib             port:gettext port:zlib port:openssl \
                         port:sqlite3 port:db46 port:ncurses port:gdbm \
-                        port:bzip2 port:readline
+                        port:bzip2 port:libedit
 depends_run             port:python_select
 
 configure.args          --enable-framework=${frameworks_dir} \
Index: python27/files/patch-libedit.diff
===================================================================
--- python27/files/patch-libedit.diff	(revision 0)
+++ python27/files/patch-libedit.diff	(working copy)
@@ -0,0 +1,199 @@
+--- configure.orig	2011-10-31 14:58:43.000000000 +1100
++++ configure	2011-10-31 15:01:31.000000000 +1100
+@@ -12855,9 +12855,9 @@
+ $as_echo_n "checking how to link readline libs... " >&6; }
+ for py_libtermcap in "" ncursesw ncurses curses termcap; do
+   if test -z "$py_libtermcap"; then
+-    READLINE_LIBS="-lreadline"
++    READLINE_LIBS="-ledit"
+   else
+-    READLINE_LIBS="-lreadline -l$py_libtermcap"
++    READLINE_LIBS="-ledit -l$py_libtermcap"
+   fi
+   LIBS="$READLINE_LIBS $LIBS_no_readline"
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+@@ -12901,13 +12901,13 @@
+ fi
+ 
+ # check for readline 2.1
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_callback_handler_install in -lreadline" >&5
+-$as_echo_n "checking for rl_callback_handler_install in -lreadline... " >&6; }
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_callback_handler_install in -ledit" >&5
++$as_echo_n "checking for rl_callback_handler_install in -ledit... " >&6; }
+ if ${ac_cv_lib_readline_rl_callback_handler_install+:} false; then :
+   $as_echo_n "(cached) " >&6
+ else
+   ac_check_lib_save_LIBS=$LIBS
+-LIBS="-lreadline $READLINE_LIBS $LIBS"
++LIBS="-ledit $READLINE_LIBS $LIBS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
+@@ -12947,7 +12947,7 @@
+ # check for readline 2.2
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+-#include <readline/readline.h>
++#include <editline/readline.h>
+ _ACEOF
+ if ac_fn_c_try_cpp "$LINENO"; then :
+   have_readline=yes
+@@ -12960,7 +12960,7 @@
+ then
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+-#include <readline/readline.h>
++#include <editline/readline.h>
+ 
+ _ACEOF
+ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+@@ -12973,7 +12973,7 @@
+ 
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+-#include <readline/readline.h>
++#include <editline/readline.h>
+ 
+ _ACEOF
+ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+@@ -12987,13 +12987,13 @@
+ fi
+ 
+ # check for readline 4.0
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_pre_input_hook in -lreadline" >&5
+-$as_echo_n "checking for rl_pre_input_hook in -lreadline... " >&6; }
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_pre_input_hook in -ledit" >&5
++$as_echo_n "checking for rl_pre_input_hook in -ledit... " >&6; }
+ if ${ac_cv_lib_readline_rl_pre_input_hook+:} false; then :
+   $as_echo_n "(cached) " >&6
+ else
+   ac_check_lib_save_LIBS=$LIBS
+-LIBS="-lreadline $READLINE_LIBS $LIBS"
++LIBS="-ledit $READLINE_LIBS $LIBS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
+@@ -13031,13 +13031,13 @@
+ 
+ 
+ # also in 4.0
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_completion_display_matches_hook in -lreadline" >&5
+-$as_echo_n "checking for rl_completion_display_matches_hook in -lreadline... " >&6; }
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_completion_display_matches_hook in -ledit" >&5
++$as_echo_n "checking for rl_completion_display_matches_hook in -ledit... " >&6; }
+ if ${ac_cv_lib_readline_rl_completion_display_matches_hook+:} false; then :
+   $as_echo_n "(cached) " >&6
+ else
+   ac_check_lib_save_LIBS=$LIBS
+-LIBS="-lreadline $READLINE_LIBS $LIBS"
++LIBS="-ledit $READLINE_LIBS $LIBS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
+@@ -13075,13 +13075,13 @@
+ 
+ 
+ # check for readline 4.2
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_completion_matches in -lreadline" >&5
+-$as_echo_n "checking for rl_completion_matches in -lreadline... " >&6; }
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_completion_matches in -ledit" >&5
++$as_echo_n "checking for rl_completion_matches in -ledit... " >&6; }
+ if ${ac_cv_lib_readline_rl_completion_matches+:} false; then :
+   $as_echo_n "(cached) " >&6
+ else
+   ac_check_lib_save_LIBS=$LIBS
+-LIBS="-lreadline $READLINE_LIBS $LIBS"
++LIBS="-ledit $READLINE_LIBS $LIBS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
+@@ -13121,7 +13121,7 @@
+ # also in readline 4.2
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+-#include <readline/readline.h>
++#include <editline/readline.h>
+ _ACEOF
+ if ac_fn_c_try_cpp "$LINENO"; then :
+   have_readline=yes
+@@ -13134,7 +13134,7 @@
+ then
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+-#include <readline/readline.h>
++#include <editline/readline.h>
+ 
+ _ACEOF
+ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+--- setup.py.orig	2011-10-31 14:58:43.000000000 +1100
++++ setup.py	2011-10-31 15:03:30.000000000 +1100
+@@ -620,7 +620,7 @@
+             missing.extend(['imageop'])
+ 
+         # readline
+-        do_readline = self.compiler.find_library_file(lib_dirs, 'readline')
++        do_readline = self.compiler.find_library_file(lib_dirs, 'edit')
+         readline_termcap_library = ""
+         curses_library = ""
+         # Determine if readline is already linked against curses or tinfo.
+@@ -671,7 +671,7 @@
+             else:
+                 readline_extra_link_args = ()
+ 
+-            readline_libs = ['readline']
++            readline_libs = ['edit']
+             if readline_termcap_library:
+                 pass # Issue 7384: Already linked against curses or tinfo.
+             elif curses_library:
+--- Modules/readline.c.orig	2011-06-12 01:46:27.000000000 +1000
++++ Modules/readline.c	2011-10-31 15:07:35.000000000 +1100
+@@ -28,8 +28,7 @@
+ 
+ /* GNU readline definitions */
+ #undef HAVE_CONFIG_H /* Else readline/chardefs.h includes strings.h */
+-#include <readline/readline.h>
+-#include <readline/history.h>
++#include <editline/readline.h>
+ 
+ #ifdef HAVE_RL_COMPLETION_MATCHES
+ #define completion_matches(x, y) \
+@@ -550,14 +549,13 @@ get_history_item(PyObject *self, PyObjec
+          * difference.
+          */
+         int length = _py_get_history_length();
+-        idx --;
+ 
+         /*
+          * Apple's readline emulation crashes when
+          * the index is out of range, therefore
+          * test for that and fail gracefully.
+          */
+-        if (idx < 0 || idx >= length) {
++        if (idx < 1 || idx > length) {
+             Py_RETURN_NONE;
+         }
+     }
+@@ -976,7 +974,6 @@ readline_until_enter_or_signal(char *pro
+             PyEval_SaveThread();
+ #endif
+             if (s < 0) {
+-                rl_free_line_state();
+                 rl_cleanup_after_signal();
+                 rl_callback_handler_remove();
+                 *signal = 1;
+@@ -1075,15 +1072,6 @@ call_readline(FILE *sys_stdin, FILE *sys
+         const char *line;
+         int length = _py_get_history_length();
+         if (length > 0)
+-#ifdef __APPLE__
+-            if (using_libedit_emulation) {
+-                /*
+-                 * Libedit's emulation uses 0-based indexes,
+-                 * the real readline uses 1-based indexes.
+-                 */
+-                line = history_get(length - 1)->line;
+-            } else
+-#endif /* __APPLE__ */
+             line = history_get(length)->line;
+         else
+             line = "";
Index: python27/Portfile
===================================================================
--- python27/Portfile	(revision 86638)
+++ python27/Portfile	(working copy)
@@ -8,7 +8,7 @@
 epoch               2
 # Remember to keep py27-tkinter's version sync'd with this
 version             2.7.2
-revision            1
+revision            2
 
 set major           [lindex [split $version .] 0]
 set branch          [join [lrange [split ${version} .] 0 1] .]
@@ -40,7 +40,8 @@
                     patch-setup_no_tkinter.py.diff \
                     patch-Lib-cgi.py.diff \
                     patch-Lib-ctypes-macholib-dyld.py.diff \
-                    patch-configure.diff
+                    patch-configure.diff \
+                    patch-libedit.diff
 #                   patch-readlinefix.diff
 
 depends_lib         port:gettext \
@@ -51,7 +52,7 @@
                     port:ncurses \
                     port:gdbm \
                     port:bzip2 \
-                    port:readline
+                    port:libedit
 depends_run         port:python_select
 
 configure.args      --enable-framework=${frameworks_dir} \
Index: python31/files/patch-libedit.diff
===================================================================
--- python31/files/patch-libedit.diff	(revision 0)
+++ python31/files/patch-libedit.diff	(working copy)
@@ -0,0 +1,167 @@
+--- configure.orig	2011-06-12 01:48:52.000000000 +1000
++++ configure	2011-10-31 15:28:14.000000000 +1100
+@@ -12494,9 +12494,9 @@
+ $as_echo_n "checking how to link readline libs... " >&6; }
+ for py_libtermcap in "" ncursesw ncurses curses termcap; do
+   if test -z "$py_libtermcap"; then
+-    READLINE_LIBS="-lreadline"
++    READLINE_LIBS="-ledit"
+   else
+-    READLINE_LIBS="-lreadline -l$py_libtermcap"
++    READLINE_LIBS="-ledit -l$py_libtermcap"
+   fi
+   LIBS="$READLINE_LIBS $LIBS_no_readline"
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+@@ -12540,13 +12540,13 @@
+ fi
+ 
+ # check for readline 2.1
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_callback_handler_install in -lreadline" >&5
+-$as_echo_n "checking for rl_callback_handler_install in -lreadline... " >&6; }
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_callback_handler_install in -ledit" >&5
++$as_echo_n "checking for rl_callback_handler_install in -ledit... " >&6; }
+ if ${ac_cv_lib_readline_rl_callback_handler_install+:} false; then :
+   $as_echo_n "(cached) " >&6
+ else
+   ac_check_lib_save_LIBS=$LIBS
+-LIBS="-lreadline $READLINE_LIBS $LIBS"
++LIBS="-ledit $READLINE_LIBS $LIBS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
+@@ -12586,7 +12586,7 @@
+ # check for readline 2.2
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+-#include <readline/readline.h>
++#include <editline/readline.h>
+ _ACEOF
+ if ac_fn_c_try_cpp "$LINENO"; then :
+   have_readline=yes
+@@ -12598,7 +12598,7 @@
+ then
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+-#include <readline/readline.h>
++#include <editline/readline.h>
+ 
+ _ACEOF
+ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+@@ -12611,7 +12611,7 @@
+ 
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+-#include <readline/readline.h>
++#include <editline/readline.h>
+ 
+ _ACEOF
+ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+@@ -12625,13 +12625,13 @@
+ fi
+ 
+ # check for readline 4.0
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_pre_input_hook in -lreadline" >&5
+-$as_echo_n "checking for rl_pre_input_hook in -lreadline... " >&6; }
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_pre_input_hook in -ledit" >&5
++$as_echo_n "checking for rl_pre_input_hook in -ledit... " >&6; }
+ if ${ac_cv_lib_readline_rl_pre_input_hook+:} false; then :
+   $as_echo_n "(cached) " >&6
+ else
+   ac_check_lib_save_LIBS=$LIBS
+-LIBS="-lreadline $READLINE_LIBS $LIBS"
++LIBS="-ledit $READLINE_LIBS $LIBS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
+@@ -12669,13 +12669,13 @@
+ 
+ 
+ # also in 4.0
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_completion_display_matches_hook in -lreadline" >&5
+-$as_echo_n "checking for rl_completion_display_matches_hook in -lreadline... " >&6; }
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_completion_display_matches_hook in -ledit" >&5
++$as_echo_n "checking for rl_completion_display_matches_hook in -ledit... " >&6; }
+ if ${ac_cv_lib_readline_rl_completion_display_matches_hook+:} false; then :
+   $as_echo_n "(cached) " >&6
+ else
+   ac_check_lib_save_LIBS=$LIBS
+-LIBS="-lreadline $READLINE_LIBS $LIBS"
++LIBS="-ledit $READLINE_LIBS $LIBS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
+@@ -12713,13 +12713,13 @@
+ 
+ 
+ # check for readline 4.2
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_completion_matches in -lreadline" >&5
+-$as_echo_n "checking for rl_completion_matches in -lreadline... " >&6; }
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_completion_matches in -ledit" >&5
++$as_echo_n "checking for rl_completion_matches in -ledit... " >&6; }
+ if ${ac_cv_lib_readline_rl_completion_matches+:} false; then :
+   $as_echo_n "(cached) " >&6
+ else
+   ac_check_lib_save_LIBS=$LIBS
+-LIBS="-lreadline $READLINE_LIBS $LIBS"
++LIBS="-ledit $READLINE_LIBS $LIBS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
+@@ -12759,7 +12759,7 @@
+ # also in readline 4.2
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+-#include <readline/readline.h>
++#include <editline/readline.h>
+ _ACEOF
+ if ac_fn_c_try_cpp "$LINENO"; then :
+   have_readline=yes
+@@ -12771,7 +12771,7 @@
+ then
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+-#include <readline/readline.h>
++#include <editline/readline.h>
+ 
+ _ACEOF
+ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+--- setup.py.orig	2011-10-31 15:26:25.000000000 +1100
++++ setup.py	2011-10-31 15:29:39.000000000 +1100
+@@ -570,7 +570,7 @@
+         exts.append( Extension('audioop', ['audioop.c']) )
+ 
+         # readline
+-        do_readline = self.compiler.find_library_file(lib_dirs, 'readline')
++        do_readline = self.compiler.find_library_file(lib_dirs, 'edit')
+         readline_termcap_library = ""
+         curses_library = ""
+         # Determine if readline is already linked against curses or tinfo.
+@@ -627,7 +627,7 @@
+             else:
+                 readline_extra_link_args = ()
+ 
+-            readline_libs = ['readline']
++            readline_libs = ['edit']
+             if readline_termcap_library:
+                 pass # Issue 7384: Already linked against curses or tinfo.
+             elif curses_library:
+--- Modules/readline.c.orig	2011-06-12 01:48:52.000000000 +1000
++++ Modules/readline.c	2011-10-31 15:34:23.000000000 +1100
+@@ -28,8 +28,7 @@
+ 
+ /* GNU readline definitions */
+ #undef HAVE_CONFIG_H /* Else readline/chardefs.h includes strings.h */
+-#include <readline/readline.h>
+-#include <readline/history.h>
++#include <editline/readline.h>
+ 
+ #ifdef HAVE_RL_COMPLETION_MATCHES
+ #define completion_matches(x, y) \
+@@ -919,7 +918,6 @@ readline_until_enter_or_signal(char *pro
+             PyEval_SaveThread();
+ #endif
+             if (s < 0) {
+-                rl_free_line_state();
+                 rl_cleanup_after_signal();
+                 rl_callback_handler_remove();
+                 *signal = 1;
Index: python31/Portfile
===================================================================
--- python31/Portfile	(revision 86638)
+++ python31/Portfile	(working copy)
@@ -8,7 +8,7 @@
 epoch                   1
 # Remember to keep py31-tkinter's version sync'd with this
 version                 3.1.4
-revision                1
+revision                2
 set major               [lindex [split $version .] 0]
 set branch              [join [lrange [split ${version} .] 0 1] .]
 categories              lang
@@ -33,11 +33,12 @@
 patchfiles              patch-setup.py.diff \
                         patch-Lib-cgi.py.diff \
                         patch-Lib-distutils-dist.py.diff \
-                        patch-setup_no_tkinter.py.diff
+                        patch-setup_no_tkinter.py.diff \
+                        patch-libedit.diff
 
 depends_lib             port:zlib port:openssl \
                         port:sqlite3 port:ncurses port:gdbm \
-                        port:bzip2 port:readline port:gettext
+                        port:bzip2 port:libedit port:gettext
 depends_run             port:python_select
 
 configure.args          --enable-framework=${frameworks_dir} \
Index: python32/files/patch-libedit.diff
===================================================================
--- python32/files/patch-libedit.diff	(revision 0)
+++ python32/files/patch-libedit.diff	(working copy)
@@ -0,0 +1,199 @@
+--- configure.orig	2011-06-12 01:48:52.000000000 +1000
++++ configure	2011-10-31 15:28:14.000000000 +1100
+@@ -12807,9 +12807,9 @@
+ $as_echo_n "checking how to link readline libs... " >&6; }
+ for py_libtermcap in "" ncursesw ncurses curses termcap; do
+   if test -z "$py_libtermcap"; then
+-    READLINE_LIBS="-lreadline"
++    READLINE_LIBS="-ledit"
+   else
+-    READLINE_LIBS="-lreadline -l$py_libtermcap"
++    READLINE_LIBS="-ledit -l$py_libtermcap"
+   fi
+   LIBS="$READLINE_LIBS $LIBS_no_readline"
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+@@ -12853,13 +12853,13 @@
+ fi
+ 
+ # check for readline 2.1
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_callback_handler_install in -lreadline" >&5
+-$as_echo_n "checking for rl_callback_handler_install in -lreadline... " >&6; }
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_callback_handler_install in -ledit" >&5
++$as_echo_n "checking for rl_callback_handler_install in -ledit... " >&6; }
+ if ${ac_cv_lib_readline_rl_callback_handler_install+:} false; then :
+   $as_echo_n "(cached) " >&6
+ else
+   ac_check_lib_save_LIBS=$LIBS
+-LIBS="-lreadline $READLINE_LIBS $LIBS"
++LIBS="-ledit $READLINE_LIBS $LIBS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
+@@ -12899,7 +12899,7 @@
+ # check for readline 2.2
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+-#include <readline/readline.h>
++#include <editline/readline.h>
+ _ACEOF
+ if ac_fn_c_try_cpp "$LINENO"; then :
+   have_readline=yes
+@@ -12912,7 +12912,7 @@
+ then
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+-#include <readline/readline.h>
++#include <editline/readline.h>
+ 
+ _ACEOF
+ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+@@ -12925,7 +12925,7 @@
+ 
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+-#include <readline/readline.h>
++#include <editline/readline.h>
+ 
+ _ACEOF
+ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+@@ -12939,13 +12939,13 @@
+ fi
+ 
+ # check for readline 4.0
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_pre_input_hook in -lreadline" >&5
+-$as_echo_n "checking for rl_pre_input_hook in -lreadline... " >&6; }
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_pre_input_hook in -ledit" >&5
++$as_echo_n "checking for rl_pre_input_hook in -ledit... " >&6; }
+ if ${ac_cv_lib_readline_rl_pre_input_hook+:} false; then :
+   $as_echo_n "(cached) " >&6
+ else
+   ac_check_lib_save_LIBS=$LIBS
+-LIBS="-lreadline $READLINE_LIBS $LIBS"
++LIBS="-ledit $READLINE_LIBS $LIBS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
+@@ -12983,13 +12983,13 @@
+ 
+ 
+ # also in 4.0
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_completion_display_matches_hook in -lreadline" >&5
+-$as_echo_n "checking for rl_completion_display_matches_hook in -lreadline... " >&6; }
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_completion_display_matches_hook in -ledit" >&5
++$as_echo_n "checking for rl_completion_display_matches_hook in -ledit... " >&6; }
+ if ${ac_cv_lib_readline_rl_completion_display_matches_hook+:} false; then :
+   $as_echo_n "(cached) " >&6
+ else
+   ac_check_lib_save_LIBS=$LIBS
+-LIBS="-lreadline $READLINE_LIBS $LIBS"
++LIBS="-ledit $READLINE_LIBS $LIBS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
+@@ -13027,13 +13027,13 @@
+ 
+ 
+ # check for readline 4.2
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_completion_matches in -lreadline" >&5
+-$as_echo_n "checking for rl_completion_matches in -lreadline... " >&6; }
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_completion_matches in -ledit" >&5
++$as_echo_n "checking for rl_completion_matches in -ledit... " >&6; }
+ if ${ac_cv_lib_readline_rl_completion_matches+:} false; then :
+   $as_echo_n "(cached) " >&6
+ else
+   ac_check_lib_save_LIBS=$LIBS
+-LIBS="-lreadline $READLINE_LIBS $LIBS"
++LIBS="-ledit $READLINE_LIBS $LIBS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
+@@ -13073,7 +13073,7 @@
+ # also in readline 4.2
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+-#include <readline/readline.h>
++#include <editline/readline.h>
+ _ACEOF
+ if ac_fn_c_try_cpp "$LINENO"; then :
+   have_readline=yes
+@@ -13086,7 +13086,7 @@
+ then
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+-#include <readline/readline.h>
++#include <editline/readline.h>
+ 
+ _ACEOF
+ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+--- setup.py.orig	2011-10-31 15:26:25.000000000 +1100
++++ setup.py	2011-10-31 15:29:39.000000000 +1100
+@@ -581,7 +581,7 @@
+         exts.append( Extension('audioop', ['audioop.c']) )
+ 
+         # readline
+-        do_readline = self.compiler.find_library_file(lib_dirs, 'readline')
++        do_readline = self.compiler.find_library_file(lib_dirs, 'edit')
+         readline_termcap_library = ""
+         curses_library = ""
+         # Determine if readline is already linked against curses or tinfo.
+@@ -637,7 +637,7 @@
+             else:
+                 readline_extra_link_args = ()
+ 
+-            readline_libs = ['readline']
++            readline_libs = ['edit']
+             if readline_termcap_library:
+                 pass # Issue 7384: Already linked against curses or tinfo.
+             elif curses_library:
+--- Modules/readline.c.orig	2011-09-04 02:16:46.000000000 +1000
++++ Modules/readline.c	2011-10-31 16:02:33.000000000 +1100
+@@ -28,8 +28,7 @@
+ 
+ /* GNU readline definitions */
+ #undef HAVE_CONFIG_H /* Else readline/chardefs.h includes strings.h */
+-#include <readline/readline.h>
+-#include <readline/history.h>
++#include <editline/readline.h>
+ 
+ #ifdef HAVE_RL_COMPLETION_MATCHES
+ #define completion_matches(x, y) \
+@@ -573,14 +572,13 @@ get_history_item(PyObject *self, PyObjec
+          * difference.
+          */
+         int length = _py_get_history_length();
+-        idx --;
+ 
+         /*
+          * Apple's readline emulation crashes when
+          * the index is out of range, therefore
+          * test for that and fail gracefully.
+          */
+-        if (idx < 0 || idx >= length) {
++        if (idx < 1 || idx > length) {
+             Py_RETURN_NONE;
+         }
+     }
+@@ -1000,7 +998,6 @@ readline_until_enter_or_signal(char *pro
+             PyEval_SaveThread();
+ #endif
+             if (s < 0) {
+-                rl_free_line_state();
+                 rl_cleanup_after_signal();
+                 rl_callback_handler_remove();
+                 *signal = 1;
+@@ -1099,15 +1096,6 @@ call_readline(FILE *sys_stdin, FILE *sys
+         const char *line;
+         int length = _py_get_history_length();
+         if (length > 0)
+-#ifdef __APPLE__
+-            if (using_libedit_emulation) {
+-                /*
+-                 * Libedit's emulation uses 0-based indexes,
+-                 * the real readline uses 1-based indexes.
+-                 */
+-                line = (const char *)history_get(length - 1)->line;
+-            } else
+-#endif /* __APPLE__ */
+             line = (const char *)history_get(length)->line;
+         else
+             line = "";
Index: python32/Portfile
===================================================================
--- python32/Portfile	(revision 86638)
+++ python32/Portfile	(working copy)
@@ -8,6 +8,7 @@
 epoch                   20110904
 # Remember to keep py32-tkinter's version sync'd with this
 version                 3.2.2
+revision                1
 
 set major               [lindex [split $version .] 0]
 set branch              [join [lrange [split ${version} .] 0 1] .]
@@ -35,11 +36,12 @@
                         patch-Lib-cgi.py.diff \
                         patch-Lib-distutils-dist.py.diff \
                         patch-configure.diff \
-                        patch-setup_no_tkinter.py.diff
+                        patch-setup_no_tkinter.py.diff \
+                        patch-libedit.diff
 
 depends_lib             port:zlib port:openssl \
                         port:sqlite3 port:ncurses port:gdbm \
-                        port:bzip2 port:readline port:gettext
+                        port:bzip2 port:libedit port:gettext
 depends_run             port:python_select
 
 configure.args          --enable-framework=${frameworks_dir} \
