diff --git a/qiskit_ibm_runtime/utils/json.py b/qiskit_ibm_runtime/utils/json.py index cf180d374..abccfec7c 100644 --- a/qiskit_ibm_runtime/utils/json.py +++ b/qiskit_ibm_runtime/utils/json.py @@ -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: diff --git a/release-notes/unreleased/1800.bug.rst b/release-notes/unreleased/1800.bug.rst new file mode 100644 index 000000000..125e2b64f --- /dev/null +++ b/release-notes/unreleased/1800.bug.rst @@ -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. \ No newline at end of file diff --git a/test/integration/test_job.py b/test/integration/test_job.py index ef5ca4e67..48e5e46c7 100644 --- a/test/integration/test_job.py +++ b/test/integration/test_job.py @@ -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):