Skip to content

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

@jpfeuffer

Description

@jpfeuffer

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions