fix(ws): replace deprecated utcfromtimestamp in vendored well_known_types#147
Open
roson9527 wants to merge 1 commit into
Open
fix(ws): replace deprecated utcfromtimestamp in vendored well_known_types#147roson9527 wants to merge 1 commit into
roson9527 wants to merge 1 commit into
Conversation
|
roson seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
…ypes 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 larksuite#145
roson9527
force-pushed
the
fix/ws-utcfromtimestamp-deprecation
branch
from
July 27, 2026 06:26
50ae197 to
850887f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #145.
The bundled protobuf stub at
lark_oapi/ws/pb/google/protobuf/internal/well_known_types.pystill callsdatetime.datetime.utcfromtimestamp(0), which is deprecated in Python 3.12+ and emitsDeprecationWarningon Python 3.13/3.14. This breaks test runs that elevateDeprecationWarningto errors and will turn into a hard failure once Python removes the API.Change
Align with current upstream
protocolbuffers/protobuf(python/google/protobuf/internal/well_known_types.py) by constructing the epoch datetime directly instead of via the deprecated helper:Semantics preserved:
_EPOCH_DATETIME_NAIVEstays a naive UTC datetime,_EPOCH_DATETIME_AWAREstays timezone-aware UTC. Callers at lines 251/266 (_EPOCH_DATETIME_NAIVE + delta/_EPOCH_DATETIME_AWARE + delta) are unchanged.Verification
warnings.simplefilter('error', DeprecationWarning)no longer raises._EPOCH_DATETIME_NAIVE == datetime(1970, 1, 1)and_EPOCH_DATETIME_AWARE == datetime(1970, 1, 1, tzinfo=timezone.utc), matching pre-change values.rg "utcfromtimestamp" lark_oapi/returns no matches.Scope
Single-file, 3-line change to vendored protobuf code. No API change, no dependency change.