[Cython] [cython-users] cimport numpy fails with Python 3 semantics

Stefan Behnel stefan_ml at behnel.de
Mon Apr 30 08:48:15 CEST 2012


mark florisson, 28.04.2012 21:57:
> On 28 April 2012 19:50, Stefan Behnel wrote:
>> mark florisson, 28.04.2012 20:33:
>>> I think each module should have its own language level, so I think
>>> that's a bug. I think the rules should be:
>>>
>>>     - if passed as command line argument, use that for all cimported
>>> modules, unless they define their only language level through the
>>> directive
>>>     - if set as a directive, the language level will apply only to that module
>>
>> That's how it works. We don't run the tests with language level 3 in
>> Jenkins because the majority of the tests is not meant to be run with Py3
>> semantics. Maybe it's time to add a numpy_cy3 test.
>>
>> If there are more problems than just this (which was a bug in numpy.pxd),
>> we may consider setting language level 2 explicitly in numpy.pxd.
> 
> Ah, great. Do we have any documentation for that?

We do now. ;)

However, I'm not sure cimported .pxd files should always inherit the
language_level setting. It's somewhat of a grey area because user provided
.pxd files would benefit from it since they likely all use the same
language level as the main module, whereas the Cython shipped (and
otherwise globally installed) .pxd files wouldn't gain anything and could
potentially break.

I think we may want to keep the current behaviour and set the language
level explicitly in the few shipped .pxd files that are not language level
agnostic (i.e. those that actually contain code).

Stefan


More information about the cython-devel mailing list