File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22#define STATIC_DATA
33
44#include "static_data.h"
5+ #include "strings/librt_strings.h"
56
67// Adopted from numpy 2.4.0: numpy/_core/src/multiarry/npy_static_data.c
78
@@ -72,4 +73,10 @@ intern_strings(void) {
7273 return 0 ;
7374}
7475
76+ #ifdef MYPYC_EXPERIMENTAL
77+
78+ void * LibRTStrings_API [LIBRT_STRINGS_API_LEN ] = {0 };
79+
80+ #endif // MYPYC_EXPERIMENTAL
81+
7582#endif
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ import_librt_strings(void)
3030// LIBRT_STRINGS_API_VERSION.
3131#define LIBRT_STRINGS_API_LEN 14
3232
33- static void * LibRTStrings_API [LIBRT_STRINGS_API_LEN ];
33+ extern void * LibRTStrings_API [LIBRT_STRINGS_API_LEN ];
3434
3535typedef struct {
3636 PyObject_HEAD
Original file line number Diff line number Diff line change @@ -1390,3 +1390,23 @@ class Parent:
13901390[file driver.py]
13911391from native import test
13921392test()
1393+
1394+ [case testExtraOpsFunction_experimental_librt]
1395+ from librt.strings import BytesWriter
1396+
1397+ def call_write(b: bytes) -> bytes:
1398+ w = BytesWriter()
1399+ w.write(b) # calls CPyBytesWriter_Write defined in byteswriter_extra_ops.c
1400+ return w.getvalue()
1401+
1402+ [file other.py]
1403+ from native import call_write
1404+
1405+ def test(b: bytes) -> bytes:
1406+ return call_write(b)
1407+
1408+ [file driver.py]
1409+ from other import test
1410+
1411+ input = b'x' * 512
1412+ assert test(input) == input
You can’t perform that action at this time.
0 commit comments