Fix refcounting bugs in src/_path.cpp

Now all the tests in tests.py that passed previously work again.