summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2020-07-10 11:38:33 +0200
committerStefan Behnel <stefan_ml@behnel.de>2020-07-10 11:38:33 +0200
commit343262aed8b329c9105900df5f35a1a43eba8655 (patch)
treea05c15912ce79ea049b41bd1a43ef283cb74c77c
parent976f5483c6df8570f34076ef25af7e7512dd9347 (diff)
downloadcython-343262aed8b329c9105900df5f35a1a43eba8655.tar.gz
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
-rw-r--r--CHANGES.rst10
-rw-r--r--Cython/Compiler/Builtin.py2
-rw-r--r--tests/run/cython3.pyx8
3 files changed, 19 insertions, 1 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index 96ae40c37..44e2ac2fd 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -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)
====================
diff --git a/Cython/Compiler/Builtin.py b/Cython/Compiler/Builtin.py
index 1bdc643aa..5fa717507 100644
--- a/Cython/Compiler/Builtin.py
+++ b/Cython/Compiler/Builtin.py
@@ -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', "", "", ""),
diff --git a/tests/run/cython3.pyx b/tests/run/cython3.pyx
index cbe0797fd..d8caa1448 100644
--- a/tests/run/cython3.pyx
+++ b/tests/run/cython3.pyx
@@ -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)