-
Notifications
You must be signed in to change notification settings - Fork 348
Open
Description
Since #1504 the S3Error exception is now a frozen dataclass:
Lines 83 to 84 in 6daf366
@dataclass(frozen=True) | |
class S3Error(MinioException): |
python/cpython#99856 says not to do this. This causes issues when the exception is throw inside a contextmanager:
from contextlib import contextmanager
from minio import Minio, S3Error
@contextmanager
def demo():
yield
client = Minio(
endpoint="play.min.io",
access_key="Q3AM3UQ867SPQQA43P2F",
secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
)
try:
with demo():
client.stat_object("my_bucket", "my_object")
except S3Error:
pass
This results in:
Traceback (most recent call last):
File "demo.py", line 15, in <module>
with demo():
^^^^^^
File "/usr/lib/python3.12/contextlib.py", line 191, in __exit__
exc.__traceback__ = traceback
^^^^^^^^^^^^^^^^^
File "<string>", line 4, in __setattr__
dataclasses.FrozenInstanceError: cannot assign to field '__traceback__'
Metadata
Metadata
Assignees
Labels
No labels