title: TypeError: __class__ assignment only supported for heap types or ModuleType subclasses
body: <p>I'm trying to copy functions from an arbitrary 'base' class into my new object.  However, I'm getting the following error with this sample code. </p>
  
  <pre><code>class my_base:
      def print_hey():
          print("HEY")
  
      def get_one():
          print(1)
  
  class my_ext:
      def __init__(self, base):
          methods = [method for method in dir(base) if callable(getattr(base, method))]
          for method in methods:
              setattr(self, method, getattr(base, method))
  
  
  me = my_ext(my_base)
  me.get_one()
  </code></pre>
  
  <p>The above gets this error on the call to <code>setattr</code>.</p>
  
  <pre><code> TypeError: __class__ assignment only supported for heap types or ModuleType subclasses
  </code></pre>
  
  <p>The statement works if I type it into the prompt after defining the above.</p>