[New-bugs-announce] [issue45746] ftplib please revisit retrlines('RETR as it produces files without newlines

Matthew H. McKenzie report at bugs.python.org
Sun Nov 7 20:49:30 EST 2021


New submission from Matthew H. McKenzie <github1 at swellhunter.org>:

Lib/ftplib.py  function retrlines

Inspired by documentation the following writes a file without line-endings:
 
from ftplib import FTP
ftp=FTP()
ftp.connect('hostname')
ftp.login('user','xxxxxxxx')
ftp.sendcmd('pasv')

with open('crap2.txt', 'w') as fp:
    ftp.retrlines('RETR crap.txt', fp.write)

Code goes to pains to slice off the line endings, and then print_line does not add them back? Apologies if this has been covered before, or I am not following the documentation correctly. Not going to suggest a fix as there may be a reason it is like this.

For RETR.
For ascii

----------
components: Library (Lib)
files: crap2.txt
messages: 405921
nosy: mckenzm
priority: normal
severity: normal
status: open
title: ftplib please revisit retrlines('RETR  as it produces files without newlines
versions: Python 3.11
Added file: https://bugs.python.org/file50429/crap2.txt

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45746>
_______________________________________


More information about the New-bugs-announce mailing list