Just van Rossum wrote:
foo.bar is registered as a "builtin" in config.c file as
(Hm, this is problemetic if the is a distinct global builtin module "bar")
Or if any other package has a module "bar"!
find_module() should then first check sys.builtin_module_names with the full name before doing anything else. (probably only when it is confirmed that "foo" is a package.)
All that would be doable, but the real problem is the name of the init function! Only one module can define a global symbol "initbar". So the one for foo.bar would have to be called "initfoo.bar" (or something similar). On the other hand, when the same module is used dynamically, the init function must be called "initbar" again (unless the current import mechanism is changed).