Code review comment for lp:~maxb/launchpad/py2.6-importfascist

Revision history for this message
Max Bowsher (maxb) wrote :

This branch upgrades the importfascist's __import__ hook to include the fifth argument 'level' which was introduced in Python 2.5.

We have survived without this change so far, as few things use it yet.

I am submitting this branch now as preparatory effort for the future move to Python 2.6, as internal parts of Python such as PyImport_Import(modulename) start to use the level parameter there.

The semantics of level are as follows:

  -1 : traditional behaviour
   0 : absolute import, do not even try to consider as relative
  >=1 : explicit relative import, stated number of levels up

Because the existing importfascist makes no attempt to support relative imports, and binning the current implementation has been discussed as a likely option, I have taken the simple route of just accepting and propagating the parameter without bothering to use it in any way.

This does not weaken the import fascist any more than it already is liable to fail to properly process relative imports.

This change was previously part of the python-migration2.6 sprint branch, now cherrypicked for landing on devel whilst still in the 2.5 era.

« Back to merge proposal