prompt-toolkit / prompt-toolkit/python-prompt-toolkit

local variable 'mouse_modifiers' referenced before assignment

Open
#1,572 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
10.6k
Forks
815
PR merge metrics
No merged PRs in 30d

Description

Since upgrading from prompt-toolkit==3.0.19 to prompt-toolkit==3.0.28, I started seeing this issue pretty frequently.

  File "/usr/lib/python3.9/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/root/.local/lib/python3.9/site-packages/prompt_toolkit/application/application.py", line 711, in read_from_input
    self.key_processor.process_keys()
  File "/root/.local/lib/python3.9/site-packages/prompt_toolkit/key_binding/key_processor.py", line 270, in process_keys
    self._process_coroutine.send(key_press)
  File "/root/.local/lib/python3.9/site-packages/prompt_toolkit/key_binding/key_processor.py", line 185, in _process
    self._call_handler(matches[-1], key_sequence=buffer[:])
  File "/root/.local/lib/python3.9/site-packages/prompt_toolkit/key_binding/key_processor.py", line 320, in _call_handler
    handler.call(event)
  File "/root/.local/lib/python3.9/site-packages/prompt_toolkit/key_binding/key_bindings.py", line 124, in call
    result = self.handler(event)
  File "/root/.local/lib/python3.9/site-packages/prompt_toolkit/key_binding/bindings/mouse.py", line 279, in _
    modifiers=mouse_modifiers,

Exception local variable 'mouse_modifiers' referenced before assignment
Press ENTER to continue...```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in prompt_toolkit/key_binding/bindings/mouse.py at the handler location shown in the traceback, and compare the mouse-event paths between prompt-toolkit 3.0.19 and 3.0.28. Reproduce the reported event-loop failure if possible; done means the local-variable exception no longer occurs for the affected mouse input.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.