File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
graalpython/com.oracle.graal.python.cext/src Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change 42
42
43
43
#include <stdio.h>
44
44
45
+ static int getbuffer (PyObject * arg , Py_buffer * view , const char * * errmsg ) {
46
+ if (PyObject_GetBuffer (arg , view , PyBUF_SIMPLE ) != 0 ) {
47
+ * errmsg = "bytes-like object" ;
48
+ return -1 ;
49
+ }
50
+ // if (!PyBuffer_IsContiguous(view, 'C')) {
51
+ // PyBuffer_Release(view);
52
+ // *errmsg = "contiguous buffer";
53
+ // return -1;
54
+ // }
55
+ return 0 ;
56
+ }
57
+
45
58
typedef struct _positional_argstack {
46
59
PyObject * argv ;
47
60
int argnum ;
@@ -89,8 +102,14 @@ UPCALL_ID(__bool__);
89
102
case 'y': \
90
103
arg = PyTruffle_GetArg(v, kwds, kwdnames, rest_keywords_only); \
91
104
if (format[format_idx + 1] == '*') { \
105
+ void** p = (void**)PyTruffle_ArgN(output_idx); \
106
+ const char* buf; \
92
107
format_idx++; /* skip over '*' */ \
93
- PyErr_Format (PyExc_TypeError , "%c* not supported" , c ); \
108
+ if (getbuffer (arg , (Py_buffer * )p , & buf ) < 0 ) { \
109
+ PyErr_Format (PyExc_TypeError , "expected bytes, got %R" , Py_TYPE (arg )); \
110
+ __return_code__ ; \
111
+ return 0 ; \
112
+ } \
94
113
__return_code__ ; \
95
114
return 0 ; \
96
115
} else if (arg == Py_None ) { \
You can’t perform that action at this time.
0 commit comments