This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Doc/reference/datamodel: Slots description needs update
Type: behavior Stage:
Components: Documentation Versions: Python 3.0, Python 2.4, Python 3.1, Python 3.2, Python 2.7, Python 2.6, Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: Byron, georg.brandl
Priority: normal Keywords: patch

Created on 2009-10-02 17:15 by Byron, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
docfix.diff Byron, 2009-10-02 17:15 Fix for Doc/reference/datamodel.rst regarding the slots description
Messages (3)
msg93447 - (view) Author: Sebastian Thiel (Byron) Date: 2009-10-02 17:15
The section starting with:
"If a class defines a slot also defined in a base class, the instance
variable
  defined by the base class slot is inaccessible rendering the meaning
of the
  program undefined. [...]"

would need to be revisited as it claims that a check for this issue
might be added in future. As far as I can tell, it has been added in
Python 2.4 or earlier as I get a TypeError in that case.

The attached diff is my attempt to fix this issue.

Kind Regards, 
Sebastian
msg93451 - (view) Author: Sebastian Thiel (Byron) Date: 2009-10-02 17:57
Additional Information:

"multiple bases have instance lay-out conflict"

This happens only if I add __slots__ to the bases so that there is no
dict. I can reproduce this easily by indirectly deriving a class from
two bases that both define the same slot. 
It only happens if all classes define __slots__ so there is no dict.

class ac( object ):
    __slots__ = "a"

class bc( ac ):
    __slots__ = "b"

class cc( ac ):
    __slots__ = "c"

class cannotbecreated( bc,cc ):
     pass
     # raises an error.

Actually I don't know whether this is intended or if it is related to
the documentation section I pointed at.
msg94354 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-10-22 15:27
As far as I can tell, the text is still correct:

>>> class a(object): __slots__ = 'a'
>>> class b(a): __slots__ = 'a'

works without raising TypeError.

I've nevertheless enhanced the docs a bit in r75610.
History
Date User Action Args
2022-04-11 14:56:53adminsetgithub: 51285
2009-10-22 15:27:42georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg94354
2009-10-02 17:57:34Byronsetmessages: + msg93451
2009-10-02 17:15:42Byroncreate