There's no reason to expect this to work. jterrace dug around in the internals of ElementTree and came up with a hacky worakround that acts directly on those internals. You're trying to use it on a different implementation, with different internals, so of course it's not going to work.
But… if you look at the source to cElementTree, you can see that the way it handles namespace registration is… to execute some Python code that imports ElementTree
and uses its namespace registry. So, instead of this:
import xml.etree.cElementTree as etree
# ...
if namespace_uri not in etree._namespace_map:
You may be able to just import both, then access it off ElementTree
instead of cElementTree
. For example:
import xml.etree.cElementTree as etree
import xml.etree.ElementTree
# ...
if namespace_uri not in ElementTree._namespace_map:
(Obviously do the same for the other references to it.)
No guarantees this will work. It'll get you past this error, but you'll have to read the code to see if replacing fixtag
will have the same effect on cElementTree that you want, or whether there's something else you have to do.