Add workaround for issue 15881 in core Python

See <http://bugs.python.org/issue15881#msg170215>.

Change-Id: I698a1b07a86295073951ef59a04d82c385043846