[Cython] Does not accept Unicode docstrings
Ondrej Certik
ondrej at certik.cz
Fri Oct 3 07:31:44 CEST 2008
On Thu, Oct 2, 2008 at 5:46 PM, P M <pagx13 at yahoo.gr> wrote:
> Hello, I am the original reporter of the bug with description "Does not accept
> Unicode docstrings" in the Debian BTS. I tried using the encoding: UTF-8
> header and using the u'' prefix, but the problem still persists. I'll try to
> post more information with this email.
>
> $ locale
> LANG=el_GR.UTF-8
> LC_CTYPE="el_GR.UTF-8"
> LC_NUMERIC="el_GR.UTF-8"
> LC_TIME="el_GR.UTF-8"
> LC_COLLATE="el_GR.UTF-8"
> LC_MONETARY="el_GR.UTF-8"
> LC_MESSAGES="el_GR.UTF-8"
> LC_PAPER="el_GR.UTF-8"
> LC_NAME="el_GR.UTF-8"
> LC_ADDRESS="el_GR.UTF-8"
> LC_TELEPHONE="el_GR.UTF-8"
> LC_MEASUREMENT="el_GR.UTF-8"
> LC_IDENTIFICATION="el_GR.UTF-8"
> LC_ALL=
> $ head -n1 `which cython`
> #!/usr/bin/python
> $ python --version
> Python 2.5.2
> $ cython --version
> Cython version 0.9.8
> $ file bug.pyx
> bug.pyx: UTF-8 Unicode text
> $ cat bug.pyx
> # -*- encoding: UTF-8 -*-
> def hello():
> u"""Γειά σου, κόσμε!"""
> 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)
> $ echo $?
> 1
> $
>
> I hope this helps :)
Thanks for the clarification.
Ondrej
More information about the Cython-dev
mailing list