In awslings quiz and awslings mock, the arrow keys did not edit the answer: the terminal's escape sequence went straight to the program.
Cause.input() only gets line editing (arrows, Home/End, history) when the readline module is loaded. Nothing in the project imported it. Worse, ^[[D was parsed as answer letters ([ ignored, D read as option D).
Fix.import readline in awslings/quiz.py, which holds every input() of the quizzes and mock exams. It is optional (try/except ImportError) because Windows has no readline.
Checked. In a pseudo-terminal, typing a, b, left arrow, c gives 'ab\x1b[Dc' before the change and 'acb' after, with the project's .venv Python 3.13.5 (GNU readline).
Not done. No automated test (only a pseudo-terminal can check it). The colored prompt is not wrapped for readline, which would only misredraw a line typed close to the terminal width.
In `awslings quiz` and `awslings mock`, the arrow keys did not edit the answer: the terminal's escape sequence went straight to the program.
**Cause.** `input()` only gets line editing (arrows, Home/End, history) when the `readline` module is loaded. Nothing in the project imported it. Worse, `^[[D` was parsed as answer letters (`[` ignored, `D` read as option D).
**Fix.** `import readline` in `awslings/quiz.py`, which holds every `input()` of the quizzes and mock exams. It is optional (`try/except ImportError`) because Windows has no `readline`.
**Checked.** In a pseudo-terminal, typing `a`, `b`, left arrow, `c` gives `'ab\x1b[Dc'` before the change and `'acb'` after, with the project's `.venv` Python 3.13.5 (GNU readline).
**Not done.** No automated test (only a pseudo-terminal can check it). The colored prompt is not wrapped for `readline`, which would only misredraw a line typed close to the terminal width.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
input() only gets line editing (arrows, Home/End, history) when the readline
module is loaded, and nothing in the project imported it. Pressing an arrow key
sent the raw escape sequence ("\x1b[D") to the program, where "[" and "D" were
parsed as answer letters. Importing it in awslings/quiz.py, which holds every
input() of the quizzes and mock exams, fixes it. The import is optional because
Windows has no readline.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
nessar
merged commit fc6584b47e into main2026-10-27 19:24:24 +01:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
In
awslings quizandawslings mock, the arrow keys did not edit the answer: the terminal's escape sequence went straight to the program.Cause.
input()only gets line editing (arrows, Home/End, history) when thereadlinemodule is loaded. Nothing in the project imported it. Worse,^[[Dwas parsed as answer letters ([ignored,Dread as option D).Fix.
import readlineinawslings/quiz.py, which holds everyinput()of the quizzes and mock exams. It is optional (try/except ImportError) because Windows has noreadline.Checked. In a pseudo-terminal, typing
a,b, left arrow,cgives'ab\x1b[Dc'before the change and'acb'after, with the project's.venvPython 3.13.5 (GNU readline).Not done. No automated test (only a pseudo-terminal can check it). The colored prompt is not wrapped for
readline, which would only misredraw a line typed close to the terminal width.🤖 Generated with Claude Code
input() only gets line editing (arrows, Home/End, history) when the readline module is loaded, and nothing in the project imported it. Pressing an arrow key sent the raw escape sequence ("\x1b[D") to the program, where "[" and "D" were parsed as answer letters. Importing it in awslings/quiz.py, which holds every input() of the quizzes and mock exams, fixes it. The import is optional because Windows has no readline. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>