fix: guard against missing loop attribute in ConsoleMaster.done()#8166
Open
kaiisfree wants to merge 1 commit into
Open
fix: guard against missing loop attribute in ConsoleMaster.done()#8166kaiisfree wants to merge 1 commit into
kaiisfree wants to merge 1 commit into
Conversation
When running() fails before the urwid event loop is created, self.loop is never assigned. This causes an AttributeError in done() when it tries to call self.loop.stop(). Initialize self.loop = None and check before calling .stop(). Fixes mitmproxy#8162 Co-Authored-By: Claude Opus 4.6 <[email protected]>
lups2000
reviewed
Apr 8, 2026
lups2000
left a comment
Member
There was a problem hiding this comment.
Thanks for the PR :) There are some errors in the tests though
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
self.loop = NoneinConsoleMaster.__init__()to preventAttributeErrorwhendone()is called beforerunning()completesself.loop.stop()with a None check indone()Problem
When the console is started without a TTY (or
running()fails for any reason before creating the urwid MainLoop),self.loopis never assigned. The subsequent call todone()then raises:Fix
Initialize
self.loop = Nonein the constructor and add a guard before calling.stop()indone().Fixes #8162
🤖 Generated with Claude Code