#124 closed defect (invalid)

Small bug in docs

Reported by: ftputiluser Owned by: schwa
Priority: minor Milestone:
Component: Library Version:
Keywords: Cc:

Description (last modified by schwa)

The very first sample code on the site seems to contain an error: https://ftputil.sschwarzer.net/trac/wiki/Documentation#introduction

    with ftp_host.open("index.html", "rb") as source:
        with ftp_host.open("newdir/index.html", "wb") as target:
            ftp_host.copyfileobj(source, target)  # similar to shutil.copyfileobj

Unless I'm mistaken and my working code is doing something it should not, that should be "with open( ... as source", as a local file, and with "ftp_host.open( ... as target" for the remove file. That is, you're opening the local file as a regular Python file object, not as an ftputil remote object.

Change History (5)

comment:1 Changed 12 months ago by schwa

Description: modified (diff)

comment:2 Changed 12 months ago by schwa

Status: newassigned

It should be possible to copy a remote file to another remote location, as in the example code. Remote files support reading and writing. So I think the code is intentional as it is.

When you say

Unless I'm mistaken and my working code is doing something it should not,

what did you try and in which way did it fail?

comment:3 Changed 12 months ago by ftputiluser

My apologies -- somehow I missed the remote file in the comments. Please allow me to hang my head in shame and slink out, while offering thanks for your time and intelligence.

comment:4 Changed 12 months ago by schwa

Now, now, it's fine. We all make mistakes. :-)

I do appreciate that you entered a ticket about a documentation bug! Not many people do this. Of course it's possible that a bug isn't really a bug, but naturally you don't know this in advance. So relax and keep entering such tickets. :-)

comment:5 Changed 12 months ago by schwa

Resolution: invalid
Status: assignedclosed

Closing this as "invalid" because it's not actually a mistake.

Note: See TracTickets for help on using tickets.