Python3: ftp file upload throws TypeError: Type str doesn't support the buffer API
<p>I'm using python 3.4.2 to upload a logfile to an ftp server (I removed the try and with statements for simplicity's sake):</p>

<pre><code>import ftplib

ftp = ftplib.FTP(url)
ftp.login(name, password)
ftp.storlines("STOR " + "mylog.log", open("log/mylog.log"))
ftp.close()
</code></pre>

<p>The mylog.log file has a "text/plain; charset=us-ascii" encoding. <s>On my macbook everything works fine.</s> When I execute my little program on a raspberry pi (via ssh), I get the following error message:</p>

<pre><code>Traceback (most recent call last):
  File "./ftptest.py", line 7, in &lt;module&gt;
    ftp.storlines("STOR " + "mylog.log", open("log/mylog.log"))
  File "/usr/lib/python3.4/ftplib.py", line 537, in storlines
    if buf[-1] in B_CRLF: buf = buf[:-1]
TypeError: Type str doesn't support the buffer API
</code></pre>

<p>I guess it's some encoding and/or local settings issue. What am I doing wrong? What is the best practice here?</p>