title: "'NoneType' object has no attribute 'sendall'" when uploading file with Python ftplib
body: <p>I made an FTP client to transfer files to an FTP server, but it keeps showing me the same errors no matter how I change the <code>storbinary</code> function</p>
  <pre><code>from ftplib import FTP
  import os
  from pathlib import Path
  
  ftp = FTP()
  ftp.connect('127.0.0.1', 2121)
  ftp.login('user', '12345')
  ftp.pwd()
  ftp.retrlines('LIST')
  ftp.quit()
  
  def uploadfile():
      filename = 'C:\\Users\\RE\\Desktop\\Software dev\\Ftp client and server\\test.txt'
      localfile = open(filename, 'rb')
      ftp.storbinary('STOR %s' %os.path.basename(filename), localfile, 1024)
      localfile.close()
  
  uploadfile()
  ftp.retrlines('LIST')
  fetchfile()
  ftp.quit()
  </code></pre>
  <p>This is my error log</p>
  <pre class="lang-none prettyprint-override"><code>Traceback (most recent call last):
    File &quot;C:\Users\RE\Desktop\Software dev\Ftp client and server\ftp-client.py&quot;, line 24, in &lt;module&gt;
      uploadfile()
    File &quot;C:\Users\RE\Desktop\Software dev\Ftp client and server\ftp-client.py&quot;, line 21, in uploadfile
      ftp.storbinary('STOR %s' %os.path.basename(filename), localfile, 1024)
    File &quot;C:\Users\RE\AppData\Local\Programs\Python\Python37\lib\ftplib.py&quot;, line 503, in storbinary
      self.voidcmd('TYPE I')
    File &quot;C:\Users\RE\AppData\Local\Programs\Python\Python37\lib\ftplib.py&quot;, line 277, in voidcmd
      self.putcmd(cmd)
    File &quot;C:\Users\RE\AppData\Local\Programs\Python\Python37\lib\ftplib.py&quot;, line 199, in putcmd
      self.putline(line)
    File &quot;C:\Users\RE\AppData\Local\Programs\Python\Python37\lib\ftplib.py&quot;, line 194, in putline
      self.sock.sendall(line.encode(self.encoding))
  AttributeError: 'NoneType' object has no attribute 'sendall'
  </code></pre>