From: SourceForge.net <no...@so...> - 2012-08-20 21:07:30
|
Bugs item #3559988, was opened at 2012-08-20 14:07 Message generated for change (Tracker Item Submitted) made by abadger1999 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=422030&aid=3559988&group_id=38414 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Toshio Kuratomi (abadger1999) Assigned to: Nobody/Anonymous (nobody) Summary: Docutils 0.10 snapshot doesn't allow user created writers Initial Comment: 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: https://bugzilla.redhat.com/show_bug.cgi?id=849744 The change that made this is: http://docutils.svn.sourceforge.net/viewvc/docutils/trunk/docutils/docutils/writers/__init__.py?r1=7317&r2=7486 Which is to fix this bug on python3.3: https://sourceforge.net/tracker/?func=detail&aid=3541369&group_id=38414&atid=422030 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: try: module = __import__(writer_name, globals(), locals(), level=0) except ImportError: 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__. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=422030&aid=3559988&group_id=38414 |