Skip to content

Commit 3102a02

Browse files
committed
Mark as experimental
1 parent 120a7fa commit 3102a02

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

mypyc/lib-rt/librt_strings.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ static PyMethodDef librt_strings_module_methods[] = {
280280
{NULL, NULL, 0, NULL}
281281
};
282282

283+
#ifdef MYPYC_EXPERIMENTAL
284+
283285
static int
284286
strings_abi_version(void) {
285287
return LIBRT_STRINGS_ABI_VERSION;
@@ -290,9 +292,12 @@ strings_api_version(void) {
290292
return LIBRT_STRINGS_API_VERSION;
291293
}
292294

295+
#endif
296+
293297
static int
294298
librt_strings_module_exec(PyObject *m)
295299
{
300+
#ifdef MYPYC_EXPERIMENTAL
296301
if (PyType_Ready(&BytesWriterType) < 0) {
297302
return -1;
298303
}
@@ -314,6 +319,7 @@ librt_strings_module_exec(PyObject *m)
314319
if (PyModule_Add(m, "_C_API", c_api_object) < 0) {
315320
return -1;
316321
}
322+
#endif
317323
return 0;
318324
}
319325

mypyc/lib-rt/librt_strings.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
#ifndef LIBRT_STRINGS_H
22
#define LIBRT_STRINGS_H
33

4+
#ifndef MYPYC_EXPERIMENTAL
5+
6+
static int
7+
import_librt_strings(void)
8+
{
9+
// All librt.base64 features are experimental for now, so don't set up the API here
10+
return 0;
11+
}
12+
13+
#else // MYPYC_EXPERIMENTAL
14+
415
// ABI version -- only an exact match is compatible. This will only be changed in
516
// very exceptional cases (likely never) due to strict backward compatibility
617
// requirements.
@@ -62,4 +73,6 @@ static inline bool CPyBytesWriter_Check(PyObject *obj) {
6273
return Py_TYPE(obj) == LibRTStrings_BytesWriter_type_internal();
6374
}
6475

76+
#endif // MYPYC_EXPERIMENTAL
77+
6578
#endif // LIBRT_STRINGS_H

mypyc/test-data/run-librt-strings.test

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,10 @@ def test_bytes_writer_wrapper_functions() -> None:
8686

8787
with assertRaises(TypeError):
8888
b.append(-1)
89+
90+
[case testStringsFeaturesNotAvailableInNonExperimentalBuild_librt]
91+
# This also ensures librt.strings can be built without experimental features
92+
import librt.strings
93+
94+
def test_bytes_writer_not_available() -> None:
95+
assert not hasattr(librt.strings, "BytesWriter")

0 commit comments

Comments
 (0)