title: How can I debug a problem calling Python's copy.deepcopy() against a custom type?
body: <p>In my code I'm trying to take copies of instances a class using <code>copy.deepcopy</code>.  The problem is that under some circumstances it is erroring with the following error:</p>
  
  <pre><code>TypeError: 'object.__new__(NotImplementedType) is not safe, use NotImplementedType.__new__()'
  </code></pre>
  
  <p>After much digging I have found that I am able to reproduce the error using the following code:</p>
  
  <pre><code>import copy
  copy.deepcopy(__builtins__) 
  </code></pre>
  
  <p>The problem appears to be that at some point it is trying to copy the <code>NotImplementedType</code> builtin.  The question is why is it doing this?  I have not overridden <code>__deepcopy__</code> in my class and it doesn't happen all the time.  Does anyone have any tips for tracking down where the request to make a copy of this type comes from?</p>
  
  <p>I've put some debugging code in the <code>copy</code> module itself to ensure that this is what's happening, but the point at which the problem occurs is so far down a recursive stack it's very hard to make much of what I'm seeing.</p>