Skip to content

Incorrect return type assumed for "repr()" builtin function with "language_level=3" #3736

@LordAro

Description

@LordAro

Cython version 0.29.21

def f() -> str:
    return repr('')

with cython -3 -o foo.c foo.py
results in an error:

Error compiling Cython file:
------------------------------------------------------------
...
def f() -> str:
    return repr('')
              ^
------------------------------------------------------------

foo.py:2:15: str objects do not support coercion to unicode, use a unicode string literal instead (u'')

As far as I'm aware, repr() returns a string, so there shouldn't be any issue here? Wrapping it str(repr('')) works fine.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions