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

PlotlyJSONEncoder doesn't work with simplejson installed #1556

Closed
jayvdb opened this issue May 7, 2019 · 2 comments · Fixed by #1561
Closed

PlotlyJSONEncoder doesn't work with simplejson installed #1556

jayvdb opened this issue May 7, 2019 · 2 comments · Fixed by #1561
Labels
bug something broken
Milestone

Comments

@jayvdb
Copy link
Contributor

jayvdb commented May 7, 2019

Similar to past issues (#415), installation of simplejson breaks plotly.py.

Example failure:

======================================================================
ERROR: test_default_plot_generates_expected_html (test_offline.PlotlyOfflineTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/abuild/rpmbuild/BUILD/plotly.py-3.9.0/plotly/tests/test_core/test_offline/test_offline.py", line 92, in test_default_plot_generates_expected_html
    cls=plotly.utils.PlotlyJSONEncoder)
  File "/usr/lib64/python2.7/site-packages/simplejson/__init__.py", line 419, in dumps
    **kw).encode(obj)
TypeError: __init__() got an unexpected keyword argument 'iterable_as_array'

The build environment can be seen at https://build.opensuse.org/package/show/home:jayvdb:py-wheels/python-plotly

@jonmmease
Copy link
Contributor

Thanks for the report @jayvdb,

Looks like the problem is that we use this snippet in various places in the codebase

from requests.compat import json as _json

Which, in turn, calls

try:
    import simplejson as json
except ImportError:
    import json

This was done in 6634971 in 2016. I believe at the time this was done as a way to support Python < 2.6. Plotly.py no longer supports Python < 2.7 so I think we should just remove this compatibility logic and always use the built-in json module.

@jonmmease jonmmease added the bug something broken label May 10, 2019
@jonmmease jonmmease changed the title PlotlyJSONEncoder doesn't work with simplejson PlotlyJSONEncoder doesn't work with simplejson installed May 10, 2019
@jonmmease jonmmease added this to the v3.10 milestone May 10, 2019
jayvdb added a commit to jayvdb/plotly.py that referenced this issue May 10, 2019
requests.compat.json may use simplejson, which is incompatible
with plotly.py usage of json.

Fixes plotly#1556
@jayvdb
Copy link
Contributor Author

jayvdb commented May 10, 2019

Bingo that solved the errors in my builds. Submitted a PR.

jonmmease pushed a commit that referenced this issue May 25, 2019
requests.compat.json may use simplejson, which is incompatible
with plotly.py usage of json.

Fixes #1556
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants