Fix handling of build errors on Python 3.