Skip to content

Commit

Permalink
in persistent_locals2, the f_locals dictionary is copied now
Browse files Browse the repository at this point in the history
  • Loading branch information
pberkes committed Jul 7, 2010
1 parent 977b47c commit 5a28c9d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions deco.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,17 @@ class persistent_locals2(object):
This decorator does not play nice with profilers, and will cause
them to not be able to assign execution time to functions.
"""

def __init__(self, func):
self._locals = {}
self.func = func

def __call__(self, *args, **kwargs):

def tracer(frame, event, arg):
if event=='return':
self._locals = frame.f_locals
self._locals = frame.f_locals.copy()

# tracer is activated on next call, return or exception
sys.setprofile(tracer)
try:
Expand Down

0 comments on commit 5a28c9d

Please sign in to comment.