Commit 06d0dca9 authored by Marius Wachtler's avatar Marius Wachtler

Set __doc__ inside exec statements

parent 51eb2a56
......@@ -348,6 +348,10 @@ Box* evalOrExec(CLFunction* cl, Box* globals, Box* boxedLocals) {
// results (since sometimes eval or exec might be called on constant strings).
EffortLevel effort = EffortLevel::INTERPRETED;
Box* doc_string = cl->source->getDocString();
if (doc_string != None)
setGlobal(boxedLocals, "__doc__", doc_string);
CompiledFunction* cf = compileFunction(cl, new FunctionSpecialization(VOID), effort, NULL);
assert(cf->clfunc->versions.size());
......
......@@ -181,3 +181,21 @@ exec s in globals(), {}
exec "import builtins_getitem"
exec "import builtins_getitem" in {}, {}
s = "print __doc__"
g = {}
l = {}
exec s in g, l
print l
s = """
'test'
print __doc__
"""
g = {}
l = {}
exec s in g, l
print l
exec s
print __doc__
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment