t.py: apply a few upstream pending pull requests to fix bugs

Signed-off-by: Christopher Larson <kergoth@gmail.com>