Skip to content

Commit 8a1d286

Browse files
committed
morph: use context for calling
1 parent 02b41fe commit 8a1d286

1 file changed

Lines changed: 3 additions & 14 deletions

File tree

‎pyteleport/morph.py‎

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -436,24 +436,13 @@ def morph_into(snapshot, nxt, call_nxt=False, object_storage=None, object_storag
436436

437437
if nxt is not NULL:
438438
code.c("!unpack TOS")
439-
# tos_context = code.callable_ctx if call_nxt else nullcontext
440-
# with tos_context:
441-
put(nxt)
439+
tos_context = code.callable_ctx if call_nxt else nullcontext
440+
with tos_context():
441+
put(nxt)
442442
if call_nxt:
443443
# TODO: move calling
444444
code.c("!call TOS")
445-
if isinstance(nxt, FunctionType):
446-
pass
447-
elif isinstance(nxt, CodeType):
448-
if python_feature_make_function_qualname:
449-
put(f"morph_into:{f_code.co_name}")
450-
code.i(MAKE_FUNCTION, 0)
451-
else:
452-
raise ValueError(f"cannot call {nxt}")
453445
if CALL is not None:
454-
code.put_null()
455-
if python_feature_call_null_swapped:
456-
code.i(SWAP, 2)
457446
code.i(CALL, 0)
458447
else:
459448
code.i(BUILD_TUPLE, 0)

0 commit comments

Comments
 (0)