[pypy-svn] r73340 - in pypy/branch/cpython-extension/pypy/module/cpyext: . include
xoraxax at codespeak.net
xoraxax at codespeak.net
Sat Apr 3 22:36:08 CEST 2010
Author: xoraxax
Date: Sat Apr 3 22:36:06 2010
New Revision: 73340
Added:
pypy/branch/cpython-extension/pypy/module/cpyext/include/pymem.h (contents, props changed)
Modified:
pypy/branch/cpython-extension/pypy/module/cpyext/include/Python.h
pypy/branch/cpython-extension/pypy/module/cpyext/pyerrors.py
Log:
Added new PyErr functions and PyMem functions, working towards _sre compliance.
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/include/Python.h
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/include/Python.h (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/include/Python.h Sat Apr 3 22:36:06 2010
@@ -65,6 +65,7 @@
#include "intobject.h"
#include "unicodeobject.h"
#include "eval.h"
+#include "pymem.h"
// XXX This shouldn't be included here
#include "structmember.h"
Added: pypy/branch/cpython-extension/pypy/module/cpyext/include/pymem.h
==============================================================================
--- (empty file)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/include/pymem.h Sat Apr 3 22:36:06 2010
@@ -0,0 +1,12 @@
+#include <stdlib.h>
+
+
+#define PyMem_MALLOC(n) malloc((n) ? (n) : 1)
+#define PyMem_REALLOC(p, n) realloc((p), (n) ? (n) : 1)
+#define PyMem_FREE free
+
+/* XXX use obmalloc like cpython does */
+#define PyObject_MALLOC PyMem_MALLOC
+#define PyObject_REALLOC PyMem_REALLOC
+#define PyObject_FREE PyMem_FREE
+
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/pyerrors.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/pyerrors.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/pyerrors.py Sat Apr 3 22:36:06 2010
@@ -56,6 +56,34 @@
def PyErr_BadInternalCall(space):
raise OperationError(space.w_SystemError, space.wrap("Bad internal call!"))
+ at cpython_api([], rffi.INT_real, error=-1)
+def PyErr_CheckSignals(space):
+ """
+ This function interacts with Python's signal handling. It checks whether a
+ signal has been sent to the processes and if so, invokes the corresponding
+ signal handler. If the signal module is supported, this can invoke a
+ signal handler written in Python. In all cases, the default effect for
+ SIGINT is to raise the KeyboardInterrupt exception. If an
+ exception is raised the error indicator is set and the function returns -1;
+ otherwise the function returns 0. The error indicator may or may not be
+ cleared if it was previously set."""
+ # XXX implement me
+ return 0
+
+ at cpython_api([], PyObject, error=CANNOT_FAIL)
+def PyErr_NoMemory(space):
+ """This is a shorthand for PyErr_SetNone(PyExc_MemoryError); it returns NULL
+ so an object allocation function can write return PyErr_NoMemory(); when it
+ runs out of memory.
+ Return value: always NULL."""
+ PyErr_SetNone(space.w_MemoryError)
+
+ at cpython_api([PyObject], lltype.Void, error=CANNOT_FAIL)
+def PyErr_SetNone(space, w_type):
+ """This is a shorthand for PyErr_SetObject(type, Py_None)."""
+ PyErr_SetObject(w_type, space.w_None)
+
+
@cpython_api([PyObject, PyObject], rffi.INT_real, error=CANNOT_FAIL)
def PyErr_GivenExceptionMatches(space, w_given, w_exc):
"""Return true if the given exception matches the exception in exc. If
More information about the Pypy-commit
mailing list