diff options
author | robot-contrib <robot-contrib@yandex-team.com> | 2023-11-22 10:14:29 +0300 |
---|---|---|
committer | robot-contrib <robot-contrib@yandex-team.com> | 2023-11-22 10:35:04 +0300 |
commit | 825aa1842027dfc2fe1643b949cca81b824a102b (patch) | |
tree | 2a83b4295e86e60a51a1c1f6f3f019d76111f2f9 | |
parent | bf842056879450bafba47a67e5ea1025cfa6aefb (diff) | |
download | ydb-825aa1842027dfc2fe1643b949cca81b824a102b.tar.gz |
Update contrib/python/pg8000 to 1.30.3
-rw-r--r-- | contrib/python/pg8000/.dist-info/METADATA | 19 | ||||
-rw-r--r-- | contrib/python/pg8000/README.rst | 17 | ||||
-rw-r--r-- | contrib/python/pg8000/pg8000/converters.py | 26 | ||||
-rw-r--r-- | contrib/python/pg8000/pg8000/native.py | 4 | ||||
-rw-r--r-- | contrib/python/pg8000/ya.make | 2 |
5 files changed, 58 insertions, 10 deletions
diff --git a/contrib/python/pg8000/.dist-info/METADATA b/contrib/python/pg8000/.dist-info/METADATA index 6980a1f026..3511e11a2a 100644 --- a/contrib/python/pg8000/.dist-info/METADATA +++ b/contrib/python/pg8000/.dist-info/METADATA @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: pg8000 -Version: 1.30.2 +Version: 1.30.3 Summary: PostgreSQL interface library License: BSD 3-Clause License Project-URL: Homepage, https://github.com/tlocke/pg8000 @@ -1223,13 +1223,21 @@ possible to change the default mapping using adapters (see the examples). +-----------------------+-----------------+-----------------------------------------+ | datetime.datetime | timestamp | +/-infinity PostgreSQL values are | | (without tzinfo) | without | represented as Python ``str`` values. | - | | timezone | | + | | timezone | If a ``timestamp`` is too big for | + | | | ``datetime.datetime`` then a ``str`` is | + | | | used. | +-----------------------+-----------------+-----------------------------------------+ | datetime.datetime | timestamp with | +/-infinity PostgreSQL values are | | (with tzinfo) | timezone | represented as Python ``str`` values. | + | | | If a ``timestamptz`` is too big for | + | | | ``datetime.datetime`` then a ``str`` is | + | | | used. | +-----------------------+-----------------+-----------------------------------------+ | datetime.date | date | +/-infinity PostgreSQL values are | | | | represented as Python ``str`` values. | + | | | If a ``date`` is too big for a | + | | | ``datetime.date`` then a ``str`` is | + | | | used. | +-----------------------+-----------------+-----------------------------------------+ | datetime.time | time without | | | | time zone | | @@ -2232,6 +2240,13 @@ Run ``tox`` to make sure all tests pass, then update the release notes, then do: Release Notes ------------- +Version 1.30.3, 2023-10-31 +`````````````````````````` + +- Fix problem with PG date overflowing Python types. Now we return the ``str`` we got from the + server if we can't parse it. + + Version 1.30.2, 2023-09-17 `````````````````````````` diff --git a/contrib/python/pg8000/README.rst b/contrib/python/pg8000/README.rst index 2d0973d268..71e0fea751 100644 --- a/contrib/python/pg8000/README.rst +++ b/contrib/python/pg8000/README.rst @@ -1195,13 +1195,21 @@ possible to change the default mapping using adapters (see the examples). +-----------------------+-----------------+-----------------------------------------+ | datetime.datetime | timestamp | +/-infinity PostgreSQL values are | | (without tzinfo) | without | represented as Python ``str`` values. | - | | timezone | | + | | timezone | If a ``timestamp`` is too big for | + | | | ``datetime.datetime`` then a ``str`` is | + | | | used. | +-----------------------+-----------------+-----------------------------------------+ | datetime.datetime | timestamp with | +/-infinity PostgreSQL values are | | (with tzinfo) | timezone | represented as Python ``str`` values. | + | | | If a ``timestamptz`` is too big for | + | | | ``datetime.datetime`` then a ``str`` is | + | | | used. | +-----------------------+-----------------+-----------------------------------------+ | datetime.date | date | +/-infinity PostgreSQL values are | | | | represented as Python ``str`` values. | + | | | If a ``date`` is too big for a | + | | | ``datetime.date`` then a ``str`` is | + | | | used. | +-----------------------+-----------------+-----------------------------------------+ | datetime.time | time without | | | | time zone | | @@ -2204,6 +2212,13 @@ Run ``tox`` to make sure all tests pass, then update the release notes, then do: Release Notes ------------- +Version 1.30.3, 2023-10-31 +`````````````````````````` + +- Fix problem with PG date overflowing Python types. Now we return the ``str`` we got from the + server if we can't parse it. + + Version 1.30.2, 2023-09-17 `````````````````````````` diff --git a/contrib/python/pg8000/pg8000/converters.py b/contrib/python/pg8000/pg8000/converters.py index b9d17df5ec..1ce16480ee 100644 --- a/contrib/python/pg8000/pg8000/converters.py +++ b/contrib/python/pg8000/pg8000/converters.py @@ -18,7 +18,7 @@ from ipaddress import ( from json import dumps, loads from uuid import UUID -from dateutil.parser import parse +from dateutil.parser import ParserError, parse from pg8000.exceptions import InterfaceError from pg8000.types import PGInterval, Range @@ -131,7 +131,11 @@ def date_in(data): if data in ("infinity", "-infinity"): return data else: - return Datetime.strptime(data, "%Y-%m-%d").date() + try: + return Datetime.strptime(data, "%Y-%m-%d").date() + except ValueError: + # pg date can overflow Python Datetime + return data def date_out(v): @@ -249,7 +253,11 @@ def timestamp_in(data): pattern = "%Y-%m-%d %H:%M:%S.%f" if "." in data else "%Y-%m-%d %H:%M:%S" return Datetime.strptime(data, pattern) except ValueError: - return parse(data) + try: + return parse(data) + except ParserError: + # pg timestamp can overflow Python Datetime + return data def timestamptz_in(data): @@ -260,7 +268,11 @@ def timestamptz_in(data): patt = "%Y-%m-%d %H:%M:%S.%f%z" if "." in data else "%Y-%m-%d %H:%M:%S%z" return Datetime.strptime(f"{data}00", patt) except ValueError: - return parse(data) + try: + return parse(data) + except ParserError: + # pg timestamptz can overflow Python Datetime + return data def unknown_out(v): @@ -758,14 +770,16 @@ def literal(value): return str(value) elif isinstance(value, (bytes, bytearray)): return f"X'{value.hex()}'" + elif isinstance(value, Datetime): + return f"'{datetime_out(value)}'" elif isinstance(value, Date): return f"'{date_out(value)}'" elif isinstance(value, Time): return f"'{time_out(value)}'" - elif isinstance(value, Datetime): - return f"'{datetime_out(value)}'" elif isinstance(value, Timedelta): return f"'{interval_out(value)}'" + elif isinstance(value, list): + return f"'{array_out(value)}'" else: val = str(value).replace("'", "''") return f"'{val}'" diff --git a/contrib/python/pg8000/pg8000/native.py b/contrib/python/pg8000/pg8000/native.py index 77e70e9af1..1f3750c27f 100644 --- a/contrib/python/pg8000/pg8000/native.py +++ b/contrib/python/pg8000/pg8000/native.py @@ -18,6 +18,8 @@ from pg8000.converters import ( INTERVAL, JSON, JSONB, + JSONB_ARRAY, + JSON_ARRAY, MACADDR, NAME, NAME_ARRAY, @@ -268,6 +270,8 @@ __all__ = [ "InterfaceError", "JSON", "JSONB", + "JSONB_ARRAY", + "JSON_ARRAY", "MACADDR", "NAME", "NAME_ARRAY", diff --git a/contrib/python/pg8000/ya.make b/contrib/python/pg8000/ya.make index 741227b3e4..6172a19312 100644 --- a/contrib/python/pg8000/ya.make +++ b/contrib/python/pg8000/ya.make @@ -2,7 +2,7 @@ PY3_LIBRARY() -VERSION(1.30.2) +VERSION(1.30.3) LICENSE(BSD-3-Clause) |