title: deepcopy does not respect metaclass
body: <p>I have a class which, by design, must follow the <em>singleton</em> pattern. So I went ahead and implemented it using a <em>metaclass</em>. Everything worked nicely until a bug was reported which, in summary, said that <code>deepcopy</code>-ied instances of my <em>singleton</em> class were not the same instances.</p>
  
  <p>I can get around this bug by inheriting from a base <em>singleton</em>-type class, but I'd rather not, for reasons pointed out in <a href="https://stackoverflow.com/q/6760685/312650">this question</a>.</p>
  
  <p>A working example of this issue is presented below:</p>
  
  <pre><code>class SingletonMeta(type):
      def __init__(cls, name, bases, dict):
          super(SingletonMeta, cls).__init__(name, bases, dict)
          cls.instance = None 
      def __call__(cls,*args,**kw):
          print "SingletonMeta __call__ was called"
          if cls.instance is None:
              cls.instance = super(SingletonMeta, cls).__call__(*args, **kw)
          return cls.instance
  
  class MyClass1(object):
      __metaclass__ = SingletonMeta
  
  class SingletonBase(object):
      _instance = None
      def __new__(class_, *args, **kwargs):
          print "SingletonBase __new__ was called"
          if not isinstance(class_._instance, class_):
              class_._instance = object.__new__(class_, *args, **kwargs)
          return class_._instance
  
  class MyClass2(SingletonBase):
    pass
  
  from copy import deepcopy as dcp
  
  mm1 = MyClass1()
  mm2 = dcp(mm1)
  print "mm1 is mm2:", mm1 is mm2
  
  mb1 = MyClass2()
  mb2 = dcp(mb1)
  print "mb1 is mb2:", mb1 is mb2
  </code></pre>
  
  <p>Output: </p>
  
  <pre><code>SingletonMeta __call__ was called
  mm1 is mm2: False
  SingletonBase __new__ was called
  SingletonBase __new__ was called
  mb1 is mb2: True
  </code></pre>
  
  <p>Can you give me any pointers as to how should one resolve this issue? I'm running Python 2.7.X</p>