File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
com.oracle.graal.python.test/src/tests/cpyext Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,20 @@ def compile_module(self, name):
7676 arguments = ("char* str" , "Py_ssize_t sz" ),
7777 )
7878
79+ # PyBytes_FromStringAndSize
80+ test_PyBytes_FromStringAndSizeNULL = CPyExtFunction (
81+ lambda args : len (b"\x00 " * args [0 ]),
82+ lambda : ( (128 , ), ),
83+ code = """PyObject* PyBytes_FromStringAndSizeNULL(Py_ssize_t n) {
84+ // we are return the length because the content is random (uninitialized)
85+ return PyBytes_Size(PyBytes_FromStringAndSize(NULL, n));
86+ }
87+ """ ,
88+ resultspec = "n" ,
89+ argspec = 'n' ,
90+ arguments = ["Py_ssize_t n" ],
91+ )
92+
7993 # PyBytes_FromString
8094 test_PyBytes_FromString = CPyExtFunction (
8195 lambda arg : bytes (arg [0 ], "utf-8" ),
Original file line number Diff line number Diff line change @@ -216,7 +216,7 @@ def PyTruffle_Object_LEN(obj):
216216##################### BYTES
217217
218218def PyBytes_FromStringAndSize (string , size , encoding ):
219- if string is not None :
219+ if string is not None and string is not Py_NoValue () :
220220 return bytes (string , encoding )
221221 assert size >= 0 ;
222222 return PyTruffle_Bytes_EmptyWithCapacity (size , native_null )
You can’t perform that action at this time.
0 commit comments