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 bug with json decoder for classes defined in __main__ #623

Merged
merged 2 commits into from
Jan 27, 2022

Conversation

chriseclectic
Copy link
Collaborator

@chriseclectic chriseclectic commented Jan 24, 2022

Summary

Fixes a bug with JSON deserialization of custom user classes defined in the __main__ scope of python scripts and notebooks.

Adds JSON unittests for testing classes, methods, and functions defined in the __main__ module. The previous tests which aimed to do this were not working correctly since their module was being serialized as test.path_to_test_file instead of __main__.

Details and comments

Fixes a bug with JSON deserialization of custom user classes defined in the __main__ scope of python scripts and notebooks.

Adds JSON unittests for testing classes, methods, and functions defined in the __main__ module. The previous tests which aimed to do this were not working correctly since their module was being serialized as test.path_to_test_file instead of __main__.
@chriseclectic chriseclectic added backport stable potential The issue or PR might be minimal and/or import enough to backport to stable Changelog: Bugfix Include in the "Fixed" section of the changelog labels Jan 24, 2022
@chriseclectic chriseclectic changed the title [WIP] Fix bug with json decoder for classes defined in __main__ Fix bug with json decoder for classes defined in __main__ Jan 24, 2022
Copy link
Collaborator

@nkanazawa1989 nkanazawa1989 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the mechanism that current logic fails? Any key mismatch when we directly look into globals?

qiskit_experiments/framework/json.py Show resolved Hide resolved
@chriseclectic chriseclectic merged commit 10803ad into qiskit-community:main Jan 27, 2022
paco-ri pushed a commit to paco-ri/qiskit-experiments that referenced this pull request Jul 11, 2022
Fixes a bug with JSON deserialization of custom user classes defined in the __main__ scope of python scripts and notebooks.

Adds JSON unittests for testing classes, methods, and functions defined in the __main__ module. The previous tests which aimed to do this were not working correctly since their module was being serialized as test.path_to_test_file instead of __main__.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport stable potential The issue or PR might be minimal and/or import enough to backport to stable Changelog: Bugfix Include in the "Fixed" section of the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants