[Python-Dev] Another approach for the import mechanism (original) (raw)

Martin v. L�wis martin@v.loewis.de
06 Dec 2002 11:47:46 +0100


"Moore, Paul" <Paul.Moore@atosorigin.com> writes:

> path[0] = os.path.join(path[0],'package.zip') > > package.zip

Of course, if path[0] was originally an object, this would break...

What do you mean with "was originally", and what do you mean with "would break"?

path[0] cannot be an object originally, because the package loader inserts a string, always.

Even if it was a (non-string) object, I can't see how this would break. os.path.join would continue to work if the object is a string subclass, or atleast supports len, getitem, and add.

The result would be a string, which would be converted to a zipimport on the next package contents import.

I think that the objects-on-sys.path issue has now been resolved, but this probably acts as a reasonable "real world" example of what needs to be supported. (Unless I've misunderstood things again :-))

I recommend you try the patch, to see how it works in the real world.

Regards, Martin