[Numpy-discussion] numpydoc for python 3?

Jaakko Luttinen jaakko.luttinen@aalto...
Wed Jan 16 05:32:33 CST 2013


On 01/14/2013 02:44 PM, Matthew Brett wrote:
> On Mon, Jan 14, 2013 at 10:35 AM, Jaakko Luttinen
> <jaakko.luttinen@aalto.fi> wrote:
>> On 01/14/2013 12:53 AM, Matthew Brett wrote:
>>> You might be able to get away without 2to3, using the kind of stuff
>>> that Pauli has used for scipy recently:
>>>
>>> https://github.com/scipy/scipy/pull/397
>>
>> Ok, thanks, maybe I'll try to make the tests valid in all Python
>> versions. It seems there's only one line which I'm not able to transform.
>>
>> In doc/sphinxext/tests/test_docscrape.py, on line 559:
>>     assert doc['Summary'][0] == u'öäöäöäöäöåååå'.encode('utf-8')
>>
>> This is invalid in Python 3.0-3.2. How could I write this in such a way
>> that it is valid in all Python versions? I'm a bit lost with these
>> unicode encodings in Python (and in general).. And I didn't want to add
>> dependency on 'six' package.
> 
> Pierre's suggestion is good; you can also do something like this:
> 
> # -*- coding: utf8 -*-
> import sys
> 
> if sys.version_info[0] >= 3:
>     a = 'öäöäöäöäöåååå'
> else:
>     a = unicode('öäöäöäöäöåååå', 'utf8')
> 
> The 'coding' line has to be the first or second line in the file.

Thanks for all the comments!

I reported an issue and made a pull request:
https://github.com/numpy/numpy/pull/2919

However, I haven't been able to make nosetests work. I get error:
"ValueError: Attempted relative import in non-package"
Don't know how to fix it properly..

-Jaakko



More information about the NumPy-Discussion mailing list