Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: gaoflow/msgpack-python
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d5e380f
Choose a base ref
...
head repository: msgpack/msgpack-python
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c6b4a48
Choose a head ref
  • 2 commits
  • 4 files changed
  • 2 contributors

Commits on Jul 5, 2026

  1. Fix Timestamp.from_datetime() precision for far-future datetimes (msg…

    …pack#710)
    
    `Timestamp.from_datetime()` computes the whole-second part from the
    float `datetime.timestamp()`. A float64 cannot hold microsecond
    precision for datetimes far from the epoch, so `timestamp()` rounds the
    seconds up while the exact `microsecond` is still used for the
    nanoseconds. The result is a `Timestamp` one second in the future, and
    near `datetime.max` it raises `OverflowError`:
    
    ```python
    >>> import datetime as dt
    >>> from msgpack.ext import Timestamp
    >>> d = dt.datetime(3000, 1, 1, 0, 0, 0, 999999, tzinfo=dt.timezone.utc)
    >>> Timestamp.from_datetime(d).to_datetime()
    datetime.datetime(3000, 1, 1, 0, 0, 1, 999999, tzinfo=datetime.timezone.utc)   # +1 second
    >>> Timestamp.from_datetime(dt.datetime(9999, 12, 31, 23, 59, 59, 999999, tzinfo=dt.timezone.utc))
    OverflowError: date value out of range
    ```
    
    The Cython packer already uses integer `timedelta` arithmetic and is
    correct. This makes the pure-Python `from_datetime()` do the same, so
    the two paths agree and the round-trip invariant
    `from_datetime(d).to_datetime() == d` holds for far-future datetimes.
    Naive datetimes keep their existing local-time interpretation (matching
    `datetime.timestamp()`).
    
    Follow-up to msgpack#662, which fixed the pre-epoch rounding direction in the
    same method.
    
    Existing tests are unchanged; I added a regression test covering the
    far-future round-trip, the exact seconds/nanoseconds, agreement with
    packing the datetime directly, and the former `OverflowError` case. Full
    suite is green on both the C-extension and pure-Python paths.
    gaoflow authored Jul 5, 2026
    Configuration menu
    Copy the full SHA
    659ee98 View commit details
    Browse the repository at this point in the history

Commits on Jul 10, 2026

  1. Configuration menu
    Copy the full SHA
    c6b4a48 View commit details
    Browse the repository at this point in the history
Loading