A new test in test_importlib is discovering that pyexpat is creating both its errors and model modules by hand in pyexpat's initialization function. Should at least set __loader__ to None there.
Should this be done in Modules/pyexpat.c file or in Lib/xml/parsers/expat.py? If modifying expat.py is sufficient, then attached simple patch does the job. By the way I couldn't find the test you are referring to. Is it in Lib/test/test_importlib of somewhere else?
The comment is out of date; I removed the test because it was constantly failing. As for the patch, it looks correct, but I plan to make a change to Python so that __loader__ is set by default (see the dependent issue #17115). If I don't get to that change I will commit the patch, else it will implicitly get fixed.