This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: cmd should have a hook in the finally block of cmdloop
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Joseph Sible
Priority: normal Keywords:

Created on 2020-01-04 19:17 by Joseph Sible, last changed 2022-04-11 14:59 by admin.

Messages (1)
msg359305 - (view) Author: Joseph Sible (Joseph Sible) Date: 2020-01-04 19:17
Currently, the cmdloop function in cmd has a preloop hook, which runs before the large try block, and a postloop hook, which runs at the end of the body of the large try block. This isn't sufficient for subclasses to safely use readline.set_completion_display_matches_hook, since an exception in the large try block would mean that postloop doesn't get called, so there wouldn't be an opportunity to restore the old value of that callback. This is analogous to how we need the finally block ourself to restore the old value of the completer. Moving where postloop is called would be a breaking change, so we should probably create a new method instead, called postloop_finally or something.
History
Date User Action Args
2022-04-11 14:59:24adminsetgithub: 83394
2020-01-04 19:17:36Joseph Siblecreate