I recently rediscovered this strange behaviour in Python’s Unicode handling.—Evan

True, on the outside there are no file-like objects. But the IncrementalParser gets passed the XML bytes in chunks, so it has to use a stateful decoder for decoding. Unfortunately this means that is has to use a stream API. (See <python.org> for a patch that somewhat fixes that.)

(Another option would be to completely ignore the stateful API and handcraft stateful decoding (or only support stateless decoding), like most XML parsers for Python do now.)—Walter