• Barry Warsaw's avatar
    Application and elaboration of patch #103305 to fix core dumps when · 0395fdd3
    Barry Warsaw yazdı
    del'ing func.func_dict.  I took the opportunity to also clean up some
    other nits with the code, namely core dumps when del'ing func_defaults
    and KeyError instead of AttributeError when del'ing a non-existant
    function attribute.
    
    Specifically,
    
    func_memberlist: Move func_dict and __dict__ into here instead of
    special casing them in the setattro and getattro methods.  I don't
    remember why I took them out of here before I first uploaded the PEP
    232 patch. :/
    
    func_getattro(): No need to special case __dict__/func_dict since
    their now in the func_memberlist and PyMember_Get() should Do The
    Right Thing (i.e. transforms NULL values into Py_None).
    
    func_setattro(): Document the intended behavior of del'ing or setting
    to None one of the special func_* attributes.  I.e.:
    
        func_code - can only be set to a code object.  It can't be del'd
        or set to None.
    
        func_defaults - can be del'd.  Can only be set to None or a tuple.
    
        func_dict - can be del'd.  Can only be set to None or a
        dictionary.
    
    Fix core dumps and incorrect exceptions as described above.  Also, if
    we're del'ing an arbitrary function attribute but func_dict is NULL,
    don't create func_dict before discovering that we'll get an
    AttributeError anyway.
    0395fdd3
funcobject.c 7.73 KB