Solves issue1460. Might not be a backport candidate: a new API function was added, and some code may rely on details in utf-7.py.