--- a/pint/delegates/txt_defparser/common.py
+++ b/pint/delegates/txt_defparser/common.py
@@ -12,13 +12,12 @@
 
 from __future__ import annotations
 
-from dataclasses import dataclass, field
+from dataclasses import dataclass
 
 from ... import errors
 from ..._vendor import flexparser as fp
 
 
-@dataclass(frozen=True)
 class DefinitionSyntaxError(errors.DefinitionSyntaxError, fp.ParsingError):
     """A syntax error was found in a definition. Combines:
 
@@ -28,7 +27,11 @@
     and an extra location attribute in which the filename or reseource is stored.
     """
 
-    location: str = field(init=False, default="")
+    msg: str
+
+    def __init__(self, msg: str, location: str = ""):
+        self.msg = msg
+        self.location = location
 
     def __str__(self) -> str:
         msg = (
--- a/pint/testing.py
+++ b/pint/testing.py
@@ -45,10 +45,10 @@
     if isinstance(m1, ndarray) or isinstance(m2, ndarray):
         np.testing.assert_array_equal(m1, m2, err_msg=msg)
     elif not isinstance(m1, Number):
-        warnings.warn(RuntimeWarning)
+        warnings.warn("", RuntimeWarning)
         return
     elif not isinstance(m2, Number):
-        warnings.warn(RuntimeWarning)
+        warnings.warn("", RuntimeWarning)
         return
     elif math.isnan(m1):
         assert math.isnan(m2), msg
@@ -64,7 +64,7 @@
     if msg is None:
         try:
             msg = f"Comparing {first!r} and {second!r}. "
-        except TypeError:
+        except (TypeError, ValueError):
             try:
                 msg = f"Comparing {first} and {second}. "
             except Exception:
@@ -76,10 +76,10 @@
     if isinstance(m1, ndarray) or isinstance(m2, ndarray):
         np.testing.assert_allclose(m1, m2, rtol=rtol, atol=atol, err_msg=msg)
     elif not isinstance(m1, Number):
-        warnings.warn(RuntimeWarning)
+        warnings.warn("", RuntimeWarning)
         return
     elif not isinstance(m2, Number):
-        warnings.warn(RuntimeWarning)
+        warnings.warn("", RuntimeWarning)
         return
     elif math.isnan(m1):
         assert math.isnan(m2), msg
