Copy over some code from CPython
Basic functionality working, with warnings