[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-05-30 Thread Brett Cannon
Brett Cannon added the comment: Giving Eric is polymorphic first argument to types.ModuleType() is going to be tricky thanks to the fact that it is not hard-coded anywhere in the C code nor documented that the first argument must be a string (the only way it might come up is from

[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-05-30 Thread Brett Cannon
Brett Cannon added the comment: Another issue with the polymorphic argument is that the module type is one of those rare things written in C with keyword parameter support, so renaming the 'name' argument to 'name_or_spec' could potentially break code. --

[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-05-30 Thread Eric Snow
Eric Snow added the comment: Yeah, it just looks too complicated to take the ModuleType signature approach, as much as I prefer it. :) I appreciate you taking a look though. -- ___ Python tracker rep...@bugs.python.org

[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-05-30 Thread Brett Cannon
Brett Cannon added the comment: And another complication is the compatibility hack to set loader when submodule_search_locations is set but loader is not since _NamespaceLoader is not exposed in C without importlib which gets us back into the whole question of whether types should function

[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-05-30 Thread Eric Snow
Eric Snow added the comment: But that part is less of a concern since we don't need namespace packages before or during bootstrapping, and afterward we have access to interp-importlib. Or am I missing something? which gets us back into the whole question of whether types should function

[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-05-30 Thread Roundup Robot
Roundup Robot added the comment: New changeset b26d021081d2 by Brett Cannon in branch 'default': Issue #20383: Introduce importlib.util.module_from_spec(). http://hg.python.org/cpython/rev/b26d021081d2 -- nosy: +python-dev ___ Python tracker

[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-05-30 Thread Brett Cannon
Brett Cannon added the comment: After all the various revelations today about how much of a hassle and murky it would be to get types.ModuleType to do what we were after, I went ahead and kept importlib.util.module_from_spec(), but dropped the module argument bit. I also deconstructed

[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-05-30 Thread Eric Snow
Eric Snow added the comment: Thanks for doing that Brett and for accommodating me. :) Also, the various little cleanups are much appreciated. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20383

[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-05-30 Thread Nick Coghlan
Nick Coghlan added the comment: Another thing to keep in the back of your minds: one of my goals for PEP 432 is to make it possible to have a fully functional embedded interpreter up and running *without* configuring the Python level import system. This is the state the interpreter would be in

[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-05-27 Thread Brett Cannon
Brett Cannon added the comment: Why do you want a one-liner wrapper for the functions for the public API when they are exactly the same? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20383

[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-05-27 Thread Eric Snow
Eric Snow added the comment: You're right that it doesn't have to be a one-line wrapper or anything more than an import-from in importlib.util. :) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20383

[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-05-26 Thread Eric Snow
Eric Snow added the comment: Okay, I didn't read closely enough. :) It may be worth updating the title. FWIW, the name module_from_spec confused me at first because my brain interpreted that as load_from_spec. Keeping the name and purpose more focused might be helpful. I have comments

[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-05-26 Thread Brett Cannon
Brett Cannon added the comment: First, about breaking up _SpecMethods: that was entirely on purpose. =) I honestly have found _SpecMethods a bit of a pain to work with because at every place where I have a spec object and I need to operate on it I end up having to wrap it and then call a

[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-05-26 Thread Eric Snow
Eric Snow added the comment: tl;dr I'm okay with pulling the functions out of _SpecMethods (and dropping the class) but I'd prefer the distinct functions continue to exist as they are. Also, I still think updating the ModuleType signature is the way to go (given current use cases). :) First,

[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-05-26 Thread Brett Cannon
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

[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-05-26 Thread Eric Snow
Eric Snow added the comment: I give. :) You've made good points about builtins and C implementations. Also, thinking about issue #21235 has changed my perspective a bit. As to _SpecMethods, I mean just drop the class and turn the methods into functions: * name: name - _spec_name (or

[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-05-24 Thread Brett Cannon
Brett Cannon added the comment: Nope, I commented where I meant to. I wanted a way to promote people to **always** create modules with properly initialized attributes while also dealing with the module creation dance at the same time. Otherwise it will require expanding the API of

[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-05-24 Thread Nick Coghlan
Nick Coghlan added the comment: I'd ask Why not a class method?, but I already know the answer (types.ModuleType is implemented in C, so it would be unnecessarily painful to implement it that way). Given that, the utility function approach sounds good to me. --

[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-05-23 Thread Eric Snow
Eric Snow added the comment: @Brett: Did those last two messages (and the patch) get on the wrong issue. The issue of module_from_spec() or the like seems somewhat orthogonal to a spec argument to ModuleType. Perhaps you meant issue #21436 or #21235? Otherwise, I have a few comments. :)

[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-05-18 Thread Brett Cannon
Brett Cannon added the comment: Here is an implementation of importlib.util.module_from_spec(). With this it makes PEP 451 conceptually work like: spec = importlib.util.find_spec(name) module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) About the only other

[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-05-11 Thread Arfrever Frehtes Taifersar Arahesis
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com: -- nosy: +Arfrever ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20383 ___

[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-05-05 Thread Brett Cannon
Brett Cannon added the comment: My current thinking on this it to introduce in importlib.util: def module_from_spec(spec, module=None): Create/initialize a module based on the provided spec. If a module is provided then spec.loader.create_module() will not be consulted.

[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-04-06 Thread Nick Coghlan
Nick Coghlan added the comment: No, the attribute level arguments won't go away - __name__ deliberately differs from __spec__.name in some cases (notably in __main__), __path__ may be manipulated after the module is loaded, and __name and __file__ are both used too heavily within module code

[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-04-06 Thread Brett Cannon
Brett Cannon added the comment: I can dream about getting rid of the attributes, but I doubt it would happen any time soon, if at all. But we do need to make it easier to set __spec__ on a new module than it currently is to help promote its use. --

[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-04-05 Thread Eric Snow
Eric Snow added the comment: Sounds good to me. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20383 ___ ___ Python-bugs-list mailing list

[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-04-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: Would allow for the name attribute to be optional ... with the idea that sometime in the future we can deprecate pulling attributes from a module directly Is there any chance that this would ever happen? The __name__ attribute has been around almost

[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-04-05 Thread Eric Snow
Eric Snow added the comment: I made roughly the same point in the current import-sig thread that relates here: https://mail.python.org/pipermail/import-sig/2014-April/000805.html Basically, I agree we should be careful with both __name__ and __file__. --

[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-04-04 Thread Brett Cannon
Brett Cannon added the comment: I envision making this happen would also allow for importlib to be updated to rely on __spec__ when possible, with the idea that sometime in the future we can deprecate pulling attributes from a module directly and shift to always working from __spec__.

[issue20383] Add a keyword-only spec argument to types.ModuleType

2014-01-24 Thread Brett Cannon
New submission from Brett Cannon: Would allow for the name attribute to be optional since it can be grabbed from the spec. Since having module.__spec__ set is now expected we should help ensure that by supporting it in the constructor. -- components: Library (Lib) messages: 209100