Assign __main__ as name of executed scripts
This commit is contained in:
parent
4266bf60e7
commit
8a1de6c4d2
2
kuroko.c
2
kuroko.c
@ -204,7 +204,7 @@ int main(int argc, char * argv[]) {
|
||||
* collect the result of the last one and use it as the
|
||||
* exit code if it's an integer. */
|
||||
for (int i = optind; i < argc; ++i) {
|
||||
KrkValue out = krk_runfile(argv[i],1,"<module>",argv[i]);
|
||||
KrkValue out = krk_runfile(argv[i],1,"__main__",argv[i]);
|
||||
if (i + 1 == argc) result = out;
|
||||
}
|
||||
}
|
||||
|
1
test/testImportContext.krk.expect
Normal file
1
test/testImportContext.krk.expect
Normal file
@ -0,0 +1 @@
|
||||
Hello, world: dummy I am a module.
|
4
test/testModuleName.krk
Normal file
4
test/testModuleName.krk
Normal file
@ -0,0 +1,4 @@
|
||||
if __name__ == '__main__':
|
||||
print("You called me directly!")
|
||||
else:
|
||||
print("My name is",__name__,"so I must have been imported.")
|
1
test/testModuleName.krk.expect
Normal file
1
test/testModuleName.krk.expect
Normal file
@ -0,0 +1 @@
|
||||
You called me directly!
|
Loading…
Reference in New Issue
Block a user