Skip to content

Commit

Permalink
Merge pull request #40 from thuml/fix_attr
Browse files Browse the repository at this point in the history
deal with none in patch
  • Loading branch information
youkaichao authored Jul 4, 2024
2 parents 7824657 + fc7d553 commit 2633083
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion depyf/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.15.0
0.16.0
6 changes: 4 additions & 2 deletions depyf/explain/enable_debugging.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,13 @@ def __call__(self, code, new_code):
@contextlib.contextmanager
def patch(parent, name, value):
old_value = getattr(parent, name, None)
setattr(parent, name, value)
if old_value is not None:
setattr(parent, name, value)
try:
yield
finally:
setattr(parent, name, old_value)
if old_value is not None:
setattr(parent, name, old_value)


@contextlib.contextmanager
Expand Down

0 comments on commit 2633083

Please sign in to comment.