1. Pypy
  2. Untitled project
  3. pypy

Commits

Armin Rigo  committed 3ccd266

Fix for test_py_string_as_string_None, which passed apparently
only by chance on 32-bit.

  • Participants
  • Parent commits cb040bc
  • Branches default

Comments (0)

Files changed (1)

File pypy/module/cpyext/stringobject.py

View file
  • Ignore whitespace
 
 @cpython_api([PyObject], rffi.CCHARP, error=0)
 def PyString_AsString(space, ref):
+    if from_ref(space, rffi.cast(PyObject, ref.c_ob_type)) is space.w_str:
+        pass    # typecheck returned "ok" without forcing 'ref' at all
+    elif not PyString_Check(space, ref):   # otherwise, use the alternate way
+        raise OperationError(space.w_TypeError, space.wrap(
+            "PyString_AsString only support strings"))
     ref_str = rffi.cast(PyStringObject, ref)
     if not ref_str.c_buffer:
         # copy string buffer