ImportError: bad magic number in 'locale': b'm\xf2\r\n' when configuring saml in UCS

Problem:

When configuring SSO saml for UMC by setting

ucr set umc/saml/idp-server=$IDP

you get an python traceback like

Module: setup_saml_sp
Try to download idp metadata (1/60)
Traceback (most recent call last):
  File "/etc/univention/templates/modules/setup_saml_sp.py", line 45, in <module>
    from saml2 import BINDING_SOAP
  File "/usr/lib/python3/dist-packages/saml2/__init__.py", line 24, in <module>
    from saml2.validate import valid_instance
  File "/usr/lib/python3/dist-packages/saml2/validate.py", line 1, in <module>
    import calendar
  File "/usr/lib/python3.7/calendar.py", line 10, in <module>
    import locale as _locale
ImportError: bad magic number in 'locale': b'm\xf2\r\n'

Solution:

Just remove the file /etc/univention/templates/modules/locale.pyc with

rm -f /etc/univention/templates/modules/locale.pyc

and try again.

Mastodon