Commit 343262ae authored by Stefan Behnel's avatar Stefan Behnel

Prevent compile error when the result of repr() is assigned to a "unicode" LHS...

Prevent compile error when the result of repr() is assigned to a "unicode" LHS with language_level=3.
Closes https://github.com/cython/cython/issues/3736
parent 976f5483
......@@ -2,6 +2,16 @@
Cython Changelog
================
0.29.22 (2020-??-??)
====================
Bugs fixed
----------
* ``repr()`` was assumed to return ``str`` instead of ``unicode`` with ``language_level=3``.
(Github issue #3736)
0.29.21 (2020-07-09)
====================
......
......@@ -203,7 +203,7 @@ builtin_function_table = [
#('raw_input', "", "", ""),
#('reduce', "", "", ""),
BuiltinFunction('reload', "O", "O", "PyImport_ReloadModule"),
BuiltinFunction('repr', "O", "O", "PyObject_Repr", builtin_return_type='str'),
BuiltinFunction('repr', "O", "O", "PyObject_Repr"), # , builtin_return_type='str'), # add in Cython 3.1
#('round', "", "", ""),
BuiltinFunction('setattr', "OOO", "r", "PyObject_SetAttr"),
#('sum', "", "", ""),
......
......@@ -630,3 +630,11 @@ async def async_def_annotations(x: 'int') -> 'float':
int
"""
return float(x)
def repr_returns_str(x) -> str:
"""
>>> repr_returns_str(123)
'123'
"""
return repr(x)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment