From c1b4d091dccc35d34def3c53555b162fcba58d93 Mon Sep 17 00:00:00 2001 From: Andrew Seier Date: Mon, 22 Dec 2014 12:47:46 -0800 Subject: [PATCH 1/3] Add (failing) test for PY3 json decode error. --- .../test_core/test_get_figure/test_get_figure.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/plotly/tests/test_core/test_get_figure/test_get_figure.py b/plotly/tests/test_core/test_get_figure/test_get_figure.py index 5e2af8bafd0..0fc86f49241 100644 --- a/plotly/tests/test_core/test_get_figure/test_get_figure.py +++ b/plotly/tests/test_core/test_get_figure/test_get_figure.py @@ -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' @@ -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) From f76eb17664dc33547a1784ed070ff8c3bb450076 Mon Sep 17 00:00:00 2001 From: Andrew Seier Date: Mon, 22 Dec 2014 12:47:56 -0800 Subject: [PATCH 2/3] Fix that test. --- plotly/plotly/plotly.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plotly/plotly/plotly.py b/plotly/plotly/plotly.py index 46e40017479..ec7ba7c520c 100644 --- a/plotly/plotly/plotly.py +++ b/plotly/plotly/plotly.py @@ -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'] From d9a117f31910d5debbd19237ede5541e4ffa262c Mon Sep 17 00:00:00 2001 From: Andrew Seier Date: Tue, 23 Dec 2014 11:20:39 -0800 Subject: [PATCH 3/3] version bump -> 1.4.14 (bug fix for python3 json decoding) --- plotly/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plotly/version.py b/plotly/version.py index 133086d0815..250ba523e7e 100644 --- a/plotly/version.py +++ b/plotly/version.py @@ -1 +1 @@ -__version__ = '1.4.13' +__version__ = '1.4.14'