title: Swapping function implementation does not work
body: <p>Suppose, I have a 3rd party library that I am not allowed to modify. Suppose, it is called Fabric, but that is important only to explain the symptoms.</p>
  
  <p>The script processes a list of existing files to get them using <code>fabric.operations.get</code>, which in its turn calls <code>fabric.sftp.SFTP.get</code>. Using <code>fabric.sftp.SFTP.get</code> produced some <code>Warning: get() encountered an exception while downloading ... Underlying exception: Permission denied</code>. I noticed the implementation was too old, and swapped the implementation of that function for one that uses sudo to work around the <code>Permission denied</code>:</p>
  
  <pre><code>import fabric.sftp
  def sftpget(....same args as in current implementation....):
    ...here I pasted fabric.sftp.SFTP.get from the Internet
  # swapping the implementation
  fabric.sftp.SFTP.get=sftpget
  </code></pre>
  
  <p>This worked in 99.999% of cases. But getting three files still results in the same error. I tried to see if that is caused by some other codepath, but the only place where that string is printed is in <code>fabric.operations.get</code> in <code>except:</code> clause (grepped <code>/usr/lib/python2.6/site-packages/</code> for <code>get() encountered an exception while downloading</code>). I tried to swap that function for a implementation that will print the stack trace of the exception, but I still only get the <code>Permission denied</code> message, and <em>no stack trace</em>.</p>
  
  <p>It looks like the function does not get swapped in this case.</p>
  
  <p>What could be the reasons for some invocations to use the original <code>fabric.operations.get</code> (since I don't see the stack traces printed) (and possibly the unpatched <code>fabric.sftp.SFTP.get</code>, since it seems sudo fix is not being used - I did check manually that those operations can be done on those files)?</p>