From 503e3e477bb44e83f34d8e70514fc7191d8d509b4ae3f61a5ff8eee46f0ac07e Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Sun, 3 Nov 2024 02:23:46 +0000 Subject: [PATCH] - Add patch support-python-313.patch: * Do not mix frozen and non-frozen dataclasses. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:numeric/python-Pint?expand=0&rev=39 --- python-Pint.changes | 6 +++ python-Pint.spec | 4 +- support-python-313.patch | 113 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 support-python-313.patch diff --git a/python-Pint.changes b/python-Pint.changes index 671eff1..aec14c5 100644 --- a/python-Pint.changes +++ b/python-Pint.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Sun Nov 3 02:22:46 UTC 2024 - Steve Kowalik + +- Add patch support-python-313.patch: + * Do not mix frozen and non-frozen dataclasses. + ------------------------------------------------------------------- Mon Aug 5 18:59:29 UTC 2024 - Dirk Müller diff --git a/python-Pint.spec b/python-Pint.spec index 93b5a88..428dc10 100644 --- a/python-Pint.spec +++ b/python-Pint.spec @@ -24,6 +24,8 @@ Summary: Physical quantities module License: BSD-3-Clause URL: https://github.com/hgrecco/pint Source: https://files.pythonhosted.org/packages/source/p/pint/pint-%{version}.tar.gz +# PATCH-FIX-UPSTREAM Based on gh#hgrecco/pint#2037 +Patch0: support-python-313.patch BuildRequires: %{python_module base >= 3.9} BuildRequires: %{python_module pip} BuildRequires: %{python_module setuptools_scm} @@ -64,7 +66,7 @@ and constants. Due to it's modular design, you to extend (or even rewrite!) the complete list without changing the source code. %prep -%setup -q -n pint-%{version} +%autosetup -p1 -n pint-%{version} %build %pyproject_wheel diff --git a/support-python-313.patch b/support-python-313.patch new file mode 100644 index 0000000..c3f94d4 --- /dev/null +++ b/support-python-313.patch @@ -0,0 +1,113 @@ +From 4b34753960979395b304c0f9a290abfc6132c06f Mon Sep 17 00:00:00 2001 +From: Simon Willison +Date: Fri, 12 Jul 2024 17:23:21 -0700 +Subject: [PATCH 2/3] @dataclass(frozen=True) for Python 3.13 compatibility + +--- + pint/errors.py | 24 ++++++++++++------------ + 1 file changed, 12 insertions(+), 12 deletions(-) + +diff --git a/pint/errors.py b/pint/errors.py +index 59d3b4569..f080f529d 100644 +--- a/pint/errors.py ++++ b/pint/errors.py +@@ -81,12 +81,12 @@ def def_err(self, msg: str): + return DefinitionError(self.name, self.__class__, msg) + + +-@dataclass(frozen=False) ++@dataclass(frozen=True) + class PintError(Exception): + """Base exception for all Pint errors.""" + + +-@dataclass(frozen=False) ++@dataclass(frozen=True) + class DefinitionError(ValueError, PintError): + """Raised when a definition is not properly constructed.""" + +@@ -102,7 +102,7 @@ def __reduce__(self): + return self.__class__, tuple(getattr(self, f.name) for f in fields(self)) + + +-@dataclass(frozen=False) ++@dataclass(frozen=True) + class DefinitionSyntaxError(ValueError, PintError): + """Raised when a textual definition has a syntax error.""" + +@@ -115,7 +115,7 @@ def __reduce__(self): + return self.__class__, tuple(getattr(self, f.name) for f in fields(self)) + + +-@dataclass(frozen=False) ++@dataclass(frozen=True) + class RedefinitionError(ValueError, PintError): + """Raised when a unit or prefix is redefined.""" + +@@ -130,7 +130,7 @@ def __reduce__(self): + return self.__class__, tuple(getattr(self, f.name) for f in fields(self)) + + +-@dataclass(frozen=False) ++@dataclass(frozen=True) + class UndefinedUnitError(AttributeError, PintError): + """Raised when the units are not defined in the unit registry.""" + +@@ -150,13 +150,13 @@ def __reduce__(self): + return self.__class__, tuple(getattr(self, f.name) for f in fields(self)) + + +-@dataclass(frozen=False) ++@dataclass(frozen=True) + class PintTypeError(TypeError, PintError): + def __reduce__(self): + return self.__class__, tuple(getattr(self, f.name) for f in fields(self)) + + +-@dataclass(frozen=False) ++@dataclass(frozen=True) + class DimensionalityError(PintTypeError): + """Raised when trying to convert between incompatible units.""" + +@@ -183,7 +183,7 @@ def __reduce__(self): + return self.__class__, tuple(getattr(self, f.name) for f in fields(self)) + + +-@dataclass(frozen=False) ++@dataclass(frozen=True) + class OffsetUnitCalculusError(PintTypeError): + """Raised on ambiguous operations with offset units.""" + +@@ -208,7 +208,7 @@ def __reduce__(self): + return self.__class__, tuple(getattr(self, f.name) for f in fields(self)) + + +-@dataclass(frozen=False) ++@dataclass(frozen=True) + class LogarithmicUnitCalculusError(PintTypeError): + """Raised on inappropriate operations with logarithmic units.""" + +@@ -233,7 +233,7 @@ def __reduce__(self): + return self.__class__, tuple(getattr(self, f.name) for f in fields(self)) + + +-@dataclass(frozen=False) ++@dataclass(frozen=True) + class UnitStrippedWarning(UserWarning, PintError): + msg: str + +@@ -241,13 +241,13 @@ def __reduce__(self): + return self.__class__, tuple(getattr(self, f.name) for f in fields(self)) + + +-@dataclass(frozen=False) ++@dataclass(frozen=True) + class UnexpectedScaleInContainer(Exception): + def __reduce__(self): + return self.__class__, tuple(getattr(self, f.name) for f in fields(self)) + + +-@dataclass(frozen=False) ++@dataclass(frozen=True) + class UndefinedBehavior(UserWarning, PintError): + msg: str