Remove weird use of eval().
Don't use TypeType - it is removed in Python 3.
Quiet 'unclosed file' warning.
Fix exec() use in Python 3.
Don't use deprecated method.
Exclude SWIG C global variables object.
Write XML in text (not binary) mode.