Python 3 Segfault Bug Affecting OS X Mavericks (10.9)

Python 3 Segfault
So as I'm sure many of you have/will, I updated to OS X Mavericks earlier today. In general, Mavericks feels super snappy and refined. However, soon after installing, I noticed that when running Python 3 interactivly Python segfaults for no apparent reason; clearly a major issue. The good news is this issue only seems to affect Python 3, and only when Python 3 is in interactive mode. This means you can run Python 2 just fine and non-interactive Python 3 features, like doctests, still work. Python 3 graphical applications also seem to work. I'll update this post when I find a solution (or, if you find one, comment below!).

This problem exists because of this bug: Basically, Python has code in Modules/readline.c that contains a workaround for a bug in libedit however the bug in libedit was fixed and Mavericks comes with the new version of libedit and the workaround now causes Python to segfault. The quick and dirty fix is to disable deadline processing by running the following command (from the bug document):

cd /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/lib-dynload
sudo mv

However this fix comes at the cost of disabling many of Python's history and editing features.
Note: To undo the previous fix run:

cd /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/lib-dynload
sudo mv

It turns out that this bug has already been fixed however the fix is not included in Python's binary installers for OS X. Most likely, since OS X 10.9 is now public, the Python community will soon provide new versions of the binary installers for OS X. However, until that happens, the solution is to uninstall Python and then reinstall via a package manager like Brew. Package managers install software by compiling directly from source so you know that you will always get the latest version. Below are directions.
CAVEAT: Don't follow these directions if you have MacPorts installed. It's never a good to have multiple package managers installed at the same time.

  1. Uninstall Python. Follow the directions here but substitute in your version number (e.g. replace 2.7 with 3.3).
  2. Install Xcode form the Mac App Store. Open it, and let it do its initialization.
  3. Install Xcode command line tools.
    xcode-select --install
  4. Install Homebrew.
    ruby -e "$(curl -fsSL"
  5. Make sure Homebrew is good to go.
    brew doctor

    Fix any warning that brew doctor gives. Usually, they come with a useful explanation. When in doubt, Google it. Once all warnings are fixed brew doctor should say "Your system is ready to brew."

  6. Install Python.
    brew install python3

And that's it! You should be good to go!