pycompat: remove large Python 2 block
We no longer support Python 2. So we can delete its compatibility
code and remove the conditional and dedent the Python 3 code.
In order to make the linter happy, we had to inline imports in the
stanza at the top of the file.
Differential Revision: https://phab.mercurial-scm.org/D12250