Skip to content
Myr

More defensive for scope depth management

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 8e31125 · Browse files · 2 files+10 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+10 added−6 removed

  • tests:+4 added−2 removed
  • other:+6 added−4 removed

2 files+10 added−6 removed

modified:click/core.py+6 added-4 removed
333 unmodified lines
334 Nested pushes automatically defer the cleanup.335 """336 if not cleanup:337 self._depth += 1338 with self as rv:339 yield rv340 if not cleanup:341 self._depth -= 1338 try:339 with self as rv:340 yield rv341 finally:342 if not cleanup:343 self._depth -= 1344345 @property346 def meta(self):347 """This is a dictionary which is shared with all the contexts
1347 unmodified lines
modified:tests/test_context.py+4 added-2 removed
156 unmodified lines
157 def test_callback():158 rv.append(42)159160 with ctx.scope(cleanup=False):161 pass161 # Internal162 assert ctx._depth == 2163164 assert rv == []165166 with ctx.scope():166 pass167 # Internal168 assert ctx._depth == 1169170 assert rv == [42]