[pypy-svn] pypy default: Missing import.

alex_gaynor commits-noreply at bitbucket.org
Mon Feb 28 05:08:42 CET 2011


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: 
Changeset: r42332:17df0857a7c8
Date: 2011-02-27 23:08 -0500
http://bitbucket.org/pypy/pypy/changeset/17df0857a7c8/

Log:	Missing import.

diff --git a/pypy/module/cpyext/stringobject.py b/pypy/module/cpyext/stringobject.py
--- a/pypy/module/cpyext/stringobject.py
+++ b/pypy/module/cpyext/stringobject.py
@@ -3,6 +3,7 @@
 from pypy.module.cpyext.api import (
     cpython_api, cpython_struct, bootstrap_function, build_type_checkers,
     PyObjectFields, Py_ssize_t, CONST_STRING)
+from pypy.module.cpyext.pyerrors import PyErr_BadArgument
 from pypy.module.cpyext.pyobject import (
     PyObject, PyObjectP, Py_DecRef, make_ref, from_ref, track_reference,
     make_typedescr, get_typedescr)
@@ -252,7 +253,7 @@
     the parameters of the same name in the string encode() method. The codec to
     be used is looked up using the Python codec registry. Return NULL if an
     exception was raised by the codec.
-    
+
     This function is not available in 3.x and does not have a PyBytes alias."""
     if not PyString_Check(space, w_str):
         PyErr_BadArgument(space)

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
@@ -49,7 +49,7 @@
         assert module.get_hello2() == 'Hello world'
         assert module.test_Size()
         raises(TypeError, module.test_Size_exception)
-    
+
         assert module.test_is_string("")
         assert not module.test_is_string(())
 
@@ -152,7 +152,7 @@
             ''')
         res = module.test_string_format_v(1, "xyz")
         assert res == "bla 1 ble xyz\n"
-        
+
     def test_format(self):
         module = self.import_extension('foo', [
             ("test_string_format", "METH_VARARGS",
@@ -203,7 +203,7 @@
         assert c_buf.c_bf_getreadbuffer(py_obj, 0, ref) == 10
         lltype.free(ref, flavor='raw')
         Py_DecRef(space, py_obj)
-        
+
     def test_Concat(self, space, api):
         ref = make_ref(space, space.wrap('abc'))
         ptr = lltype.malloc(PyObjectP.TO, 1, flavor='raw')
@@ -215,7 +215,7 @@
         ptr[0] = lltype.nullptr(PyObject.TO)
         api.PyString_Concat(ptr, space.wrap('def')) # should not crash
         lltype.free(ptr, flavor='raw')
-    
+
     def test_ConcatAndDel(self, space, api):
         ref1 = make_ref(space, space.wrap('abc'))
         ref2 = make_ref(space, space.wrap('def'))
@@ -279,3 +279,7 @@
         res = api.PyString_AsEncodedObject(
             ptr, lltype.nullptr(rffi.CCHARP.TO), lltype.nullptr(rffi.CCHARP.TO))
         assert space.unwrap(res) == "abc"
+
+        self.raises(space, api, TypeError, api.PyString_AsEncodedObject,
+            space.wrap(2), lltype.nullptr(rffi.CCHARP.TO), lltype.nullptr(rffi.CCHARP.TO)
+        )


More information about the Pypy-commit mailing list