[issue37623] namedtuple integration for importlib.abc.Loader

2019-08-04 Thread Andrew Yurisich
Andrew Yurisich added the comment: If anyone is interested in the progress I was able to make as a result of this discussion, feel free to check out https://github.com/captain-kark/python-module-resources/blob/d85453ff4f5022127874a5842449d95bb5eda234/module_resources/module_resources.py and

[issue37623] namedtuple integration for importlib.abc.Loader

2019-07-19 Thread Andrew Yurisich
Andrew Yurisich added the comment: This issue was raised due to a misunderstanding of the namedtuple creation process. After creating the fields, but before assigning them, __spec__ is trivially added to namedtuple class' definition as a property. Thanks again @serhiy.storchaka -- r

[issue37623] namedtuple integration for importlib.abc.Loader

2019-07-19 Thread Andrew Yurisich
Andrew Yurisich added the comment: You're right, I was invoking the namedtuple on the same line that I was defining it, freezing it in the process. I split it to into two statements, and snuck the __spec__ attribute between the definition and the instantiation. I'll update the examples on my G

[issue37623] namedtuple integration for importlib.abc.Loader

2019-07-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It is not hard to set __spec__ (as well as any other attributes) after creating a namedtuple class. A = namedtuple(...) A.__spec__ = ... or class A(namedtuple(...)): __spec__ = ... __spec__ do not have anything to namedtuple. It is not like __module_

[issue37623] namedtuple integration for importlib.abc.Loader

2019-07-19 Thread Eric V. Smith
Eric V. Smith added the comment: I think using a dataclass here would be easier, since you can control class variables. Is there some reason that your loader must be a namedtuple? Something like: from typing import ClassVar from dataclasses import dataclass @dataclass class MyLoader: __

[issue37623] namedtuple integration for importlib.abc.Loader

2019-07-19 Thread Raymond Hettinger
Change by Raymond Hettinger : -- nosy: +ethan.furman ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://

[issue37623] namedtuple integration for importlib.abc.Loader

2019-07-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: Brett, do you have any thoughts on this? My initial take is that __spec__ is primarily about import logic and that it likely shouldn't creep into exec'd code like dataclasses and named tuples. Also, I'm reluctant to expand the API for something that loo

[issue37623] namedtuple integration for importlib.abc.Loader

2019-07-18 Thread Eric V. Smith
Change by Eric V. Smith : -- assignee: -> rhettinger nosy: +eric.smith, rhettinger ___ Python tracker ___ ___ Python-bugs-list mail

[issue37623] namedtuple integration for importlib.abc.Loader

2019-07-18 Thread Roundup Robot
Change by Roundup Robot : -- keywords: +patch pull_requests: +14639 stage: -> patch review pull_request: https://github.com/python/cpython/pull/14848 ___ Python tracker ___ __

[issue37623] namedtuple integration for importlib.abc.Loader

2019-07-18 Thread Andrew Yurisich
New submission from Andrew Yurisich : I wanted to return a namedtuple from a concrete implementation of an importlib.abc.Loader base class, and wasn't able to provide a __spec__ property on the underlying class behind the namedtuple. All return values from importlib.abc.Loader#create_module n