Skip to content

Commit 8da339e

Browse files
committed
context_manager_helpers: Comment on what default enter & exit obj are
1 parent 8aa1969 commit 8da339e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

shared/runtime/context_manager_helpers.h

+8
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,13 @@
88

99
#include "py/obj.h"
1010

11+
// An object that has a `deinit` method can use `default___enter___obj` and
12+
// `default___exit___obj` to define the `__enter__` and `__exit__` members in
13+
// its object table.
14+
//
15+
// `__enter__` returns the object itself, and `__exit__` calls its `deinit`.
16+
//
17+
// If enter/exit do anything else, such as taking & releasing a lock, these are
18+
// not suitable.
1119
#define default___enter___obj (mp_identity_obj)
1220
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(default___exit___obj);

0 commit comments

Comments
 (0)