generate safer cleanup code that also works in the case something goes badly wrong early at module init time

--HG--
extra : rebase_source : 015495e6aee6c59b11ee9169d2ad597ff54bfd0c
fix comparison of single character unicode literals

--HG--
extra : rebase_source : 5e91ffb0a20724dc92084bb68288cb6000814dca