Skip to content

AttributeError: 'datetime.date' object has no attribute 'timetz'

I tried to query the bot for Mensa 1 Abendmensa about 20 minutes ago and it did not respond. Server logs show an error: AttributeError: 'datetime.date' object has no attribute 'timetz'

Trace

ct 25 15:05:30 mensabot python3[41975]: Traceback (most recent call last):
Oct 25 15:05:30 mensabot python3[41975]:   File "/opt/mensa-matrix-bot/mensa_matrix_bot.py", line 372, in <module>
Oct 25 15:05:30 mensabot python3[41975]:     bot.run()
Oct 25 15:05:30 mensabot python3[41975]:   File "/opt/mensa-matrix-bot/.direnv/python-3.11.2/lib/python3.11/site-packages/simplematrixbotlib/bot.py", line 96, in run
Oct 25 15:05:30 mensabot python3[41975]:     asyncio.run(self.main())
Oct 25 15:05:30 mensabot python3[41975]:   File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
Oct 25 15:05:30 mensabot python3[41975]:     return runner.run(main)
Oct 25 15:05:30 mensabot python3[41975]:            ^^^^^^^^^^^^^^^^
Oct 25 15:05:30 mensabot python3[41975]:   File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
Oct 25 15:05:30 mensabot python3[41975]:     return self._loop.run_until_complete(task)
Oct 25 15:05:30 mensabot python3[41975]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 25 15:05:30 mensabot python3[41975]:   File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
Oct 25 15:05:30 mensabot python3[41975]:     return future.result()
Oct 25 15:05:30 mensabot python3[41975]:            ^^^^^^^^^^^^^^^
Oct 25 15:05:30 mensabot python3[41975]:   File "/opt/mensa-matrix-bot/.direnv/python-3.11.2/lib/python3.11/site-packages/simplematrixbotlib/bot.py", line 89, in main
Oct 25 15:05:30 mensabot python3[41975]:     await self.async_client.sync_forever(timeout=3000, full_state=True)
Oct 25 15:05:30 mensabot python3[41975]:   File "/opt/mensa-matrix-bot/.direnv/python-3.11.2/lib/python3.11/site-packages/nio/client/base_client.py", line 105, in wrapper
Oct 25 15:05:30 mensabot python3[41975]:     return await func(self, *args, **kwargs)
Oct 25 15:05:30 mensabot python3[41975]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 25 15:05:30 mensabot python3[41975]:   File "/opt/mensa-matrix-bot/.direnv/python-3.11.2/lib/python3.11/site-packages/nio/client/async_client.py", line 1330, in sync_forever
Oct 25 15:05:30 mensabot python3[41975]:     await self.run_response_callbacks([await response])
Oct 25 15:05:30 mensabot python3[41975]:                                        ^^^^^^^^^^^^^^
Oct 25 15:05:30 mensabot python3[41975]:   File "/usr/lib/python3.11/asyncio/tasks.py", line 605, in _wait_for_one
Oct 25 15:05:30 mensabot python3[41975]:     return f.result()  # May raise f.exception().
Oct 25 15:05:30 mensabot python3[41975]:            ^^^^^^^^^^
Oct 25 15:05:30 mensabot python3[41975]:   File "/opt/mensa-matrix-bot/.direnv/python-3.11.2/lib/python3.11/site-packages/nio/client/base_client.py", line 105, in wrapper
Oct 25 15:05:30 mensabot python3[41975]:     return await func(self, *args, **kwargs)
Oct 25 15:05:30 mensabot python3[41975]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 25 15:05:30 mensabot python3[41975]:   File "/opt/mensa-matrix-bot/.direnv/python-3.11.2/lib/python3.11/site-packages/nio/client/async_client.py", line 1173, in sync
Oct 25 15:05:30 mensabot python3[41975]:     response = await self._send(
Oct 25 15:05:30 mensabot python3[41975]:                ^^^^^^^^^^^^^^^^^
Oct 25 15:05:30 mensabot python3[41975]:   File "/opt/mensa-matrix-bot/.direnv/python-3.11.2/lib/python3.11/site-packages/nio/client/async_client.py", line 823, in _send
Oct 25 15:05:30 mensabot python3[41975]:     await self.receive_response(resp)
Oct 25 15:05:30 mensabot python3[41975]:   File "/opt/mensa-matrix-bot/.direnv/python-3.11.2/lib/python3.11/site-packages/nio/client/async_client.py", line 723, in receive_response
Oct 25 15:05:30 mensabot python3[41975]:     await self._handle_sync(response)
Oct 25 15:05:30 mensabot python3[41975]:   File "/opt/mensa-matrix-bot/.direnv/python-3.11.2/lib/python3.11/site-packages/nio/client/async_client.py", line 690, in _handle_sync
Oct 25 15:05:30 mensabot python3[41975]:     await self._handle_joined_rooms(response)
Oct 25 15:05:30 mensabot python3[41975]:   File "/opt/mensa-matrix-bot/.direnv/python-3.11.2/lib/python3.11/site-packages/nio/client/async_client.py", line 617, in _handle_joined_rooms
Oct 25 15:05:30 mensabot python3[41975]:     await cb.execute(event, room)
Oct 25 15:05:30 mensabot python3[41975]:   File "/opt/mensa-matrix-bot/.direnv/python-3.11.2/lib/python3.11/site-packages/nio/client/base_client.py", line 131, in execute
Oct 25 15:05:30 mensabot python3[41975]:     await result
Oct 25 15:05:30 mensabot python3[41975]:   File "/opt/mensa-matrix-bot/mensa_matrix_bot.py", line 337, in mensa_message_event
Oct 25 15:05:30 mensabot python3[41975]:     if opening_hours.start_day <= weekday <= opening_hours.end_day and selected_day.timetz() <= opening_hours.end_time:

Not triaged this further and haven't seen this before. On a quick glance datetime.timetz() exists but date.timetz() does not. Is this a mistake in the bot's code? Or did some python/dep update broke it? Probably an easy fix

Attached output of https://sls.api.stw-on.de/v1/location/102/menu/2024-10-25/2024-11-08?time=evening, maybe it helps debugging this.