
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2017-05-24 20:41 byAaron Hall, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 1822 | merged | Aaron Hall,2017-05-26 04:45 | |
| Messages (4) | |||
|---|---|---|---|
| msg294389 -(view) | Author: Aaron Hall (Aaron Hall)* | Date: 2017-05-24 20:41 | |
We have __slots__ with other ABC's, seehttp://bugs.python.org/issue11333 andhttp://bugs.python.org/issue21421.There are no downsides to having empty slots on a non-instantiable class, but it does give the option of denying __dict__ creation for subclassers. The possibility of breaking is for someone using __slots__ but relying on __dict__ creation in a subclass - they will have to explicitly add "__dict__" to __slots__. Since we have added __slots__ to other ABC's, I will provide a PR soon on this. Diff should look like this (inLib/abc.py):class ABC(metaclass=ABCMeta): """Helper class that provides a standard way to create an ABC using inheritance. """- pass+ __slots__ = ()(I also want to add a test for this, and ensure other ABC's also have this if they don't.) | |||
| msg294420 -(view) | Author: Raymond Hettinger (rhettinger)*![]() | Date: 2017-05-25 00:46 | |
This seems reasonable. | |||
| msg295297 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2017-06-06 19:34 | |
New changesetff48739ed0a3f366c4d56d3c86a37cbdeec600de by Serhiy Storchaka (Aaron Hall, MBA) in branch 'master':bpo-30463: Add an empty __slots__ to abc.ABC.https://github.com/python/cpython/commit/ff48739ed0a3f366c4d56d3c86a37cbdeec600de | |||
| msg356740 -(view) | Author: Chris Withers (cjw296)*![]() | Date: 2019-11-16 01:14 | |
I will note that this means with:class BaseClass(ABC): passclass MyDerivedClass(BaseClass): def __init__(self, thing): self.thing = thingthing = MyDerivedClass()thing now has both __slots__ and, evidently, a dict. That's a bit weird and confusing. | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:46 | admin | set | github: 74648 |
| 2019-11-16 01:14:18 | cjw296 | set | nosy: +cjw296 messages: +msg356740 |
| 2017-06-06 19:38:51 | serhiy.storchaka | set | status: open -> closed versions: + Python 3.7 resolution: fixed components: + Library (Lib) type: enhancement stage: resolved |
| 2017-06-06 19:34:59 | serhiy.storchaka | set | nosy: +serhiy.storchaka messages: +msg295297 |
| 2017-05-26 20:24:30 | levkivskyi | set | nosy: +levkivskyi |
| 2017-05-26 04:45:34 | Aaron Hall | set | pull_requests: +pull_request1908 |
| 2017-05-25 00:46:51 | rhettinger | set | nosy: +rhettinger messages: +msg294420 |
| 2017-05-24 20:41:17 | Aaron Hall | create | |