|
| 1 | +diff --git a/pythran/pythonic/python/core.hpp b/pythran/pythonic/python/core.hpp |
| 2 | +index 4cbe3e0..24340b0 100644 |
| 3 | +--- a/pythran/pythonic/python/core.hpp |
| 4 | ++++ b/pythran/pythonic/python/core.hpp |
| 5 | +@@ -53,7 +53,14 @@ namespace python |
| 6 | + { |
| 7 | + |
| 8 | + #ifndef PyString_AS_STRING |
| 9 | +-#define PyString_AS_STRING (char *)_PyUnicode_COMPACT_DATA |
| 10 | ++ static inline const char* PyString_AS_STRING(PyObject* obj) { |
| 11 | ++ const char* str = PyUnicode_AsUTF8(obj); |
| 12 | ++ if (!str) { |
| 13 | ++ PyErr_Clear(); |
| 14 | ++ str = "<invalid string>"; |
| 15 | ++ } |
| 16 | ++ return str; |
| 17 | ++ } |
| 18 | + #endif |
| 19 | + |
| 20 | + inline void PyObject_TypePrettyPrinter(std::ostream &oss, PyObject *obj) |
| 21 | +diff --git a/pythran/pythonic/types/str.hpp b/pythran/pythonic/types/str.hpp |
| 22 | +index e5dbe60..41d1658 100644 |
| 23 | +--- a/pythran/pythonic/types/str.hpp |
| 24 | ++++ b/pythran/pythonic/types/str.hpp |
| 25 | +@@ -741,10 +741,17 @@ namespace std |
| 26 | + #define PyString_FromStringAndSize PyUnicode_FromStringAndSize |
| 27 | + |
| 28 | + #ifndef PyString_Check |
| 29 | +-#define PyString_Check(x) PyUnicode_Check(x) && PyUnicode_IS_COMPACT_ASCII(x) |
| 30 | ++#define PyString_Check(x) PyUnicode_Check(x) |
| 31 | + #endif |
| 32 | + #ifndef PyString_AS_STRING |
| 33 | +-#define PyString_AS_STRING (char *)_PyUnicode_COMPACT_DATA |
| 34 | ++ static inline const char* PyString_AS_STRING(PyObject* obj) { |
| 35 | ++ const char* str = PyUnicode_AsUTF8(obj); |
| 36 | ++ if (!str) { |
| 37 | ++ PyErr_Clear(); |
| 38 | ++ str = "<invalid string>"; |
| 39 | ++ } |
| 40 | ++ return str; |
| 41 | ++ } |
| 42 | + #endif |
| 43 | + #ifndef PyString_GET_SIZE |
| 44 | + #define PyString_GET_SIZE PyUnicode_GET_LENGTH |
| 45 | +diff --git a/pythran/tables.py b/pythran/tables.py |
| 46 | +index d62abe1..4ba279d 100644 |
| 47 | +--- a/pythran/tables.py |
| 48 | ++++ b/pythran/tables.py |
| 49 | +@@ -4617,7 +4617,10 @@ def save_arguments(module_name, elements): |
| 50 | + # some function are actually forward function, detect those |
| 51 | + # and accept to use our description instead. |
| 52 | + if looks_like_a_forward_function(spec): |
| 53 | +- assert signature.args.args, "{} require an explicit description".format(elem) |
| 54 | ++ # GraalPy change: we have signatures for more builtins than |
| 55 | ++ # CPython and this trips up on type constructors like `dict` or |
| 56 | ++ # `BaseException`. |
| 57 | ++ # assert signature.args.args, "{} require an explicit description".format(elem) |
| 58 | + continue |
| 59 | + |
| 60 | + args = [ast.Name(arg, ast.Param(), None, None) |
| 61 | +@@ -4630,7 +4633,8 @@ def save_arguments(module_name, elements): |
| 62 | + defaults = list(spec.defaults or []) |
| 63 | + args += [ast.Name(arg, ast.Param(), None, None) |
| 64 | + for arg in spec.kwonlyargs] |
| 65 | +- defaults += [spec.kwonlydefaults[kw] for kw in spec.kwonlyargs] |
| 66 | ++ if spec.kwonlydefaults: |
| 67 | ++ defaults += [spec.kwonlydefaults[kw] for kw in spec.kwonlyargs] |
| 68 | + |
| 69 | + # Check if we already have a pythran description for that object |
| 70 | + if signature.args.args: |
0 commit comments