Brett Cannon added the comment:

I think we view the fundamentals of built-in types differently as well. =) A 
module instance can exist without a spec no problem. As long as you don't pass 
that module instance through some chunk of code that expects __spec__ -- or any 
other attribute for that matter -- then the instance is fine and operates as 
expected. There is nothing fundamental to module objects which dictates any 
real attribute is set (not even __name__). If I wanted to construct a module 
from scratch and just wanted a blank module object which I assign attributes to 
manually then I can do that, and that's what types.ModuleType provides (sans 
its module name requirement in its constructor which really isn't necessary 
either).

This also means that tying the functionality of the module type to importlib is 
the wrong direction to have the dependency. That means I refuse to add code to 
the module type which requires that importlib have been imported and set up. 
Just think of someone who embeds Python and has no use for imports; why should 
the module type then be broken because of that choice? That means anything done 
to the module type needs to be done entirely in C.

But luckily for you bytes broke the glass ceiling of pivoting on a type's 
constructor based on its input type (it is the only one, though). So I'll let 
go on arguing that one. =)

Anyway, I'll think about changing types.ModuleType, but having to implement 
init_module_attrs() in pure C and then exposing it in _imp just doesn't sound 
like much fun.

And as for your preference that "the distinct functions continue to exist as 
they are", are you saying you want the code duplicated or that you just don't 
like me merging the create() and init_module_attrs() functions?

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue20383>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to