Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConversionProviders for libcpp_container[libcpp_*_string, *] not picked up -> Careful with typing #173

Open
jpfeuffer opened this issue Dec 21, 2022 · 0 comments

Comments

@jpfeuffer
Copy link
Contributor

jpfeuffer commented Dec 21, 2022

Since ConversionProviders only work for wrapped classes they won't be picked up for libcpp types in nested constructs.
Instead, it falls back to Cythons autoconversion.
This means, although the usage of the type of libcpp string (utf8 or normal) has not impact on the code, it impacts typing.
You must choose the correct libcpp string "version" in your pxd that reflects Cythons autoconversion.
Currently, this is "libcpp_utf8_string" for input (accepts both unicode and bytes) and "libcpp_string" for output (returns bytes).
Autoconversion settings are reflected in the Cython compilerdirectives:

c_string_type (bytes / str / unicode)
Globally set the type of an implicit coercion from char* or std::string.

c_string_encoding (ascii, default, utf-8, etc.)
Globally set the encoding to use when implicitly coercing char* or std:string to a unicode object. Coercion from a unicode object to C type is only allowed when set to ascii or default, the latter being utf-8 in Python 3 and nearly-always ascii in Python 2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant