[Python-Dev] [Python-checkins] r43033 - in python/trunk/Lib: distutils/sysconfig.py encodings/init.py (original) (raw)
Guido van Rossum guido at python.org
Wed Mar 15 22:34:38 CET 2006
- Previous message: [Python-Dev] [Python-checkins] r43033 - in python/trunk/Lib: distutils/sysconfig.py encodings/__init__.py
- Next message: [Python-Dev] [Python-checkins] r43033 - in python/trunk/Lib: distutils/sysconfig.py encodings/__init__.py
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Because Thomas designed it this way. :-)
I believe his design makes sense though: "import foo" translates to import(foo, ...).
There's a separate setting, only known to the compiler, that says whether "from future import absolute_import" is in effect (there's no way to slip a flag into globals to convey this setting, since code is compiled independently from globals, and there are ways to pass flags to the compiler without explicitly doing the future import).
So the compiler emits different code when the future syntax is in effect, and that opcode must pass its knowledge to import. This is done trough the 5th argument, which also tells us how many leading dots there were. Without the future import, the 5th argument is omitted (as long as there aren't any leading dots).
--Guido
On 3/15/06, Phillip J. Eby <pje at telecommunity.com> wrote:
At 10:33 AM 3/15/2006 -0800, Guido van Rossum wrote: >Well, absolute imports without the future statement will not use the >5th argument, so they won't break, right? That's what MAL also says. >Someone please fix this.
Why is a 5th argument needed to do absolute imports? Shouldn't it suffice to supply a globals argument with no path and an undotted name? ISTM that passing in the builtins dictionary as the globals argument ought to do the trick.
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-Dev] [Python-checkins] r43033 - in python/trunk/Lib: distutils/sysconfig.py encodings/__init__.py
- Next message: [Python-Dev] [Python-checkins] r43033 - in python/trunk/Lib: distutils/sysconfig.py encodings/__init__.py
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]