Skip to content

Python 3.12 deprecates timezone non aware utcfromtimestamp() and utcnow() #705

@traylenator

Description

@traylenator

Describe the bug

There are some deprecation warnings with Python 3.12.

To Reproduce
Run tests with Python 3.12

Expected behavior
Tests should run clean.

For example:

  /builddir/build/BUILD/reactivex-4.0.4/reactivex/internal/basic.py:17: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
    return datetime.utcnow()

tests/test_observable/test_delay.py::TestDelay::test_delay_datetime_offset_error1_impl
  /builddir/build/BUILD/reactivex-4.0.4/tests/test_observable/test_delay.py:204: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
    return xs.pipe(delay(datetime.utcfromtimestamp(250)))

tests/test_observable/test_delay.py::TestDelay::test_delay_datetime_offset_error2_impl
  /builddir/build/BUILD/reactivex-4.0.4/tests/test_observable/test_delay.py:247: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
    return xs.pipe(delay(datetime.utcfromtimestamp(350)))

https://docs.python.org/3.12/whatsnew/3.12.html#deprecated

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions