title: Portable meta class between python2 and python3
body: <p>I'm trying to get a python2 program working in python3, it has the following Meta class definition.  Which works just fine on Py2.  What's the "best" way to have this be compatible with both py2 and py3?</p>
  
  <p>It's failing in the unit test where it does:</p>
  
  <pre><code>try:
      raise Actor.DoesNotExist
  except Actor.DoesNotExist:
      pass
  </code></pre>
  
  <p>Failure is:</p>
  
  <pre><code>AttributeError: type object 'Actor' has no attribute 'DoesNotExist'
  </code></pre>
  
  <p>The base meta class definition is:</p>
  
  <pre><code>class MetaDocument(type):
      def __new__(meta,name,bases,dct):
  
          class DoesNotExist(BaseException):
              pass
  
          class MultipleDocumentsReturned(BaseException):
              pass
          dct['DoesNotExist'] = DoesNotExist
          dct['MultipleDocumentsReturned'] = MultipleDocumentsReturned
          class_type = type.__new__(meta, name, bases, dct)
          if not class_type in document_classes:
              if name == 'Document' and bases == (object,):
                  pass
              else:
                  document_classes.append(class_type)
          return class_type
  
  class Document(object):
      __metaclass__ = MetaDocument
  </code></pre>