title: How to create new closure cell objects?
body: <p>I need to monkey-patch my library to replace an instance of a symbol, and it's getting referenced by some function closures. I need to copy those functions (since I also need access to original unpatched version of the function as well), but <code>__closure__</code> is immutable, and I can't <code>copy.copy</code> it, so how can I create new closure cells objects in Python 2.7?</p>
  
  <p>I for example given this function</p>
  
  <pre><code>def f():
      def incorrectfunction():
          return 0
      def g():
          return incorrectfunction()
      return g
  
  def correctfunction():
      return 42
  
  func = f()
  patched_func = patchit(f)   # replace "incorrectfunction"
  print func(), patched_func()
  </code></pre>
  
  <p>And I want to see</p>
  
  <pre><code>0, 42
  </code></pre>