Skip to content
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

Closed
ksamuel opened this issue Nov 18, 2013 · 1 comment
Closed

Make SFTPClient._async_request check basestring, not str #235

ksamuel opened this issue Nov 18, 2013 · 1 comment

Comments

@ksamuel
Copy link

@ksamuel ksamuel commented Nov 18, 2013

Arround line 700, we got :

        for item in arg:
            if isinstance(item, int):
                msg.add_int(item)
            elif isinstance(item, long):
                msg.add_int64(item)
            elif isinstance(item, str):
                msg.add_string(item)
            elif isinstance(item, SFTPAttributes):
                item._pack(msg)
            else:
                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 'us.us'>
@bitprophet
Copy link
Member

@bitprophet 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
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants