From c1dbfb1c97b910e71b3fd5da20f2f6a46301cf3f Mon Sep 17 00:00:00 2001 From: Justin Drew <2396364+jdrew82@users.noreply.github.com> Date: Mon, 2 Mar 2026 16:13:30 -0600 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Update=20exception=20?= =?UTF-8?q?catch=20to=20catch=20all=20and=20do=20simple=20copy=20to=20hand?= =?UTF-8?q?le=20any=20other=20possible=20deepcopy=20issues.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changes/339.fixed | 1 + diffsync/__init__.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changes/339.fixed diff --git a/changes/339.fixed b/changes/339.fixed new file mode 100644 index 00000000..2fa50ce7 --- /dev/null +++ b/changes/339.fixed @@ -0,0 +1 @@ +Fixed bug with deepcopy in dunder new. diff --git a/diffsync/__init__.py b/diffsync/__init__.py index c48e7053..600207cf 100644 --- a/diffsync/__init__.py +++ b/diffsync/__init__.py @@ -488,7 +488,7 @@ def __new__(cls, **kwargs): # type: ignore[no-untyped-def] for key, value in kwargs.items(): try: meta_kwargs[key] = deepcopy(value) - except (TypeError, AttributeError): + except Exception: # Some objects (e.g. Kafka Consumer, DB connections) cannot be deep copied meta_kwargs[key] = value instance = super().__new__(cls) From 7ebca7e2ef264bb5cf88d45185faa0388a19bebc Mon Sep 17 00:00:00 2001 From: Justin Drew <2396364+jdrew82@users.noreply.github.com> Date: Tue, 3 Mar 2026 09:04:11 -0600 Subject: [PATCH 2/2] fix: Add ignore for broad Exception catch --- diffsync/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diffsync/__init__.py b/diffsync/__init__.py index 600207cf..402320ea 100644 --- a/diffsync/__init__.py +++ b/diffsync/__init__.py @@ -488,7 +488,7 @@ def __new__(cls, **kwargs): # type: ignore[no-untyped-def] for key, value in kwargs.items(): try: meta_kwargs[key] = deepcopy(value) - except Exception: + except Exception: # pylint: disable=broad-exception-caught # Some objects (e.g. Kafka Consumer, DB connections) cannot be deep copied meta_kwargs[key] = value instance = super().__new__(cls)