question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WordCompleter docs example throws AssertionError

See original GitHub issue

Hello,

I am using version 2.0.7 with python 2.7

~/programming/card-game-maxeta % pip install prompt_toolkit
Requirement already satisfied: prompt_toolkit in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (2.0.7)
Requirement already satisfied: wcwidth in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from prompt_toolkit) (0.1.7)
Requirement already satisfied: six>=1.9.0 in /Library/Python/2.7/site-packages (from prompt_toolkit) (1.11.0)

and I am running the python file pt_fun.py whose contents is

from prompt_toolkit import prompt
from prompt_toolkit.completion import WordCompleter

html_completer = WordCompleter(['<html>', '<body>', '<head>', '<title>'])
text = prompt('Enter HTML: ', completer=html_completer)
print('You said: %s' % text)

which is verbatim what is shown in the stable and 2.0.7 docs.

It throws the error:

~/programming/card-game-maxeta % python pt_fun.py
Traceback (most recent call last):
  File "pt_fun.py", line 5, in <module>
    text = prompt('Enter HTML: ', completer=html_completer)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/prompt_toolkit/shortcuts/prompt.py", line 840, in prompt
^[[32;1R    return session.prompt(*a, **kw)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/prompt_toolkit/shortcuts/prompt.py", line 733, in prompt
    return run_sync()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/prompt_toolkit/shortcuts/prompt.py", line 722, in run_sync
    return self.app.run(inputhook=self.inputhook, pre_run=pre_run2)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/prompt_toolkit/application/application.py", line 699, in run
    return run()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/prompt_toolkit/application/application.py", line 673, in run
    return f.result()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/prompt_toolkit/eventloop/future.py", line 149, in result
    raise self._exception
AssertionError

Thank you, Matthew

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jonathanslenderscommented, Dec 19, 2018

@MareoRaft: in your example the error is that the prompt string is not a unicode object but str (in Python 2). Try to put a lowercase u in front of the string:

text = prompt(u'Enter HTML: ', completer=html_completer)

The error message is not clear indeed. We have to fix that.

0reactions
MareoRaftcommented, Jan 6, 2019

@jonathanslenders Please feel free to reopen if you want to use this ticket to make sure the error message gets updated. Like you said, it really should be a better error message.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is actively throwing AssertionError in Java good practice?
For my part I throw AssertionError . I think the main reason for not checking assertions in production is the cost of checking...
Read more >
Python Exception Handling: AssertionError - Airbrake Blog
A brief look at the AssertionError in Python, including a functional code sample illustrating how to create and use assert statements.
Read more >
8.9 Java assert statement and AssertionError exception
12.1 Multithreading concepts · 1.13 Assert Statements in Java · 12.4 Prime Calculator example.
Read more >
python dict move key to start - joshpauly.com
For example, heres a program that uses a dictionary that contains other ... allows the functions to modify or A simple WordCompleter is...
Read more >
java.lang.AssertionError java code examples - Tabnine
if (qd == null) { throw new AssertionError("Upstream is not fuseable.");
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found