File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed
Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -512,9 +512,12 @@ _unpickle_context_set_module(struct _unpickle_context *ctx,
512512 struct sync_module_result res = {0 };
513513 struct sync_module_result * cached = NULL ;
514514 const char * filename = NULL ;
515+ const char * run_modname = modname ;
515516 if (strcmp (modname , "__main__" ) == 0 ) {
516517 cached = & ctx -> main .cached ;
517518 filename = ctx -> main .filename ;
519+ // We don't want to trigger "if __name__ == '__main__':".
520+ run_modname = "<fake __main__>" ;
518521 }
519522 else {
520523 res .failed = PyExc_NotImplementedError ;
@@ -533,7 +536,7 @@ _unpickle_context_set_module(struct _unpickle_context *ctx,
533536 res .failed = PyExc_NotImplementedError ;
534537 goto finally ;
535538 }
536- res .loaded = runpy_run_path (filename , modname );
539+ res .loaded = runpy_run_path (filename , run_modname );
537540 if (res .loaded == NULL ) {
538541 Py_CLEAR (res .module );
539542 res .failed = _PyErr_GetRaisedException (ctx -> tstate );
You can’t perform that action at this time.
0 commit comments