Skip to content

Python3 bytes decoding fix #169

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

Merged
merged 4 commits into from
Dec 23, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plotly/plotly/plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def get_figure(file_owner_or_url, file_id=None, raw=False):
verify=get_config()['plotly_ssl_verification'])
if response.status_code == 200:
if six.PY3:
content = json.loads(response.content.decode('unicode_escape'))
content = json.loads(response.content.decode('utf-8'))
else:
content = json.loads(response.content)
response_payload = content['payload']
Expand Down
15 changes: 15 additions & 0 deletions plotly/tests/test_core/test_get_figure/test_get_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
from plotly.plotly import plotly as py
from plotly import exceptions
from nose.tools import raises
import six
import json

from unittest import TestCase
from unittest import skipIf


# username for tests: 'plotlyimagetest'
Expand Down Expand Up @@ -191,4 +196,14 @@ def test_all():
"following output is produced...")


class TestBytesVStrings(TestCase):

@skipIf(not six.PY3, 'Decoding and missing escapes is only seen in PY3')
def test_proper_escaping(self):
un = 'PlotlyImageTest'
ak = '786r5mecv0'
url = "https://plot.ly/~PlotlyImageTest/91/"
py.sign_in(un, ak)
print("getting: https://plot.ly/~PlotlyImageTest/91/")
print("###########################################\n\n")
fig = py.get_figure(url)
2 changes: 1 addition & 1 deletion plotly/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.4.13'
__version__ = '1.4.14'