refine Python 2 support