Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Exception No formatted text" raised by prompt-toolkit in interactive mode #725

Closed
andy-maier opened this issue Aug 12, 2020 · 2 comments · Fixed by #726
Closed

"Exception No formatted text" raised by prompt-toolkit in interactive mode #725

andy-maier opened this issue Aug 12, 2020 · 2 comments · Fixed by #726

Comments

@andy-maier
Copy link
Contributor

andy-maier commented Aug 12, 2020

This can be reproduced on Python 2.7 with the master branch of pywbemtools, as follows:

$ pywbemcli -n assoc
pywbemcli> cl<RIGHT-ARROW>

The result is the following exception:

Unhandled exception in event loop:
  File "/Users/maiera/virtualenvs/pywbemtools27/lib/python2.7/site-packages/prompt_toolkit/eventloop/posix.py", line 155, in _run_task
    t()
  File "/Users/maiera/virtualenvs/pywbemtools27/lib/python2.7/site-packages/prompt_toolkit/eventloop/context.py", line 116, in new_func
    return func(*a, **kw)
  File "/Users/maiera/virtualenvs/pywbemtools27/lib/python2.7/site-packages/prompt_toolkit/application/application.py", line 403, in redraw
    self._redraw()
  File "/Users/maiera/virtualenvs/pywbemtools27/lib/python2.7/site-packages/prompt_toolkit/application/application.py", line 471, in _redraw
    self.renderer.render(self, self.layout)
  File "/Users/maiera/virtualenvs/pywbemtools27/lib/python2.7/site-packages/prompt_toolkit/renderer.py", line 588, in render
    screen.draw_all_floats()
  File "/Users/maiera/virtualenvs/pywbemtools27/lib/python2.7/site-packages/prompt_toolkit/layout/screen.py", line 232, in draw_all_floats
    functions[0][1]()
  File "/Users/maiera/virtualenvs/pywbemtools27/lib/python2.7/site-packages/prompt_toolkit/layout/containers.py", line 710, in _draw_float
    width = fl.content.preferred_width(write_position.width).preferred
  File "/Users/maiera/virtualenvs/pywbemtools27/lib/python2.7/site-packages/prompt_toolkit/layout/containers.py", line 2183, in preferred_width
    return self.content.preferred_width(max_available_width)
  File "/Users/maiera/virtualenvs/pywbemtools27/lib/python2.7/site-packages/prompt_toolkit/layout/containers.py", line 1349, in preferred_width
    dont_extend=self.dont_extend_width())
  File "/Users/maiera/virtualenvs/pywbemtools27/lib/python2.7/site-packages/prompt_toolkit/layout/containers.py", line 1390, in _merge_dimensions
    preferred = get_preferred()
  File "/Users/maiera/virtualenvs/pywbemtools27/lib/python2.7/site-packages/prompt_toolkit/layout/containers.py", line 1338, in preferred_content_width
    max_available_width - total_margin_width)
  File "/Users/maiera/virtualenvs/pywbemtools27/lib/python2.7/site-packages/prompt_toolkit/layout/menus.py", line 55, in preferred_width
    menu_meta_width = self._get_menu_meta_width(500, complete_state)
  File "/Users/maiera/virtualenvs/pywbemtools27/lib/python2.7/site-packages/prompt_toolkit/layout/menus.py", line 122, in _get_menu_meta_width
    max(meta_width(c) for c in complete_state.completions) + 2)
  File "/Users/maiera/virtualenvs/pywbemtools27/lib/python2.7/site-packages/prompt_toolkit/layout/menus.py", line 122, in <genexpr>
    max(meta_width(c) for c in complete_state.completions) + 2)
  File "/Users/maiera/virtualenvs/pywbemtools27/lib/python2.7/site-packages/prompt_toolkit/layout/menus.py", line 117, in meta_width
    return get_cwidth(completion.display_meta_text)
  File "/Users/maiera/virtualenvs/pywbemtools27/lib/python2.7/site-packages/prompt_toolkit/completion/base.py", line 98, in display_meta_text
    return fragment_list_to_text(self.display_meta)
  File "/Users/maiera/virtualenvs/pywbemtools27/lib/python2.7/site-packages/prompt_toolkit/completion/base.py", line 92, in display_meta
    return to_formatted_text(self._display_meta)
  File "/Users/maiera/virtualenvs/pywbemtools27/lib/python2.7/site-packages/prompt_toolkit/formatted_text/base.py", line 50, in to_formatted_text
    'HTML, ANSI or a FormattedText instance. Got %r' % value)

Exception No formatted text. Expecting a unicode object, HTML, ANSI or a FormattedText instance. Got 'Filter the returned classes to return only deprecated classes (--deprecated) or classes that are not deprecated (--no-deprecated). If the option is not defined no filtering occurs'
Press ENTER to continue...                                                                                                  

According to Karl, this seems to be a left-over non-unicode message in common_options.py line 119.

@andy-maier andy-maier added this to the 0.8.0 milestone Aug 12, 2020
@andy-maier andy-maier added the roll back needed Roll back into latest fix branch is needed label Aug 12, 2020
@KSchopmeyer
Copy link
Contributor

The problem was added by me when I added the --deprecated option. Forgot the unicode flag on the strings.

KSchopmeyer added a commit that referenced this issue Aug 12, 2020
Fixed issue where the help for the --deprecated command is not unicode.

Adds test for this option.
KSchopmeyer added a commit that referenced this issue Aug 12, 2020
Fixed issue where the help for the --deprecated command is not unicode.

Adds test for this option.
@KSchopmeyer KSchopmeyer linked a pull request Aug 12, 2020 that will close this issue
andy-maier pushed a commit that referenced this issue Aug 12, 2020
Fixed issue where the help for the --deprecated command is not unicode.

Adds test for this option.
@andy-maier
Copy link
Contributor Author

The fix does not need to be rolled back into 0.6 because the option on which the issue existed was introduced only in 0.7.

@andy-maier andy-maier added resolution: fixed and removed roll back needed Roll back into latest fix branch is needed labels Aug 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants