Bug 474090

Summary: Cheetah does not understand all arguments for python-2.5+ import hooks
Product: [Fedora] Fedora Reporter: Toshio Ernie Kuratomi <a.badger>
Component: python-cheetahAssignee: Mike Bonnet <mikeb>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: rawhideCC: mikeb, tyler
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-03-23 19:35:32 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Patch to add level argument to importHook none

Description Toshio Ernie Kuratomi 2008-12-02 06:48:28 UTC
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):


How reproducible:
every time

Steps to Reproduce:
1. Using python-2.6
2. In the python-cheetah/devel branch, disable the python-cheetah-import.patch
3. make i386
  
Actual results:
Tests fail and rpm fails to build due to importHook() not taking the extra parameter.

Expected results:
Tests pass.

Additional info:
python-cheetah-import.patch is incomplete.  It accepts the level parameter but doesn't change the import processing if it's present.

Comment 1 R. Tyler Ballance 2009-03-22 21:14:56 UTC
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.


Cheers.

Comment 2 Toshio Ernie Kuratomi 2009-03-23 05:08:17 UTC
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.
python /usr/lib/python2.6/site-packages/CheetahTests/Test.py

This should issue an exception in the test suite.

I'll attach the patch we're using.

Comment 3 Toshio Ernie Kuratomi 2009-03-23 05:11:39 UTC
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::

  http://www.python.org/doc/2.5.2/lib/built-in-funcs.html

Comment 4 R. Tyler Ballance 2009-03-23 17:57:28 UTC
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.

Comment 5 Toshio Ernie Kuratomi 2009-03-23 19:35:32 UTC
Thanks!  I'll close this as we're patched to work and the patch has been merged upstream.