aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/traceback.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/traceback.py')
-rw-r--r--Lib/traceback.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/traceback.py b/Lib/traceback.py
index cf5f355ff04..8d518728fa1 100644
--- a/Lib/traceback.py
+++ b/Lib/traceback.py
@@ -1037,6 +1037,16 @@ def _compute_suggestion_error(exc_value, tb, wrong_name):
+ list(frame.f_globals)
+ list(frame.f_builtins)
)
+
+ # Check first if we are in a method and the instance
+ # has the wrong name as attribute
+ if 'self' in frame.f_locals:
+ self = frame.f_locals['self']
+ if hasattr(self, wrong_name):
+ return f"self.{wrong_name}"
+
+ # Compute closest match
+
if len(d) > _MAX_CANDIDATE_ITEMS:
return None
wrong_name_len = len(wrong_name)