Opened 7 years ago

Closed 7 years ago

#80 closed defect (duplicate)

.makedirs() problem with unicode

Reported by: ftputiluser Owned by: schwa
Priority: major Milestone: 3.1
Component: Library Version:
Keywords: makedirs Cc:


First, let me thank you for this excellent module. It saved me a lot of time and frustration.

Now to the problem. I have written a ftp module/wrapper over proftpd. It works nice. I have also written a lot of tests (pytest) of this module, which uses ftputil.

Everything worked nicely, until suddenly, out of nowhere, after month of using, ftputil starts to fail at strange unicode error.

It fails when the .makedirs() is called. I've realized, that it is probably caused by localized error message '550 paired: Adres\xc3\xa1\xc5\x99 nen\xc3\xad pr\xc3\xa1zdn\xc3\xbd' sent by server, which is in czech language.

self = <ftputil.error.FtplibErrorToFTPOSError object at 0x96959ec>
exc_type = <class 'ftplib.error_perm'>
exc_value = error_perm('550 paired: Adres\xc3\xa1\xc5\x99 nen\xc3\xad pr\xc3\xa1zdn\xc3\xbd',)
traceback = <traceback object at 0x9724a04>

    def __exit__(self, exc_type, exc_value, traceback):
        if exc_type is None:
            # No exception
        if isinstance(exc_value, ftplib.error_temp):
            raise TemporaryError(*exc_value.args)
        elif isinstance(exc_value, ftplib.error_perm):
            # If `exc_value.args[0]` is present, assume it's a byte or
            # unicode string.
>           if exc_value.args and exc_value.args[0].startswith("502"):
E           UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 17: ordinal not in range(128)

/usr/local/lib/python2.7/dist-packages/ftputil/ UnicodeDecodeError

ordinal not in range(128) is one of the biggest fails of python and my most feared sentence. Sometimes, it wakes me from dreams, because I've seen this shit so many times, that it is one of the most frustrating things in my life.

I would like to tell you how to fix it, but this shit is sneaky, so easiest solution will be if you try to convert it to unicode and if it fails, just drop that crap.

If you gonna need more information, write me at bystrousak[]

Change History (6)

comment:1 Changed 7 years ago by ftputiluser

Resolution: invalid
Status: newclosed

comment:2 Changed 7 years ago by schwa

Resolution: invalid
Status: closedreopened

comment:3 Changed 7 years ago by schwa

Thanks for the compliments and the report.

Sorry for the trouble with the duplicate tickets, I deleted them and re-opened this first one. (I had these database errors in the past, but haven't yet been able to fix them.)

Speaking of duplication, it seems the problem you encountered is also described in ticket #77. If yes, this should be fixed in the version control repository. Please get the current ftputil default branch (see SourceCode) or replace your version of with the one you can get via the source code browser (see ftputil/ Does the new code fix the bug?

comment:4 Changed 7 years ago by schwa

Status: reopenednew

comment:5 Changed 7 years ago by ftputiluser

Everything works with new file, thanks.

Can you please create new realease of PIP package?

comment:6 Changed 7 years ago by schwa

Milestone: 3.1
Resolution: duplicate
Status: newclosed

This is a duplicate of #77.

Note: See TracTickets for help on using tickets.