]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Say "can't parse x", not "can't manage x"
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 16 May 2021 01:39:55 +0000 (03:39 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 1 Jun 2021 23:57:23 +0000 (00:57 +0100)
These are parsing error. Stuff we can't manage (e.g. year < 10K) is
complained of elsewhere

psycopg3/psycopg3/types/date.py
psycopg3_c/psycopg3_c/types/date.pyx

index 5b3dee5fb38ce0b0ede55123a4211ffbc992a493..587d98f1e4fb2e3a16d78de430a239c71c2cbfea 100644 (file)
@@ -283,7 +283,7 @@ class DateLoader(Loader):
             s = bytes(data).decode("utf8", "replace")
             if len(s) != 10:
                 raise DataError(f"date not supported: {s!r}") from None
-            raise DataError(f"can't manage date {s!r}: {e}") from None
+            raise DataError(f"can't parse date {s!r}: {e}") from None
 
 
 class DateBinaryLoader(Loader):
@@ -328,7 +328,7 @@ class TimeLoader(Loader):
             return time(int(ho), int(mi), int(se), ims)
         except ValueError as e:
             s = bytes(data).decode("utf8", "replace")
-            raise DataError(f"can't manage time {s!r}: {e}") from None
+            raise DataError(f"can't parse time {s!r}: {e}") from None
 
 
 class TimeBinaryLoader(Loader):
@@ -391,7 +391,7 @@ class TimetzLoader(Loader):
             return time(int(ho), int(mi), int(se), ims, tz)
         except ValueError as e:
             s = bytes(data).decode("utf8", "replace")
-            raise DataError(f"can't manage timetz {s!r}: {e}") from None
+            raise DataError(f"can't parse timetz {s!r}: {e}") from None
 
 
 class TimetzBinaryLoader(Loader):
@@ -506,7 +506,7 @@ class TimestampLoader(Loader):
                 imo = _month_abbr[mo]
             except KeyError:
                 s = mo.decode("utf8", "replace")
-                raise DataError(f"unexpected month: {s!r}") from None
+                raise DataError(f"can't parse month: {s!r}") from None
 
         # Pad the fraction of second to get millis
         if ms:
@@ -523,7 +523,7 @@ class TimestampLoader(Loader):
             )
         except ValueError as e:
             s = bytes(data).decode("utf8", "replace")
-            raise DataError(f"can't manage timestamp {s!r}: {e}") from None
+            raise DataError(f"can't parse timestamp {s!r}: {e}") from None
 
 
 class TimestampBinaryLoader(Loader):
@@ -604,13 +604,13 @@ class TimestamptzLoader(Loader):
             return (dt - tzoff).astimezone(self._timezone)
         except ValueError as e:
             s = bytes(data).decode("utf8", "replace")
-            raise DataError(f"can't manage timestamp {s!r}: {e}") from None
+            raise DataError(f"can't parse timestamptz {s!r}: {e}") from None
 
     def _load_notimpl(self, data: Buffer) -> datetime:
         s = bytes(data).decode("utf8", "replace")
         ds = _get_datestyle(self.connection).decode("ascii")
         raise NotImplementedError(
-            f"can't parse datetimetz with DateStyle {ds!r}: {s!r}"
+            f"can't parse timestamptz with DateStyle {ds!r}: {s!r}"
         )
 
 
@@ -688,7 +688,7 @@ class IntervalLoader(Loader):
             return timedelta(days=days, seconds=seconds)
         except OverflowError as e:
             s = bytes(data).decode("utf8", "replace")
-            raise DataError(f"can't manage interval {s!r}: {e}") from None
+            raise DataError(f"can't parse interval {s!r}: {e}") from None
 
     def _load_notimpl(self, data: Buffer) -> timedelta:
         s = bytes(data).decode("utf8", "replace")
index 773308ae06bfd0959cbc3993c5e7ef22725042f7..cfa7c2cabe8406850363208d98ab8407f470a688 100644 (file)
@@ -120,7 +120,7 @@ cdef class DateLoader(CLoader):
                 return date_new(vals[2], vals[0], vals[1])
         except ValueError as ex:
             s = bytes(data).decode("utf8", "replace")
-            raise e.DataError(f"can't manage date {s!r}: {ex}") from None
+            raise e.DataError(f"can't parse date {s!r}: {ex}") from None
 
 
 @cython.final