[pypy-dev] __file__ attribute of mixed modules
tismer at stackless.com
Tue Nov 13 09:19:13 CET 2007
Antonio Cuni wrote:
> Hi all,
> I'm having troubles running pypy-cli on windows.
> One of the problem is due to the __file__ attribute of mixed modules;
> currently it's something like path/to/mixed/module/*.py.
> When site.py runs, it tries to compute the abspath of every module
> loaded; after a bit of indirections, abspath call the posix__getfullpath
> helper written in C#.
> The most obvious (and probably most correct) way to implement
> posix__getfullpath is to delegate to System.IO.Path.GetFullPath; here is
> where problems come, since the CLR implementation of GetFullPath
> complains if we pass it a name with an asterisk (Mono doesn't). This
> prevents pypy-cli to start.
> One possible solution would be to place a check inside the C# helper and
> not call GetFullPath in case there is an asterisk in the name (or maybe
> remove the asterisk, call GetFullPath and re-insert the asterisk). I
> think this solution is ugly and hackish.
> Another solution is to change the way we assign __file__ to mixed
> modules; e.g., we could use the name of the directory itself, or
> __init__.py instead of *.py. Or maybe some weird name like
> 'i_dont_really_exist.py', etc.
I think we have to choose some different notation than "*".
It is probably meant as a wild card, but I'm not astonished
that this doesn't work well with all path functions.
We should stick with correct filename syntax for all platforms.
In any case, I would recommend to stick with GetFullPath and
not implement them alone. The rules are that weird and half-defined
that it is fine to let MS worry about that.
The __init__.py naming is not that bad. There are other ways
possible to distinguish mixed modules from others.
ciao - chris
Christian Tismer :^) <mailto:tismer at stackless.com>
tismerysoft GmbH : Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9A : *Starship* http://starship.python.net/
14109 Berlin : PGP key -> http://wwwkeys.pgp.net/
work +49 30 802 86 56 mobile +49 173 24 18 776 fax +49 30 80 90 57 05
PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04
whom do you want to sponsor today? http://www.stackless.com/
More information about the Pypy-dev