On 07/31/2012 03:16 PM, Toshio Kuratomi wrote: > On Fri, Jul 27, 2012 at 12:27:31PM +1000, Nick Coghlan wrote: >> On 07/27/2012 07:28 AM, David Malcolm wrote: >>> With my proposed approach, you have to opt-in, your code can say: when I >>> say "xml", I really mean "xml", not "_xmlplus". >> >> You can do much the same thing at the application level without patching >> the stdlib: >> >> import xml >> xml.__path__.reverse() # If both are available, prefer stdlib over PyXML >> >> The key point is to keep both path fragments, and just rearrange the >> order so the standard lib if first. That way the PyXML-only stuff will >> still be accessible, but the stdlib will be preferred for any name >> conflicts in package level components that get imported after the path >> reversal. >> > Thanks, Nick! > > I just patched docutils with this and submitted the patch to docutils > upstream. Works in my testing.
It occurs to me that this will behave a little strangely if two different libraries in the same process try to make the same change. A more robust check would be: if "_xmlplus" in xml.__path__[0]: xml.__path__.reverse() Cheers, Nick. -- Nick Coghlan Red Hat Infrastructure Engineering & Development, Brisbane _______________________________________________ python-devel mailing list python-devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/python-devel