
At 05:54 PM 3/13/2010 +0100, Lennart Regebro wrote:
On Sat, Mar 13, 2010 at 17:42, Lennart Regebro <regebro@gmail.com> wrote:
On Sat, Mar 13, 2010 at 16:07, P.J. Eby <pje@telecommunity.com> wrote:
2. It is finding a valid site.py, but the standard import protocols (i.e., imp.find_module/load_module and path_importer_cache[modulename].load_module()) are not working correctly when called on an existing module.
Yeah, this seems like the problem. It imports it, but neither globals or locals change. It's hard to say exactly what the problem is as I can't debug what happens in CPython, as no matter what I put into the local site.py, nothing seems to happen. So I't hard to me to check what the behaviour *should* be, but it seems clear that this is where the difference is.
Actually, I suddenly remembered -v, and ran python -v. and the local site.py is *not* being imported, which explains why no matter what I write in it it gets ignored. So there seems to be at least two differences here.
Perhaps PyPy also has an optimization that makes it use a built-in version of site.py, instead of using standard import logic. Finding that would be a bit harder than tracking down the imp problem, though, as it doesn't appear that site is a "builtin" in PyPy the way imp is. It does appear to be imported by http://codespeak.net/pypy/dist/pypy/bin/py.py however. (I'm assuming, btw, that by "local site.py" you mean the patching site.py, not a site.py located in say, PyPy's site-packages directory.)