Skip to content

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?

@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