Commit 457bd713 authored by Stefan Behnel's avatar Stefan Behnel

fix unicode integer indexing for PEP 393

parent 9f49a988
......@@ -2442,7 +2442,7 @@ class IndexNode(ExprNode):
elif self.base.type is tuple_type:
return "PyTuple_GET_ITEM(%s, %s)" % (self.base.result(), self.index.result())
elif self.base.type is unicode_type and self.type.is_unicode_char:
return "PyUnicode_AS_UNICODE(%s)[%s]" % (self.base.result(), self.index.result())
return "__Pyx_PyUnicode_READ_CHAR(%s, %s)" % (self.base.result(), self.index.result())
elif (self.type.is_ptr or self.type.is_array) and self.type == self.base.type:
error(self.pos, "Invalid use of pointer slice")
else:
......
......@@ -581,9 +581,11 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
/* new Py3.3 unicode representation (PEP 393) */
#ifdef PyUnicode_GET_LENGTH
#define CYTHON_PEP393_ENABLED
#define __Pyx_PyUnicode_GET_LENGTH PyUnicode_GET_LENGTH
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
#else
#define __Pyx_PyUnicode_GET_LENGTH PyUnicode_GET_SIZE
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) (PyUnicode_AS_UNICODE(u)[i])
#endif
#if PY_MAJOR_VERSION >= 3
......
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