Working on a snapshot since we're going to need to support python-3.3 for the next version of Fedora. A mercurial maintainer noticed that the behaviour of docutils has changed. mercurial has a locally created writer to take in rst and output manpages. With the snapshot they are unable to get docutils to load this:
The change that made this is:
Which is to fix this bug on python3.3:
It looks like the python-3.3 change is that python3.3 no longer allows __import__ to take a level argument of -1. That argument allowed __import__ to search both absolute and relative paths for the module. The current code fixed that by changing level to "1" which only searches a relative path for the module. This works for the modules inside of docutils because they are located in the parent package of the code that loads them. Out-of-tree modules break with this scheme because the module is not a child of the docutils package.
To fix this the code can do something like this:
module = __import__(writer_name, globals(), locals(), level=0)
module = __import__(writer_name, globals(), locals(), level=1)
What this does is first look for the module as an absolute import. This will be triggered if it's a user defined module. If no module is found as an absolute import it then looks in the parent of the module that called it. This is where all current modules shipped with docutils are called.
This code is what is closest to level=-1 which is present in python2.x and python3 up to python3.2.
It might make sense to revisit hardcoded's patch to issue 3541369 to implement this as the try: except is boilerplate in all the places we need to use __import__.