Skip to content

bug: obj.astimezone() raised OSError: [Errno 22] Invalid argument #5895

@Creeper19472

Description

@Creeper19472

Duplicate Check

Describe the bug

Flet encountered this error when handling a dialog containing a DateRangePicker.

Code sample

Code
import flet as ft


def main(page: ft.Page):
    range_picker = ft.DateRangePicker()
    page.add(range_picker)
    page.show_dialog(range_picker)


if __name__ == "__main__":
    ft.run(main)

To reproduce

  1. Run the repro code
  2. It fails

Expected behavior

No exceptions thrown

Screenshots / Videos

Captures Image

Operating System

Windows

Operating system details

Windows 11 25H2 (26200.7171)

Flet version

0.70.0.dev6999

Regression

I'm not sure / I don't know

Suggestions

No response

Logs

Logs
Unhandled error in main() handler
Traceback (most recent call last):
  File "d:\[REDACTED]\.venv\Lib\site-packages\flet\app.py", line 269, in on_session_created
    main(session.page)
    ~~~~^^^^^^^^^^^^^^
  File "d:\[REDACTED]\src\include\ui\issues\daterange.py", line 6, in main
    page.add(range_picker)
    ~~~~~~~~^^^^^^^^^^^^^^
  File "d:\[REDACTED]\.venv\Lib\site-packages\flet\controls\base_page.py", line 284, in add
    self.update()
    ~~~~~~~~~~~^^
  File "d:\[REDACTED]\.venv\Lib\site-packages\flet\controls\page.py", line 448, in update
    self.__update(self)
    ~~~~~~~~~~~~~^^^^^^
  File "d:\[REDACTED]\.venv\Lib\site-packages\flet\controls\page.py", line 457, in __update
    self.session.patch_control(c)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
  File "d:\[REDACTED]\.venv\Lib\site-packages\flet\messaging\session.py", line 138, in patch_control
    self.__send_message(
    ~~~~~~~~~~~~~~~~~~~^
        ClientMessage(
        ^^^^^^^^^^^^^^
    ...<2 lines>...
        )
        ^
    )
    ^
  File "d:\[REDACTED]\.venv\Lib\site-packages\flet\messaging\session.py", line 281, in __send_message
    self.__conn.send_message(message)
    ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "d:\[REDACTED]\.venv\Lib\site-packages\flet\messaging\flet_socket_server.py", line 221, in send_message
    m = msgpack.packb(
        [message.action, message.body],
        default=configure_encode_object_for_msgpack(BaseControl),
    )
  File "d:\[REDACTED]\.venv\Lib\site-packages\msgpack\__init__.py", line 36, in packb
    return Packer(**kwargs).pack(o)
           ~~~~~~~~~~~~~~~~~~~~~^^^
  File "msgpack/_packer.pyx", line 279, in msgpack._cmsgpack.Packer.pack
  File "msgpack/_packer.pyx", line 276, in msgpack._cmsgpack.Packer.pack
  File "msgpack/_packer.pyx", line 265, in msgpack._cmsgpack.Packer._pack
  File "msgpack/_packer.pyx", line 232, in msgpack._cmsgpack.Packer._pack_inner
  File "msgpack/_packer.pyx", line 270, in msgpack._cmsgpack.Packer._pack
  File "msgpack/_packer.pyx", line 213, in msgpack._cmsgpack.Packer._pack_inner
  File "msgpack/_packer.pyx", line 265, in msgpack._cmsgpack.Packer._pack
  File "msgpack/_packer.pyx", line 232, in msgpack._cmsgpack.Packer._pack_inner
  File "msgpack/_packer.pyx", line 265, in msgpack._cmsgpack.Packer._pack
  File "msgpack/_packer.pyx", line 232, in msgpack._cmsgpack.Packer._pack_inner
  File "msgpack/_packer.pyx", line 265, in msgpack._cmsgpack.Packer._pack
  File "msgpack/_packer.pyx", line 232, in msgpack._cmsgpack.Packer._pack_inner
  File "msgpack/_packer.pyx", line 270, in msgpack._cmsgpack.Packer._pack
  File "msgpack/_packer.pyx", line 213, in msgpack._cmsgpack.Packer._pack_inner
  File "msgpack/_packer.pyx", line 267, in msgpack._cmsgpack.Packer._pack
  File "d:\[REDACTED]\.venv\Lib\site-packages\flet\messaging\protocol.py", line 77, in encode_object_for_msgpack
    obj = obj.astimezone()
OSError: [Errno 22] Invalid argument

Additional details

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions