Bug 474090 - Cheetah does not understand all arguments for python-2.5+ import hooks
Summary: Cheetah does not understand all arguments for python-2.5+ import hooks
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: python-cheetah
Version: rawhide
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Mike Bonnet
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2008-12-02 06:48 UTC by Toshio Ernie Kuratomi
Modified: 2009-03-23 19:35 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2009-03-23 19:35:32 UTC
Type: ---
Embargoed:


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

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.


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