New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make SFTPClient._async_request check basestring, not str #235

ksamuel opened this Issue Nov 18, 2013 · 1 comment


None yet
2 participants

ksamuel commented Nov 18, 2013

Arround line 700, we got :

        for item in arg:
            if isinstance(item, int):
            elif isinstance(item, long):
            elif isinstance(item, str):
            elif isinstance(item, SFTPAttributes):
                raise Exception('unknown type for %r type %r' % (item, type(item)))

Which mean you can't pass subclasses of unicode there. Either you make this check :

isinstance(item, basetring)

Or you make an explicit message explaining you reject non encoded strings. Otherwise, it's hard to understand what's going on when you get :

Exception: unknown type for unicode_subclass(u'/stuff') type <class ''>

This comment has been minimized.


bitprophet commented Mar 14, 2014

Thanks for looking out! This should have been fixed in the recent merge of Python 3 support; that line now looks like this:

elif isinstance(item, (string_types, bytes_types)):
- and string_types under Python 2 is basestring.

This change is live in version 1.13 and I will go backport it to a few older branches that are Python 2 only; their next bugfix releases will have the change.

@bitprophet bitprophet closed this Mar 14, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment