[Python-apps-team] Bug#500847: [cython] Does not accept Unicode docstrings

Ondrej Certik ondrej at certik.cz
Thu Oct 2 07:39:31 UTC 2008


On Thu, Oct 2, 2008 at 1:28 AM, P M <pagx13 at yahoo.gr> wrote:
> Package: cython
> Version: 0.9.8-1
> Severity: normal
>
> Cython does not accept Unicode docstrings in .pyx files. I have attached a
> sample session with a .pyx file, where I define a function with a docstring
> containing Greek characters. The file's contents are in UTF-8. What is more,
> instead of an error message, I got a python traceback! This problem does not
> show up with comments in Unicode or other string literals.
>
> $ cat bug.pyx
> def hello():
>        '''Γειά σου, κόσμε!'''
>        print 'Hello, world!'
> $ cython bug.pyx
> Traceback (most recent call last):
>  File "/usr/bin/cython", line 8, in <module>
>    main(command_line = 1)
>  File "/var/lib/python-support/python2.5/Cython/Compiler/Main.py", line 527,
> in main
>    result = compile(sources, options)
>  File "/var/lib/python-support/python2.5/Cython/Compiler/Main.py", line 505,
> in compile
>    return compile_multiple(source, options)
>  File "/var/lib/python-support/python2.5/Cython/Compiler/Main.py", line 472,
> in compile_multiple
>    result = context.compile(source, options)
>  File "/var/lib/python-support/python2.5/Cython/Compiler/Main.py", line 327,
> in compile
>    tree.process_implementation(scope, options, result)
>  File "/var/lib/python-support/python2.5/Cython/Compiler/ModuleNode.py", line
> 59, in process_implementation
>    self.generate_c_code(env, options, result)
>  File "/var/lib/python-support/python2.5/Cython/Compiler/ModuleNode.py", line
> 243, in generate_c_code
>    self.body.generate_function_definitions(env, code, options.transforms)
>  File "/var/lib/python-support/python2.5/Cython/Compiler/Nodes.py", line 839,
> in generate_function_definitions
>    with_pymethdef = env.is_py_class_scope)
>  File "/var/lib/python-support/python2.5/Cython/Compiler/Nodes.py", line
> 1442, in generate_function_header
>    self.entry.doc))
>  File "/var/lib/python-support/python2.5/Cython/Compiler/Code.py", line 52,
> in putln
>    self.put(code)
>  File "/var/lib/python-support/python2.5/Cython/Compiler/Code.py", line 69,
> in put
>    self._write(code)
> UnicodeEncodeError: 'ascii' codec can't encode characters in position 38-41:
> ordinal not in range(128)
> $
>
> Thank you for your time.

Thanks, I reported it upstream.

Ondrej


More information about the Python-apps-team mailing list