Skip to content

pt 2.0, python 3.6 on Windows: object of type 'generator' has no len() #563

Open
@jskm

Description

@jskm

When trying to run the example programs under examples/full_screen, I get an endless stream of exceptions as follows:

Unhandled exception in event loop:
  File "C:\Code\prompt_testing\lib\site-packages\prompt_toolkit\eventloop\win32.py", line 98, in _run_task
    t()
  File "C:\Code\prompt_testing\lib\site-packages\prompt_toolkit\eventloop\context.py", line 115, in new_func
    return func(*a, **kw)
  File "C:\Code\prompt_testing\lib\site-packages\prompt_toolkit\application\application.py", line 492, in read_from_input
    self.key_processor.feed_multiple(keys)
  File "C:\Code\prompt_testing\lib\site-packages\prompt_toolkit\key_binding\key_processor.py", line 241, in feed_multiple
    self._keys_pressed += len(key_presses)

Exception object of type 'generator' has no len()

It looks like this error only happens on Windows. application.py#L489 calls read_keys() on a Win32Input, which returns a generator.

Is Application.run(set_exception_handler=True) working as intended? According to the docs:

set_exception_handler – When set, in case of an exception, go out of the alternate screen and hide the application, display the exception, and wait for the user to press ENTER.

In this case, there was an infinite loop that did not wait and couldn't be broken without closing the console.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions