Bug 474090 - Cheetah does not understand all arguments for python-2.5+ import hooks
Cheetah does not understand all arguments for python-2.5+ import hooks
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: python-cheetah (Show other bugs)
rawhide
All Linux
low Severity medium
: ---
: ---
Assigned To: Mike Bonnet
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2008-12-02 01:48 EST by Toshio Ernie Kuratomi
Modified: 2009-03-23 15:35 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-03-23 15:35:32 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Patch to add level argument to importHook (1.01 KB, patch)
2009-03-23 01:11 EDT, Toshio Ernie Kuratomi
no flags Details | Diff

  None (edit)
Description Toshio Ernie Kuratomi 2008-12-02 01:48:28 EST
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 17:14:56 EDT
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 01:08:17 EDT
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 01:11:39 EDT
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 13:57:28 EDT
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 15:35:32 EDT
Thanks!  I'll close this as we're patched to work and the patch has been merged upstream.

Note You need to log in before you can comment on or make changes to this bug.