Author: David Ripton <[email protected]>
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",
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to