Commit fa3ed96f authored by Kevin Modzelewski's avatar Kevin Modzelewski

exec of tuple

parent 919e8d25
......@@ -401,6 +401,18 @@ Box* eval(Box* boxedCode) {
}
Box* exec(Box* boxedCode, Box* globals, Box* locals) {
if (isSubclass(boxedCode->cls, tuple_cls)) {
RELEASE_ASSERT(!globals, "");
RELEASE_ASSERT(!locals, "");
BoxedTuple* t = static_cast<BoxedTuple*>(boxedCode);
RELEASE_ASSERT(t->size() >= 2 && t->size() <= 3, "%ld", t->size());
boxedCode = t->elts[0];
globals = t->elts[1];
if (t->size() >= 3)
locals = t->elts[2];
}
if (globals == None)
globals = NULL;
......@@ -444,7 +456,7 @@ Box* exec(Box* boxedCode, Box* globals, Box* locals) {
}
// TODO same issues as in `eval`
RELEASE_ASSERT(boxedCode->cls == str_cls, "");
RELEASE_ASSERT(boxedCode->cls == str_cls, "%s", boxedCode->cls->tp_name);
const char* code = static_cast<BoxedString*>(boxedCode)->s.data();
AST_Module* parsedModule = parse_string(code);
AST_Suite* parsedSuite = new AST_Suite(std::move(parsedModule->interned_strings));
......
......@@ -16,10 +16,11 @@ print "Running", args
subprocess.check_call(args)
sh_script = """
set -ex
set -e
. test_env/bin/activate
set -ux
python -c 'import __future__'
python -c 'import sys; print sys.executable'
. test_env/bin/activate
pip install bcrypt==1.1.0
python -c 'import bcrypt; assert bcrypt.__version__ == "1.1.0"; assert bcrypt.hashpw("password1", "$2a$12$0123456789012345678901").endswith("I1hdtg4K"); print "bcrypt seems to work"'
""".strip()
......
......@@ -125,3 +125,9 @@ def show(obj, msg):
print msg
return obj
exec show("print 'in exec'", "body") in show(None, "globals"), show(None, "locals")
g = {}
l = {}
exec ("a=1; print a", g, l)
print g.keys(), l.keys()
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