From dd0fb0cce1965b359fb8438b4120bef8862ac808 Mon Sep 17 00:00:00 2001 From: Liam Cooke Date: Thu, 18 May 2017 11:40:45 +1000 Subject: [PATCH] Fix: "update()" appears in local scope; docstrings --- see/exceptions.py | 1 + see/inspector.py | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/see/exceptions.py b/see/exceptions.py index 3c78bb1..00130eb 100644 --- a/see/exceptions.py +++ b/see/exceptions.py @@ -7,6 +7,7 @@ """ + class SeeError(Exception): """ Generic see exception. diff --git a/see/inspector.py b/see/inspector.py index c9f885c..cc7c365 100644 --- a/see/inspector.py +++ b/see/inspector.py @@ -15,15 +15,21 @@ from .features import FEATURES, PY3 -class UseLocalScope(object): - +class LocalScope(object): + """ + Local scope proxy object. + """ def __repr__(self): return 'anything' - def update(self, frame=None): - self.__dict__ = frame.f_back.f_locals + def _update(self, frame=None): + """ + Replace this object's namespace with the local namespace of a given + stack frame. + """ + self.__dict__ = frame.f_locals -LOCALS = UseLocalScope() +LOCALS = LocalScope() class SeeResult(tuple): @@ -73,7 +79,8 @@ def see(obj=LOCALS, pattern=None, r=None): """ use_locals = obj is LOCALS if use_locals: - LOCALS.update(inspect.currentframe()) + # Get the local scope from the caller's stack frame. + LOCALS._update(inspect.currentframe().f_back) actions = [] attrs = dir(obj)