[Python-Dev] Dots in name break import -- fixable? (original) (raw)

Evan Simpson evan at 4-am.com
Tue Jan 6 16:34:41 EST 2004


There must be some code in the import machinery that assumes (with excellent reason) that the name of the module from which it is called will never contain periods. Consider the following:

name = 'a.b.c' import string string <module 'a.b.string' from '/usr/lib/python2.3/string.pyc'>

The peculiar behavior is only triggered by periods:

name = ''.join(map(chr, range(1, 256))).replace('.', '') import string string <module 'string' from '/usr/lib/python2.3/string.pyc'>

Would this be easy to fix?

It would fall into the realm of "so don't do that!" except that Zope's Python Scripts set their name to their Zope Id, which can contain periods.

Cheers,

Evan @ 4-am



More information about the Python-Dev mailing list