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):
76
76
arguments = ("char* str" , "Py_ssize_t sz" ),
77
77
)
78
78
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
+
79
93
# PyBytes_FromString
80
94
test_PyBytes_FromString = CPyExtFunction (
81
95
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):
216
216
##################### BYTES
217
217
218
218
def PyBytes_FromStringAndSize (string , size , encoding ):
219
- if string is not None :
219
+ if string is not None and string is not Py_NoValue () :
220
220
return bytes (string , encoding )
221
221
assert size >= 0 ;
222
222
return PyTruffle_Bytes_EmptyWithCapacity (size , native_null )
You can’t perform that action at this time.
0 commit comments