Red Hat Bugzilla – Bug 474090
Cheetah does not understand all arguments for python-2.5+ import hooks
Last modified: 2009-03-23 15:35:32 EDT
Description of problem:
While rebuilding cheetah for python-2.6 we encountered a problem where it failed to pass its unit tests. Further diagnosis found that cheetah overrides the pythonstandard import hook (so it can import its templates?) but does not understand the level parameter that was added in python-2.5 to allow relative and absolute imports to be differentiated. In python-2.6, one of the standard libraries that cheetah imports (re) uses this syntax so cheetah issues an exception.
I've added a patch for cheetah's importHook function so that we can rebuild it against python-2.6 but it's only a workaround (or the first step of a new patch). The patch causes cheetah's importHook to accept the relative and absolute distinction made via the level parameter. To be complete, the importHook must then decide whether to perform a relative import, absolute import, or try both. Currently it tries both no matter what and so it's incomplete.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Using python-2.6
2. In the python-cheetah/devel branch, disable the python-cheetah-import.patch
3. make i386
Tests fail and rpm fails to build due to importHook() not taking the extra parameter.
python-cheetah-import.patch is incomplete. It accepts the level parameter but doesn't change the import processing if it's present.
Can you please supply either a valid patch, valid test case for the issue (or both!).
I'm not entirely certain how to reproduce the error such that I can fix it in the next release of Cheetah Community Edition.
test case would be:
Make sure you're running with python-2.6 (so that the re module has the code that causes cheetah problems)
install cheetah from source.
This should issue an exception in the test suite.
I'll attach the patch we're using.
Created attachment 336241 [details]
Patch to add level argument to importHook
This is the patch we're using. It simply adds the level argument but doesn't do anything with it. This is enough to fix the unit tests but cheetah doesn't actually conform to the importHook spec until it does something with that argument. Information on the signature for the new importHook is here::
I have committed a slightly modified version of this patch into the Cheetah Community Edition git repository, in the "next" branch which can be found here: http://github.com/rtyler/cheetah/tree/next
The next version of Cheetah CE will be v2.1.1 and is slated for release on April 16th.
Thanks! I'll close this as we're patched to work and the patch has been merged upstream.