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

examples/asyncio-ssh-python-embed.py: '_GeneratorContextManager' object has no attribute 'typeahead_hash' #569

Open
hmaerki opened this issue Feb 8, 2024 · 0 comments

Comments

@hmaerki
Copy link

hmaerki commented Feb 8, 2024

When running examples/asyncio-ssh-python-embed.py this error occurs:

Traceback (most recent call last):
  File "/workspaces/ptpython/ptpython/repl.py", line 240, in run_async
    text = await loop.run_in_executor(None, self.read)
  File "/home/codespace/.python/current/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/workspaces/ptpython/ptpython/python_input.py", line 1102, in read
    result = self.app.run(pre_run=pre_run, in_thread=True)
  File "/home/codespace/.python/current/lib/python3.10/site-packages/prompt_toolkit/application/application.py", line 954, in run
    raise exception
  File "/home/codespace/.python/current/lib/python3.10/site-packages/prompt_toolkit/application/application.py", line 939, in run_in_thread
    result = self.run(
  File "/home/codespace/.python/current/lib/python3.10/site-packages/prompt_toolkit/application/application.py", line 1002, in run
    return asyncio.run(coro)
  File "/home/codespace/.python/current/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/home/codespace/.python/current/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/codespace/.python/current/lib/python3.10/site-packages/prompt_toolkit/application/application.py", line 886, in run_async
    return await _run_async(f)
  File "/home/codespace/.python/current/lib/python3.10/site-packages/prompt_toolkit/application/application.py", line 676, in _run_async
    self.key_processor.feed_multiple(get_typeahead(self.input))
  File "/home/codespace/.python/current/lib/python3.10/site-packages/prompt_toolkit/input/typeahead.py", line 65, in get_typeahead
    key = input_obj.typeahead_hash()
AttributeError: '_GeneratorContextManager' object has no attribute 'typeahead_hash'
DEBUG:asyncio:Using selector: EpollSelector

My suspicion

This line

self._input_pipe = create_pipe_input()

Calls https://github.com/prompt-toolkit/python-prompt-toolkit/blob/b76992eaf5709be9b5e51975b945e0ff23329f2f/src/prompt_toolkit/input/defaults.py#L59C1-L71C20

However, here it says:

Breaking change: In prompt_toolkit 3.0.28 and earlier, this was returning
the PipeInput directly, rather than through a context manager.

So I suspect that the example was not updated since this breaking change.

Environment to show this error

github codespace
Python 3.10.13 (main, Jan 10 2024, 19:45:45) [GCC 9.4.0] on linux
pip list
Package                   Version         Editable project location
------------------------- --------------- -------------------------
anyio                     4.2.0
appdirs                   1.4.4
argon2-cffi               23.1.0
argon2-cffi-bindings      21.2.0
arrow                     1.3.0
asttokens                 2.4.1
async-lru                 2.0.4
asyncssh                  2.14.2
attrs                     23.2.0
Babel                     2.14.0
beautifulsoup4            4.12.2
bleach                    6.1.0
certifi                   2023.11.17
cffi                      1.16.0
charset-normalizer        3.3.2
colorama                  0.4.6
comm                      0.2.1
contourpy                 1.2.0
cryptography              42.0.2
cycler                    0.12.1
debugpy                   1.8.0
decorator                 5.1.1
defusedxml                0.7.1
exceptiongroup            1.2.0
executing                 2.0.1
fastjsonschema            2.19.1
filelock                  3.13.1
fonttools                 4.47.0
fqdn                      1.5.1
fsspec                    2023.12.2
gitdb                     4.0.11
GitPython                 3.1.41
idna                      3.6
ipykernel                 6.28.0
ipython                   8.20.0
isoduration               20.11.0
jedi                      0.19.1
Jinja2                    3.1.2
joblib                    1.3.2
json5                     0.9.14
jsonpointer               2.4
jsonschema                4.20.0
jsonschema-specifications 2023.12.1
jupyter_client            8.6.0
jupyter_core              5.7.1
jupyter-events            0.9.0
jupyter-lsp               2.2.1
jupyter_server            2.12.3
jupyter-server-mathjax    0.2.6
jupyter_server_terminals  0.5.1
jupyterlab                4.0.10
jupyterlab_git            0.50.0
jupyterlab_pygments       0.3.0
jupyterlab_server         2.25.2
kiwisolver                1.4.5
MarkupSafe                2.1.3
matplotlib                3.8.2
matplotlib-inline         0.1.6
mistune                   3.0.2
mpmath                    1.3.0
nbclient                  0.9.0
nbconvert                 7.14.0
nbdime                    4.0.1
nbformat                  5.9.2
nest-asyncio              1.5.8
networkx                  3.2.1
notebook_shim             0.2.3
numpy                     1.26.3
nvidia-cublas-cu12        12.1.3.1
nvidia-cuda-cupti-cu12    12.1.105
nvidia-cuda-nvrtc-cu12    12.1.105
nvidia-cuda-runtime-cu12  12.1.105
nvidia-cudnn-cu12         8.9.2.26
nvidia-cufft-cu12         11.0.2.54
nvidia-curand-cu12        10.3.2.106
nvidia-cusolver-cu12      11.4.5.107
nvidia-cusparse-cu12      12.1.0.106
nvidia-nccl-cu12          2.18.1
nvidia-nvjitlink-cu12     12.3.101
nvidia-nvtx-cu12          12.1.105
overrides                 7.4.0
packaging                 23.2
pandas                    2.1.4
pandocfilters             1.5.0
parso                     0.8.3
pexpect                   4.9.0
pillow                    10.2.0
pip                       24.0
platformdirs              4.1.0
plotly                    5.18.0
prometheus-client         0.19.0
prompt-toolkit            3.0.43
psutil                    5.9.7
ptpython                  3.0.20          /workspaces/ptpython
ptyprocess                0.7.0
pure-eval                 0.2.2
pycparser                 2.21
Pygments                  2.17.2
pyparsing                 3.1.1
python-dateutil           2.8.2
python-json-logger        2.0.7
pytz                      2023.3.post1
PyYAML                    6.0.1
pyzmq                     25.1.2
referencing               0.32.1
requests                  2.31.0
rfc3339-validator         0.1.4
rfc3986-validator         0.1.1
rpds-py                   0.16.2
scikit-learn              1.3.2
scipy                     1.11.4
seaborn                   0.13.1
Send2Trash                1.8.2
setuptools                68.2.2
six                       1.16.0
smmap                     5.0.1
sniffio                   1.3.0
soupsieve                 2.5
stack-data                0.6.3
sympy                     1.12
tenacity                  8.2.3
terminado                 0.18.0
threadpoolctl             3.2.0
tinycss2                  1.2.1
tomli                     2.0.1
torch                     2.1.2
tornado                   6.4
traitlets                 5.14.1
triton                    2.1.0
types-python-dateutil     2.8.19.20240106
typing_extensions         4.9.0
tzdata                    2023.4
uri-template              1.3.0
urllib3                   2.0.7
wcwidth                   0.2.13
webcolors                 1.13
webencodings              0.5.1
websocket-client          1.7.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant