[Cython] cython-devel-py3: problem with keywords
Stefan Behnel
stefan_ml at behnel.de
Sun May 18 09:13:04 CEST 2008
Hi,
Stefan Behnel wrote:
> That's actually a tricky problem. Py2 does not accept unicode as keyword
> arguments and Py3 requires them, so we have to distinguish between Py2 and Py3
> here. However, keywords are not really identifiers. You could pass any byte
> string or unicode string in Py2 using the **dict syntax.
>
> To make things worse, Cython stores keyword arguments as a StringNode in a
> generic DictItemNode of a DictNode. So I find it difficult to figure out the
> right place to store the information that the string must behave like an
> identifier.
Here is a patch. It adds a new KeywordNameNode class that makes keyword names
behave just like identifiers and also interns them.
The way this is implemented would allow non-ASCII keyword names in Py3,
although we can't currently enable that in the parser, as the resulting C code
would not work in Py2. You'd end up with UTF-8 encoded byte string names, and
you can't pass these directly from Py2, neither can ParseTupleAndKeywords
handle them.
Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kwcall-py3.patch
Type: text/x-patch
Size: 6114 bytes
Desc: not available
Url : http://codespeak.net/pipermail/cython-dev/attachments/20080518/368a771d/attachment.bin
More information about the Cython-dev
mailing list