[Patches] [ python-Patches-635933 ] make some type attrs writable

noreply@sourceforge.net noreply@sourceforge.net
Sat, 09 Nov 2002 07:01:56 -0800


Patches item #635933, was opened at 2002-11-09 14:59
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=635933&group_id=5470

Category: Core (C code)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Michael Hudson (mwh)
Assigned to: Guido van Rossum (gvanrossum)
Summary: make some type attrs writable

Initial Comment:
As per discussion on python-dev, this patch makes the
following attributes of type objects writable from Python:

 - __name__
 - __bases__
 - __mro__

It also relaxes the restriction on not returning
__module__ when that's been set to a non-string. This
(tiny) part is a 2.2.3 candidate IMHO.

It lets the following work:

class C(object):
    pass

class D(C):
    pass

class E(object):
    def meth(self):
        print 1

d = D()
D.__bases__ = (C, E)
d.meth()

but that's the extent of my testing so far.  Needs a
test and docs -- if the current behaviour is documented
anywhere.

Currently, if an assignment to __bases__ would change
__base__, it complains (was easiest).

Assigned to Guido so he sees it, but anyone else is
encouraged to review it!

----------------------------------------------------------------------

>Comment By: Michael Hudson (mwh)
Date: 2002-11-09 15:01

Message:
Logged In: YES 
user_id=6656

Hmm, I misunderstood __base__.  It's the base class that
*leads* to the solid base, not the solid base.  So an
assignment to __bases__ may justifyable change it.  Oops.

Will try again later...

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=635933&group_id=5470