Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add _sandbox._test_crash()

  • Loading branch information...
commit 8afca09e474d2834ebe47698678f96f6adb5fcab 1 parent d650a72
@haypo authored
Showing with 20 additions and 3 deletions.
  1. +18 −1 _sandbox/module.c
  2. +2 −2 sandbox/__init__.py
View
19 _sandbox/module.c
@@ -3,10 +3,11 @@
/**
* Version history:
+ * - Version 3: add _test_crash() function
* - Version 2: add dictionary_of() function
* - Version 1: initial version
*/
-#define VERSION 2
+#define VERSION 3
#if PY_MAJOR_VERSION >= 3
# define PYTHON3
@@ -113,6 +114,20 @@ dictionary_of(PyObject *self, PyObject *args)
return NULL;
}
+static PyObject *
+sandbox_test_crash(PyObject *self)
+{
+ volatile int *x;
+ volatile int y;
+ x = NULL;
+ y = *x;
+#ifdef PYTHON3
+ return PyLong_FromLong(y);
+#else
+ return PyInt_FromLong(y);
+#endif
+}
+
static PyMethodDef sandbox_methods[] = {
{"set_error_class", set_error_class, METH_VARARGS,
PyDoc_STR("set_error_class(error_class) -> None")},
@@ -126,6 +141,8 @@ static PyMethodDef sandbox_methods[] = {
PyDoc_STR("restore_code_new() -> None")},
{"dictionary_of", dictionary_of, METH_VARARGS,
PyDoc_STR("dictionary_of(obj) -> dict")},
+ {"_test_crash", (PyCFunction)sandbox_test_crash, METH_NOARGS,
+ PyDoc_STR("_test_crash(): crash the process")},
{NULL, NULL} /* sentinel */
};
View
4 sandbox/__init__.py
@@ -8,7 +8,7 @@ class SandboxError(Exception):
class Timeout(SandboxError):
pass
-class Protection:
+class Protection(object):
def enable(self, sandbox):
pass
@@ -32,7 +32,7 @@ def disable(self, sandbox):
HAVE_CSANDBOX = True
set_error_class(SandboxError)
del set_error_class
- if _sandbox_version != 2:
+ if _sandbox_version != 3:
raise SandboxError(
"_sandbox version %s is not supported" % _sandbox_version)
Please sign in to comment.
Something went wrong with that request. Please try again.