Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Infinite recursion error on deep copy `AzureBackendConfig` due to __getattr__ implementation

Đang mở Phù hợp với người mới
#708 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

@jessetvogel đang làm issue này rồi.

Từ ngày 6/1/2026.

  • #709 của @jessetvogel — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
68/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
azure, python
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu tại azure-quantum/azure/quantum/qiskit/backends/backend.py, ở AzureBackendConfig.getattr, sau đó chạy bản tái hiện deepcopy từ issue. Xác minh rằng việc sao chép một instance có metadata rỗng không còn gây ra RecursionError, trong khi các thuộc tính bị thiếu vẫn gây ra AttributeError và các thuộc tính dựa trên metadata tiếp tục hoạt động.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

The class AzureBackendConfig in azure.quantum.qiskit.backends.backend has a field metadata containing any remaining properties of the class. The __getattr__ method of this class is implemented in such a way that, if the attribute is not found, the metadata dict is checked. However, this leads to a RecursionError: maximum recursion depth exceeded when an instance of the class is copied using copy.deepcopy (which apparently happens sometimes).

The relevant piece of code:

class AzureBackendConfig:

    ...

    def __getattr__(self, name: str) -> Any:
        if name == "max_experiments":
            return 1
        try:
            return self.__dict__[name]
        except KeyError as exc:
            if name in self.metadata:
                return self.metadata[name]
            raise AttributeError(
                f"'{type(self).__name__}' object has no attribute '{name}'"
            ) from exc

Simplified reproduction of the error:

import copy
from dataclasses import dataclass, field
from typing import Any

@dataclass
class A:
    metadata: dict[str, Any] = field(default_factory=dict)

    def __getattr__(self, name: str) -> Any:
        try:
            return self.__dict__[name]
        except KeyError as exc:
            if name in self.metadata:
                return self.metadata[name]
            raise AttributeError(
                f"'{type(self).__name__}' object has no attribute '{name}'"
            ) from exc

a = A()

copy.deepcopy(a)  # RecursionError: maximum recursion depth exceeded

A possible solution would be to change the problematic line to:

if "metadata" in self.__dict__ and name in self.metadata:
Ngôn ngữ chính
Python
Star
162
Fork
113
Merge trung bình
4 ngày 21 giờ
Pull request đã merge (30 ngày)
3

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/azure-quantum-python

Tất cả issue của microsoft/azure-quantum-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.