Skip to content

Commit

Permalink
Fix simplejson incompatibility (Qiskit#1800)
Browse files Browse the repository at this point in the history
* Fix simplejson incompatibility

* release note

* Add test

---------

Co-authored-by: ptristan3 <[email protected]>
  • Loading branch information
2 people authored and ihincks committed Aug 12, 2024
1 parent 669a11b commit 829f46a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions qiskit_ibm_runtime/utils/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ class RuntimeDecoder(json.JSONDecoder):
"""JSON Decoder used by runtime service."""

def __init__(self, *args: Any, **kwargs: Any):
if "encoding" in kwargs:
kwargs.pop("encoding")
super().__init__(object_hook=self.object_hook, *args, **kwargs)

def object_hook(self, obj: Any) -> Any:
Expand Down
2 changes: 2 additions & 0 deletions release-notes/unreleased/1800.bug.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixed an issue where users were unable to retrieve job results if
the python library ``simplejson`` was installed in their environment.
11 changes: 11 additions & 0 deletions test/integration/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ def test_run_program(self, service):
self.assertEqual(JobStatus.DONE, job.status())
self.assertTrue(job.result())

@run_integration_test
def test_run_with_simplejson(self, service):
"""Test retrieving job results with simplejson package installed."""
try:
__import__("simplejson")
job = self._run_program(service=service)
job.wait_for_final_state()
self.assertTrue(job.result())
except ImportError:
self.assertRaises(ImportError)

@run_integration_test
@quantum_only
def test_run_program_log_level(self, service):
Expand Down

0 comments on commit 829f46a

Please sign in to comment.