mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
gh-132385: Fix instance error suggestions trigger potential exceptions in traceback (#132387)
This commit is contained in:
parent
20f8ed595d
commit
641253cfac
3 changed files with 29 additions and 1 deletions
|
|
@ -1636,7 +1636,11 @@ def _compute_suggestion_error(exc_value, tb, wrong_name):
|
|||
# has the wrong name as attribute
|
||||
if 'self' in frame.f_locals:
|
||||
self = frame.f_locals['self']
|
||||
if hasattr(self, wrong_name):
|
||||
try:
|
||||
has_wrong_name = hasattr(self, wrong_name)
|
||||
except Exception:
|
||||
has_wrong_name = False
|
||||
if has_wrong_name:
|
||||
return f"self.{wrong_name}"
|
||||
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue