Skip to content

Fix regex match in test_from_timestamp_with_overflow_value on Windows (fixes #2999) - #3046

Open
eminsk wants to merge 1 commit into
marshmallow-code:devfrom
eminsk:fix/timestamp-overflow-test-windows
Open

Fix regex match in test_from_timestamp_with_overflow_value on Windows (fixes #2999)#3046
eminsk wants to merge 1 commit into
marshmallow-code:devfrom
eminsk:fix/timestamp-overflow-test-windows

Conversation

@eminsk

@eminsk eminsk commented Sep 8, 2026

Copy link
Copy Markdown

Problem (fixes #2999)

On Windows runners and systems, test_from_timestamp_with_overflow_value fails with an AssertionError because the underlying C runtime raises an OSError ([Errno 22] Invalid argument) instead of Python's ValueError.

marshmallow.utils.from_timestamp catches OSError and wraps it into:

except OSError as exc:
    raise ValueError("Error converting value to datetime") from exc

Consequently, the exception raised on Windows is ValueError("Error converting value to datetime"), which did not match the previous pattern r"out of range|year must be in 1\.\.9999".

Solution

  1. Updated test_from_timestamp_with_overflow_value regex pattern to also accept Error converting value to datetime (raised from Windows OSError) and Timestamp is too large (raised from OverflowError).
  2. Added test_from_timestamp_ms_with_overflow_value to ensure consistent test coverage for millisecond timestamps across platforms.
  3. Updated AUTHORS.rst and CHANGELOG.rst.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_from_timestamp_with_overflow_value test failing on Windows because of message mismatch

1 participant