title: Python 3 corrupted file writing to smb share (Python 2 works)
body: <p>I've got code for copying files to a network share.  The code works fine (on mac) from python 2.7.17, but gives me a corrupt file with Python 3.7.6.  I don't know if this is a bug, or a change between python2 and python3 that I'm unaware of, but I'm at a loss for how to get my code working.</p>
  
  <p>I'm reading a 300MB file from local filesystem into memory, checking the sha1 of the content, then writing the content to a network share (<code>mount -t smbfs ...</code> called from <code>subprocess.check_output</code>).</p>
  
  <pre><code>def read(path):
      with open(path, "rb") as f:
          return f.read()
  def write(content, smbpath, sha1):
      with open(smbpath, "wb") as f:
          if (sha1 == hashlib.sha1(content).hexdigest())
              f.write(content)
  
  localroot = &lt;local path&gt;
  smbroot = &lt;remote path&gt;
  file = &lt;some file.7z&gt;
  content = read(os.path.join(localroot, file)
  write(content, os.path.join(smbroot, file), &lt;sha read from local system&gt;)
  </code></pre>
  
  <p>Python says the file SHA values match, but when I compute the sha manually (<code>shasum smbroot/&lt;file&gt;</code> from terminal), it gives a different sha.  If I copy the file back to the local filesystem, it differs from the original and produces the same (invalid) SHA as <code>shasum</code> produced on the share.</p>
  
  <p>I suspected an issue might be with the network disk, but </p>
  
  <ul>
  <li>it works fine from python2 and </li>
  <li>copying files manually from the terminal works.</li>
  </ul>
  
  <p>So this seems to be specific to Python3.  Are there known changes or bugs?</p>