Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
codejail
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
codejail
Commits
50ad8f33
Commit
50ad8f33
authored
May 10, 2013
by
Ned Batchelder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use simplejson if it is available.
parent
af82ed25
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
codejail/safe_exec.py
+9
-2
No files found.
codejail/safe_exec.py
View file @
50ad8f33
"""Safe execution of untrusted Python code."""
import
json
import
logging
import
os.path
import
shutil
import
sys
import
textwrap
try
:
import
simplejson
as
json
except
ImportError
:
import
json
from
codejail
import
jail_code
from
codejail.util
import
temp_directory
,
change_directory
...
...
@@ -60,8 +64,11 @@ def safe_exec(code, globals_dict, files=None, python_path=None):
the_code
.
append
(
textwrap
.
dedent
(
"""
import json
import sys
try:
import simplejson as json
except ImportError:
import json
"""
# We need to prevent the sandboxed code from printing to stdout,
# or it will pollute the json we print there. This isn't a
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment