(Edited this answer to link to current version of the implementation given by tim.tadh)
This Python library implements the Zhang-Shasha algorithm correctly: https://github.com/timtadh/zhang-shasha
It began as a direct port of the Java source listed in the currently accepted answer (the one with the tarball link), but that implementation is not correct and is nearly impossible to run at all.