[Python-Dev] 2.5b3, commit r46372 regressed PEP 302 machinery (sf not letting me post)

Robin Bryce robinbryce at gmail.com
Mon Aug 7 13:01:31 CEST 2006


Hi,

Appologies for the lack of an sf#. I tried to submit this there but
couldn't. (sf is logging me out each time I visit a new page and it is
refusing my attempt to post anonymously).

Python 2.5b3 (trunk:51136M, Aug  7 2006, 10:48:15)
[GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2


The need for speed patch commited in revision r46372 included a change
whose intent was to reduce the number of open calls. The `continue`
statement at line 1283 in import.c:r51136 has the effect of skipping
the builtin import machinery if the find_module method of a custom
importer returns None.

In Python 2.4.3, if find_module returned None the builtin machinery is
allowed to process the path tail.

In my particular case I am working on an importer that deals with kid
templates that may or may not exist as .py[c] files.

The short of it is that in Python 2.4.3 this produces a usable module
``__import__('foo.a/templateuri')`` wheras in 2.5b3 I get import
error. The python 2.4.3 implementation *allows* module paths that are
not seperated with '.' Python 2.5b3 does not allow this and it does
not look like this was an intentional change. I believe this point
about 'illeagal' module paths is actualy independent of the regresion
I am asserting. Detailed session logs are attatched (following the sf
guidance even though I'm posting to py-dev)

The 'use case' for the importer is: Robin wants to package a default
template file as normal python module and provide a custom importer
that allows users of his package to reference both: there own
templates and html files on the file system in arbitrary locations AND
the stock templates provided as python modules under the same name
space. He would like to leave normal imports to the standard
machinery.

Cheers,

Robin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bugreport.rst
Type: application/octet-stream
Size: 2594 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-dev/attachments/20060807/c1a25e6d/attachment.obj 


More information about the Python-Dev mailing list