Serhiy Storchaka added the comment: I hope following patch is free from undefined behavior. ---------- _______________________________________ Python tracker <report at bugs.python.org> <http://bugs.python.org/issue27097> _______________________________________