title: How do I properly override __setattr__ and __getattribute__ on new-style classes in Python?
body: <p>I want to override my Python class's <code>__getattribute__</code> and <code>__setattr__</code> methods. My use case is the usual one: I have a few special names that I want to handle, and I want the default behavior for anything else. For <code>__getattribute__</code>, it seems that I can request the default behavior simply by raising <code>AttributeError</code>. However, how can I achieve the same in <code>__setattr__</code>? Here is a trivial example, implementing a class with immutable fields "A", "B", and "C".</p>
  
  <pre><code>class ABCImmutable(SomeSuperclass):
      def __getattribute__(self, name):
          if name in ("A", "B", "C"):
              return "Immutable value of %s" % name
          else:
              # This should trigger the default behavior for any other
              # attribute name.
              raise AttributeError()
  
      def __setattr__(self, name, value):
          if name in ("A", "B", "C"):
              raise AttributeError("%s is an immutable attribute.")
          else:
              # How do I request the default behavior?
              ???
  </code></pre>
  
  <p>What goes in place of the question marks? With old-style classes, the answer was apparently <code>self.__dict__[name] = value</code>, but documentation indicates that this is wrong for new-style classes.</p>