benjamin.peterson
2008-08-16 16:11:03 UTC
Author: benjamin.peterson
Date: Sat Aug 16 18:11:03 2008
New Revision: 65712
Log:
add _testcapi.raise_memoryerror to make test_exceptions.test_MemoryError simpler
Modified:
python/branches/py3k/Lib/test/test_exceptions.py
python/branches/py3k/Modules/_testcapimodule.c
Modified: python/branches/py3k/Lib/test/test_exceptions.py
==============================================================================
--- python/branches/py3k/Lib/test/test_exceptions.py (original)
+++ python/branches/py3k/Lib/test/test_exceptions.py Sat Aug 16 18:11:03 2008
@@ -593,9 +593,10 @@
# PyErr_NoMemory always raises the same exception instance.
# Check that the traceback is not doubled.
import traceback
+ from _testcapi import raise_memoryerror
def raiseMemError():
try:
- "a" * (sys.maxsize // 2)
+ raise_memoryerror()
except MemoryError as e:
tb = e.__traceback__
else:
Modified: python/branches/py3k/Modules/_testcapimodule.c
==============================================================================
--- python/branches/py3k/Modules/_testcapimodule.c (original)
+++ python/branches/py3k/Modules/_testcapimodule.c Sat Aug 16 18:11:03 2008
@@ -971,8 +971,19 @@
+
+/* reliably raise a MemoryError */
+static PyObject *
+raise_memoryerror(PyObject *self)
+{
+ PyErr_NoMemory();
+ return NULL;
+}
+
+
static PyMethodDef TestMethods[] = {
{"raise_exception", raise_exception, METH_VARARGS},
+ {"raise_memoryerror", (PyCFunction)raise_memoryerror, METH_NOARGS},
{"test_config", (PyCFunction)test_config, METH_NOARGS},
{"test_list_api", (PyCFunction)test_list_api, METH_NOARGS},
{"test_dict_iteration", (PyCFunction)test_dict_iteration,METH_NOARGS},
Date: Sat Aug 16 18:11:03 2008
New Revision: 65712
Log:
add _testcapi.raise_memoryerror to make test_exceptions.test_MemoryError simpler
Modified:
python/branches/py3k/Lib/test/test_exceptions.py
python/branches/py3k/Modules/_testcapimodule.c
Modified: python/branches/py3k/Lib/test/test_exceptions.py
==============================================================================
--- python/branches/py3k/Lib/test/test_exceptions.py (original)
+++ python/branches/py3k/Lib/test/test_exceptions.py Sat Aug 16 18:11:03 2008
@@ -593,9 +593,10 @@
# PyErr_NoMemory always raises the same exception instance.
# Check that the traceback is not doubled.
import traceback
+ from _testcapi import raise_memoryerror
def raiseMemError():
try:
- "a" * (sys.maxsize // 2)
+ raise_memoryerror()
except MemoryError as e:
tb = e.__traceback__
else:
Modified: python/branches/py3k/Modules/_testcapimodule.c
==============================================================================
--- python/branches/py3k/Modules/_testcapimodule.c (original)
+++ python/branches/py3k/Modules/_testcapimodule.c Sat Aug 16 18:11:03 2008
@@ -971,8 +971,19 @@
+
+/* reliably raise a MemoryError */
+static PyObject *
+raise_memoryerror(PyObject *self)
+{
+ PyErr_NoMemory();
+ return NULL;
+}
+
+
static PyMethodDef TestMethods[] = {
{"raise_exception", raise_exception, METH_VARARGS},
+ {"raise_memoryerror", (PyCFunction)raise_memoryerror, METH_NOARGS},
{"test_config", (PyCFunction)test_config, METH_NOARGS},
{"test_list_api", (PyCFunction)test_list_api, METH_NOARGS},
{"test_dict_iteration", (PyCFunction)test_dict_iteration,METH_NOARGS},