numpy/numpy — pull request #366 by certik (2012-07-27 19:38:55+00:00)
Title: WIP: A fix for the PyUnicodeObject Python 3.3

This is a work in progress (WIP).

Currently NumPy fails in Python 3.3 with:

https://gist.github.com/3189711

This PR makes it compile in Python 3.3. Relevant sources of information:

http://www.python.org/dev/peps/pep-0393/
http://docs.python.org/dev/c-api/unicode.html#PyUnicode_FromKindAndData

Known issues that I am still working on:

* The `PY_VERSION_HEX` macro does not seem to be recognized in `numpy/core/src/multiarray/scalartypes.c.src`. This prevents to write code that works in both 3.3 and 3.2

* What is the 3.3 equivalent of `itemsize = ((PyUnicodeObject *)robj)->length * sizeof(Py_UNICODE);`? See
`scalartypes.c.src`. I currently use `itemsize = ((PyUnicodeObject *)robj)->_base.utf8_length * sizeof(Py_UNICODE);` but this is most probably wrong.

* Tests currently segfault with:
```
test_api.test_fastCopyAndTranspose ... ok
test_api.test_array_astype ... ok
test_api.test_copyto_fromscalar ... ok
test_api.test_copyto ... ok
test_api.test_copy_order ... ok
Basic test of array2string. ... ok
Test custom format function for each element in array. ... Segmentation fault (core dumped)
```
Probably related to the previous point.

If you have hints how to fix any of these 3 issues, that'd be awesome.