[pypy-commit] pypy default: Add a (surprisingly passing) test for PyString_AsString(PyNone) raising.
dripton
noreply at buildbot.pypy.org
Tue Mar 13 18:25:34 CET 2012
Author: David Ripton <dripton at ripton.net>
Branch:
Changeset: r53446:552929f87da8
Date: 2012-03-13 10:10 -0700
http://bitbucket.org/pypy/pypy/changeset/552929f87da8/
Log: Add a (surprisingly passing) test for PyString_AsString(PyNone)
raising.
According to CPython docs, passing a non-String to PyString_AsString
should return 0 and raise a TypeError.
See issue1085.
diff --git a/pypy/module/cpyext/test/test_stringobject.py b/pypy/module/cpyext/test/test_stringobject.py
--- a/pypy/module/cpyext/test/test_stringobject.py
+++ b/pypy/module/cpyext/test/test_stringobject.py
@@ -105,6 +105,15 @@
)])
assert module.string_as_string("huheduwe") == "huhe"
+ def test_py_string_as_string_None(self):
+ module = self.import_extension('foo', [
+ ("string_None", "METH_VARARGS",
+ '''
+ return PyString_AsString(Py_None);
+ '''
+ )])
+ raises(TypeError, module.string_None)
+
def test_AsStringAndSize(self):
module = self.import_extension('foo', [
("getstring", "METH_NOARGS",
More information about the pypy-commit
mailing list