From 11b2d3a31e726f61c0cb4ed406efc5ee8951c90b Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Wed, 21 May 2008 18:56:31 +0200 Subject: [PATCH] fix intern() builtin in Py3 --- Cython/Compiler/Builtin.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Cython/Compiler/Builtin.py b/Cython/Compiler/Builtin.py index 68f6815b..e30f7c0e 100644 --- a/Cython/Compiler/Builtin.py +++ b/Cython/Compiler/Builtin.py @@ -24,7 +24,7 @@ builtin_function_table = [ #('hex', "", "", ""), #('id', "", "", ""), #('input', "", "", ""), - ('intern', "s", "O", "PyString_InternFromString"), + ('intern', "s", "O", "__Pyx_InternFromString"), ('isinstance', "OO", "b", "PyObject_IsInstance"), ('issubclass', "OO", "b", "PyObject_IsSubclass"), ('iter', "O", "O", "PyObject_GetIter"), @@ -118,8 +118,18 @@ bad: } """] +intern_utility_code = [""" +#if PY_MAJOR_VERSION >= 3 +# define __Pyx_InternFromString(s) PyUnicode_InternFromString(s) +#else +# define __Pyx_InternFromString(s) PyString_InternFromString(s) +#endif +""",""" +"""] + builtin_utility_code = { 'getattr3': getattr3_utility_code, + 'intern' : intern_utility_code, } builtin_scope = BuiltinScope() -- 2.26.2