Skip to content

Commit 1bac78b

Browse files
committed
Update patch for pythran
1 parent 5f26295 commit 1bac78b

File tree

3 files changed

+88
-8
lines changed

3 files changed

+88
-8
lines changed

graalpython/lib-graalpython/patches/metadata.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,11 +513,15 @@ patch = 'pythran-0.12.0.patch'
513513
license = 'BSD-3-Clause'
514514

515515
[[pythran.rules]]
516-
install-priority = 10
517516
version = '== 0.13.*'
518517
patch = 'pythran-0.13.patch'
519518
license = 'BSD-3-Clause'
520519

520+
[[pythran.rules]]
521+
version = '>= 0.14'
522+
patch = 'pythran-0.15.patch'
523+
license = 'BSD-3-Clause'
524+
521525
[[pyzmq.rules]]
522526
# 26+ needs Cython 3
523527
version = '< 26'
Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,44 @@
11
diff --git a/pythran/pythonic/python/core.hpp b/pythran/pythonic/python/core.hpp
2-
index ff44c01..23b4413 100644
2+
index 4cbe3e0..24340b0 100644
33
--- a/pythran/pythonic/python/core.hpp
44
+++ b/pythran/pythonic/python/core.hpp
5-
@@ -53,7 +53,7 @@ namespace python
5+
@@ -53,7 +53,14 @@ namespace python
66
{
77

88
#ifndef PyString_AS_STRING
99
-#define PyString_AS_STRING (char *)_PyUnicode_COMPACT_DATA
10-
+#define PyString_AS_STRING PyBytes_AS_STRING
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+
+ }
1118
#endif
1219

1320
inline void PyObject_TypePrettyPrinter(std::ostream &oss, PyObject *obj)
1421
diff --git a/pythran/pythonic/types/str.hpp b/pythran/pythonic/types/str.hpp
15-
index 1f7a981..00440a9 100644
22+
index 1f7a981..e975333 100644
1623
--- a/pythran/pythonic/types/str.hpp
1724
+++ b/pythran/pythonic/types/str.hpp
18-
@@ -744,7 +744,7 @@ namespace std
19-
#define PyString_Check(x) PyUnicode_Check(x) && PyUnicode_IS_COMPACT_ASCII(x)
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)
2031
#endif
2132
#ifndef PyString_AS_STRING
2233
-#define PyString_AS_STRING (char *)_PyUnicode_COMPACT_DATA
23-
+#define PyString_AS_STRING PyBytes_AS_STRING
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+
+ }
2442
#endif
2543
#ifndef PyString_GET_SIZE
2644
#define PyString_GET_SIZE PyUnicode_GET_LENGTH
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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 1f7a981..e975333 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 d1d2027..eb631fd 100644
47+
--- a/pythran/tables.py
48+
+++ b/pythran/tables.py
49+
@@ -4595,7 +4595,8 @@ def save_arguments(module_name, elements):
50+
defaults = list(spec.defaults or [])
51+
args += [ast.Name(arg, ast.Param(), None, None)
52+
for arg in spec.kwonlyargs]
53+
- defaults += [spec.kwonlydefaults[kw] for kw in spec.kwonlyargs]
54+
+ if spec.kwonlydefaults:
55+
+ defaults += [spec.kwonlydefaults[kw] for kw in spec.kwonlyargs]
56+
57+
# Check if we already have a pythran description for that object
58+
if signature.args.args:

0 commit comments

Comments
 (0)