Topic/default/py3 fixes
I've got more fixes locally, but these were pretty trivial so I thought I'd clear these first instead of dumping a ton of changes at once. If the core hooks proposed in the last patch sound reasonable, I can add those upstream and then send another MR. That way when py2 is dropped, there are only ~5 hg revisions without support for the hook, so it shouldn't be an ongoing maintenance headache.