Copied some Python compat stuff to get py 2.3 running... just googled for it on python.org mailing list.