Skip to content

Commit

Permalink
Fix PY3 encoding of parameters for OAuth flow.
Browse files Browse the repository at this point in the history
  • Loading branch information
braincore committed Jan 30, 2016
1 parent ac8c886 commit bad1ac6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@
# built documents.
#
# The short X.Y version.
version = '5.2'
version = '5.2.1'
# The full version, including alpha/beta/rc tags.
release = '5.2'
release = '5.2.1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion dropbox/dropbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
]

# TODO(kelkabany): We need to auto populate this as done in the v1 SDK.
__version__ = '5.2'
__version__ = '5.2.1'

import contextlib
import json
Expand Down
10 changes: 7 additions & 3 deletions dropbox/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,13 @@ def _params_to_urlencoded(params):
the exception of unicode objects which are utf8-encoded.
"""
def encode(o):
if isinstance(o, six.text_type):
return o.encode('utf8')
if isinstance(o, six.binary_type):
return o
else:
return str(o)
if isinstance(o, six.text_type):
return o.encode('utf-8')
else:
return str(o).encode('utf-8')

This comment has been minimized.

Copy link
@cakoose

cakoose Feb 1, 2016

@braincore: Though this is convenient for numbers, it'll mask bugs in other cases. Maybe it's better to require that params consists solely of str/unicode values and assert on anything else?

Also, might be easier to read with elif.

This comment has been minimized.

Copy link
@braincore

braincore Feb 1, 2016

Author Contributor

I was thinking about making that change. Sadly, this type of behavior is in line with the convention for things like urllib.urlencode, and I didn't want to introduce a backwards incompatibility. This is all code inherited from v1, and I wish it had been rewritten rather than ported.

This comment has been minimized.

Copy link
@cakoose

cakoose Feb 1, 2016

I thought an underscore-prefixed function was the standard way of indicating that something is internal. We should be able to change those, right?

This comment has been minimized.

Copy link
@cakoose

cakoose Feb 1, 2016

Oh whoops, nevermind. There are external calls that reach it.


utf8_params = {encode(k): encode(v) for k, v in six.iteritems(params)}
return url_encode(utf8_params)
2 changes: 1 addition & 1 deletion dropbox/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
else:
url_encode = urllib.urlencode

SDK_VERSION = "5.2"
SDK_VERSION = "5.2.1"

TRUSTED_CERT_FILE = pkg_resources.resource_filename(__name__, 'trusted-certs.crt')

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

dist = setup(
name='dropbox',
version='5.2',
version='5.2.1',
description='Official Dropbox API Client',
author='Dropbox',
author_email='[email protected]',
Expand Down

0 comments on commit bad1ac6

Please sign in to comment.