diff --git a/ignore-utf16.patch b/ignore-utf16.patch new file mode 100644 index 0000000..f87c3a0 --- /dev/null +++ b/ignore-utf16.patch @@ -0,0 +1,32 @@ +From 412479e5d6b02f7dd7e20f870132a413dc83898a Mon Sep 17 00:00:00 2001 +From: Doyle Rowland +Date: Thu, 14 Aug 2025 17:58:02 -0400 +Subject: [PATCH] fix: explicitly ignore utf_16 and utf_32 encoding + +--- + src/docformatter/encode.py | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +diff --git a/src/docformatter/encode.py b/src/docformatter/encode.py +index ac55ee9..c7e36f0 100644 +--- a/src/docformatter/encode.py ++++ b/src/docformatter/encode.py +@@ -64,9 +64,15 @@ def do_detect_encoding(self, filename) -> None: + """ + try: + detection_result = from_path(filename).best() +- self.encoding = ( +- detection_result.encoding if detection_result else self.DEFAULT_ENCODING +- ) ++ if detection_result and detection_result.encoding in ["utf_16", "utf_32"]: ++ # Treat undetectable/binary encodings as failure ++ self.encoding = self.DEFAULT_ENCODING ++ else: ++ self.encoding = ( ++ detection_result.encoding ++ if detection_result ++ else self.DEFAULT_ENCODING ++ ) + + # Check for correctness of encoding. + with self.do_open_with_encoding(filename) as check_file: diff --git a/python-docformatter.changes b/python-docformatter.changes index 2350d7b..29ee10b 100644 --- a/python-docformatter.changes +++ b/python-docformatter.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Fri Nov 14 13:51:14 UTC 2025 - Markéta Machová + +- Add upstream ignore-utf16.patch to fix test failure + ------------------------------------------------------------------- Mon May 19 10:01:24 UTC 2025 - John Paul Adrian Glaubitz diff --git a/python-docformatter.spec b/python-docformatter.spec index 3c2350e..4cfe21e 100644 --- a/python-docformatter.spec +++ b/python-docformatter.spec @@ -1,7 +1,7 @@ # # spec file for package python-docformatter # -# Copyright (c) 2025 SUSE LLC +# Copyright (c) 2025 SUSE LLC and contributors # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -26,6 +26,8 @@ URL: https://github.com/myint/docformatter Source: https://github.com/PyCQA/docformatter/archive/refs/tags/v%{version}.tar.gz#/docformatter-%{version}.tar.gz # PATCH-FIX-OPENSUSE Do not require virtualenvs to run the tests Patch0: do-not-require-venv.patch +# PATCH-FIX-UPSTREAM cherry-pick from https://github.com/PyCQA/docformatter/pull/323 fix: issue 321 +Patch1: ignore-utf16.patch BuildRequires: %{python_module base >= 3.7} BuildRequires: %{python_module pip} BuildRequires: %{python_module poetry-core}