File tree Expand file tree Collapse file tree 3 files changed +26
-0
lines changed
Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -280,6 +280,8 @@ static PyMethodDef librt_strings_module_methods[] = {
280280 {NULL , NULL , 0 , NULL }
281281};
282282
283+ #ifdef MYPYC_EXPERIMENTAL
284+
283285static int
284286strings_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+
293297static int
294298librt_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
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff 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")
You can’t perform that action at this time.
0 commit comments