Hoyt Koepke wrote:
>> Are you sure? I changed the line to this:
>>
>> from numpy import random as rn
>>
>> And it worked with Cython 0.10. Possibly the code that handles "import
>> <foo>.<bar> as <baz>" is incorrect. It's a tricky bit of syntax.
>
> You're right; this does work. I think in trying a bunch of
> combinations to figure it out, I must have missed recompiling
> something and so missed this. Sorry for the noise!
It's not noise. This does appear to be a bug.
/* "/Users/rkern/today/geometry/geometry.pyx":4
*
*
* import numpy.random as rn # <<<<<<<<<<<<<<
* from copy import copy
*
*/
__pyx_1 = PyList_New(1); if (unlikely(!__pyx_1)) {__pyx_filename =
__pyx_f[0]; __pyx_lineno = 4; __pyx_c
lineno = __LINE__; goto __pyx_L1_error;}
Py_INCREF(__pyx_kp_29);
PyList_SET_ITEM(__pyx_1, 0, __pyx_kp_29);
__pyx_2 = __Pyx_Import(__pyx_kp_28, ((PyObject *)__pyx_1)); if
(unlikely(!__pyx_2)) {__pyx_filename = __
pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
Py_DECREF(((PyObject *)__pyx_1)); __pyx_1 = 0;
if (PyObject_SetAttr(__pyx_m, __pyx_kp_rn, __pyx_2) < 0) {__pyx_filename =
__pyx_f[0]; __pyx_lineno = 4;
__pyx_clineno = __LINE__; goto __pyx_L1_error;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
_pyx_kp_29 is never given a value in the generated code so the from_list is
invalid. I am guessing that the "as" is fooling the code generator into
thinking
that there is a from_list.
If that gets fixed, there's more stuff that's broken. The module that gets
returned from __Pyx_Import() as __pyx_2 will be numpy, not numpy.random, so
there must be one or more PyObject_GetAttr()s to get the actual module that
should be assigned to the name "rn".
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev