Debian Codegraph @

lib_pypy/hpy/devel/src/runtime/ctx_bytes.c

raw symbols SCIP
1 #include <Python.h>
2 #include "hpy.h"
3 #include "hpy/runtime/ctx_funcs.h"
4
5 #ifndef HPY_ABI_CPYTHON
6 // for _h2py and _py2h
7 # include "handles.h"
8 #endif
9
10
11 _HPy_HIDDEN HPy
12 ctx_Bytes_FromStringAndSize(HPyContext *ctx, const char *v, HPy_ssize_t len)
13 {
14 if (v == NULL) {
15 // The CPython API allows passing a null pointer to
16 // PyBytes_FromStringAndSize and returns uninitialized memory of the
17 // requested size which can then be initialized after the call.
18 // In HPy the underlying memory is opaque and so cannot be initialized
19 // after the call and so we raise an error instead.
20 HPyErr_SetString(ctx, ctx->h_ValueError,
21 "NULL char * passed to HPyBytes_FromStringAndSize");
22 return HPy_NULL;
23 }
24 return _py2h(PyBytes_FromStringAndSize(v, len));
25 }