[New-bugs-announce] [issue39213] cmd should have a hook in the finally block of cmdloop

Joseph Sible report at bugs.python.org
Sat Jan 4 14:17:36 EST 2020

New submission from Joseph Sible <josephcsible at gmail.com>:

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.

components: Library (Lib)
messages: 359305
nosy: Joseph Sible
priority: normal
severity: normal
status: open
title: cmd should have a hook in the finally block of cmdloop
type: enhancement
versions: Python 3.8

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list