From 532f97a551f915b7c533a861e68308c83a8c0dd9 Mon Sep 17 00:00:00 2001 From: Sep Dehpour Date: Wed, 24 Jun 2026 12:08:01 +0200 Subject: [PATCH 1/3] reverting version in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3ccdb4a0..0d4f10e8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# DeepDiff v 9.1.0 +# DeepDiff v 9.0.0 ![Downloads](https://img.shields.io/pypi/dm/deepdiff.svg?style=flat) ![Python Versions](https://img.shields.io/pypi/pyversions/deepdiff.svg?style=flat) From f48b9bdd9097045245a81510af533815b06ba499 Mon Sep 17 00:00:00 2001 From: Sep Dehpour Date: Wed, 24 Jun 2026 12:08:01 +0200 Subject: [PATCH 2/3] 9.1.0 --- .bumpversion.cfg | 2 +- CITATION.cff | 2 +- README.md | 2 +- deepdiff/__init__.py | 2 +- deepdiff/docstrings/index.rst | 2 +- docs/conf.py | 4 ++-- pyproject.toml | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index c781f85e..588c1d5d 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 9.0.0 +current_version = 9.1.0 commit = False tag = False tag_name = {new_version} diff --git a/CITATION.cff b/CITATION.cff index 06dbb01e..1335dd9e 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -5,6 +5,6 @@ authors: given-names: "Sep" orcid: "https://orcid.org/0009-0009-5828-4345" title: "DeepDiff" -version: 9.0.0 +version: 9.1.0 date-released: 2026 url: "https://github.com/seperman/deepdiff" diff --git a/README.md b/README.md index 0d4f10e8..3ccdb4a0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# DeepDiff v 9.0.0 +# DeepDiff v 9.1.0 ![Downloads](https://img.shields.io/pypi/dm/deepdiff.svg?style=flat) ![Python Versions](https://img.shields.io/pypi/pyversions/deepdiff.svg?style=flat) diff --git a/deepdiff/__init__.py b/deepdiff/__init__.py index 312b0e35..80349365 100644 --- a/deepdiff/__init__.py +++ b/deepdiff/__init__.py @@ -1,6 +1,6 @@ """This module offers the DeepDiff, DeepSearch, grep, Delta and DeepHash classes.""" # flake8: noqa -__version__ = '9.0.0' +__version__ = '9.1.0' import logging if __name__ == '__main__': diff --git a/deepdiff/docstrings/index.rst b/deepdiff/docstrings/index.rst index a374150f..b295e97e 100644 --- a/deepdiff/docstrings/index.rst +++ b/deepdiff/docstrings/index.rst @@ -4,7 +4,7 @@ contain the root `toctree` directive. -DeepDiff 9.0.0 documentation! +DeepDiff 9.1.0 documentation! ============================= .. |qluster_link| raw:: html diff --git a/docs/conf.py b/docs/conf.py index deb7dd41..83eb1ac0 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -64,9 +64,9 @@ # built documents. # # The short X.Y version. -version = '9.0.0' +version = '9.1.0' # The full version, including alpha/beta/rc tags. -release = '9.0.0' +release = '9.1.0' load_dotenv(override=True) DOC_VERSION = os.environ.get('DOC_VERSION', version) diff --git a/pyproject.toml b/pyproject.toml index 8d9cb691..980cb6f9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi" [project] name = "deepdiff" -version = "9.0.0" +version = "9.1.0" dependencies = [ "cachebox>=5.2,<6", "orderly-set>=5.5.0,<6", From 894f95e59d2dea10ee7d5e88e7e9ce7206599e57 Mon Sep 17 00:00:00 2001 From: Vincent Gao Date: Wed, 24 Jun 2026 12:08:01 +0200 Subject: [PATCH 3/3] fix: avoid ValueError on NaN/Inf with significant_digits=0 number_to_string called int() on non-finite float values (NaN, Inf, -Inf) when significant_digits=0, raising ValueError or OverflowError. Guard the int() conversion with math.isfinite() so that NaN and Inf pass through as-is (their string representations compare correctly). Fixes the crash: >>> DeepDiff(float('nan'), float('nan'), significant_digits=0) ValueError: cannot convert float NaN to integer >>> DeepDiff(float('inf'), float('inf'), significant_digits=0) OverflowError: cannot convert float infinity to integer --- deepdiff/helper.py | 3 ++- tests/test_diff_text.py | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/deepdiff/helper.py b/deepdiff/helper.py index 3fc61183..18d7e55a 100644 --- a/deepdiff/helper.py +++ b/deepdiff/helper.py @@ -1,6 +1,7 @@ import sys import re import os +import math import datetime import uuid import logging @@ -513,7 +514,7 @@ def number_to_string(number: Any, significant_digits: int, number_format_notatio else: number = round(number=number, ndigits=significant_digits) # type: ignore - if significant_digits == 0: + if significant_digits == 0 and math.isfinite(number): # type: ignore number = int(number) # type: ignore if number == 0.0: diff --git a/tests/test_diff_text.py b/tests/test_diff_text.py index fb0087be..c93d185b 100755 --- a/tests/test_diff_text.py +++ b/tests/test_diff_text.py @@ -1877,6 +1877,29 @@ def gen2(): def test_ignore_nan_inequality(self, t1, t2, params, expected_result): assert expected_result == list(DeepDiff(t1, t2, **params).keys()) + @pytest.mark.parametrize('t1, t2, params', [ + (float('nan'), float('nan'), {'significant_digits': 0}), + (float('nan'), float('nan'), {'significant_digits': 2}), + (float('inf'), float('inf'), {'significant_digits': 0}), + (float('inf'), float('inf'), {'significant_digits': 2}), + (float('-inf'), float('-inf'), {'significant_digits': 0}), + (float('-inf'), float('-inf'), {'significant_digits': 2}), + ({'a': float('nan'), 'b': 1.5}, {'a': float('nan'), 'b': 2.7}, + {'significant_digits': 0}), + ({'a': float('inf')}, {'a': float('inf')}, + {'significant_digits': 0}), + ]) + def test_significant_digits_with_nan_inf(self, t1, t2, params): + """ + Test that significant_digits does not crash with NaN or Inf values. + Regression test for ValueError/OverflowError when converting NaN/Inf + to int in number_to_string with significant_digits=0. + """ + try: + DeepDiff(t1, t2, **params) + except (ValueError, OverflowError) as e: + pytest.fail(f"DeepDiff with {params} on {t1!r} raised {type(e).__name__}: {e}") + @pytest.mark.parametrize('ignore_order, ignore_private_variables, expected', [ (True, True, {}), (False, True, {}),