Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Fixed bug in deepcopy of IBMBackend #658

Merged
merged 3 commits into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion qiskit_ibm_provider/ibm_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def __getattr__(self, name: str) -> Any:
does not yet exist on IBMBackend class.
"""
# Prevent recursion since these properties are accessed within __getattr__
if name in ["_properties", "_defaults", "_target"]:
if name in ["_properties", "_defaults", "_target", "_configuration"]:
raise AttributeError(
"'{}' object has no attribute '{}'".format(
self.__class__.__name__, name
Expand Down
5 changes: 5 additions & 0 deletions releasenotes/notes/backend_deepcopy-032282246b52e391.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
Fixed infinite recursion when attempting to deepcopy an IBMBackend.

8 changes: 7 additions & 1 deletion test/unit/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# that they have been altered from the originals.

"""Tests for the backend functions."""

import copy
from datetime import datetime
from unittest import mock
import warnings
Expand Down Expand Up @@ -318,3 +318,9 @@ def test_multi_openqasm3_submission(self):
backend.run(circuits=qasm3_circs, dynamic=True)

mock_run.assert_called_once()

def test_deepcopy(self):
"""Test that deepcopy of a backend works properly"""
backend = self._create_dc_test_backend()
backend_copy = copy.deepcopy(backend)
self.assertEqual(backend_copy.name, backend.name)