From 850887fda3a742f9631b502af971ef0d08200b4d Mon Sep 17 00:00:00 2001 From: roson Date: Mon, 27 Jul 2026 14:24:22 +0800 Subject: [PATCH] fix(ws): replace deprecated utcfromtimestamp in vendored well_known_types The bundled protobuf well_known_types.py still constructed the epoch datetime via datetime.datetime.utcfromtimestamp(0), which is deprecated in Python 3.12+ and emits DeprecationWarning on 3.13/3.14. Align with upstream protocolbuffers/protobuf, which constructs the naive epoch datetime directly and derives the aware value from it. Fixes #145 --- .../ws/pb/google/protobuf/internal/well_known_types.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lark_oapi/ws/pb/google/protobuf/internal/well_known_types.py b/lark_oapi/ws/pb/google/protobuf/internal/well_known_types.py index 1ea4f88b5..7c28a8922 100644 --- a/lark_oapi/ws/pb/google/protobuf/internal/well_known_types.py +++ b/lark_oapi/ws/pb/google/protobuf/internal/well_known_types.py @@ -88,9 +88,9 @@ def Is(self, descriptor): return '/' in self.type_url and self.TypeName() == descriptor.full_name -_EPOCH_DATETIME_NAIVE = datetime.datetime.utcfromtimestamp(0) -_EPOCH_DATETIME_AWARE = datetime.datetime.fromtimestamp( - 0, tz=datetime.timezone.utc) +_EPOCH_DATETIME_NAIVE = datetime.datetime(1970, 1, 1, tzinfo=None) +_EPOCH_DATETIME_AWARE = _EPOCH_DATETIME_NAIVE.replace( + tzinfo=datetime.timezone.utc) class Timestamp(object):