Uploaded image for project: 'Motor'
  1. Motor
  2. MOTOR-1215

Stop using datetime.utcnow

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 3.4
    • Affects Version/s: None
    • Component/s: None
    • None

      Related to PYTHON-3702, datetime.utcnow is deprecated in Python 3.12. Motor should stop using it:

      $ git grep utcnow
      motor/aiohttp/__init__.py:249:                datetime.datetime.utcnow() + datetime.timedelta(seconds=cache_time)
      motor/web.py:126:                "Expires", datetime.datetime.utcnow() + datetime.timedelta(seconds=cache_time)
      pyproject.toml:113:    "ignore:datetime.datetime.utcnow:DeprecationWarning",
      test/asyncio_tests/test_aiohttp_gridfs.py:65:        cls.put_start = datetime.datetime.utcnow().replace(microsecond=0)
      test/asyncio_tests/test_aiohttp_gridfs.py:72:        cls.put_end = datetime.datetime.utcnow().replace(microsecond=0)
      test/asyncio_tests/test_aiohttp_gridfs.py:235:        now = datetime.datetime.utcnow()
      test/asyncio_tests/test_aiohttp_gridfs.py:279:        now = datetime.datetime.utcnow()
      test/tornado_tests/test_motor_web.py:46:        self.put_start = datetime.datetime.utcnow().replace(microsecond=0)
      test/tornado_tests/test_motor_web.py:54:        self.put_end = datetime.datetime.utcnow().replace(microsecond=0)
      test/tornado_tests/test_motor_web.py:177:        now = datetime.datetime.utcnow()
      test/tornado_tests/test_motor_web.py:222:            < expires - datetime.datetime.utcnow()
      

      When we do this we can remove the utcnow warnings here: https://github.com/mongodb/motor/blob/45133078995301b62884e9ff4c9b248b64af83a1/pyproject.toml#L112-L113

            Assignee:
            jib.adegunloye@mongodb.com Jib Adegunloye
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: