X Tutup
The Wayback Machine - https://web.archive.org/web/20210821014841/https://github.com/plotly/plotly.py/pull/3351
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

Fix error in orjson engine when a dict has a non-string value as a key #3351

Merged
merged 2 commits into from Aug 20, 2021

Conversation

@jonmmease
Copy link
Member

@jonmmease jonmmease commented Aug 19, 2021

Background

Python's built-in json library can handle encoding dictionaries with keys that aren't strings by coercing them to strings implicitly. The orjson library requires the keys to be strings, otherwise an error is raised.

This would very rarely come up in plotly figures. But now that we're updating Dash (for Dash 2) to use the active plotly.py json engine, it comes up on occasion.

Change

All dict keys are converted to strings during the existing cleaning pass that is used prior to orjson encoding.

Tests

Test added that encodes a dict with integer keys.

@jonmmease jonmmease mentioned this pull request Aug 19, 2021
15 of 19 tasks
@nicolaskruchten
Copy link
Member

@nicolaskruchten nicolaskruchten commented Aug 20, 2021

💃

@jonmmease jonmmease merged commit bd17799 into master Aug 20, 2021
15 checks passed
15 checks passed
ci/circleci: build-doc Your tests passed on CircleCI!
Details
ci/circleci: check-code-formatting Your tests passed on CircleCI!
Details
ci/circleci: plotlyjs_dev_build Your tests passed on CircleCI!
Details
ci/circleci: python_36_core Your tests passed on CircleCI!
Details
ci/circleci: python_36_optional Your tests passed on CircleCI!
Details
ci/circleci: python_37_chart_studio Your tests passed on CircleCI!
Details
ci/circleci: python_37_core Your tests passed on CircleCI!
Details
ci/circleci: python_37_optional Your tests passed on CircleCI!
Details
ci/circleci: python_37_percy Your tests passed on CircleCI!
Details
ci/circleci: python_38_core Your tests passed on CircleCI!
Details
ci/circleci: python_38_optional Your tests passed on CircleCI!
Details
ci/circleci: python_38_orca Your tests passed on CircleCI!
Details
ci/circleci: python_39_core Your tests passed on CircleCI!
Details
ci/circleci: python_39_optional Your tests passed on CircleCI!
Details
@percy
percy/plotly.py Visual review automatically approved, no visual changes found.
Details
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 issues

Successfully merging this pull request may close these issues.

None yet

2 participants
X Tutup