Title: Fix PEP 3115 to NOT imply that the class dictionary is used in the final created class
Type: Stage:
Components: Versions:
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: joydiamond
Priority: normal Keywords:

Created on 2018-11-04 00:07 by joydiamond, last changed 2018-11-04 00:07 by joydiamond.

Messages (1)
msg329213 - (view) Author: Joy Diamond (joydiamond) Date: 2018-11-04 00:07
Fix the following in


    def __new__(cls, name, bases, classdict):
        # Note that we replace the classdict with a regular
        # dict before passing it to the superclass, so that we
        # don't continue to record member names after the class
        # has been created.
        result = type.__new__(cls, name, bases, dict(classdict))
        result.member_names = classdict.member_names
        return result


    def __new__(cls, name, bases, classdict):
        result = type.__new__(cls, name, bases, classdict)
        result.member_names = classdict.member_names
        return result

REMOVING the incorrect comment & copying of `classdict`

According to:

"When a new class is created by type.__new__, the object provided as the namespace parameter is copied to a new ordered mapping and the original object is discarded."

Hence there is no need to copy `classdict`
Date User Action Args
2018-11-04 00:07:33joydiamondcreate