Fixed #21509 – Narrowed catching of exceptions in XML assertions.

https://code.djangoproject.com/ticket/21509